mirror of
https://github.com/knex/knex.git
synced 2025-06-26 22:00:25 +00:00
feat: Add JSON parameter support for MSSQL connection (#5200)
Co-authored-by: k144 <k144@debian-BULLSEYE-live-builder-AMD64>
This commit is contained in:
parent
8bb9e830ff
commit
8a50dd7462
@ -69,8 +69,10 @@ function connectionObject(parsed) {
|
||||
}
|
||||
if (parsed.searchParams) {
|
||||
for (const [key, value] of parsed.searchParams.entries()) {
|
||||
const isMySQLLike = ['mysql:', 'mariadb:'].includes(parsed.protocol);
|
||||
if (isMySQLLike) {
|
||||
const isNestedConfigSupported = ['mysql:', 'mariadb:', 'mssql:'].includes(
|
||||
parsed.protocol
|
||||
);
|
||||
if (isNestedConfigSupported) {
|
||||
try {
|
||||
connection[key] = JSON.parse(value);
|
||||
} catch (err) {
|
||||
|
@ -311,3 +311,27 @@ test('#4628, supports mysql / mariadb client JSON parameters', function (t) {
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
test('support MSSQL JSON parameters for config object', function (t) {
|
||||
t.plan(1);
|
||||
t.deepLooseEqual(
|
||||
parseConnection(
|
||||
'mssql://user:password@host/database?domain=testDomain&options={"instanceName": "TestInstance001", "readOnlyIntent": true}'
|
||||
),
|
||||
|
||||
{
|
||||
client: 'mssql',
|
||||
connection: {
|
||||
server: 'host',
|
||||
user: 'user',
|
||||
password: 'password',
|
||||
database: 'database',
|
||||
domain: 'testDomain',
|
||||
options: {
|
||||
instanceName: 'TestInstance001',
|
||||
readOnlyIntent: true,
|
||||
},
|
||||
},
|
||||
}
|
||||
);
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user