snowflake-kysely-dialect 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +90 -0
- package/dist/SnowflakeAdapter.d.ts +9 -0
- package/dist/SnowflakeAdapter.js +21 -0
- package/dist/SnowflakeConnection.d.ts +11 -0
- package/dist/SnowflakeConnection.js +80 -0
- package/dist/SnowflakeDialect.d.ts +15 -0
- package/dist/SnowflakeDialect.js +26 -0
- package/dist/SnowflakeDriver.d.ts +14 -0
- package/dist/SnowflakeDriver.js +61 -0
- package/dist/SnowflakeIntrospector.d.ts +8 -0
- package/dist/SnowflakeIntrospector.js +79 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +21 -0
- package/package.json +31 -0
package/README.md
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# snowflake-kysely-dialect
|
|
2
|
+
|
|
3
|
+
A [Kysely](https://kysely.dev) dialect for [Snowflake](https://www.snowflake.com).
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install snowflake-kysely-dialect kysely snowflake-sdk
|
|
9
|
+
# or
|
|
10
|
+
yarn add snowflake-kysely-dialect kysely snowflake-sdk
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import { Kysely } from 'kysely'
|
|
17
|
+
import { SnowflakeDialect } from 'snowflake-kysely-dialect'
|
|
18
|
+
|
|
19
|
+
interface Database {
|
|
20
|
+
users: {
|
|
21
|
+
id: number
|
|
22
|
+
name: string
|
|
23
|
+
email: string
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const db = new Kysely<Database>({
|
|
28
|
+
dialect: new SnowflakeDialect({
|
|
29
|
+
connection: {
|
|
30
|
+
account: 'your-account',
|
|
31
|
+
username: 'your-username',
|
|
32
|
+
password: 'your-password',
|
|
33
|
+
database: 'your-database',
|
|
34
|
+
schema: 'your-schema',
|
|
35
|
+
warehouse: 'your-warehouse',
|
|
36
|
+
},
|
|
37
|
+
}),
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
// Select
|
|
41
|
+
const users = await db.selectFrom('users').selectAll().execute()
|
|
42
|
+
|
|
43
|
+
// Insert
|
|
44
|
+
await db.insertInto('users').values({ id: 1, name: 'Alice', email: 'alice@example.com' }).execute()
|
|
45
|
+
|
|
46
|
+
// Update
|
|
47
|
+
await db.updateTable('users').set({ name: 'Bob' }).where('id', '=', 1).execute()
|
|
48
|
+
|
|
49
|
+
// Delete
|
|
50
|
+
await db.deleteFrom('users').where('id', '=', 1).execute()
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Transactions
|
|
54
|
+
|
|
55
|
+
Transactions are fully supported:
|
|
56
|
+
|
|
57
|
+
```ts
|
|
58
|
+
await db.transaction().execute(async (trx) => {
|
|
59
|
+
await trx.insertInto('users').values({ id: 2, name: 'Carol', email: 'carol@example.com' }).execute()
|
|
60
|
+
await trx.updateTable('users').set({ name: 'Dave' }).where('id', '=', 1).execute()
|
|
61
|
+
})
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Streaming
|
|
65
|
+
|
|
66
|
+
```ts
|
|
67
|
+
const stream = await db.selectFrom('users').selectAll().stream()
|
|
68
|
+
|
|
69
|
+
for await (const row of stream) {
|
|
70
|
+
console.log(row)
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Introspection
|
|
75
|
+
|
|
76
|
+
```ts
|
|
77
|
+
const tables = await db.introspection.getTables()
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Notes
|
|
81
|
+
|
|
82
|
+
- Uses `PostgresQueryCompiler` under the hood — Snowflake's SQL dialect (double-quoted identifiers, window functions, standard string functions) is closer to Postgres than MySQL.
|
|
83
|
+
- Uses a connection pool backed by `snowflake-sdk`'s built-in pool. Pool size and timeouts are configurable via the `poolOptions` config key.
|
|
84
|
+
- `RETURNING` is not supported by Snowflake and is disabled in the adapter.
|
|
85
|
+
- Snowflake folds unquoted identifiers to uppercase. Use quoted identifiers (via `sql.id(...)`) when you need case-sensitive names.
|
|
86
|
+
- `VARIANT` / `OBJECT` columns (JSON), `TIMESTAMP_NTZ` / `TIMESTAMP_LTZ` / `TIMESTAMP_TZ`, and `NUMBER` precision are the most common sources of type round-tripping surprises — test these explicitly in your application.
|
|
87
|
+
|
|
88
|
+
## License
|
|
89
|
+
|
|
90
|
+
MIT
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { DialectAdapterBase, type Kysely, type MigrationLockOptions } from 'kysely';
|
|
2
|
+
export declare class SnowflakeAdapter extends DialectAdapterBase {
|
|
3
|
+
get supportsTransactionalDdl(): boolean;
|
|
4
|
+
get supportsReturning(): boolean;
|
|
5
|
+
get supportsCreateIfNotExists(): boolean;
|
|
6
|
+
get supportsOutput(): boolean;
|
|
7
|
+
acquireMigrationLock(_db: Kysely<any>, _opt: MigrationLockOptions): Promise<void>;
|
|
8
|
+
releaseMigrationLock(_db: Kysely<any>, _opt: MigrationLockOptions): Promise<void>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SnowflakeAdapter = void 0;
|
|
4
|
+
const kysely_1 = require("kysely");
|
|
5
|
+
class SnowflakeAdapter extends kysely_1.DialectAdapterBase {
|
|
6
|
+
get supportsTransactionalDdl() {
|
|
7
|
+
return true;
|
|
8
|
+
}
|
|
9
|
+
get supportsReturning() {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
get supportsCreateIfNotExists() {
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
15
|
+
get supportsOutput() {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
async acquireMigrationLock(_db, _opt) { }
|
|
19
|
+
async releaseMigrationLock(_db, _opt) { }
|
|
20
|
+
}
|
|
21
|
+
exports.SnowflakeAdapter = SnowflakeAdapter;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type CompiledQuery, type DatabaseConnection, type QueryResult } from 'kysely';
|
|
2
|
+
import { type Connection } from 'snowflake-sdk';
|
|
3
|
+
export declare class SnowflakeConnection implements DatabaseConnection {
|
|
4
|
+
#private;
|
|
5
|
+
constructor(conn: Connection);
|
|
6
|
+
beginTransaction(): Promise<void>;
|
|
7
|
+
commitTransaction(): Promise<void>;
|
|
8
|
+
rollbackTransaction(): Promise<void>;
|
|
9
|
+
executeQuery<O>(compiledQuery: CompiledQuery): Promise<QueryResult<O>>;
|
|
10
|
+
streamQuery<O>(compiledQuery: CompiledQuery, _chunkSize: number): AsyncIterableIterator<QueryResult<O>>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SnowflakeConnection = void 0;
|
|
4
|
+
class SnowflakeConnection {
|
|
5
|
+
#conn;
|
|
6
|
+
constructor(conn) {
|
|
7
|
+
this.#conn = conn;
|
|
8
|
+
}
|
|
9
|
+
async #executeRaw(sqlText) {
|
|
10
|
+
await new Promise((resolve, reject) => {
|
|
11
|
+
this.#conn.execute({
|
|
12
|
+
sqlText,
|
|
13
|
+
complete: (err) => {
|
|
14
|
+
if (err)
|
|
15
|
+
reject(err);
|
|
16
|
+
else
|
|
17
|
+
resolve();
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
async beginTransaction() {
|
|
23
|
+
await this.#executeRaw('BEGIN');
|
|
24
|
+
}
|
|
25
|
+
async commitTransaction() {
|
|
26
|
+
await this.#executeRaw('COMMIT');
|
|
27
|
+
}
|
|
28
|
+
async rollbackTransaction() {
|
|
29
|
+
await this.#executeRaw('ROLLBACK');
|
|
30
|
+
}
|
|
31
|
+
#translatePlaceholders(sql) {
|
|
32
|
+
return sql.replace(/\$\d+/g, '?');
|
|
33
|
+
}
|
|
34
|
+
async executeQuery(compiledQuery) {
|
|
35
|
+
const sqlText = this.#translatePlaceholders(compiledQuery.sql);
|
|
36
|
+
const binds = compiledQuery.parameters;
|
|
37
|
+
return new Promise((resolve, reject) => {
|
|
38
|
+
this.#conn.execute({
|
|
39
|
+
sqlText,
|
|
40
|
+
binds,
|
|
41
|
+
complete(err, stmt, rows) {
|
|
42
|
+
if (err)
|
|
43
|
+
return reject(err);
|
|
44
|
+
const numUpdated = stmt.getNumUpdatedRows();
|
|
45
|
+
if (numUpdated != null && numUpdated >= 0) {
|
|
46
|
+
const n = BigInt(numUpdated);
|
|
47
|
+
resolve({
|
|
48
|
+
rows: (rows ?? []),
|
|
49
|
+
numAffectedRows: n,
|
|
50
|
+
numChangedRows: n,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
resolve({ rows: (rows ?? []) });
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
async *streamQuery(compiledQuery, _chunkSize) {
|
|
61
|
+
const sqlText = this.#translatePlaceholders(compiledQuery.sql);
|
|
62
|
+
const binds = compiledQuery.parameters;
|
|
63
|
+
const readable = await new Promise((resolve, reject) => {
|
|
64
|
+
this.#conn.execute({
|
|
65
|
+
sqlText,
|
|
66
|
+
binds,
|
|
67
|
+
streamResult: true,
|
|
68
|
+
complete: (err, stmt) => {
|
|
69
|
+
if (err)
|
|
70
|
+
return reject(err);
|
|
71
|
+
resolve(stmt.streamRows());
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
for await (const row of readable) {
|
|
76
|
+
yield { rows: [row] };
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
exports.SnowflakeConnection = SnowflakeConnection;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type DatabaseIntrospector, type Dialect, type Driver, type Kysely, type QueryCompiler } from 'kysely';
|
|
2
|
+
import type { ConnectionOptions, PoolOptions } from 'snowflake-sdk';
|
|
3
|
+
import { SnowflakeAdapter } from './SnowflakeAdapter.js';
|
|
4
|
+
export interface SnowflakeDialectConfig {
|
|
5
|
+
connection: ConnectionOptions;
|
|
6
|
+
poolOptions?: PoolOptions;
|
|
7
|
+
}
|
|
8
|
+
export declare class SnowflakeDialect implements Dialect {
|
|
9
|
+
#private;
|
|
10
|
+
constructor(config: SnowflakeDialectConfig);
|
|
11
|
+
createAdapter(): SnowflakeAdapter;
|
|
12
|
+
createDriver(): Driver;
|
|
13
|
+
createQueryCompiler(): QueryCompiler;
|
|
14
|
+
createIntrospector(db: Kysely<any>): DatabaseIntrospector;
|
|
15
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SnowflakeDialect = void 0;
|
|
4
|
+
const kysely_1 = require("kysely");
|
|
5
|
+
const SnowflakeAdapter_js_1 = require("./SnowflakeAdapter.js");
|
|
6
|
+
const SnowflakeDriver_js_1 = require("./SnowflakeDriver.js");
|
|
7
|
+
const SnowflakeIntrospector_js_1 = require("./SnowflakeIntrospector.js");
|
|
8
|
+
class SnowflakeDialect {
|
|
9
|
+
#config;
|
|
10
|
+
constructor(config) {
|
|
11
|
+
this.#config = config;
|
|
12
|
+
}
|
|
13
|
+
createAdapter() {
|
|
14
|
+
return new SnowflakeAdapter_js_1.SnowflakeAdapter();
|
|
15
|
+
}
|
|
16
|
+
createDriver() {
|
|
17
|
+
return new SnowflakeDriver_js_1.SnowflakeDriver(this.#config);
|
|
18
|
+
}
|
|
19
|
+
createQueryCompiler() {
|
|
20
|
+
return new kysely_1.PostgresQueryCompiler();
|
|
21
|
+
}
|
|
22
|
+
createIntrospector(db) {
|
|
23
|
+
return new SnowflakeIntrospector_js_1.SnowflakeIntrospector(db);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
exports.SnowflakeDialect = SnowflakeDialect;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type DatabaseConnection, type Driver } from 'kysely';
|
|
2
|
+
import { SnowflakeConnection } from './SnowflakeConnection.js';
|
|
3
|
+
import { type SnowflakeDialectConfig } from './SnowflakeDialect.js';
|
|
4
|
+
export declare class SnowflakeDriver implements Driver {
|
|
5
|
+
#private;
|
|
6
|
+
constructor(config: SnowflakeDialectConfig);
|
|
7
|
+
init(): Promise<void>;
|
|
8
|
+
acquireConnection(): Promise<DatabaseConnection>;
|
|
9
|
+
beginTransaction(conn: SnowflakeConnection): Promise<void>;
|
|
10
|
+
commitTransaction(conn: SnowflakeConnection): Promise<void>;
|
|
11
|
+
rollbackTransaction(conn: SnowflakeConnection): Promise<void>;
|
|
12
|
+
releaseConnection(conn: SnowflakeConnection): Promise<void>;
|
|
13
|
+
destroy(): Promise<void>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.SnowflakeDriver = void 0;
|
|
7
|
+
const snowflake_sdk_1 = __importDefault(require("snowflake-sdk"));
|
|
8
|
+
const SnowflakeConnection_js_1 = require("./SnowflakeConnection.js");
|
|
9
|
+
const DEFAULT_POOL_OPTIONS = {
|
|
10
|
+
max: 10,
|
|
11
|
+
min: 2,
|
|
12
|
+
acquireTimeoutMillis: 60_000,
|
|
13
|
+
idleTimeoutMillis: 600_000,
|
|
14
|
+
evictionRunIntervalMillis: 300_000,
|
|
15
|
+
};
|
|
16
|
+
class SnowflakeDriver {
|
|
17
|
+
#config;
|
|
18
|
+
#pool = null;
|
|
19
|
+
#pendingReleases = new Map();
|
|
20
|
+
constructor(config) {
|
|
21
|
+
this.#config = config;
|
|
22
|
+
}
|
|
23
|
+
async init() {
|
|
24
|
+
this.#pool = snowflake_sdk_1.default.createPool(this.#config.connection, { ...DEFAULT_POOL_OPTIONS, ...this.#config.poolOptions });
|
|
25
|
+
}
|
|
26
|
+
async acquireConnection() {
|
|
27
|
+
return new Promise((resolveAcquire, rejectAcquire) => {
|
|
28
|
+
this.#pool.use(async (sdkConn) => {
|
|
29
|
+
const conn = new SnowflakeConnection_js_1.SnowflakeConnection(sdkConn);
|
|
30
|
+
return new Promise((resolveRelease) => {
|
|
31
|
+
this.#pendingReleases.set(conn, resolveRelease);
|
|
32
|
+
resolveAcquire(conn);
|
|
33
|
+
});
|
|
34
|
+
}).catch(rejectAcquire);
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
async beginTransaction(conn) {
|
|
38
|
+
return conn.beginTransaction();
|
|
39
|
+
}
|
|
40
|
+
async commitTransaction(conn) {
|
|
41
|
+
return conn.commitTransaction();
|
|
42
|
+
}
|
|
43
|
+
async rollbackTransaction(conn) {
|
|
44
|
+
return conn.rollbackTransaction();
|
|
45
|
+
}
|
|
46
|
+
async releaseConnection(conn) {
|
|
47
|
+
const release = this.#pendingReleases.get(conn);
|
|
48
|
+
if (release) {
|
|
49
|
+
this.#pendingReleases.delete(conn);
|
|
50
|
+
release();
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
async destroy() {
|
|
54
|
+
if (this.#pool) {
|
|
55
|
+
await this.#pool.drain();
|
|
56
|
+
this.#pool.clear();
|
|
57
|
+
this.#pool = null;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
exports.SnowflakeDriver = SnowflakeDriver;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type DatabaseIntrospector, type DatabaseMetadata, type DatabaseMetadataOptions, type Kysely, type SchemaMetadata, type TableMetadata } from 'kysely';
|
|
2
|
+
export declare class SnowflakeIntrospector implements DatabaseIntrospector {
|
|
3
|
+
#private;
|
|
4
|
+
constructor(db: Kysely<any>);
|
|
5
|
+
getSchemas(): Promise<SchemaMetadata[]>;
|
|
6
|
+
getTables(options?: DatabaseMetadataOptions): Promise<TableMetadata[]>;
|
|
7
|
+
getMetadata(options?: DatabaseMetadataOptions): Promise<DatabaseMetadata>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SnowflakeIntrospector = void 0;
|
|
4
|
+
const kysely_1 = require("kysely");
|
|
5
|
+
class SnowflakeIntrospector {
|
|
6
|
+
#db;
|
|
7
|
+
constructor(db) {
|
|
8
|
+
this.#db = db;
|
|
9
|
+
}
|
|
10
|
+
async getSchemas() {
|
|
11
|
+
// Use uppercase table reference — PostgresQueryCompiler double-quotes identifiers,
|
|
12
|
+
// so lowercase "information_schema" would miss Snowflake's INFORMATION_SCHEMA.
|
|
13
|
+
const rows = await this.#db
|
|
14
|
+
.selectFrom('INFORMATION_SCHEMA.SCHEMATA')
|
|
15
|
+
.select('SCHEMA_NAME')
|
|
16
|
+
.$castTo()
|
|
17
|
+
.execute();
|
|
18
|
+
return rows.map((it) => ({ name: it.SCHEMA_NAME }));
|
|
19
|
+
}
|
|
20
|
+
async getTables(options = { withInternalKyselyTables: false }) {
|
|
21
|
+
let query = this.#db
|
|
22
|
+
.selectFrom('INFORMATION_SCHEMA.COLUMNS as columns')
|
|
23
|
+
.innerJoin('INFORMATION_SCHEMA.TABLES as tables', (b) => b
|
|
24
|
+
.onRef('columns.TABLE_CATALOG', '=', 'tables.TABLE_CATALOG')
|
|
25
|
+
.onRef('columns.TABLE_SCHEMA', '=', 'tables.TABLE_SCHEMA')
|
|
26
|
+
.onRef('columns.TABLE_NAME', '=', 'tables.TABLE_NAME'))
|
|
27
|
+
.select([
|
|
28
|
+
'columns.COLUMN_NAME',
|
|
29
|
+
'columns.COLUMN_DEFAULT',
|
|
30
|
+
'columns.TABLE_NAME',
|
|
31
|
+
'columns.TABLE_SCHEMA',
|
|
32
|
+
'tables.TABLE_TYPE',
|
|
33
|
+
'columns.IS_NULLABLE',
|
|
34
|
+
'columns.DATA_TYPE',
|
|
35
|
+
'columns.IS_IDENTITY',
|
|
36
|
+
])
|
|
37
|
+
// Exclude the virtual INFORMATION_SCHEMA schema from results
|
|
38
|
+
.where('columns.TABLE_SCHEMA', '!=', 'INFORMATION_SCHEMA')
|
|
39
|
+
.orderBy('columns.TABLE_NAME')
|
|
40
|
+
.orderBy('columns.ORDINAL_POSITION')
|
|
41
|
+
.$castTo();
|
|
42
|
+
if (!options.withInternalKyselyTables) {
|
|
43
|
+
query = query
|
|
44
|
+
.where('columns.TABLE_NAME', '!=', kysely_1.DEFAULT_MIGRATION_TABLE)
|
|
45
|
+
.where('columns.TABLE_NAME', '!=', kysely_1.DEFAULT_MIGRATION_LOCK_TABLE);
|
|
46
|
+
}
|
|
47
|
+
const rawColumns = await query.execute();
|
|
48
|
+
return this.#parseTableMetadata(rawColumns);
|
|
49
|
+
}
|
|
50
|
+
async getMetadata(options) {
|
|
51
|
+
return {
|
|
52
|
+
tables: await this.getTables(options),
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
#parseTableMetadata(columns) {
|
|
56
|
+
return columns.reduce((tables, it) => {
|
|
57
|
+
let table = tables.find((tbl) => tbl.name === it.TABLE_NAME && tbl.schema === it.TABLE_SCHEMA);
|
|
58
|
+
if (!table) {
|
|
59
|
+
table = Object.freeze({
|
|
60
|
+
name: it.TABLE_NAME,
|
|
61
|
+
isView: it.TABLE_TYPE === 'VIEW',
|
|
62
|
+
schema: it.TABLE_SCHEMA,
|
|
63
|
+
columns: [],
|
|
64
|
+
});
|
|
65
|
+
tables.push(table);
|
|
66
|
+
}
|
|
67
|
+
table.columns.push(Object.freeze({
|
|
68
|
+
name: it.COLUMN_NAME,
|
|
69
|
+
dataType: it.DATA_TYPE,
|
|
70
|
+
isNullable: it.IS_NULLABLE === 'YES',
|
|
71
|
+
// Snowflake uses IDENTITY columns (sequences), not auto_increment
|
|
72
|
+
isAutoIncrementing: it.IS_IDENTITY === 'YES',
|
|
73
|
+
hasDefaultValue: it.COLUMN_DEFAULT !== null,
|
|
74
|
+
}));
|
|
75
|
+
return tables;
|
|
76
|
+
}, []);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
exports.SnowflakeIntrospector = SnowflakeIntrospector;
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./SnowflakeAdapter.js"), exports);
|
|
18
|
+
__exportStar(require("./SnowflakeConnection.js"), exports);
|
|
19
|
+
__exportStar(require("./SnowflakeDialect.js"), exports);
|
|
20
|
+
__exportStar(require("./SnowflakeDriver.js"), exports);
|
|
21
|
+
__exportStar(require("./SnowflakeIntrospector.js"), exports);
|
package/package.json
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "snowflake-kysely-dialect",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Snowflake dialect for Kysely",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist"
|
|
9
|
+
],
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "tsc",
|
|
12
|
+
"prepare": "tsc",
|
|
13
|
+
"test": "vitest"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"kysely",
|
|
17
|
+
"snowflake"
|
|
18
|
+
],
|
|
19
|
+
"license": "MIT",
|
|
20
|
+
"peerDependencies": {
|
|
21
|
+
"kysely": "*",
|
|
22
|
+
"snowflake-sdk": "*"
|
|
23
|
+
},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@types/node": "^22.0.0",
|
|
26
|
+
"kysely": "^0.28.0",
|
|
27
|
+
"snowflake-sdk": "^2.4.0",
|
|
28
|
+
"typescript": "^5.3.3",
|
|
29
|
+
"vitest": "^1.2.1"
|
|
30
|
+
}
|
|
31
|
+
}
|