kysely 0.30.0-beta.1 → 0.30.0-beta.2

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.
Files changed (30) hide show
  1. package/README.md +1 -1
  2. package/dist/dialect/database-introspector.d.ts +38 -4
  3. package/dist/dialect/mssql/mssql-introspector.d.ts +2 -2
  4. package/dist/dialect/mssql/mssql-introspector.js +32 -2
  5. package/dist/dialect/mysql/mysql-introspector.d.ts +2 -2
  6. package/dist/dialect/mysql/mysql-introspector.js +34 -11
  7. package/dist/dialect/postgres/postgres-introspector.d.ts +2 -2
  8. package/dist/dialect/postgres/postgres-introspector.js +18 -7
  9. package/dist/dialect/sqlite/sqlite-driver.js +7 -8
  10. package/dist/dialect/sqlite/sqlite-introspector.js +7 -3
  11. package/dist/driver/dummy-driver.d.ts +2 -2
  12. package/dist/driver/dummy-driver.js +2 -2
  13. package/dist/kysely.d.ts +27 -7
  14. package/dist/kysely.js +0 -14
  15. package/dist/migration/migrator.js +22 -13
  16. package/dist/query-builder/delete-query-builder.d.ts +2 -2
  17. package/dist/query-builder/function-module.d.ts +8 -2
  18. package/dist/query-builder/join-builder.d.ts +2 -2
  19. package/dist/query-builder/merge-query-builder.d.ts +9 -1
  20. package/dist/query-builder/select-query-builder.d.ts +28 -6
  21. package/dist/query-builder/update-query-builder.d.ts +1 -1
  22. package/dist/query-creator.d.ts +9 -0
  23. package/dist/raw-builder/raw-builder.d.ts +5 -0
  24. package/dist/raw-builder/raw-builder.js +12 -0
  25. package/dist/readonly/readonly-kysely.d.ts +64 -10
  26. package/dist/readonly/readonly-query-creator.d.ts +9 -1
  27. package/dist/schema/create-type-builder.d.ts +1 -1
  28. package/dist/schema/create-type-builder.js +1 -1
  29. package/dist/util/abort.js +2 -0
  30. package/package.json +18 -16
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  [![Stand With Ukraine](https://raw.githubusercontent.com/vshymanskyy/StandWithUkraine/main/banner2-direct.svg)](https://stand-with-ukraine.pp.ua)
2
2
 
3
3
  [![NPM Version](https://img.shields.io/npm/v/kysely?style=flat&label=latest)](https://github.com/kysely-org/kysely/releases/latest)
4
- [![Socket Badge](https://badge.socket.dev/npm/package/kysely/0.30.0-beta.1)](https://socket.dev/npm/package/kysely/overview/0.30.0-beta.1)
4
+ [![Socket Badge](https://badge.socket.dev/npm/package/kysely/0.30.0-beta.2)](https://socket.dev/npm/package/kysely/overview/0.30.0-beta.2)
5
5
  [![Tests](https://github.com/kysely-org/kysely/actions/workflows/test.yml/badge.svg)](https://github.com/kysely-org/kysely)
6
6
  [![License](https://img.shields.io/github/license/kysely-org/kysely?style=flat)](https://github.com/kysely-org/kysely/blob/master/LICENSE)
7
7
  [![Issues](https://img.shields.io/github/issues-closed/kysely-org/kysely?logo=github)](https://github.com/kysely-org/kysely/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc)
@@ -1,3 +1,5 @@
1
+ import type { Expression } from '../expression/expression.js';
2
+ import type { SqlBool } from '../util/type-utils.js';
1
3
  /**
2
4
  * An interface for getting the database metadata (names of the tables and columns etc.)
3
5
  */
@@ -5,27 +7,59 @@ export interface DatabaseIntrospector {
5
7
  /**
6
8
  * Get schema metadata.
7
9
  */
8
- getSchemas(): Promise<SchemaMetadata[]>;
10
+ getSchemas(options?: DatabaseSchemaMetadataOptions): Promise<SchemaMetadata[]>;
9
11
  /**
10
12
  * Get tables and views metadata.
11
13
  */
12
14
  getTables(options?: DatabaseMetadataOptions): Promise<TableMetadata[]>;
13
15
  }
16
+ export interface DatabaseSchemaMetadataOptions {
17
+ /**
18
+ * An optional SQL `where` expression for filtering the schemas returned by
19
+ * the introspector.
20
+ *
21
+ * The refs argument contains an SQL reference to the schema name column
22
+ * within the catalog query this expression will be used in.
23
+ */
24
+ where?: (refs: Readonly<{
25
+ schema: Expression<string>;
26
+ }>) => Expression<SqlBool>;
27
+ }
14
28
  export interface DatabaseMetadataOptions {
29
+ /**
30
+ * An optional SQL `where` expression for filtering the tables returned by
31
+ * the introspector.
32
+ *
33
+ * The refs argument contains SQL references to the table name and optional
34
+ * schema name columns within the catalog query this expression will be used
35
+ * in.
36
+ */
37
+ where?: (refs: Readonly<{
38
+ table: Expression<string>;
39
+ schema?: Expression<string>;
40
+ }>) => Expression<SqlBool>;
15
41
  /**
16
42
  * If this is true, the metadata contains the internal kysely tables
17
43
  * such as the migration tables.
18
44
  */
19
45
  withInternalKyselyTables: boolean;
46
+ /**
47
+ * If this is true, tables from non-default databases are also returned.
48
+ *
49
+ * This option only affects MySQL and defaults to false. System databases are
50
+ * excluded regardless of this option.
51
+ */
52
+ withNonDefaultDatabases?: boolean;
20
53
  }
21
54
  export interface SchemaMetadata {
22
55
  readonly name: string;
23
56
  }
24
57
  export interface TableMetadata {
25
- readonly name: string;
26
- readonly isView: boolean;
27
- readonly isForeign: boolean;
28
58
  readonly columns: ColumnMetadata[];
59
+ readonly comment?: string;
60
+ readonly isForeign: boolean;
61
+ readonly isView: boolean;
62
+ readonly name: string;
29
63
  readonly schema?: string;
30
64
  }
31
65
  export interface ColumnMetadata {
@@ -1,12 +1,12 @@
1
1
  import type { Kysely } from '../../kysely.js';
2
- import type { DatabaseIntrospector, DatabaseMetadataOptions, SchemaMetadata, TableMetadata } from '../database-introspector.js';
2
+ import type { DatabaseIntrospector, DatabaseMetadataOptions, DatabaseSchemaMetadataOptions, SchemaMetadata, TableMetadata } from '../database-introspector.js';
3
3
  export declare class MssqlIntrospector implements DatabaseIntrospector {
4
4
  #private;
5
5
  constructor(db: Kysely<any>);
6
6
  /**
7
7
  * Get schema metadata.
8
8
  */
9
- getSchemas(): Promise<SchemaMetadata[]>;
9
+ getSchemas(options?: DatabaseSchemaMetadataOptions): Promise<SchemaMetadata[]>;
10
10
  /**
11
11
  * Get tables and views metadata.
12
12
  */
@@ -1,15 +1,28 @@
1
1
  /// <reference types="./mssql-introspector.d.ts" />
2
2
  import { DEFAULT_MIGRATION_LOCK_TABLE, DEFAULT_MIGRATION_TABLE, } from '../../migration/migrator.js';
3
+ import { sql } from '../../raw-builder/sql.js';
3
4
  import { freeze } from '../../util/object-utils.js';
4
5
  export class MssqlIntrospector {
5
6
  #db;
6
7
  constructor(db) {
7
8
  this.#db = db;
8
9
  }
9
- async getSchemas() {
10
- return await this.#db.selectFrom('sys.schemas').select('name').execute();
10
+ async getSchemas(options = {}) {
11
+ let query = this.#db.selectFrom('sys.schemas').select('name');
12
+ if (options.where) {
13
+ query = query.where(options.where({ schema: sql.ref('name') }));
14
+ }
15
+ return await query.execute();
11
16
  }
12
17
  async getTables(options = { withInternalKyselyTables: false }) {
18
+ const tablesWhere = options.where?.({
19
+ schema: sql.ref('table_schemas.name'),
20
+ table: sql.ref('tables.name'),
21
+ });
22
+ const viewsWhere = options.where?.({
23
+ schema: sql.ref('view_schemas.name'),
24
+ table: sql.ref('views.name'),
25
+ });
13
26
  const rawColumns = await this.#db
14
27
  .selectFrom('sys.tables as tables')
15
28
  .leftJoin('sys.schemas as table_schemas', 'table_schemas.schema_id', 'tables.schema_id')
@@ -17,12 +30,19 @@ export class MssqlIntrospector {
17
30
  .innerJoin('sys.types as types', 'types.user_type_id', 'columns.user_type_id')
18
31
  .leftJoin('sys.schemas as type_schemas', 'type_schemas.schema_id', 'types.schema_id')
19
32
  .leftJoin('sys.extended_properties as comments', (join) => join
33
+ .on('comments.class', '=', 1)
20
34
  .onRef('comments.major_id', '=', 'tables.object_id')
21
35
  .onRef('comments.minor_id', '=', 'columns.column_id')
22
36
  .on('comments.name', '=', 'MS_Description'))
37
+ .leftJoin('sys.extended_properties as table_comments', (join) => join
38
+ .on('table_comments.class', '=', 1)
39
+ .onRef('table_comments.major_id', '=', 'tables.object_id')
40
+ .on('table_comments.minor_id', '=', 0)
41
+ .on('table_comments.name', '=', 'MS_Description'))
23
42
  .$if(!options.withInternalKyselyTables, (qb) => qb
24
43
  .where('tables.name', '!=', DEFAULT_MIGRATION_TABLE)
25
44
  .where('tables.name', '!=', DEFAULT_MIGRATION_LOCK_TABLE))
45
+ .$if(!!tablesWhere, (qb) => qb.where(tablesWhere))
26
46
  .select([
27
47
  'tables.name as table_name',
28
48
  (eb) => eb
@@ -41,6 +61,7 @@ export class MssqlIntrospector {
41
61
  'types.name as type_name',
42
62
  'type_schemas.name as type_schema_name',
43
63
  'comments.value as column_comment',
64
+ 'table_comments.value as table_comment',
44
65
  ])
45
66
  .unionAll(this.#db
46
67
  .selectFrom('sys.views as views')
@@ -49,9 +70,16 @@ export class MssqlIntrospector {
49
70
  .innerJoin('sys.types as types', 'types.user_type_id', 'columns.user_type_id')
50
71
  .leftJoin('sys.schemas as type_schemas', 'type_schemas.schema_id', 'types.schema_id')
51
72
  .leftJoin('sys.extended_properties as comments', (join) => join
73
+ .on('comments.class', '=', 1)
52
74
  .onRef('comments.major_id', '=', 'views.object_id')
53
75
  .onRef('comments.minor_id', '=', 'columns.column_id')
54
76
  .on('comments.name', '=', 'MS_Description'))
77
+ .leftJoin('sys.extended_properties as table_comments', (join) => join
78
+ .on('table_comments.class', '=', 1)
79
+ .onRef('table_comments.major_id', '=', 'views.object_id')
80
+ .on('table_comments.minor_id', '=', 0)
81
+ .on('table_comments.name', '=', 'MS_Description'))
82
+ .$if(!!viewsWhere, (qb) => qb.where(viewsWhere))
55
83
  .select([
56
84
  'views.name as table_name',
57
85
  'views.type as table_type',
@@ -67,6 +95,7 @@ export class MssqlIntrospector {
67
95
  'types.name as type_name',
68
96
  'type_schemas.name as type_schema_name',
69
97
  'comments.value as column_comment',
98
+ 'table_comments.value as table_comment',
70
99
  ]))
71
100
  .orderBy('table_schema_name')
72
101
  .orderBy('table_name')
@@ -79,6 +108,7 @@ export class MssqlIntrospector {
79
108
  tableDictionary[key] ||
80
109
  freeze({
81
110
  columns: [],
111
+ comment: rawColumn.table_comment ?? undefined,
82
112
  isForeign: false,
83
113
  isView: rawColumn.table_type === 'V ',
84
114
  name: rawColumn.table_name,
@@ -1,4 +1,4 @@
1
- import type { DatabaseIntrospector, DatabaseMetadataOptions, SchemaMetadata, TableMetadata } from '../database-introspector.js';
1
+ import type { DatabaseIntrospector, DatabaseMetadataOptions, DatabaseSchemaMetadataOptions, SchemaMetadata, TableMetadata } from '../database-introspector.js';
2
2
  import type { Kysely } from '../../kysely.js';
3
3
  export declare class MysqlIntrospector implements DatabaseIntrospector {
4
4
  #private;
@@ -6,7 +6,7 @@ export declare class MysqlIntrospector implements DatabaseIntrospector {
6
6
  /**
7
7
  * Get schema metadata.
8
8
  */
9
- getSchemas(): Promise<SchemaMetadata[]>;
9
+ getSchemas(options?: DatabaseSchemaMetadataOptions): Promise<SchemaMetadata[]>;
10
10
  /**
11
11
  * Get tables and views metadata.
12
12
  */
@@ -2,18 +2,27 @@
2
2
  import { DEFAULT_MIGRATION_LOCK_TABLE, DEFAULT_MIGRATION_TABLE, } from '../../migration/migrator.js';
3
3
  import { freeze } from '../../util/object-utils.js';
4
4
  import { sql } from '../../raw-builder/sql.js';
5
+ const SYSTEM_DATABASES = [
6
+ 'information_schema',
7
+ 'mysql',
8
+ 'performance_schema',
9
+ 'sys',
10
+ 'ndbinfo',
11
+ ];
5
12
  export class MysqlIntrospector {
6
13
  #db;
7
14
  constructor(db) {
8
15
  this.#db = db;
9
16
  }
10
- async getSchemas() {
11
- let rawSchemas = await this.#db
17
+ async getSchemas(options = {}) {
18
+ let query = this.#db
12
19
  .selectFrom('information_schema.schemata')
13
- .select('schema_name')
14
- .$castTo()
15
- .execute();
16
- return rawSchemas.map((it) => ({ name: it.SCHEMA_NAME }));
20
+ .select('schema_name as name')
21
+ .$narrowType();
22
+ if (options.where) {
23
+ query = query.where(options.where({ schema: sql.ref('schema_name') }));
24
+ }
25
+ return await query.execute();
17
26
  }
18
27
  async getTables(options = { withInternalKyselyTables: false }) {
19
28
  let query = this.#db
@@ -28,34 +37,48 @@ export class MysqlIntrospector {
28
37
  'columns.TABLE_NAME',
29
38
  'columns.TABLE_SCHEMA',
30
39
  'tables.TABLE_TYPE',
40
+ 'tables.TABLE_COMMENT',
31
41
  'tables.ENGINE',
32
42
  'columns.IS_NULLABLE',
33
43
  'columns.DATA_TYPE',
34
44
  'columns.EXTRA',
35
45
  'columns.COLUMN_COMMENT',
36
46
  ])
37
- .where('columns.TABLE_SCHEMA', '=', sql `database()`)
47
+ .where('columns.TABLE_SCHEMA', 'not in', SYSTEM_DATABASES)
48
+ .orderBy('columns.TABLE_SCHEMA')
38
49
  .orderBy('columns.TABLE_NAME')
39
50
  .orderBy('columns.ORDINAL_POSITION')
40
51
  .$castTo();
52
+ if (!options.withNonDefaultDatabases) {
53
+ query = query.where('columns.TABLE_SCHEMA', '=', sql `database()`);
54
+ }
41
55
  if (!options.withInternalKyselyTables) {
42
56
  query = query
43
57
  .where('columns.TABLE_NAME', '!=', DEFAULT_MIGRATION_TABLE)
44
58
  .where('columns.TABLE_NAME', '!=', DEFAULT_MIGRATION_LOCK_TABLE);
45
59
  }
60
+ if (options.where) {
61
+ query = query.where(options.where({
62
+ schema: sql.ref('columns.TABLE_SCHEMA'),
63
+ table: sql.ref('columns.TABLE_NAME'),
64
+ }));
65
+ }
46
66
  const rawColumns = await query.execute();
47
67
  return this.#parseTableMetadata(rawColumns);
48
68
  }
49
69
  #parseTableMetadata(columns) {
50
70
  return columns.reduce((tables, it) => {
51
- let table = tables.find((tbl) => tbl.name === it.TABLE_NAME);
71
+ let table = tables.find((tbl) => tbl.name === it.TABLE_NAME && tbl.schema === it.TABLE_SCHEMA);
52
72
  if (!table) {
53
73
  table = freeze({
54
- name: it.TABLE_NAME,
55
- isView: it.TABLE_TYPE === 'VIEW',
74
+ columns: [],
75
+ comment: it.TABLE_TYPE === 'VIEW' || it.TABLE_COMMENT === ''
76
+ ? undefined
77
+ : it.TABLE_COMMENT,
56
78
  isForeign: it.ENGINE === 'FEDERATED',
79
+ isView: it.TABLE_TYPE === 'VIEW',
80
+ name: it.TABLE_NAME,
57
81
  schema: it.TABLE_SCHEMA,
58
- columns: [],
59
82
  });
60
83
  tables.push(table);
61
84
  }
@@ -1,4 +1,4 @@
1
- import type { DatabaseIntrospector, DatabaseMetadataOptions, SchemaMetadata, TableMetadata } from '../database-introspector.js';
1
+ import type { DatabaseIntrospector, DatabaseMetadataOptions, DatabaseSchemaMetadataOptions, SchemaMetadata, TableMetadata } from '../database-introspector.js';
2
2
  import type { Kysely } from '../../kysely.js';
3
3
  export declare class PostgresIntrospector implements DatabaseIntrospector {
4
4
  #private;
@@ -6,7 +6,7 @@ export declare class PostgresIntrospector implements DatabaseIntrospector {
6
6
  /**
7
7
  * Get schema metadata.
8
8
  */
9
- getSchemas(): Promise<SchemaMetadata[]>;
9
+ getSchemas(options?: DatabaseSchemaMetadataOptions): Promise<SchemaMetadata[]>;
10
10
  /**
11
11
  * Get tables and views metadata.
12
12
  */
@@ -7,13 +7,15 @@ export class PostgresIntrospector {
7
7
  constructor(db) {
8
8
  this.#db = db;
9
9
  }
10
- async getSchemas() {
11
- let rawSchemas = await this.#db
10
+ async getSchemas(options = {}) {
11
+ let query = this.#db
12
12
  .selectFrom('pg_catalog.pg_namespace')
13
- .select('nspname')
14
- .$castTo()
15
- .execute();
16
- return rawSchemas.map((it) => ({ name: it.nspname }));
13
+ .select('nspname as name')
14
+ .$narrowType();
15
+ if (options.where) {
16
+ query = query.where(options.where({ schema: sql.ref('nspname') }));
17
+ }
18
+ return await query.execute();
17
19
  }
18
20
  async getTables(options = { withInternalKyselyTables: false }) {
19
21
  let query = this.#db
@@ -36,12 +38,14 @@ export class PostgresIntrospector {
36
38
  'ns.nspname as schema',
37
39
  'typ.typname as type',
38
40
  'dtns.nspname as type_schema',
41
+ sql `obj_description(c.oid, 'pg_class')`.as('table_description'),
39
42
  sql `col_description(a.attrelid, a.attnum)`.as('column_description'),
40
43
  sql `pg_get_serial_sequence(quote_ident(ns.nspname) || '.' || quote_ident(c.relname), a.attname)`.as('auto_incrementing'),
41
44
  ])
42
45
  .where('c.relkind', 'in', [
43
46
  'r' /*regular table*/,
44
47
  'v' /*view*/,
48
+ 'm' /*materialized view*/,
45
49
  'p' /*partitioned table*/,
46
50
  'f' /*foreign table*/,
47
51
  ])
@@ -63,6 +67,12 @@ export class PostgresIntrospector {
63
67
  .where('c.relname', '!=', DEFAULT_MIGRATION_TABLE)
64
68
  .where('c.relname', '!=', DEFAULT_MIGRATION_LOCK_TABLE);
65
69
  }
70
+ if (options.where) {
71
+ query = query.where(options.where({
72
+ schema: sql.ref('ns.nspname'),
73
+ table: sql.ref('c.relname'),
74
+ }));
75
+ }
66
76
  const rawColumns = await query.execute();
67
77
  return this.#parseTableMetadata(rawColumns);
68
78
  }
@@ -79,8 +89,9 @@ export class PostgresIntrospector {
79
89
  if (!table) {
80
90
  table = freeze({
81
91
  columns: [],
92
+ comment: column.table_description ?? undefined,
82
93
  isForeign: column.table_type === 'f',
83
- isView: column.table_type === 'v',
94
+ isView: column.table_type === 'v' || column.table_type === 'm',
84
95
  name: column.table,
85
96
  schema: column.schema,
86
97
  });
@@ -1,5 +1,4 @@
1
1
  /// <reference types="./sqlite-driver.d.ts" />
2
- import { SelectQueryNode } from '../../operation-node/select-query-node.js';
3
2
  import { parseSavepointCommand } from '../../parser/savepoint-parser.js';
4
3
  import { CompiledQuery } from '../../query-compiler/compiled-query.js';
5
4
  import { freeze, isFunction } from '../../util/object-utils.js';
@@ -68,14 +67,14 @@ class SqliteConnection {
68
67
  rows: [],
69
68
  };
70
69
  }
71
- async *streamQuery(compiledQuery, _chunkSize) {
72
- const { sql, parameters, query } = compiledQuery;
73
- const stmt = this.#db.prepare(sql);
74
- if (!SelectQueryNode.is(query)) {
75
- throw new Error('Sqlite driver only supports streaming of select queries');
70
+ async *streamQuery(compiledQuery) {
71
+ const { sql, parameters } = compiledQuery;
72
+ const statement = this.#db.prepare(sql);
73
+ if (!statement.reader) {
74
+ throw new Error('Sqlite driver only supports streaming of queries that return rows');
76
75
  }
77
- const iter = stmt.iterate(parameters);
78
- for (const row of iter) {
76
+ const rows = statement.iterate(parameters);
77
+ for (const row of rows) {
79
78
  yield {
80
79
  rows: [row],
81
80
  };
@@ -25,6 +25,9 @@ export class SqliteIntrospector {
25
25
  .where('name', '!=', DEFAULT_MIGRATION_TABLE)
26
26
  .where('name', '!=', DEFAULT_MIGRATION_LOCK_TABLE);
27
27
  }
28
+ if (options.where) {
29
+ tablesQuery = tablesQuery.where(options.where({ table: sql.ref('name') }));
30
+ }
28
31
  return tablesQuery;
29
32
  }
30
33
  async #getTableMetadata(options) {
@@ -70,9 +73,6 @@ export class SqliteIntrospector {
70
73
  }
71
74
  }
72
75
  return {
73
- name: name,
74
- isView: type === 'view',
75
- isForeign: false,
76
76
  columns: columns.map((col) => ({
77
77
  name: col.name,
78
78
  dataType: col.type,
@@ -81,6 +81,10 @@ export class SqliteIntrospector {
81
81
  hasDefaultValue: col.dflt_value != null,
82
82
  comment: undefined,
83
83
  })),
84
+ comment: undefined,
85
+ isForeign: false,
86
+ isView: type === 'view',
87
+ name,
84
88
  };
85
89
  });
86
90
  }
@@ -29,8 +29,8 @@ import type { Driver } from './driver.js';
29
29
  * })
30
30
  * ```
31
31
  *
32
- * You can use it to build a query and compile it to SQL but trying to
33
- * execute the query will throw an error.
32
+ * You can use it to build a query and compile it to SQL. Executing queries
33
+ * returns empty results without communicating with a database.
34
34
  *
35
35
  * ```ts
36
36
  * const { sql } = db.selectFrom('person').selectAll().compile()
@@ -28,8 +28,8 @@
28
28
  * })
29
29
  * ```
30
30
  *
31
- * You can use it to build a query and compile it to SQL but trying to
32
- * execute the query will throw an error.
31
+ * You can use it to build a query and compile it to SQL. Executing queries
32
+ * returns empty results without communicating with a database.
33
33
  *
34
34
  * ```ts
35
35
  * const { sql } = db.selectFrom('person').selectAll().compile()
package/dist/kysely.d.ts CHANGED
@@ -14,7 +14,6 @@ import type { CompiledQuery } from './query-compiler/compiled-query.js';
14
14
  import { type Compilable } from './util/compilable.js';
15
15
  import { CaseBuilder } from './query-builder/case-builder.js';
16
16
  import type { Expression } from './expression/expression.js';
17
- import type { DrainOuterGeneric } from './util/type-utils.js';
18
17
  import type { ReleaseSavepoint, RollbackToSavepoint } from './parser/savepoint-parser.js';
19
18
  import { type ControlledConnection } from './util/provide-controlled-connection.js';
20
19
  import type { AbortableOperationOptions, AbortableQueryOptions } from './util/abort.js';
@@ -60,6 +59,7 @@ declare global {
60
59
  */
61
60
  export declare class Kysely<DB> extends QueryCreator<DB> implements QueryExecutorProvider, AsyncDisposable {
62
61
  #private;
62
+ protected readonly '~DB': QueryCreator<DB>['~DB'];
63
63
  constructor(args: KyselyConfig);
64
64
  constructor(args: KyselyProps);
65
65
  /**
@@ -380,7 +380,7 @@ export declare class Kysely<DB> extends QueryCreator<DB> implements QueryExecuto
380
380
  * .execute()
381
381
  * ```
382
382
  */
383
- $extendTables<T extends Record<string, Record<string, any>>>(): Kysely<DrainOuterGeneric<DB & T>>;
383
+ $extendTables<T extends Record<string, Record<string, any>>>(): Kysely<DB & T>;
384
384
  /**
385
385
  * Returns a copy of this Kysely instance without the given tables (provided as
386
386
  * a union type of table names).
@@ -446,7 +446,7 @@ export declare class Kysely<DB> extends QueryCreator<DB> implements QueryExecuto
446
446
  /**
447
447
  * @deprecated use {@link $extendTables} instead.
448
448
  */
449
- withTables<T extends Record<string, Record<string, any>>>(): Kysely<DrainOuterGeneric<DB & T>>;
449
+ withTables<T extends Record<string, Record<string, any>>>(): Kysely<DB & T>;
450
450
  /**
451
451
  * Releases all resources and disconnects from the database.
452
452
  *
@@ -514,19 +514,30 @@ export declare class Transaction<DB> extends Kysely<DB> {
514
514
  *
515
515
  * @deprecated use {@link $extendTables} instead.
516
516
  */
517
- withTables<T extends Record<string, Record<string, any>>>(): Transaction<DrainOuterGeneric<DB & T>>;
517
+ withTables<T extends Record<string, Record<string, any>>>(): Transaction<DB & T>;
518
+ /**
519
+ * @deprecated use {@link $extendTables} instead.
520
+ */
521
+ withTables<T extends Record<string, Record<string, any>>>(): Kysely<DB & T>;
522
+ withTables<T extends Record<string, Record<string, any>>>(): Transaction<DB & T>;
518
523
  /**
519
524
  * Similar to {@link Kysely.$extendTables} but returns the transaction.
520
525
  */
521
- $extendTables<T extends Record<string, Record<string, any>>>(): Transaction<DrainOuterGeneric<DB & T>>;
526
+ $extendTables<T extends Record<string, Record<string, any>>>(): Transaction<DB & T>;
527
+ $extendTables<T extends Record<string, Record<string, any>>>(): Kysely<DB & T>;
528
+ $extendTables<T extends Record<string, Record<string, any>>>(): Transaction<DB & T>;
522
529
  /**
523
530
  * Similar to {@link Kysely.$omitTables} but returns the transaction.
524
531
  */
525
532
  $omitTables<T extends keyof DB>(): Transaction<DB extends object ? Omit<DB, T> : DB>;
533
+ $omitTables<T extends keyof DB>(): Kysely<DB extends object ? Omit<DB, T> : DB>;
534
+ $omitTables<T extends keyof DB>(): Transaction<DB extends object ? Omit<DB, T> : DB>;
526
535
  /**
527
536
  * Similar to {@link Kysely.$pickTables} but returns the transaction.
528
537
  */
529
538
  $pickTables<T extends keyof DB>(): Transaction<DB extends object ? Pick<DB, T> : DB>;
539
+ $pickTables<T extends keyof DB>(): Kysely<DB extends object ? Pick<DB, T> : DB>;
540
+ $pickTables<T extends keyof DB>(): Transaction<DB extends object ? Pick<DB, T> : DB>;
530
541
  }
531
542
  export interface KyselyProps {
532
543
  readonly config: KyselyConfig;
@@ -777,10 +788,19 @@ export declare class ControlledTransaction<DB, S extends string[] = []> extends
777
788
  *
778
789
  * @deprecated use {@link $extendTables} instead.
779
790
  */
780
- withTables<T extends Record<string, Record<string, any>>>(): ControlledTransaction<DrainOuterGeneric<DB & T>, S>;
781
- $extendTables<T extends Record<string, Record<string, any>>>(): ControlledTransaction<DrainOuterGeneric<DB & T>, S>;
791
+ withTables<T extends Record<string, Record<string, any>>>(): ControlledTransaction<DB & T, S>;
792
+ withTables<T extends Record<string, Record<string, any>>>(): Kysely<DB & T>;
793
+ withTables<T extends Record<string, Record<string, any>>>(): ControlledTransaction<DB & T, S>;
794
+ $extendTables<T extends Record<string, Record<string, any>>>(): ControlledTransaction<DB & T, S>;
795
+ $extendTables<T extends Record<string, Record<string, any>>>(): Kysely<DB & T>;
796
+ $extendTables<T extends Record<string, Record<string, any>>>(): ControlledTransaction<DB & T, S>;
797
+ $omitTables<T extends keyof DB>(): ControlledTransaction<DB extends object ? Omit<DB, T> : DB, S>;
798
+ $omitTables<T extends keyof DB>(): Kysely<DB extends object ? Omit<DB, T> : DB>;
799
+ $omitTables<T extends keyof DB>(): Transaction<DB extends object ? Omit<DB, T> : DB>;
782
800
  $omitTables<T extends keyof DB>(): ControlledTransaction<DB extends object ? Omit<DB, T> : DB, S>;
783
801
  $pickTables<T extends keyof DB>(): ControlledTransaction<DB extends object ? Pick<DB, T> : DB, S>;
802
+ $pickTables<T extends keyof DB>(): Kysely<DB extends object ? Pick<DB, T> : DB>;
803
+ $pickTables<T extends keyof DB>(): ControlledTransaction<DB extends object ? Pick<DB, T> : DB, S>;
784
804
  }
785
805
  interface ControlledTransactionProps extends KyselyProps {
786
806
  readonly connection: ControlledConnection;
package/dist/kysely.js CHANGED
@@ -601,29 +601,15 @@ export class Transaction extends Kysely {
601
601
  executor: this.#props.executor.withPluginAtFront(new WithSchemaPlugin(schema)),
602
602
  });
603
603
  }
604
- /**
605
- * Similar to {@link Kysely.withTables} but returns the transaction.
606
- *
607
- * @deprecated use {@link $extendTables} instead.
608
- */
609
604
  withTables() {
610
605
  return new Transaction({ ...this.#props });
611
606
  }
612
- /**
613
- * Similar to {@link Kysely.$extendTables} but returns the transaction.
614
- */
615
607
  $extendTables() {
616
608
  return new Transaction({ ...this.#props });
617
609
  }
618
- /**
619
- * Similar to {@link Kysely.$omitTables} but returns the transaction.
620
- */
621
610
  $omitTables() {
622
611
  return new Transaction({ ...this.#props });
623
612
  }
624
- /**
625
- * Similar to {@link Kysely.$pickTables} but returns the transaction.
626
- */
627
613
  $pickTables() {
628
614
  return new Transaction({ ...this.#props });
629
615
  }
@@ -1,6 +1,7 @@
1
1
  /// <reference types="./migrator.d.ts" />
2
2
  import { NoopPlugin } from '../plugin/noop-plugin.js';
3
3
  import { WithSchemaPlugin } from '../plugin/with-schema/with-schema-plugin.js';
4
+ import { sql } from '../raw-builder/sql.js';
4
5
  import { logOnce } from '../util/log-once.js';
5
6
  import { freeze, isObject } from '../util/object-utils.js';
6
7
  export const DEFAULT_MIGRATION_TABLE = 'kysely_migration';
@@ -53,7 +54,7 @@ export class Migrator {
53
54
  * The returned array is sorted by migration name.
54
55
  */
55
56
  async getMigrations() {
56
- const tableExists = await this.#doesTableExist(this.#migrationTable);
57
+ const tableExists = await this.#doesTableExist(this.#migrationTableSchema, this.#migrationTable);
57
58
  const executedMigrations = tableExists
58
59
  ? await this.#props.db
59
60
  .withPlugin(this.#schemaPlugin)
@@ -329,7 +330,7 @@ export class Migrator {
329
330
  // Use default schema. Nothing to do.
330
331
  return;
331
332
  }
332
- const schemaExists = await this.#doesSchemaExist();
333
+ const schemaExists = await this.#doesSchemaExist(this.#migrationTableSchema);
333
334
  if (schemaExists) {
334
335
  return;
335
336
  }
@@ -337,7 +338,7 @@ export class Migrator {
337
338
  await this.#createIfNotExists(this.#props.db.schema.createSchema(this.#migrationTableSchema));
338
339
  }
339
340
  catch (error) {
340
- const schemaExists = await this.#doesSchemaExist();
341
+ const schemaExists = await this.#doesSchemaExist(this.#migrationTableSchema);
341
342
  // At least on PostgreSQL, `if not exists` doesn't guarantee the `create schema`
342
343
  // query doesn't throw if the schema already exits. That's why we check if
343
344
  // the schema exist here and ignore the error if it does.
@@ -347,7 +348,7 @@ export class Migrator {
347
348
  }
348
349
  }
349
350
  async #ensureMigrationTableExists() {
350
- const tableExists = await this.#doesTableExist(this.#migrationTable);
351
+ const tableExists = await this.#doesTableExist(this.#migrationTableSchema, this.#migrationTable);
351
352
  if (tableExists) {
352
353
  return;
353
354
  }
@@ -361,7 +362,7 @@ export class Migrator {
361
362
  .addColumn('timestamp', 'varchar(255)', (col) => col.notNull()));
362
363
  }
363
364
  catch (error) {
364
- const tableExists = await this.#doesTableExist(this.#migrationTable);
365
+ const tableExists = await this.#doesTableExist(this.#migrationTableSchema, this.#migrationTable);
365
366
  // At least on PostgreSQL, `if not exists` doesn't guarantee the `create table`
366
367
  // query doesn't throw if the table already exits. That's why we check if
367
368
  // the table exist here and ignore the error if it does.
@@ -371,7 +372,7 @@ export class Migrator {
371
372
  }
372
373
  }
373
374
  async #ensureMigrationLockTableExists() {
374
- const tableExists = await this.#doesTableExist(this.#migrationLockTable);
375
+ const tableExists = await this.#doesTableExist(this.#migrationTableSchema, this.#migrationLockTable);
375
376
  if (tableExists) {
376
377
  return;
377
378
  }
@@ -383,7 +384,7 @@ export class Migrator {
383
384
  .addColumn('is_locked', 'integer', (col) => col.notNull().defaultTo(0)));
384
385
  }
385
386
  catch (error) {
386
- const tableExists = await this.#doesTableExist(this.#migrationLockTable);
387
+ const tableExists = await this.#doesTableExist(this.#migrationTableSchema, this.#migrationLockTable);
387
388
  // At least on PostgreSQL, `if not exists` doesn't guarantee the `create table`
388
389
  // query doesn't throw if the table already exits. That's why we check if
389
390
  // the table exist here and ignore the error if it does.
@@ -411,16 +412,24 @@ export class Migrator {
411
412
  }
412
413
  }
413
414
  }
414
- async #doesSchemaExist() {
415
- const schemas = await this.#props.db.introspection.getSchemas();
416
- return schemas.some((it) => it.name === this.#migrationTableSchema);
415
+ async #doesSchemaExist(schemaName) {
416
+ const schemas = await this.#props.db.introspection.getSchemas({
417
+ where: ({ schema }) => sql `${schema} = ${schemaName}`,
418
+ });
419
+ // we still keep this in case the introspector doesn't implement support for
420
+ // `where`.
421
+ return schemas.some((it) => it.name === schemaName);
417
422
  }
418
- async #doesTableExist(tableName) {
419
- const schema = this.#migrationTableSchema;
423
+ async #doesTableExist(schemaName, tableName) {
420
424
  const tables = await this.#props.db.introspection.getTables({
425
+ where: ({ schema, table }) => schemaName != null && schema
426
+ ? sql `${schema} = ${schemaName} and ${table} = ${tableName}`
427
+ : sql `${table} = ${tableName}`,
421
428
  withInternalKyselyTables: true,
422
429
  });
423
- return tables.some((it) => it.name === tableName && (!schema || it.schema === schema));
430
+ // we still keep this in case the introspector doesn't implement support for
431
+ // `where`.
432
+ return tables.some((it) => it.name === tableName && (!schemaName || it.schema === schemaName));
424
433
  }
425
434
  async #doesLockRowExists() {
426
435
  const lockRow = await this.#props.db
@@ -1039,7 +1039,7 @@ export declare class DeleteQueryBuilder<DB, TB extends keyof DB, O> implements W
1039
1039
  * delete from `pet` order by `created_at` limit ?
1040
1040
  * ```
1041
1041
  */
1042
- limit(limit: ValueExpression<DB, TB, number>): DeleteQueryBuilder<DB, TB, O>;
1042
+ limit<VE extends ValueExpression<DB, TB, number>>(limit: VE): DeleteQueryBuilder<DB, TB, O>;
1043
1043
  /**
1044
1044
  * This can be used to add any additional SQL to the end of the query.
1045
1045
  *
@@ -1122,7 +1122,7 @@ export declare class DeleteQueryBuilder<DB, TB extends keyof DB, O> implements W
1122
1122
  * }>
1123
1123
  * ```
1124
1124
  */
1125
- $if<O2>(condition: boolean, func: (qb: this) => DeleteQueryBuilder<any, any, O2>): O2 extends DeleteResult ? DeleteQueryBuilder<DB, TB, DeleteResult> : O2 extends O & infer E ? DeleteQueryBuilder<DB, TB, O & Partial<E>> : DeleteQueryBuilder<DB, TB, Partial<O2>>;
1125
+ $if<O2>(condition: boolean, func: (qb: this) => DeleteQueryBuilder<any, any, O2>): unknown extends O2 ? DeleteQueryBuilder<any, any, O2> : O2 extends DeleteResult ? DeleteQueryBuilder<DB, TB, DeleteResult> : O2 extends O & infer E ? DeleteQueryBuilder<DB, TB, O & Partial<E>> : DeleteQueryBuilder<DB, TB, Partial<O2>>;
1126
1126
  /**
1127
1127
  * Change the output type of the query.
1128
1128
  *
@@ -3,10 +3,16 @@ import type { Expression } from '../expression/expression.js';
3
3
  import type { ExtractTypeFromCoalesce1, ExtractTypeFromCoalesce3, ExtractTypeFromCoalesce2, ExtractTypeFromCoalesce4, ExtractTypeFromCoalesce5 } from '../parser/coalesce-parser.js';
4
4
  import { type ExtractTypeFromReferenceExpression, type ReferenceExpression, type StringReference, type ExtractTypeFromStringReference } from '../parser/reference-parser.js';
5
5
  import type { KyselyTypeError } from '../util/type-error.js';
6
- import type { IsNever, ShallowDehydrateObject, ShallowDehydrateValue, Simplify } from '../util/type-utils.js';
6
+ import type { IsAny, IsNever, ShallowDehydrateObject, ShallowDehydrateValue, Simplify } from '../util/type-utils.js';
7
7
  import { AggregateFunctionBuilder } from './aggregate-function-builder.js';
8
8
  import type { SelectQueryBuilderExpression } from '../query-builder/select-query-builder-expression.js';
9
9
  import type { Selectable, SelectType } from '../util/column-type.js';
10
+ declare class FunctionModule<DB, TB extends keyof DB> {
11
+ protected readonly '~DB'?: IsAny<DB> extends true ? any : {
12
+ [T in TB]: Selectable<DB[T]>;
13
+ };
14
+ }
15
+ export type { FunctionModule };
10
16
  /**
11
17
  * Helpers for type safe SQL function calls.
12
18
  *
@@ -79,7 +85,7 @@ import type { Selectable, SelectType } from '../util/column-type.js';
79
85
  * having count("pet"."id") > $3
80
86
  * ```
81
87
  */
82
- export interface FunctionModule<DB, TB extends keyof DB> {
88
+ interface FunctionModule<DB, TB extends keyof DB> {
83
89
  /**
84
90
  * Creates a function call.
85
91
  *
@@ -14,14 +14,14 @@ export declare class JoinBuilder<DB, TB extends keyof DB> implements OperationNo
14
14
  * See {@link WhereInterface.where} for documentation and examples.
15
15
  */
16
16
  on<RE extends ReferenceExpression<DB, TB>>(lhs: RE, op: ComparisonOperatorExpression, rhs: OperandValueExpressionOrList<DB, TB, RE>): JoinBuilder<DB, TB>;
17
- on(expression: ExpressionOrFactory<DB, TB, SqlBool>): JoinBuilder<DB, TB>;
17
+ on<E extends ExpressionOrFactory<DB, TB, SqlBool>>(expression: E): JoinBuilder<DB, TB>;
18
18
  /**
19
19
  * Just like {@link WhereInterface.whereRef} but adds an item to the join's
20
20
  * `on` clause instead.
21
21
  *
22
22
  * See {@link WhereInterface.whereRef} for documentation and examples.
23
23
  */
24
- onRef(lhs: ReferenceExpression<DB, TB>, op: ComparisonOperatorExpression, rhs: ReferenceExpression<DB, TB>): JoinBuilder<DB, TB>;
24
+ onRef<LRE extends ReferenceExpression<DB, TB>, RRE extends ReferenceExpression<DB, TB>>(lhs: LRE, op: ComparisonOperatorExpression, rhs: RRE): JoinBuilder<DB, TB>;
25
25
  /**
26
26
  * Adds `on true`.
27
27
  */
@@ -14,16 +14,24 @@ import type { ValueExpression } from '../parser/value-parser.js';
14
14
  import type { CompiledQuery } from '../query-compiler/compiled-query.js';
15
15
  import type { QueryExecutor } from '../query-executor/query-executor.js';
16
16
  import type { AbortableQueryOptions } from '../util/abort.js';
17
+ import type { Insertable, Selectable, Updateable } from '../util/column-type.js';
17
18
  import type { Compilable } from '../util/compilable.js';
18
19
  import type { Executable, ExecuteTakeFirstOrThrowOptions } from '../util/executable.js';
19
20
  import type { QueryId } from '../util/query-id.js';
20
- import type { ShallowRecord, SimplifyResult, SimplifySingleResult, SqlBool } from '../util/type-utils.js';
21
+ import type { IsAny, ShallowRecord, SimplifyResult, SimplifySingleResult, SqlBool } from '../util/type-utils.js';
21
22
  import { MergeResult } from './merge-result.js';
22
23
  import type { OutputCallback, OutputExpression, OutputInterface, OutputPrefix, SelectExpressionFromOutputCallback, SelectExpressionFromOutputExpression } from './output-interface.js';
23
24
  import type { MultiTableReturningInterface } from './returning-interface.js';
24
25
  import { UpdateQueryBuilder } from './update-query-builder.js';
25
26
  export declare class MergeQueryBuilder<DB, TT extends keyof DB, O> implements MultiTableReturningInterface<DB, TT, O>, OutputInterface<DB, TT, O> {
26
27
  #private;
28
+ protected readonly '~DB': IsAny<DB> extends true ? any : {
29
+ [T in keyof DB]: {
30
+ select: () => Selectable<DB[T]>;
31
+ insert: (row: Insertable<DB[T]>) => void;
32
+ update: (row: Updateable<DB[T]>) => void;
33
+ };
34
+ };
27
35
  constructor(props: MergeQueryBuilderProps);
28
36
  /**
29
37
  * This can be used to add any additional SQL to the end of the query.
@@ -1377,7 +1377,7 @@ export interface SelectQueryBuilder<DB, TB extends keyof DB, O> extends WhereInt
1377
1377
  * select "first_name" from "person" limit $1 offset $2
1378
1378
  * ```
1379
1379
  */
1380
- limit(limit: ValueExpression<DB, TB, number | bigint | null>): SelectQueryBuilder<DB, TB, O>;
1380
+ limit<VE extends ValueExpression<DB, TB, number | bigint | null>>(limit: VE): SelectQueryBuilder<DB, TB, O>;
1381
1381
  /**
1382
1382
  * Adds an `offset` clause to the query.
1383
1383
  *
@@ -1400,7 +1400,7 @@ export interface SelectQueryBuilder<DB, TB extends keyof DB, O> extends WhereInt
1400
1400
  * select "first_name" from "person" limit $1 offset $2
1401
1401
  * ```
1402
1402
  */
1403
- offset(offset: ValueExpression<DB, TB, number | bigint>): SelectQueryBuilder<DB, TB, O>;
1403
+ offset<VE extends ValueExpression<DB, TB, number | bigint>>(offset: VE): SelectQueryBuilder<DB, TB, O>;
1404
1404
  /**
1405
1405
  * Adds a `fetch` clause to the query.
1406
1406
  *
@@ -2367,22 +2367,44 @@ export interface SelectQueryBuilderProps {
2367
2367
  export interface AliasedSelectQueryBuilder<out O = undefined, out A extends string = never> extends AliasedExpression<O, A> {
2368
2368
  get isAliasedSelectQueryBuilder(): true;
2369
2369
  }
2370
- export type SelectQueryBuilderWithInnerJoin<DB, TB extends keyof DB, O, TE extends TableExpression<DB, TB>> = TE extends `${infer T} as ${infer A}` ? T extends keyof DB ? InnerJoinedBuilder<DB, TB, O, A, DB[T]> : never : TE extends keyof DB ? SelectQueryBuilder<DB, TB | TE, O> : TE extends AliasedExpression<infer QO, infer QA> ? InnerJoinedBuilder<DB, TB, O, QA, QO> : TE extends (qb: any) => AliasedExpression<infer QO, infer QA> ? InnerJoinedBuilder<DB, TB, O, QA, QO> : never;
2370
+ /**
2371
+ * Guards a join's result type against being computed for an unknown table
2372
+ * expression.
2373
+ *
2374
+ * `TableExpression<DB, TB> extends TE` only holds when `TE` is as wide as its
2375
+ * own constraint, which never happens at a call site - there `TE` is a specific
2376
+ * table name, alias or subquery. It does happen when the compiler asks what a
2377
+ * join returns for an arbitrary table expression, which is what it has to do
2378
+ * whenever it compares two `SelectQueryBuilder` types structurally.
2379
+ *
2380
+ * Without this guard that comparison never terminates on its own: computing the
2381
+ * join result yields a `SelectQueryBuilder` over a wider `DB`, whose own join
2382
+ * methods yield a wider one still, so the compiler only stops when it hits its
2383
+ * internal recursion limit. That limit differs between TypeScript versions - 7.0
2384
+ * searches a level deeper than 5.9 and 6.0 - which made comparing two select
2385
+ * query builders over 6x more expensive there.
2386
+ *
2387
+ * Collapsing to a fixed type makes the recursion converge instead: joining an
2388
+ * unknown table expression again produces the same type, so the compiler
2389
+ * recognises the pair it is already comparing and stops immediately.
2390
+ */
2391
+ type JoinResultForUnknownTable<O> = SelectQueryBuilder<any, any, O>;
2392
+ export type SelectQueryBuilderWithInnerJoin<DB, TB extends keyof DB, O, TE extends TableExpression<DB, TB>> = TableExpression<DB, TB> extends TE ? JoinResultForUnknownTable<O> : TE extends `${infer T} as ${infer A}` ? T extends keyof DB ? InnerJoinedBuilder<DB, TB, O, A, DB[T]> : never : TE extends keyof DB ? SelectQueryBuilder<DB, TB | TE, O> : TE extends AliasedExpression<infer QO, infer QA> ? InnerJoinedBuilder<DB, TB, O, QA, QO> : TE extends (qb: any) => AliasedExpression<infer QO, infer QA> ? InnerJoinedBuilder<DB, TB, O, QA, QO> : never;
2371
2393
  type InnerJoinedBuilder<DB, TB extends keyof DB, O, A extends string, R> = A extends keyof DB ? SelectQueryBuilder<InnerJoinedDB<DB, A, R>, TB | A, O> : SelectQueryBuilder<DB & ShallowRecord<A, R>, TB | A, O>;
2372
2394
  type InnerJoinedDB<DB, A extends string, R> = DrainOuterGeneric<{
2373
2395
  [C in keyof DB | A]: C extends A ? R : C extends keyof DB ? DB[C] : never;
2374
2396
  }>;
2375
- export type SelectQueryBuilderWithLeftJoin<DB, TB extends keyof DB, O, TE extends TableExpression<DB, TB>> = TE extends `${infer T} as ${infer A}` ? T extends keyof DB ? LeftJoinedBuilder<DB, TB, O, A, DB[T]> : never : TE extends keyof DB ? LeftJoinedBuilder<DB, TB, O, TE, DB[TE]> : TE extends AliasedExpression<infer QO, infer QA> ? LeftJoinedBuilder<DB, TB, O, QA, QO> : TE extends (qb: any) => AliasedExpression<infer QO, infer QA> ? LeftJoinedBuilder<DB, TB, O, QA, QO> : never;
2397
+ export type SelectQueryBuilderWithLeftJoin<DB, TB extends keyof DB, O, TE extends TableExpression<DB, TB>> = TableExpression<DB, TB> extends TE ? JoinResultForUnknownTable<O> : TE extends `${infer T} as ${infer A}` ? T extends keyof DB ? LeftJoinedBuilder<DB, TB, O, A, DB[T]> : never : TE extends keyof DB ? LeftJoinedBuilder<DB, TB, O, TE, DB[TE]> : TE extends AliasedExpression<infer QO, infer QA> ? LeftJoinedBuilder<DB, TB, O, QA, QO> : TE extends (qb: any) => AliasedExpression<infer QO, infer QA> ? LeftJoinedBuilder<DB, TB, O, QA, QO> : never;
2376
2398
  type LeftJoinedBuilder<DB, TB extends keyof DB, O, A extends keyof any, R> = A extends keyof DB ? SelectQueryBuilder<LeftJoinedDB<DB, A, R>, TB | A, O> : SelectQueryBuilder<DB & ShallowRecord<A, Nullable<R>>, TB | A, O>;
2377
2399
  type LeftJoinedDB<DB, A extends keyof any, R> = DrainOuterGeneric<{
2378
2400
  [C in keyof DB | A]: C extends A ? Nullable<R> : C extends keyof DB ? DB[C] : never;
2379
2401
  }>;
2380
- export type SelectQueryBuilderWithRightJoin<DB, TB extends keyof DB, O, TE extends TableExpression<DB, TB>> = TE extends `${infer T} as ${infer A}` ? T extends keyof DB ? RightJoinedBuilder<DB, TB, O, A, DB[T]> : never : TE extends keyof DB ? RightJoinedBuilder<DB, TB, O, TE, DB[TE]> : TE extends AliasedExpression<infer QO, infer QA> ? RightJoinedBuilder<DB, TB, O, QA, QO> : TE extends (qb: any) => AliasedExpression<infer QO, infer QA> ? RightJoinedBuilder<DB, TB, O, QA, QO> : never;
2402
+ export type SelectQueryBuilderWithRightJoin<DB, TB extends keyof DB, O, TE extends TableExpression<DB, TB>> = TableExpression<DB, TB> extends TE ? JoinResultForUnknownTable<O> : TE extends `${infer T} as ${infer A}` ? T extends keyof DB ? RightJoinedBuilder<DB, TB, O, A, DB[T]> : never : TE extends keyof DB ? RightJoinedBuilder<DB, TB, O, TE, DB[TE]> : TE extends AliasedExpression<infer QO, infer QA> ? RightJoinedBuilder<DB, TB, O, QA, QO> : TE extends (qb: any) => AliasedExpression<infer QO, infer QA> ? RightJoinedBuilder<DB, TB, O, QA, QO> : never;
2381
2403
  type RightJoinedBuilder<DB, TB extends keyof DB, O, A extends keyof any, R> = SelectQueryBuilder<RightJoinedDB<DB, TB, A, R>, TB | A, O>;
2382
2404
  type RightJoinedDB<DB, TB extends keyof DB, A extends keyof any, R> = DrainOuterGeneric<{
2383
2405
  [C in keyof DB | A]: C extends A ? R : C extends TB ? Nullable<DB[C]> : C extends keyof DB ? DB[C] : never;
2384
2406
  }>;
2385
- export type SelectQueryBuilderWithFullJoin<DB, TB extends keyof DB, O, TE extends TableExpression<DB, TB>> = TE extends `${infer T} as ${infer A}` ? T extends keyof DB ? OuterJoinedBuilder<DB, TB, O, A, DB[T]> : never : TE extends keyof DB ? OuterJoinedBuilder<DB, TB, O, TE, DB[TE]> : TE extends AliasedExpression<infer QO, infer QA> ? OuterJoinedBuilder<DB, TB, O, QA, QO> : TE extends (qb: any) => AliasedExpression<infer QO, infer QA> ? OuterJoinedBuilder<DB, TB, O, QA, QO> : never;
2407
+ export type SelectQueryBuilderWithFullJoin<DB, TB extends keyof DB, O, TE extends TableExpression<DB, TB>> = TableExpression<DB, TB> extends TE ? JoinResultForUnknownTable<O> : TE extends `${infer T} as ${infer A}` ? T extends keyof DB ? OuterJoinedBuilder<DB, TB, O, A, DB[T]> : never : TE extends keyof DB ? OuterJoinedBuilder<DB, TB, O, TE, DB[TE]> : TE extends AliasedExpression<infer QO, infer QA> ? OuterJoinedBuilder<DB, TB, O, QA, QO> : TE extends (qb: any) => AliasedExpression<infer QO, infer QA> ? OuterJoinedBuilder<DB, TB, O, QA, QO> : never;
2386
2408
  type OuterJoinedBuilder<DB, TB extends keyof DB, O, A extends keyof any, R> = SelectQueryBuilder<OuterJoinedBuilderDB<DB, TB, A, R>, TB | A, O>;
2387
2409
  type OuterJoinedBuilderDB<DB, TB extends keyof DB, A extends keyof any, R> = DrainOuterGeneric<{
2388
2410
  [C in keyof DB | A]: C extends A ? Nullable<R> : C extends TB ? Nullable<DB[C]> : C extends keyof DB ? DB[C] : never;
@@ -1148,7 +1148,7 @@ export declare class UpdateQueryBuilder<DB, UT extends keyof DB, TB extends keyo
1148
1148
  * }>
1149
1149
  * ```
1150
1150
  */
1151
- $if<O2>(condition: boolean, func: (qb: this) => UpdateQueryBuilder<any, any, any, O2>): O2 extends UpdateResult ? UpdateQueryBuilder<DB, UT, TB, UpdateResult> : O2 extends O & infer E ? UpdateQueryBuilder<DB, UT, TB, O & Partial<E>> : UpdateQueryBuilder<DB, UT, TB, Partial<O2>>;
1151
+ $if<O2>(condition: boolean, func: (qb: this) => UpdateQueryBuilder<any, any, any, O2>): unknown extends O2 ? UpdateQueryBuilder<any, any, any, O2> : O2 extends UpdateResult ? UpdateQueryBuilder<DB, UT, TB, UpdateResult> : O2 extends O & infer E ? UpdateQueryBuilder<DB, UT, TB, O & Partial<E>> : UpdateQueryBuilder<DB, UT, TB, Partial<O2>>;
1152
1152
  /**
1153
1153
  * Change the output type of the query.
1154
1154
  *
@@ -12,8 +12,17 @@ import type { SelectFrom } from './parser/select-from-parser.js';
12
12
  import type { DeleteFrom } from './parser/delete-from-parser.js';
13
13
  import type { UpdateTable } from './parser/update-parser.js';
14
14
  import type { MergeInto } from './parser/merge-into-parser.js';
15
+ import type { IsAny } from './util/type-utils.js';
16
+ import type { Insertable, Selectable, Updateable } from './util/column-type.js';
15
17
  export declare class QueryCreator<DB> {
16
18
  #private;
19
+ protected readonly '~DB': IsAny<DB> extends true ? any : {
20
+ [T in keyof DB]: {
21
+ select: () => Selectable<DB[T]>;
22
+ insert: (row: Insertable<DB[T]>) => void;
23
+ update: (row: Updateable<DB[T]>) => void;
24
+ };
25
+ };
17
26
  constructor(props: QueryCreatorProps);
18
27
  /**
19
28
  * Creates a `select` query builder for the given table or tables.
@@ -6,6 +6,7 @@ import type { QueryExecutorProvider } from '../query-executor/query-executor-pro
6
6
  import type { QueryId } from '../util/query-id.js';
7
7
  import type { AliasableExpression, AliasedExpression, Expression } from '../expression/expression.js';
8
8
  import type { AbortableQueryOptions } from '../util/abort.js';
9
+ import type { StreamOptions } from '../util/streamable.js';
9
10
  /**
10
11
  * An instance of this class can be used to create raw SQL snippets or queries.
11
12
  *
@@ -181,6 +182,10 @@ export interface RawBuilder<O> extends AliasableExpression<O> {
181
182
  * ```
182
183
  */
183
184
  execute(executorProvider: QueryExecutorProvider, options?: AbortableQueryOptions): Promise<QueryResult<O>>;
185
+ /**
186
+ * Executes the raw query and streams the rows.
187
+ */
188
+ stream(executorOrProvider: QueryExecutorProvider, options?: StreamOptions | StreamOptions['chunkSize']): AsyncIterableIterator<O>;
184
189
  /**
185
190
  * Creates the OperationNode that describes how to compile this expression into SQL.
186
191
  *
@@ -42,6 +42,18 @@ class RawBuilderImpl {
42
42
  const executor = this.#getExecutor(executorProvider);
43
43
  return executor.executeQuery(this.#compile(executor), options);
44
44
  }
45
+ async *stream(executorProvider, chunkSizeOrOptions) {
46
+ const executor = this.#getExecutor(executorProvider);
47
+ if (typeof chunkSizeOrOptions !== 'object') {
48
+ chunkSizeOrOptions = {
49
+ chunkSize: chunkSizeOrOptions,
50
+ };
51
+ }
52
+ const stream = executor.stream(this.#compile(executor), chunkSizeOrOptions.chunkSize ?? 100, chunkSizeOrOptions);
53
+ for await (const item of stream) {
54
+ yield* item.rows;
55
+ }
56
+ }
45
57
  #getExecutor(executorProvider) {
46
58
  const executor = executorProvider !== undefined
47
59
  ? executorProvider.getExecutor()
@@ -5,11 +5,11 @@ import type { KyselyPlugin } from '../plugin/kysely-plugin.js';
5
5
  import type { SelectQueryBuilder } from '../query-builder/select-query-builder.js';
6
6
  import type { AbortableOperationOptions, AbortableQueryOptions } from '../util/abort.js';
7
7
  import type { KyselyTypeError } from '../util/type-error.js';
8
- import type { DrainOuterGeneric } from '../util/type-utils.js';
9
8
  import type { ReadonlyCompiledQuery } from './readonly-compiled-query.js';
10
9
  import type { ReadonlyQueryResult } from './readonly-database-connection.js';
11
10
  import type { ReadonlyAccessMode } from './readonly-driver.js';
12
11
  import type { ReadonlyQueryCreator } from './readonly-query-creator.js';
12
+ export type { ReadonlyKysely, ReadonlyTransaction, ReadonlyControlledTransaction, };
13
13
  /**
14
14
  * A helper type that allows you to expose a type-level read-only {@link Kysely} version
15
15
  * to your service's consumers.
@@ -43,7 +43,13 @@ import type { ReadonlyQueryCreator } from './readonly-query-creator.js';
43
43
  * db.deleteFrom('person') // typescript compiler error!
44
44
  * ```
45
45
  */
46
- export interface ReadonlyKysely<DB> extends ReadonlyQueryCreator<DB>, Pick<Kysely<DB>, 'case' | 'destroy' | 'dynamic' | 'fn' | 'introspection' | 'isTransaction'> {
46
+ declare class ReadonlyKysely<DB> extends ReadonlyQueryCreator<DB> {
47
+ case: Kysely<DB>['case'];
48
+ destroy: Kysely<DB>['destroy'];
49
+ get dynamic(): Kysely<DB>['dynamic'];
50
+ readonly fn: Kysely<DB>['fn'];
51
+ get introspection(): Kysely<DB>['introspection'];
52
+ get isTransaction(): Kysely<DB>['isTransaction'];
47
53
  /**
48
54
  * Similar to {@link Kysely.connection} but read-only.
49
55
  */
@@ -89,11 +95,11 @@ export interface ReadonlyKysely<DB> extends ReadonlyQueryCreator<DB>, Pick<Kysel
89
95
  *
90
96
  * @deprecated use {@link $extendTables} instead.
91
97
  */
92
- withTables<T extends Record<string, Record<string, any>>>(): ReadonlyKysely<DrainOuterGeneric<DB & T>>;
98
+ withTables<T extends Record<string, Record<string, any>>>(): ReadonlyKysely<DB & T>;
93
99
  /**
94
100
  * Similar to {@link Kysely.$extendTables} but read-only.
95
101
  */
96
- $extendTables<T extends Record<string, Record<string, any>>>(): ReadonlyKysely<DrainOuterGeneric<DB & T>>;
102
+ $extendTables<T extends Record<string, Record<string, any>>>(): ReadonlyKysely<DB & T>;
97
103
  /**
98
104
  * Similar to {@link Kysely.$omitTables} but read-only.
99
105
  */
@@ -132,7 +138,24 @@ export interface ReadonlyTransactionBuilder<DB> {
132
138
  /**
133
139
  * Similar to {@link Transaction} but read-only.
134
140
  */
135
- export interface ReadonlyTransaction<DB> extends Pick<ReadonlyKysely<DB>, 'case' | 'deleteFrom' | 'dynamic' | 'executeQuery' | 'fn' | 'getExecutor' | 'insertInto' | 'introspection' | 'mergeInto' | 'replaceInto' | 'schema' | 'selectFrom' | 'selectNoFrom' | 'updateTable' | 'with' | 'withRecursive'>, Pick<Transaction<DB>, 'connection' | 'destroy' | 'isTransaction' | 'startTransaction' | 'transaction'> {
141
+ declare class ReadonlyTransaction<DB> extends ReadonlyKysely<DB> {
142
+ /**
143
+ * @deprecated calling the connection method for a Transaction is not supported
144
+ */
145
+ connection(): never;
146
+ /**
147
+ * @deprecated calling the destroy method for a Transaction is not supported
148
+ */
149
+ destroy: Transaction<DB>['destroy'];
150
+ get isTransaction(): true;
151
+ /**
152
+ * @deprecated calling the controlled transaction method for a Transaction is not supported
153
+ */
154
+ startTransaction(): never;
155
+ /**
156
+ * @deprecated calling the transaction method for a Transaction is not supported
157
+ */
158
+ transaction(): never;
136
159
  /**
137
160
  * Similar to {@link Transaction.withoutPlugins} but read-only.
138
161
  */
@@ -150,19 +173,32 @@ export interface ReadonlyTransaction<DB> extends Pick<ReadonlyKysely<DB>, 'case'
150
173
  *
151
174
  * @deprecated use {@link $extendTables} instead.
152
175
  */
153
- withTables<T extends Record<string, Record<string, any>>>(): ReadonlyTransaction<DrainOuterGeneric<DB & T>>;
176
+ withTables<T extends Record<string, Record<string, any>>>(): ReadonlyTransaction<DB & T>;
177
+ /**
178
+ * Similar to {@link Kysely.withTables} but read-only.
179
+ *
180
+ * @deprecated use {@link $extendTables} instead.
181
+ */
182
+ withTables<T extends Record<string, Record<string, any>>>(): ReadonlyKysely<DB & T>;
183
+ withTables<T extends Record<string, Record<string, any>>>(): ReadonlyTransaction<DB & T>;
154
184
  /**
155
185
  * Similar to {@link Transaction.$extendTables} but read-only.
156
186
  */
157
- $extendTables<T extends Record<string, Record<string, any>>>(): ReadonlyTransaction<DrainOuterGeneric<DB & T>>;
187
+ $extendTables<T extends Record<string, Record<string, any>>>(): ReadonlyTransaction<DB & T>;
188
+ $extendTables<T extends Record<string, Record<string, any>>>(): ReadonlyKysely<DB & T>;
189
+ $extendTables<T extends Record<string, Record<string, any>>>(): ReadonlyTransaction<DB & T>;
158
190
  /**
159
191
  * Similar to {@link Transaction.$omitTables} but read-only.
160
192
  */
161
193
  $omitTables<T extends keyof DB>(): ReadonlyTransaction<DB extends object ? Omit<DB, T> : DB>;
194
+ $omitTables<T extends keyof DB>(): ReadonlyKysely<DB extends object ? Omit<DB, T> : DB>;
195
+ $omitTables<T extends keyof DB>(): ReadonlyTransaction<DB extends object ? Omit<DB, T> : DB>;
162
196
  /**
163
197
  * Similar to {@link Transaction.$pickTables} but read-only.
164
198
  */
165
199
  $pickTables<T extends keyof DB>(): ReadonlyTransaction<DB extends object ? Pick<DB, T> : DB>;
200
+ $pickTables<T extends keyof DB>(): ReadonlyKysely<DB extends object ? Pick<DB, T> : DB>;
201
+ $pickTables<T extends keyof DB>(): ReadonlyTransaction<DB extends object ? Pick<DB, T> : DB>;
166
202
  }
167
203
  /**
168
204
  * Similar to {@link ControlledTransactionBuilder} but read-only.
@@ -184,7 +220,11 @@ export interface ReadonlyControlledTransactionBuilder<DB> {
184
220
  /**
185
221
  * Similar to {@link ControlledTransaction} but read-only.
186
222
  */
187
- export interface ReadonlyControlledTransaction<DB, S extends string[] = []> extends ReadonlyTransaction<DB>, Pick<ControlledTransaction<DB, S>, 'commit' | 'isCommitted' | 'isRolledBack' | 'rollback'> {
223
+ declare class ReadonlyControlledTransaction<DB, S extends string[] = []> extends ReadonlyTransaction<DB> {
224
+ commit: ControlledTransaction<DB, S>['commit'];
225
+ get isCommitted(): ControlledTransaction<DB, S>['isCommitted'];
226
+ get isRolledBack(): ControlledTransaction<DB, S>['isRolledBack'];
227
+ rollback: ControlledTransaction<DB, S>['rollback'];
188
228
  /**
189
229
  * Similar to {@link ControlledTransaction.releaseSavepoint} but read-only.
190
230
  */
@@ -214,17 +254,31 @@ export interface ReadonlyControlledTransaction<DB, S extends string[] = []> exte
214
254
  *
215
255
  * @deprecated use {@link $extendTables} instead.
216
256
  */
217
- withTables<T extends Record<string, Record<string, any>>>(): ReadonlyControlledTransaction<DrainOuterGeneric<DB & T>, S>;
257
+ withTables<T extends Record<string, Record<string, any>>>(): ReadonlyControlledTransaction<DB & T, S>;
258
+ /**
259
+ * Similar to {@link Transaction.withTables} but read-only.
260
+ *
261
+ * @deprecated use {@link $extendTables} instead.
262
+ */
263
+ withTables<T extends Record<string, Record<string, any>>>(): ReadonlyKysely<DB & T>;
264
+ withTables<T extends Record<string, Record<string, any>>>(): ReadonlyControlledTransaction<DB & T, S>;
218
265
  /**
219
266
  * Similar to {@link ControlledTransaction.$extendTables} but read-only.
220
267
  */
221
- $extendTables<T extends Record<string, Record<string, any>>>(): ReadonlyControlledTransaction<DrainOuterGeneric<DB & T>, S>;
268
+ $extendTables<T extends Record<string, Record<string, any>>>(): ReadonlyControlledTransaction<DB & T, S>;
269
+ $extendTables<T extends Record<string, Record<string, any>>>(): ReadonlyKysely<DB & T>;
270
+ $extendTables<T extends Record<string, Record<string, any>>>(): ReadonlyControlledTransaction<DB & T, S>;
222
271
  /**
223
272
  * Similar to {@link ControlledTransaction.$omitTables} but read-only.
224
273
  */
225
274
  $omitTables<T extends keyof DB>(): ReadonlyControlledTransaction<DB extends object ? Omit<DB, T> : DB, S>;
275
+ $omitTables<T extends keyof DB>(): ReadonlyKysely<DB extends object ? Omit<DB, T> : DB>;
276
+ $omitTables<T extends keyof DB>(): ReadonlyTransaction<DB extends object ? Omit<DB, T> : DB>;
277
+ $omitTables<T extends keyof DB>(): ReadonlyControlledTransaction<DB extends object ? Omit<DB, T> : DB, S>;
226
278
  /**
227
279
  * Similar to {@link ControlledTransaction.$pickTables} but read-only.
228
280
  */
229
281
  $pickTables<T extends keyof DB>(): ReadonlyControlledTransaction<DB extends object ? Pick<DB, T> : DB, S>;
282
+ $pickTables<T extends keyof DB>(): ReadonlyKysely<DB extends object ? Pick<DB, T> : DB>;
283
+ $pickTables<T extends keyof DB>(): ReadonlyControlledTransaction<DB extends object ? Pick<DB, T> : DB, S>;
230
284
  }
@@ -1,11 +1,19 @@
1
1
  import type { CTEBuilderCallback } from '../query-builder/cte-builder.js';
2
2
  import type { QueryCreator } from '../query-creator.js';
3
+ import type { Selectable } from '../util/column-type.js';
4
+ import type { IsAny } from '../util/type-utils.js';
3
5
  import type { KyselyTypeError } from '../util/type-error.js';
4
6
  import type { ReadonlyCommonTableExpression, ReadonlyQueryCreatorWithCommonTableExpression, ReadonlyRecursiveCommonTableExpression } from './readonly-with-parser.js';
7
+ export type { ReadonlyQueryCreator };
5
8
  /**
6
9
  * Similar to {@link QueryCreator} but read-only.
7
10
  */
8
- export interface ReadonlyQueryCreator<DB> extends Pick<QueryCreator<DB>, 'selectFrom' | 'selectNoFrom'> {
11
+ declare class ReadonlyQueryCreator<DB> {
12
+ protected readonly '~DB': IsAny<DB> extends true ? any : {
13
+ [T in keyof DB]: Selectable<DB[T]>;
14
+ };
15
+ selectFrom: QueryCreator<DB>['selectFrom'];
16
+ selectNoFrom: QueryCreator<DB>['selectNoFrom'];
9
17
  /**
10
18
  * @deprecated not allowed with a read-only Kysely instance.
11
19
  */
@@ -10,7 +10,7 @@ export declare class CreateTypeBuilder implements OperationNodeSource, Compilabl
10
10
  constructor(props: CreateTypeBuilderProps);
11
11
  toOperationNode(): CreateTypeNode;
12
12
  /**
13
- * Creates an anum type.
13
+ * Creates an enum type.
14
14
  *
15
15
  * ### Examples
16
16
  *
@@ -10,7 +10,7 @@ export class CreateTypeBuilder {
10
10
  return this.#props.executor.transformQuery(this.#props.node, this.#props.queryId);
11
11
  }
12
12
  /**
13
- * Creates an anum type.
13
+ * Creates an enum type.
14
14
  *
15
15
  * ### Examples
16
16
  *
@@ -8,6 +8,7 @@ export function getInflightQueryAbortHandler(abortStrategy = 'ignore query', con
8
8
  if (abortStrategy === 'cancel query') {
9
9
  const handler = connection.cancelQuery;
10
10
  if (!handler) {
11
+ beforeThrow();
11
12
  throwUnsupportedInflightQueryAbortStrategyError(abortStrategy, connection.killSession ? 'kill session' : undefined);
12
13
  }
13
14
  return handler.bind(connection);
@@ -15,6 +16,7 @@ export function getInflightQueryAbortHandler(abortStrategy = 'ignore query', con
15
16
  if (abortStrategy === 'kill session') {
16
17
  const handler = connection.killSession;
17
18
  if (!handler) {
19
+ beforeThrow();
18
20
  throwUnsupportedInflightQueryAbortStrategyError(abortStrategy, connection.cancelQuery ? 'cancel query' : undefined);
19
21
  }
20
22
  return handler.bind(connection);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kysely",
3
- "version": "0.30.0-beta.1",
3
+ "version": "0.30.0-beta.2",
4
4
  "description": "Type safe SQL query builder",
5
5
  "repository": {
6
6
  "type": "git",
@@ -63,39 +63,40 @@
63
63
  "devDependencies": {
64
64
  "@arethetypeswrong/cli": "0.18.5",
65
65
  "@electric-sql/pglite": "0.5.4",
66
- "@types/better-sqlite3": "7.6.13",
66
+ "@types/better-sqlite3": "9.6.0",
67
67
  "@types/chai": "5.2.3",
68
68
  "@types/chai-as-promised": "8.0.2",
69
69
  "@types/mocha": "10.0.10",
70
- "@types/node": "26.1.1",
71
- "@types/pg": "8.20.0",
70
+ "@types/node": "26.2.0",
71
+ "@types/pg": "8.21.0",
72
72
  "@types/pg-cursor": "2.7.2",
73
73
  "@types/prototype-pollution-vulnerable-lodash.merge-dont-upgrade": "npm:@types/lodash.merge@4.6.1",
74
- "@types/semver": "7.7.1",
74
+ "@types/semver": "7.8.0",
75
75
  "@types/sinon": "22.0.0",
76
- "better-sqlite3": "12.11.1",
76
+ "better-sqlite3": "13.0.3",
77
77
  "chai": "6.2.2",
78
78
  "chai-as-promised": "8.0.2",
79
- "esbuild": "0.28.1",
79
+ "esbuild": "0.28.2",
80
80
  "jsr": "0.14.3",
81
- "mocha": "11.7.6",
82
- "mysql2": "3.23.0",
81
+ "mocha": "11.8.0",
82
+ "mysql2": "3.23.3",
83
83
  "pathe": "2.0.3",
84
- "pg": "8.22.0",
85
- "pg-cursor": "2.21.0",
86
- "playwright": "1.61.1",
87
- "prettier": "3.9.5",
84
+ "pg": "8.23.0",
85
+ "pg-cursor": "2.22.0",
86
+ "playwright": "1.62.1",
87
+ "prettier": "3.9.6",
88
88
  "prototype-pollution-vulnerable-lodash.merge-dont-upgrade": "npm:lodash.merge@4.6.1",
89
89
  "remeda": "2.39.0",
90
90
  "semver": "7.8.5",
91
- "sinon": "22.0.0",
91
+ "sinon": "22.1.0",
92
92
  "std-env": "4.2.0",
93
93
  "tarn": "3.1.2",
94
94
  "tedious": "20.0.0",
95
95
  "tsd": "0.33.0",
96
- "tsx": "4.23.1",
96
+ "tsx": "4.23.12",
97
97
  "typescript": "7.0.2",
98
- "typescript-6": "npm:typescript@6.0.3"
98
+ "typescript-6": "npm:typescript@6.0.3",
99
+ "vitest": "5.0.0"
99
100
  },
100
101
  "scripts": {
101
102
  "clean": "rm -rf dist & rm -rf test/node/dist & rm -rf test/browser/bundle.js",
@@ -110,6 +111,7 @@
110
111
  "test:cloudflare-workers": "pnpm build && pnpm -r test --filter kysely-cloudflare-workers-test",
111
112
  "test:deno": "deno run --allow-env --allow-read --allow-net --no-lock test/deno/test.ts",
112
113
  "test:typings": "tsd test/typings",
114
+ "test:typings:vitest": "vitest run --config test/typings/vitest.config.ts",
113
115
  "test:esmimports": "node scripts/check-esm-imports.cjs",
114
116
  "test:esbuild": "esbuild --bundle --platform=node --external:pg-native dist/index.js --outfile=/dev/null",
115
117
  "test:exports": "attw --profile esm-only --pack . && node scripts/check-exports.cjs",