Skip to content

Commit 459e4f2

Browse files
committed
Allow customising the snowflake driver name
1 parent e3c18bc commit 459e4f2

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

ggsql-vscode/src/connections.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,8 @@ function readSnowflakeConnections(): {
200200
* Build an ODBC connection string for Snowflake with the given parts.
201201
*/
202202
function buildSnowflakeOdbc(parts: Record<string, string | undefined>): string {
203-
let connStr = `Driver=Snowflake;Server=${parts.account}.snowflakecomputing.com`;
203+
const driver = parts.driver || 'Snowflake';
204+
let connStr = `Driver=${driver};Server=${parts.account}.snowflakecomputing.com`;
204205
if (parts.uid) {
205206
connStr += `;UID=${parts.uid}`;
206207
}
@@ -271,6 +272,8 @@ function createSnowflakeDefaultDriver(
271272
];
272273
}
273274

275+
inputs.push({ id: 'driver', label: 'Driver', type: 'string', value: 'Snowflake' });
276+
274277
return {
275278
driverId: 'ggsql-snowflake-default',
276279
metadata: {
@@ -282,7 +285,9 @@ function createSnowflakeDefaultDriver(
282285
generateCode: (inputs) => {
283286
const name =
284287
inputs.find((i) => i.id === 'connection_name')?.value?.trim() || 'default';
285-
return `-- @connect: odbc://Driver=Snowflake;ConnectionName=${name}`;
288+
const driver =
289+
inputs.find((i) => i.id === 'driver')?.value?.trim() || 'Snowflake';
290+
return `-- @connect: odbc://Driver=${driver};ConnectionName=${name}`;
286291
},
287292
connect: snowflakeConnect(positronApi),
288293
};
@@ -308,6 +313,7 @@ function createSnowflakePasswordDriver(
308313
{ id: 'warehouse', label: 'Warehouse', type: 'string' },
309314
{ id: 'database', label: 'Database', type: 'string', value: '' },
310315
{ id: 'schema', label: 'Schema', type: 'string', value: '' },
316+
{ id: 'driver', label: 'Driver', type: 'string', value: 'Snowflake' },
311317
],
312318
} as ConnectionsDriverMetadata,
313319
generateCode: (inputs) => {
@@ -320,6 +326,7 @@ function createSnowflakePasswordDriver(
320326
warehouse: get('warehouse'),
321327
database: get('database') || undefined,
322328
schema: get('schema') || undefined,
329+
driver: get('driver') || undefined,
323330
});
324331
},
325332
connect: snowflakeConnect(positronApi),
@@ -345,6 +352,7 @@ function createSnowflakeSSODriver(
345352
{ id: 'warehouse', label: 'Warehouse', type: 'string' },
346353
{ id: 'database', label: 'Database', type: 'string', value: '' },
347354
{ id: 'schema', label: 'Schema', type: 'string', value: '' },
355+
{ id: 'driver', label: 'Driver', type: 'string', value: 'Snowflake' },
348356
],
349357
} as ConnectionsDriverMetadata,
350358
generateCode: (inputs) => {
@@ -357,6 +365,7 @@ function createSnowflakeSSODriver(
357365
warehouse: get('warehouse'),
358366
database: get('database') || undefined,
359367
schema: get('schema') || undefined,
368+
driver: get('driver') || undefined,
360369
});
361370
},
362371
connect: snowflakeConnect(positronApi),
@@ -382,6 +391,7 @@ function createSnowflakePATDriver(
382391
{ id: 'warehouse', label: 'Warehouse', type: 'string' },
383392
{ id: 'database', label: 'Database', type: 'string', value: '' },
384393
{ id: 'schema', label: 'Schema', type: 'string', value: '' },
394+
{ id: 'driver', label: 'Driver', type: 'string', value: 'Snowflake' },
385395
],
386396
} as ConnectionsDriverMetadata,
387397
generateCode: (inputs) => {
@@ -394,6 +404,7 @@ function createSnowflakePATDriver(
394404
warehouse: get('warehouse'),
395405
database: get('database') || undefined,
396406
schema: get('schema') || undefined,
407+
driver: get('driver') || undefined,
397408
});
398409
},
399410
connect: snowflakeConnect(positronApi),

0 commit comments

Comments
 (0)