kysely 0.27.3 → 0.27.5
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/.renovaterc.json +3 -0
- package/CONTRIBUTING.md +2 -2
- package/README.md +7 -7
- package/deno.check.d.ts +86 -0
- package/deno.check.json +21 -0
- package/dist/cjs/dialect/dialect-adapter-base.d.ts +13 -3
- package/dist/cjs/dialect/dialect-adapter-base.js +4 -1
- package/dist/cjs/dialect/dialect-adapter.d.ts +16 -2
- package/dist/cjs/dialect/mssql/mssql-adapter.d.ts +12 -7
- package/dist/cjs/dialect/mssql/mssql-adapter.js +2 -4
- package/dist/cjs/dialect/mssql/mssql-dialect-config.d.ts +83 -55
- package/dist/cjs/dialect/mssql/mssql-driver.d.ts +1 -0
- package/dist/cjs/dialect/mssql/mssql-driver.js +114 -48
- package/dist/cjs/dialect/mysql/mysql-adapter.d.ts +11 -2
- package/dist/cjs/dialect/mysql/mysql-dialect-config.d.ts +4 -0
- package/dist/cjs/dialect/mysql/mysql-driver.js +3 -0
- package/dist/cjs/dialect/postgres/postgres-adapter.d.ts +11 -2
- package/dist/cjs/dialect/postgres/postgres-dialect-config.d.ts +10 -3
- package/dist/cjs/dialect/postgres/postgres-driver.js +3 -0
- package/dist/cjs/dialect/postgres/postgres-introspector.js +5 -1
- package/dist/cjs/dialect/sqlite/sqlite-adapter.d.ts +11 -2
- package/dist/cjs/driver/database-connection.d.ts +3 -1
- package/dist/cjs/driver/dummy-driver.d.ts +13 -12
- package/dist/cjs/driver/dummy-driver.js +13 -12
- package/dist/cjs/dynamic/dynamic-reference-builder.js +2 -2
- package/dist/cjs/dynamic/dynamic.d.ts +7 -7
- package/dist/cjs/dynamic/dynamic.js +7 -7
- package/dist/cjs/expression/expression-builder.d.ts +153 -62
- package/dist/cjs/expression/expression-builder.js +2 -3
- package/dist/cjs/expression/expression-wrapper.d.ts +92 -23
- package/dist/cjs/expression/expression.d.ts +40 -5
- package/dist/cjs/expression/expression.js +2 -3
- package/dist/cjs/helpers/mssql.d.ts +74 -14
- package/dist/cjs/helpers/mssql.js +77 -18
- package/dist/cjs/helpers/mysql.d.ts +17 -13
- package/dist/cjs/helpers/mysql.js +20 -17
- package/dist/cjs/helpers/postgres.d.ts +11 -8
- package/dist/cjs/helpers/postgres.js +14 -12
- package/dist/cjs/helpers/sqlite.d.ts +41 -16
- package/dist/cjs/helpers/sqlite.js +44 -20
- package/dist/cjs/index.d.ts +28 -21
- package/dist/cjs/index.js +28 -21
- package/dist/cjs/kysely.d.ts +100 -42
- package/dist/cjs/kysely.js +63 -39
- package/dist/cjs/migration/file-migration-provider.d.ts +2 -2
- package/dist/cjs/migration/file-migration-provider.js +2 -2
- package/dist/cjs/migration/migrator.d.ts +82 -14
- package/dist/cjs/migration/migrator.js +82 -14
- package/dist/cjs/operation-node/aggregate-function-node.d.ts +4 -0
- package/dist/cjs/operation-node/aggregate-function-node.js +9 -0
- package/dist/cjs/operation-node/alter-column-node.d.ts +1 -1
- package/dist/cjs/operation-node/case-node.d.ts +1 -1
- package/dist/cjs/operation-node/column-definition-node.d.ts +1 -0
- package/dist/cjs/operation-node/data-type-node.d.ts +2 -2
- package/dist/cjs/operation-node/data-type-node.js +17 -3
- package/dist/cjs/operation-node/delete-query-node.d.ts +3 -0
- package/dist/cjs/operation-node/foreign-key-constraint-node.d.ts +4 -4
- package/dist/cjs/operation-node/having-node.d.ts +1 -1
- package/dist/cjs/operation-node/insert-query-node.d.ts +3 -0
- package/dist/cjs/operation-node/merge-query-node.d.ts +3 -0
- package/dist/cjs/operation-node/on-node.d.ts +1 -1
- package/dist/cjs/operation-node/operation-node-source.js +1 -2
- package/dist/cjs/operation-node/operation-node-transformer.d.ts +11 -3
- package/dist/cjs/operation-node/operation-node-transformer.js +26 -3
- package/dist/cjs/operation-node/operation-node-visitor.d.ts +2 -0
- package/dist/cjs/operation-node/operation-node-visitor.js +1 -0
- package/dist/cjs/operation-node/operation-node.d.ts +1 -1
- package/dist/cjs/operation-node/operator-node.d.ts +3 -3
- package/dist/cjs/operation-node/operator-node.js +8 -6
- package/dist/cjs/operation-node/output-node.d.ts +13 -0
- package/dist/cjs/operation-node/output-node.js +26 -0
- package/dist/cjs/operation-node/query-node.d.ts +15 -6
- package/dist/cjs/operation-node/query-node.js +17 -0
- package/dist/cjs/operation-node/select-query-node.d.ts +1 -1
- package/dist/cjs/operation-node/select-query-node.js +6 -8
- package/dist/cjs/operation-node/update-query-node.d.ts +3 -0
- package/dist/cjs/operation-node/where-node.d.ts +1 -1
- package/dist/cjs/parser/binary-operation-parser.js +5 -6
- package/dist/cjs/parser/data-type-parser.js +1 -2
- package/dist/cjs/parser/default-value-parser.js +1 -2
- package/dist/cjs/parser/expression-parser.js +3 -4
- package/dist/cjs/parser/fetch-parser.js +1 -2
- package/dist/cjs/parser/group-by-parser.js +1 -2
- package/dist/cjs/parser/identifier-parser.js +1 -2
- package/dist/cjs/parser/insert-values-parser.js +1 -2
- package/dist/cjs/parser/join-parser.js +1 -2
- package/dist/cjs/parser/merge-parser.js +2 -3
- package/dist/cjs/parser/on-commit-action-parse.js +1 -2
- package/dist/cjs/parser/on-modify-action-parser.js +1 -2
- package/dist/cjs/parser/order-by-parser.js +3 -4
- package/dist/cjs/parser/parse-utils.js +4 -5
- package/dist/cjs/parser/partition-by-parser.js +1 -2
- package/dist/cjs/parser/reference-parser.js +8 -9
- package/dist/cjs/parser/returning-parser.d.ts +4 -3
- package/dist/cjs/parser/select-parser.js +2 -3
- package/dist/cjs/parser/set-operation-parser.js +1 -2
- package/dist/cjs/parser/table-parser.js +4 -5
- package/dist/cjs/parser/top-parser.js +1 -2
- package/dist/cjs/parser/unary-operation-parser.js +3 -4
- package/dist/cjs/parser/update-set-parser.js +2 -3
- package/dist/cjs/parser/value-parser.js +4 -5
- package/dist/cjs/parser/with-parser.js +1 -2
- package/dist/cjs/plugin/camel-case/camel-case-plugin.d.ts +54 -27
- package/dist/cjs/plugin/camel-case/camel-case-plugin.js +26 -21
- package/dist/cjs/plugin/camel-case/camel-case.js +2 -3
- package/dist/cjs/plugin/deduplicate-joins/deduplicate-joins-plugin.d.ts +29 -7
- package/dist/cjs/plugin/deduplicate-joins/deduplicate-joins-plugin.js +1 -1
- package/dist/cjs/plugin/deduplicate-joins/deduplicate-joins-transformer.js +2 -2
- package/dist/cjs/plugin/immediate-value/immediate-value-plugin.d.ts +28 -6
- package/dist/cjs/plugin/kysely-plugin.d.ts +28 -6
- package/dist/cjs/plugin/noop-plugin.d.ts +28 -6
- package/dist/cjs/plugin/parse-json-results/parse-json-results-plugin.d.ts +80 -9
- package/dist/cjs/plugin/parse-json-results/parse-json-results-plugin.js +53 -14
- package/dist/cjs/plugin/with-schema/with-schema-plugin.d.ts +28 -6
- package/dist/cjs/query-builder/aggregate-function-builder.d.ts +43 -1
- package/dist/cjs/query-builder/aggregate-function-builder.js +30 -0
- package/dist/cjs/query-builder/delete-query-builder.d.ts +219 -43
- package/dist/cjs/query-builder/delete-query-builder.js +95 -31
- package/dist/cjs/query-builder/function-module.d.ts +40 -93
- package/dist/cjs/query-builder/function-module.js +1 -2
- package/dist/cjs/query-builder/insert-query-builder.d.ts +326 -67
- package/dist/cjs/query-builder/insert-query-builder.js +212 -61
- package/dist/cjs/query-builder/insert-result.d.ts +10 -5
- package/dist/cjs/query-builder/insert-result.js +10 -5
- package/dist/cjs/query-builder/json-path-builder.d.ts +33 -9
- package/dist/cjs/query-builder/json-path-builder.js +8 -5
- package/dist/cjs/query-builder/merge-query-builder.d.ts +312 -10
- package/dist/cjs/query-builder/merge-query-builder.js +98 -7
- package/dist/cjs/query-builder/no-result-error.js +2 -2
- package/dist/cjs/query-builder/on-conflict-builder.d.ts +53 -20
- package/dist/cjs/query-builder/on-conflict-builder.js +41 -16
- package/dist/cjs/query-builder/output-interface.d.ts +138 -0
- package/dist/cjs/query-builder/output-interface.js +2 -0
- package/dist/cjs/query-builder/returning-interface.d.ts +7 -5
- package/dist/cjs/query-builder/select-query-builder-expression.d.ts +8 -0
- package/dist/cjs/query-builder/select-query-builder.d.ts +370 -73
- package/dist/cjs/query-builder/select-query-builder.js +14 -9
- package/dist/cjs/query-builder/update-query-builder.d.ts +225 -31
- package/dist/cjs/query-builder/update-query-builder.js +96 -17
- package/dist/cjs/query-builder/update-result.d.ts +9 -0
- package/dist/cjs/query-builder/update-result.js +9 -0
- package/dist/cjs/query-builder/where-interface.d.ts +6 -2
- package/dist/cjs/query-compiler/default-query-compiler.d.ts +2 -0
- package/dist/cjs/query-compiler/default-query-compiler.js +45 -1
- package/dist/cjs/query-creator.d.ts +122 -21
- package/dist/cjs/query-creator.js +56 -3
- package/dist/cjs/raw-builder/raw-builder.d.ts +29 -7
- package/dist/cjs/raw-builder/raw-builder.js +1 -2
- package/dist/cjs/raw-builder/sql.d.ts +31 -12
- package/dist/cjs/schema/alter-column-builder.d.ts +17 -3
- package/dist/cjs/schema/alter-column-builder.js +20 -3
- package/dist/cjs/schema/alter-table-add-index-builder.d.ts +44 -10
- package/dist/cjs/schema/alter-table-add-index-builder.js +27 -10
- package/dist/cjs/schema/alter-table-builder.js +1 -2
- package/dist/cjs/schema/column-definition-builder.d.ts +286 -24
- package/dist/cjs/schema/column-definition-builder.js +288 -24
- package/dist/cjs/schema/create-table-builder.d.ts +86 -33
- package/dist/cjs/schema/create-table-builder.js +86 -33
- package/dist/cjs/util/assert.js +2 -3
- package/dist/cjs/util/column-type.d.ts +5 -9
- package/dist/cjs/util/compilable.js +1 -2
- package/dist/cjs/util/json-object-args.js +1 -2
- package/dist/cjs/util/log-once.js +1 -2
- package/dist/cjs/util/object-utils.js +38 -26
- package/dist/cjs/util/performance-now.js +1 -2
- package/dist/cjs/util/prevent-await.js +1 -2
- package/dist/cjs/util/query-id.js +1 -2
- package/dist/cjs/util/random-string.js +1 -2
- package/dist/cjs/util/require-all-props.d.ts +4 -2
- package/dist/cjs/util/require-all-props.js +5 -4
- package/dist/cjs/util/stack-trace-utils.js +1 -2
- package/dist/cjs/util/streamable.d.ts +1 -1
- package/dist/cjs/util/type-utils.d.ts +4 -2
- package/dist/esm/dialect/dialect-adapter-base.d.ts +13 -3
- package/dist/esm/dialect/dialect-adapter-base.js +4 -1
- package/dist/esm/dialect/dialect-adapter.d.ts +16 -2
- package/dist/esm/dialect/mssql/mssql-adapter.d.ts +12 -7
- package/dist/esm/dialect/mssql/mssql-adapter.js +2 -4
- package/dist/esm/dialect/mssql/mssql-dialect-config.d.ts +83 -55
- package/dist/esm/dialect/mssql/mssql-driver.d.ts +1 -0
- package/dist/esm/dialect/mssql/mssql-driver.js +114 -48
- package/dist/esm/dialect/mysql/mysql-adapter.d.ts +11 -2
- package/dist/esm/dialect/mysql/mysql-dialect-config.d.ts +4 -0
- package/dist/esm/dialect/mysql/mysql-driver.js +3 -0
- package/dist/esm/dialect/postgres/postgres-adapter.d.ts +11 -2
- package/dist/esm/dialect/postgres/postgres-dialect-config.d.ts +10 -3
- package/dist/esm/dialect/postgres/postgres-driver.js +3 -0
- package/dist/esm/dialect/postgres/postgres-introspector.js +5 -1
- package/dist/esm/dialect/sqlite/sqlite-adapter.d.ts +11 -2
- package/dist/esm/driver/database-connection.d.ts +3 -1
- package/dist/esm/driver/dummy-driver.d.ts +13 -12
- package/dist/esm/driver/dummy-driver.js +13 -12
- package/dist/esm/dynamic/dynamic.d.ts +7 -7
- package/dist/esm/dynamic/dynamic.js +7 -7
- package/dist/esm/expression/expression-builder.d.ts +153 -62
- package/dist/esm/expression/expression-wrapper.d.ts +92 -23
- package/dist/esm/expression/expression.d.ts +40 -5
- package/dist/esm/helpers/mssql.d.ts +74 -14
- package/dist/esm/helpers/mssql.js +74 -14
- package/dist/esm/helpers/mysql.d.ts +17 -13
- package/dist/esm/helpers/mysql.js +17 -13
- package/dist/esm/helpers/postgres.d.ts +11 -8
- package/dist/esm/helpers/postgres.js +11 -8
- package/dist/esm/helpers/sqlite.d.ts +41 -16
- package/dist/esm/helpers/sqlite.js +41 -16
- package/dist/esm/index.d.ts +28 -21
- package/dist/esm/index.js +28 -21
- package/dist/esm/kysely.d.ts +100 -42
- package/dist/esm/kysely.js +61 -37
- package/dist/esm/migration/file-migration-provider.d.ts +2 -2
- package/dist/esm/migration/file-migration-provider.js +2 -2
- package/dist/esm/migration/migrator.d.ts +82 -14
- package/dist/esm/migration/migrator.js +82 -14
- package/dist/esm/operation-node/aggregate-function-node.d.ts +4 -0
- package/dist/esm/operation-node/aggregate-function-node.js +9 -0
- package/dist/esm/operation-node/alter-column-node.d.ts +1 -1
- package/dist/esm/operation-node/case-node.d.ts +1 -1
- package/dist/esm/operation-node/column-definition-node.d.ts +1 -0
- package/dist/esm/operation-node/data-type-node.d.ts +2 -2
- package/dist/esm/operation-node/data-type-node.js +15 -1
- package/dist/esm/operation-node/delete-query-node.d.ts +3 -0
- package/dist/esm/operation-node/foreign-key-constraint-node.d.ts +4 -4
- package/dist/esm/operation-node/having-node.d.ts +1 -1
- package/dist/esm/operation-node/insert-query-node.d.ts +3 -0
- package/dist/esm/operation-node/merge-query-node.d.ts +3 -0
- package/dist/esm/operation-node/on-node.d.ts +1 -1
- package/dist/esm/operation-node/operation-node-transformer.d.ts +11 -3
- package/dist/esm/operation-node/operation-node-transformer.js +26 -3
- package/dist/esm/operation-node/operation-node-visitor.d.ts +2 -0
- package/dist/esm/operation-node/operation-node-visitor.js +1 -0
- package/dist/esm/operation-node/operation-node.d.ts +1 -1
- package/dist/esm/operation-node/operator-node.d.ts +3 -3
- package/dist/esm/operation-node/operator-node.js +2 -0
- package/dist/esm/operation-node/output-node.d.ts +13 -0
- package/dist/esm/operation-node/output-node.js +24 -0
- package/dist/esm/operation-node/query-node.d.ts +15 -6
- package/dist/esm/operation-node/query-node.js +17 -0
- package/dist/esm/operation-node/select-query-node.d.ts +1 -1
- package/dist/esm/operation-node/select-query-node.js +6 -8
- package/dist/esm/operation-node/update-query-node.d.ts +3 -0
- package/dist/esm/operation-node/where-node.d.ts +1 -1
- package/dist/esm/parser/returning-parser.d.ts +4 -3
- package/dist/esm/plugin/camel-case/camel-case-plugin.d.ts +54 -27
- package/dist/esm/plugin/camel-case/camel-case-plugin.js +26 -21
- package/dist/esm/plugin/deduplicate-joins/deduplicate-joins-plugin.d.ts +29 -7
- package/dist/esm/plugin/deduplicate-joins/deduplicate-joins-plugin.js +1 -1
- package/dist/esm/plugin/deduplicate-joins/deduplicate-joins-transformer.js +2 -2
- package/dist/esm/plugin/immediate-value/immediate-value-plugin.d.ts +28 -6
- package/dist/esm/plugin/kysely-plugin.d.ts +28 -6
- package/dist/esm/plugin/noop-plugin.d.ts +28 -6
- package/dist/esm/plugin/parse-json-results/parse-json-results-plugin.d.ts +80 -9
- package/dist/esm/plugin/parse-json-results/parse-json-results-plugin.js +53 -14
- package/dist/esm/plugin/with-schema/with-schema-plugin.d.ts +28 -6
- package/dist/esm/query-builder/aggregate-function-builder.d.ts +43 -1
- package/dist/esm/query-builder/aggregate-function-builder.js +30 -0
- package/dist/esm/query-builder/delete-query-builder.d.ts +219 -43
- package/dist/esm/query-builder/delete-query-builder.js +95 -31
- package/dist/esm/query-builder/function-module.d.ts +40 -93
- package/dist/esm/query-builder/insert-query-builder.d.ts +326 -67
- package/dist/esm/query-builder/insert-query-builder.js +212 -61
- package/dist/esm/query-builder/insert-result.d.ts +10 -5
- package/dist/esm/query-builder/insert-result.js +10 -5
- package/dist/esm/query-builder/json-path-builder.d.ts +33 -9
- package/dist/esm/query-builder/json-path-builder.js +8 -5
- package/dist/esm/query-builder/merge-query-builder.d.ts +312 -10
- package/dist/esm/query-builder/merge-query-builder.js +98 -7
- package/dist/esm/query-builder/on-conflict-builder.d.ts +53 -20
- package/dist/esm/query-builder/on-conflict-builder.js +41 -16
- package/dist/esm/query-builder/output-interface.d.ts +138 -0
- package/dist/esm/query-builder/output-interface.js +2 -0
- package/dist/esm/query-builder/returning-interface.d.ts +7 -5
- package/dist/esm/query-builder/select-query-builder-expression.d.ts +8 -0
- package/dist/esm/query-builder/select-query-builder.d.ts +370 -73
- package/dist/esm/query-builder/select-query-builder.js +13 -7
- package/dist/esm/query-builder/update-query-builder.d.ts +225 -31
- package/dist/esm/query-builder/update-query-builder.js +96 -17
- package/dist/esm/query-builder/update-result.d.ts +9 -0
- package/dist/esm/query-builder/update-result.js +9 -0
- package/dist/esm/query-builder/where-interface.d.ts +6 -2
- package/dist/esm/query-compiler/default-query-compiler.d.ts +2 -0
- package/dist/esm/query-compiler/default-query-compiler.js +45 -1
- package/dist/esm/query-creator.d.ts +122 -21
- package/dist/esm/query-creator.js +56 -3
- package/dist/esm/raw-builder/raw-builder.d.ts +29 -7
- package/dist/esm/raw-builder/sql.d.ts +31 -12
- package/dist/esm/schema/alter-column-builder.d.ts +17 -3
- package/dist/esm/schema/alter-column-builder.js +20 -3
- package/dist/esm/schema/alter-table-add-index-builder.d.ts +44 -10
- package/dist/esm/schema/alter-table-add-index-builder.js +27 -10
- package/dist/esm/schema/alter-table-builder.js +1 -2
- package/dist/esm/schema/column-definition-builder.d.ts +286 -24
- package/dist/esm/schema/column-definition-builder.js +288 -24
- package/dist/esm/schema/create-table-builder.d.ts +86 -33
- package/dist/esm/schema/create-table-builder.js +86 -33
- package/dist/esm/util/column-type.d.ts +5 -9
- package/dist/esm/util/object-utils.js +18 -5
- package/dist/esm/util/require-all-props.d.ts +4 -2
- package/dist/esm/util/require-all-props.js +4 -2
- package/dist/esm/util/streamable.d.ts +1 -1
- package/dist/esm/util/type-utils.d.ts +4 -2
- package/package.json +30 -24
package/dist/esm/kysely.js
CHANGED
|
@@ -21,37 +21,27 @@ import { WithSchemaPlugin } from './plugin/with-schema/with-schema-plugin.js';
|
|
|
21
21
|
* The main Kysely class.
|
|
22
22
|
*
|
|
23
23
|
* You should create one instance of `Kysely` per database using the {@link Kysely}
|
|
24
|
-
* constructor. Each `Kysely` instance maintains
|
|
24
|
+
* constructor. Each `Kysely` instance maintains its own connection pool.
|
|
25
25
|
*
|
|
26
26
|
* ### Examples
|
|
27
27
|
*
|
|
28
|
-
* This example assumes your database has
|
|
28
|
+
* This example assumes your database has a "person" table:
|
|
29
29
|
*
|
|
30
30
|
* ```ts
|
|
31
|
-
* import
|
|
32
|
-
*
|
|
33
|
-
* interface PersonTable {
|
|
34
|
-
* id: Generated<number>
|
|
35
|
-
* first_name: string
|
|
36
|
-
* last_name: string
|
|
37
|
-
* }
|
|
38
|
-
*
|
|
39
|
-
* interface PetTable {
|
|
40
|
-
* id: Generated<number>
|
|
41
|
-
* owner_id: number
|
|
42
|
-
* name: string
|
|
43
|
-
* species: 'cat' | 'dog'
|
|
44
|
-
* }
|
|
31
|
+
* import * as Sqlite from 'better-sqlite3'
|
|
32
|
+
* import { type Generated, Kysely, SqliteDialect } from 'kysely'
|
|
45
33
|
*
|
|
46
34
|
* interface Database {
|
|
47
|
-
* person:
|
|
48
|
-
*
|
|
35
|
+
* person: {
|
|
36
|
+
* id: Generated<number>
|
|
37
|
+
* first_name: string
|
|
38
|
+
* last_name: string | null
|
|
39
|
+
* }
|
|
49
40
|
* }
|
|
50
41
|
*
|
|
51
42
|
* const db = new Kysely<Database>({
|
|
52
|
-
* dialect: new
|
|
53
|
-
*
|
|
54
|
-
* database: 'kysely_test',
|
|
43
|
+
* dialect: new SqliteDialect({
|
|
44
|
+
* database: new Sqlite(':memory:'),
|
|
55
45
|
* })
|
|
56
46
|
* })
|
|
57
47
|
* ```
|
|
@@ -116,30 +106,52 @@ export class Kysely extends QueryCreator {
|
|
|
116
106
|
});
|
|
117
107
|
}
|
|
118
108
|
/**
|
|
119
|
-
* Returns a {@link FunctionModule} that can be used to write type
|
|
109
|
+
* Returns a {@link FunctionModule} that can be used to write somewhat type-safe function
|
|
120
110
|
* calls.
|
|
121
111
|
*
|
|
122
112
|
* ```ts
|
|
113
|
+
* const { count } = db.fn
|
|
114
|
+
*
|
|
123
115
|
* await db.selectFrom('person')
|
|
124
116
|
* .innerJoin('pet', 'pet.owner_id', 'person.id')
|
|
125
|
-
* .select(
|
|
126
|
-
* '
|
|
127
|
-
*
|
|
117
|
+
* .select([
|
|
118
|
+
* 'id',
|
|
119
|
+
* count('pet.id').as('person_count'),
|
|
128
120
|
* ])
|
|
129
121
|
* .groupBy('person.id')
|
|
130
|
-
* .having(
|
|
122
|
+
* .having(count('pet.id'), '>', 10)
|
|
131
123
|
* .execute()
|
|
132
124
|
* ```
|
|
133
125
|
*
|
|
134
126
|
* The generated SQL (PostgreSQL):
|
|
135
127
|
*
|
|
136
128
|
* ```sql
|
|
137
|
-
* select "person"."id", count("pet"."id") as "
|
|
129
|
+
* select "person"."id", count("pet"."id") as "person_count"
|
|
138
130
|
* from "person"
|
|
139
131
|
* inner join "pet" on "pet"."owner_id" = "person"."id"
|
|
140
132
|
* group by "person"."id"
|
|
141
133
|
* having count("pet"."id") > $1
|
|
142
134
|
* ```
|
|
135
|
+
*
|
|
136
|
+
* Why "somewhat" type-safe? Because the function calls are not bound to the
|
|
137
|
+
* current query context. They allow you to reference columns and tables that
|
|
138
|
+
* are not in the current query. E.g. remove the `innerJoin` from the previous
|
|
139
|
+
* query and TypeScript won't even complain.
|
|
140
|
+
*
|
|
141
|
+
* If you want to make the function calls fully type-safe, you can use the
|
|
142
|
+
* {@link ExpressionBuilder.fn} getter for a query context-aware, stricter {@link FunctionModule}.
|
|
143
|
+
*
|
|
144
|
+
* ```ts
|
|
145
|
+
* await db.selectFrom('person')
|
|
146
|
+
* .innerJoin('pet', 'pet.owner_id', 'person.id')
|
|
147
|
+
* .select((eb) => [
|
|
148
|
+
* 'person.id',
|
|
149
|
+
* eb.fn.count('pet.id').as('pet_count')
|
|
150
|
+
* ])
|
|
151
|
+
* .groupBy('person.id')
|
|
152
|
+
* .having((eb) => eb.fn.count('pet.id'), '>', 10)
|
|
153
|
+
* .execute()
|
|
154
|
+
* ```
|
|
143
155
|
*/
|
|
144
156
|
get fn() {
|
|
145
157
|
return createFunctionModule();
|
|
@@ -150,8 +162,11 @@ export class Kysely extends QueryCreator {
|
|
|
150
162
|
* The returned {@link TransactionBuilder} can be used to configure the transaction. The
|
|
151
163
|
* {@link TransactionBuilder.execute} method can then be called to run the transaction.
|
|
152
164
|
* {@link TransactionBuilder.execute} takes a function that is run inside the
|
|
153
|
-
* transaction. If the function throws
|
|
154
|
-
* the
|
|
165
|
+
* transaction. If the function throws an exception,
|
|
166
|
+
* 1. the exception is caught,
|
|
167
|
+
* 2. the transaction is rolled back, and
|
|
168
|
+
* 3. the exception is thrown again.
|
|
169
|
+
* Otherwise the transaction is committed.
|
|
155
170
|
*
|
|
156
171
|
* The callback function passed to the {@link TransactionBuilder.execute | execute}
|
|
157
172
|
* method gets the transaction object as its only argument. The transaction is
|
|
@@ -162,9 +177,12 @@ export class Kysely extends QueryCreator {
|
|
|
162
177
|
*
|
|
163
178
|
* <!-- siteExample("transactions", "Simple transaction", 10) -->
|
|
164
179
|
*
|
|
165
|
-
* This example inserts two rows in a transaction. If an
|
|
166
|
-
* the callback passed to the `execute` method,
|
|
167
|
-
*
|
|
180
|
+
* This example inserts two rows in a transaction. If an exception is thrown inside
|
|
181
|
+
* the callback passed to the `execute` method,
|
|
182
|
+
* 1. the exception is caught,
|
|
183
|
+
* 2. the transaction is rolled back, and
|
|
184
|
+
* 3. the exception is thrown again.
|
|
185
|
+
* Otherwise the transaction is committed.
|
|
168
186
|
*
|
|
169
187
|
* ```ts
|
|
170
188
|
* const catto = await db.transaction().execute(async (trx) => {
|
|
@@ -192,12 +210,18 @@ export class Kysely extends QueryCreator {
|
|
|
192
210
|
* Setting the isolation level:
|
|
193
211
|
*
|
|
194
212
|
* ```ts
|
|
213
|
+
* import type { Kysely } from 'kysely'
|
|
214
|
+
*
|
|
195
215
|
* await db
|
|
196
216
|
* .transaction()
|
|
197
217
|
* .setIsolationLevel('serializable')
|
|
198
218
|
* .execute(async (trx) => {
|
|
199
219
|
* await doStuff(trx)
|
|
200
220
|
* })
|
|
221
|
+
*
|
|
222
|
+
* async function doStuff(kysely: typeof db) {
|
|
223
|
+
* // ...
|
|
224
|
+
* }
|
|
201
225
|
* ```
|
|
202
226
|
*/
|
|
203
227
|
transaction() {
|
|
@@ -217,6 +241,10 @@ export class Kysely extends QueryCreator {
|
|
|
217
241
|
* // the same connection.
|
|
218
242
|
* await doStuff(db)
|
|
219
243
|
* })
|
|
244
|
+
*
|
|
245
|
+
* async function doStuff(kysely: typeof db) {
|
|
246
|
+
* // ...
|
|
247
|
+
* }
|
|
220
248
|
* ```
|
|
221
249
|
*/
|
|
222
250
|
connection() {
|
|
@@ -260,7 +288,6 @@ export class Kysely extends QueryCreator {
|
|
|
260
288
|
*
|
|
261
289
|
* The following example adds and uses a temporary table:
|
|
262
290
|
*
|
|
263
|
-
* @example
|
|
264
291
|
* ```ts
|
|
265
292
|
* await db.schema
|
|
266
293
|
* .createTable('temp_table')
|
|
@@ -309,7 +336,7 @@ export class Kysely extends QueryCreator {
|
|
|
309
336
|
/**
|
|
310
337
|
* Executes a given compiled query or query builder.
|
|
311
338
|
*
|
|
312
|
-
* See {@link https://github.com/
|
|
339
|
+
* See {@link https://github.com/kysely-org/kysely/blob/master/site/docs/recipes/0004-splitting-query-building-and-execution.md#execute-compiled-queries splitting build, compile and execute code recipe} for more information.
|
|
313
340
|
*/
|
|
314
341
|
executeQuery(query, queryId = createQueryId()) {
|
|
315
342
|
const compiledQuery = isCompilable(query) ? query.compile() : query;
|
|
@@ -349,9 +376,6 @@ export class Transaction extends Kysely {
|
|
|
349
376
|
executor: this.#props.executor.withoutPlugins(),
|
|
350
377
|
});
|
|
351
378
|
}
|
|
352
|
-
/**
|
|
353
|
-
* @override
|
|
354
|
-
*/
|
|
355
379
|
withSchema(schema) {
|
|
356
380
|
return new Transaction({
|
|
357
381
|
...this.#props,
|
|
@@ -5,8 +5,8 @@ import { Migration, MigrationProvider } from './migrator.js';
|
|
|
5
5
|
* ### Examples
|
|
6
6
|
*
|
|
7
7
|
* ```ts
|
|
8
|
-
* import { promises as fs } from 'fs'
|
|
9
|
-
* import path from 'path'
|
|
8
|
+
* import { promises as fs } from 'node:fs'
|
|
9
|
+
* import path from 'node:path'
|
|
10
10
|
*
|
|
11
11
|
* new FileMigrationProvider({
|
|
12
12
|
* fs,
|
|
@@ -6,8 +6,8 @@ import { isFunction, isObject } from '../util/object-utils.js';
|
|
|
6
6
|
* ### Examples
|
|
7
7
|
*
|
|
8
8
|
* ```ts
|
|
9
|
-
* import { promises as fs } from 'fs'
|
|
10
|
-
* import path from 'path'
|
|
9
|
+
* import { promises as fs } from 'node:fs'
|
|
10
|
+
* import path from 'node:path'
|
|
11
11
|
*
|
|
12
12
|
* new FileMigrationProvider({
|
|
13
13
|
* fs,
|
|
@@ -25,16 +25,29 @@ export interface Migration {
|
|
|
25
25
|
* other way.
|
|
26
26
|
*
|
|
27
27
|
* ```ts
|
|
28
|
-
* import { promises as fs } from 'fs'
|
|
29
|
-
* import path from 'path'
|
|
28
|
+
* import { promises as fs } from 'node:fs'
|
|
29
|
+
* import path from 'node:path'
|
|
30
|
+
* import * as Sqlite from 'better-sqlite3'
|
|
31
|
+
* import {
|
|
32
|
+
* FileMigrationProvider,
|
|
33
|
+
* Kysely,
|
|
34
|
+
* Migrator,
|
|
35
|
+
* SqliteDialect
|
|
36
|
+
* } from 'kysely'
|
|
37
|
+
*
|
|
38
|
+
* const db = new Kysely<any>({
|
|
39
|
+
* dialect: new SqliteDialect({
|
|
40
|
+
* database: Sqlite(':memory:')
|
|
41
|
+
* })
|
|
42
|
+
* })
|
|
30
43
|
*
|
|
31
44
|
* const migrator = new Migrator({
|
|
32
45
|
* db,
|
|
33
46
|
* provider: new FileMigrationProvider({
|
|
34
47
|
* fs,
|
|
35
|
-
* path,
|
|
36
48
|
* // Path to the folder that contains all your migrations.
|
|
37
|
-
* migrationFolder: 'some/path/to/migrations'
|
|
49
|
+
* migrationFolder: 'some/path/to/migrations',
|
|
50
|
+
* path,
|
|
38
51
|
* })
|
|
39
52
|
* })
|
|
40
53
|
* ```
|
|
@@ -64,19 +77,18 @@ export declare class Migrator {
|
|
|
64
77
|
* ### Examples
|
|
65
78
|
*
|
|
66
79
|
* ```ts
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
* }),
|
|
72
|
-
* })
|
|
80
|
+
* import { promises as fs } from 'node:fs'
|
|
81
|
+
* import path from 'node:path'
|
|
82
|
+
* import * as Sqlite from 'better-sqlite3'
|
|
83
|
+
* import { FileMigrationProvider, Migrator } from 'kysely'
|
|
73
84
|
*
|
|
74
85
|
* const migrator = new Migrator({
|
|
75
86
|
* db,
|
|
76
|
-
* provider: new FileMigrationProvider(
|
|
77
|
-
*
|
|
78
|
-
* 'some/path/to/migrations'
|
|
79
|
-
*
|
|
87
|
+
* provider: new FileMigrationProvider({
|
|
88
|
+
* fs,
|
|
89
|
+
* migrationFolder: 'some/path/to/migrations',
|
|
90
|
+
* path,
|
|
91
|
+
* })
|
|
80
92
|
* })
|
|
81
93
|
*
|
|
82
94
|
* const { error, results } = await migrator.migrateToLatest()
|
|
@@ -107,6 +119,20 @@ export declare class Migrator {
|
|
|
107
119
|
* ### Examples
|
|
108
120
|
*
|
|
109
121
|
* ```ts
|
|
122
|
+
* import { promises as fs } from 'node:fs'
|
|
123
|
+
* import path from 'node:path'
|
|
124
|
+
* import { FileMigrationProvider, Migrator } from 'kysely'
|
|
125
|
+
*
|
|
126
|
+
* const migrator = new Migrator({
|
|
127
|
+
* db,
|
|
128
|
+
* provider: new FileMigrationProvider({
|
|
129
|
+
* fs,
|
|
130
|
+
* // Path to the folder that contains all your migrations.
|
|
131
|
+
* migrationFolder: 'some/path/to/migrations',
|
|
132
|
+
* path,
|
|
133
|
+
* })
|
|
134
|
+
* })
|
|
135
|
+
*
|
|
110
136
|
* await migrator.migrateTo('some_migration')
|
|
111
137
|
* ```
|
|
112
138
|
*
|
|
@@ -116,6 +142,20 @@ export declare class Migrator {
|
|
|
116
142
|
* you can use a special constant `NO_MIGRATIONS`:
|
|
117
143
|
*
|
|
118
144
|
* ```ts
|
|
145
|
+
* import { promises as fs } from 'node:fs'
|
|
146
|
+
* import path from 'node:path'
|
|
147
|
+
* import { FileMigrationProvider, Migrator, NO_MIGRATIONS } from 'kysely'
|
|
148
|
+
*
|
|
149
|
+
* const migrator = new Migrator({
|
|
150
|
+
* db,
|
|
151
|
+
* provider: new FileMigrationProvider({
|
|
152
|
+
* fs,
|
|
153
|
+
* // Path to the folder that contains all your migrations.
|
|
154
|
+
* migrationFolder: 'some/path/to/migrations',
|
|
155
|
+
* path,
|
|
156
|
+
* })
|
|
157
|
+
* })
|
|
158
|
+
*
|
|
119
159
|
* await migrator.migrateTo(NO_MIGRATIONS)
|
|
120
160
|
* ```
|
|
121
161
|
*/
|
|
@@ -131,6 +171,20 @@ export declare class Migrator {
|
|
|
131
171
|
* ### Examples
|
|
132
172
|
*
|
|
133
173
|
* ```ts
|
|
174
|
+
* import { promises as fs } from 'node:fs'
|
|
175
|
+
* import path from 'node:path'
|
|
176
|
+
* import { FileMigrationProvider, Migrator } from 'kysely'
|
|
177
|
+
*
|
|
178
|
+
* const migrator = new Migrator({
|
|
179
|
+
* db,
|
|
180
|
+
* provider: new FileMigrationProvider({
|
|
181
|
+
* fs,
|
|
182
|
+
* // Path to the folder that contains all your migrations.
|
|
183
|
+
* migrationFolder: 'some/path/to/migrations',
|
|
184
|
+
* path,
|
|
185
|
+
* })
|
|
186
|
+
* })
|
|
187
|
+
*
|
|
134
188
|
* await migrator.migrateUp()
|
|
135
189
|
* ```
|
|
136
190
|
*/
|
|
@@ -146,6 +200,20 @@ export declare class Migrator {
|
|
|
146
200
|
* ### Examples
|
|
147
201
|
*
|
|
148
202
|
* ```ts
|
|
203
|
+
* import { promises as fs } from 'node:fs'
|
|
204
|
+
* import path from 'node:path'
|
|
205
|
+
* import { FileMigrationProvider, Migrator } from 'kysely'
|
|
206
|
+
*
|
|
207
|
+
* const migrator = new Migrator({
|
|
208
|
+
* db,
|
|
209
|
+
* provider: new FileMigrationProvider({
|
|
210
|
+
* fs,
|
|
211
|
+
* // Path to the folder that contains all your migrations.
|
|
212
|
+
* migrationFolder: 'some/path/to/migrations',
|
|
213
|
+
* path,
|
|
214
|
+
* })
|
|
215
|
+
* })
|
|
216
|
+
*
|
|
149
217
|
* await migrator.migrateDown()
|
|
150
218
|
* ```
|
|
151
219
|
*/
|
|
@@ -18,16 +18,29 @@ export const NO_MIGRATIONS = freeze({ __noMigrations__: true });
|
|
|
18
18
|
* other way.
|
|
19
19
|
*
|
|
20
20
|
* ```ts
|
|
21
|
-
* import { promises as fs } from 'fs'
|
|
22
|
-
* import path from 'path'
|
|
21
|
+
* import { promises as fs } from 'node:fs'
|
|
22
|
+
* import path from 'node:path'
|
|
23
|
+
* import * as Sqlite from 'better-sqlite3'
|
|
24
|
+
* import {
|
|
25
|
+
* FileMigrationProvider,
|
|
26
|
+
* Kysely,
|
|
27
|
+
* Migrator,
|
|
28
|
+
* SqliteDialect
|
|
29
|
+
* } from 'kysely'
|
|
30
|
+
*
|
|
31
|
+
* const db = new Kysely<any>({
|
|
32
|
+
* dialect: new SqliteDialect({
|
|
33
|
+
* database: Sqlite(':memory:')
|
|
34
|
+
* })
|
|
35
|
+
* })
|
|
23
36
|
*
|
|
24
37
|
* const migrator = new Migrator({
|
|
25
38
|
* db,
|
|
26
39
|
* provider: new FileMigrationProvider({
|
|
27
40
|
* fs,
|
|
28
|
-
* path,
|
|
29
41
|
* // Path to the folder that contains all your migrations.
|
|
30
|
-
* migrationFolder: 'some/path/to/migrations'
|
|
42
|
+
* migrationFolder: 'some/path/to/migrations',
|
|
43
|
+
* path,
|
|
31
44
|
* })
|
|
32
45
|
* })
|
|
33
46
|
* ```
|
|
@@ -76,19 +89,18 @@ export class Migrator {
|
|
|
76
89
|
* ### Examples
|
|
77
90
|
*
|
|
78
91
|
* ```ts
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
* }),
|
|
84
|
-
* })
|
|
92
|
+
* import { promises as fs } from 'node:fs'
|
|
93
|
+
* import path from 'node:path'
|
|
94
|
+
* import * as Sqlite from 'better-sqlite3'
|
|
95
|
+
* import { FileMigrationProvider, Migrator } from 'kysely'
|
|
85
96
|
*
|
|
86
97
|
* const migrator = new Migrator({
|
|
87
98
|
* db,
|
|
88
|
-
* provider: new FileMigrationProvider(
|
|
89
|
-
*
|
|
90
|
-
* 'some/path/to/migrations'
|
|
91
|
-
*
|
|
99
|
+
* provider: new FileMigrationProvider({
|
|
100
|
+
* fs,
|
|
101
|
+
* migrationFolder: 'some/path/to/migrations',
|
|
102
|
+
* path,
|
|
103
|
+
* })
|
|
92
104
|
* })
|
|
93
105
|
*
|
|
94
106
|
* const { error, results } = await migrator.migrateToLatest()
|
|
@@ -121,6 +133,20 @@ export class Migrator {
|
|
|
121
133
|
* ### Examples
|
|
122
134
|
*
|
|
123
135
|
* ```ts
|
|
136
|
+
* import { promises as fs } from 'node:fs'
|
|
137
|
+
* import path from 'node:path'
|
|
138
|
+
* import { FileMigrationProvider, Migrator } from 'kysely'
|
|
139
|
+
*
|
|
140
|
+
* const migrator = new Migrator({
|
|
141
|
+
* db,
|
|
142
|
+
* provider: new FileMigrationProvider({
|
|
143
|
+
* fs,
|
|
144
|
+
* // Path to the folder that contains all your migrations.
|
|
145
|
+
* migrationFolder: 'some/path/to/migrations',
|
|
146
|
+
* path,
|
|
147
|
+
* })
|
|
148
|
+
* })
|
|
149
|
+
*
|
|
124
150
|
* await migrator.migrateTo('some_migration')
|
|
125
151
|
* ```
|
|
126
152
|
*
|
|
@@ -130,6 +156,20 @@ export class Migrator {
|
|
|
130
156
|
* you can use a special constant `NO_MIGRATIONS`:
|
|
131
157
|
*
|
|
132
158
|
* ```ts
|
|
159
|
+
* import { promises as fs } from 'node:fs'
|
|
160
|
+
* import path from 'node:path'
|
|
161
|
+
* import { FileMigrationProvider, Migrator, NO_MIGRATIONS } from 'kysely'
|
|
162
|
+
*
|
|
163
|
+
* const migrator = new Migrator({
|
|
164
|
+
* db,
|
|
165
|
+
* provider: new FileMigrationProvider({
|
|
166
|
+
* fs,
|
|
167
|
+
* // Path to the folder that contains all your migrations.
|
|
168
|
+
* migrationFolder: 'some/path/to/migrations',
|
|
169
|
+
* path,
|
|
170
|
+
* })
|
|
171
|
+
* })
|
|
172
|
+
*
|
|
133
173
|
* await migrator.migrateTo(NO_MIGRATIONS)
|
|
134
174
|
* ```
|
|
135
175
|
*/
|
|
@@ -168,6 +208,20 @@ export class Migrator {
|
|
|
168
208
|
* ### Examples
|
|
169
209
|
*
|
|
170
210
|
* ```ts
|
|
211
|
+
* import { promises as fs } from 'node:fs'
|
|
212
|
+
* import path from 'node:path'
|
|
213
|
+
* import { FileMigrationProvider, Migrator } from 'kysely'
|
|
214
|
+
*
|
|
215
|
+
* const migrator = new Migrator({
|
|
216
|
+
* db,
|
|
217
|
+
* provider: new FileMigrationProvider({
|
|
218
|
+
* fs,
|
|
219
|
+
* // Path to the folder that contains all your migrations.
|
|
220
|
+
* migrationFolder: 'some/path/to/migrations',
|
|
221
|
+
* path,
|
|
222
|
+
* })
|
|
223
|
+
* })
|
|
224
|
+
*
|
|
171
225
|
* await migrator.migrateUp()
|
|
172
226
|
* ```
|
|
173
227
|
*/
|
|
@@ -185,6 +239,20 @@ export class Migrator {
|
|
|
185
239
|
* ### Examples
|
|
186
240
|
*
|
|
187
241
|
* ```ts
|
|
242
|
+
* import { promises as fs } from 'node:fs'
|
|
243
|
+
* import path from 'node:path'
|
|
244
|
+
* import { FileMigrationProvider, Migrator } from 'kysely'
|
|
245
|
+
*
|
|
246
|
+
* const migrator = new Migrator({
|
|
247
|
+
* db,
|
|
248
|
+
* provider: new FileMigrationProvider({
|
|
249
|
+
* fs,
|
|
250
|
+
* // Path to the folder that contains all your migrations.
|
|
251
|
+
* migrationFolder: 'some/path/to/migrations',
|
|
252
|
+
* path,
|
|
253
|
+
* })
|
|
254
|
+
* })
|
|
255
|
+
*
|
|
188
256
|
* await migrator.migrateDown()
|
|
189
257
|
* ```
|
|
190
258
|
*/
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { OperationNode } from './operation-node.js';
|
|
2
2
|
import { OverNode } from './over-node.js';
|
|
3
3
|
import { WhereNode } from './where-node.js';
|
|
4
|
+
import { OrderByNode } from './order-by-node.js';
|
|
5
|
+
import { OrderByItemNode } from './order-by-item-node.js';
|
|
4
6
|
export interface AggregateFunctionNode extends OperationNode {
|
|
5
7
|
readonly kind: 'AggregateFunctionNode';
|
|
6
8
|
readonly func: string;
|
|
7
9
|
readonly aggregated: readonly OperationNode[];
|
|
8
10
|
readonly distinct?: boolean;
|
|
11
|
+
readonly orderBy?: OrderByNode;
|
|
9
12
|
readonly filter?: WhereNode;
|
|
10
13
|
readonly over?: OverNode;
|
|
11
14
|
}
|
|
@@ -16,6 +19,7 @@ export declare const AggregateFunctionNode: Readonly<{
|
|
|
16
19
|
is(node: OperationNode): node is AggregateFunctionNode;
|
|
17
20
|
create(aggregateFunction: string, aggregated?: readonly OperationNode[]): AggregateFunctionNode;
|
|
18
21
|
cloneWithDistinct(aggregateFunctionNode: AggregateFunctionNode): AggregateFunctionNode;
|
|
22
|
+
cloneWithOrderBy(aggregateFunctionNode: AggregateFunctionNode, orderItems: ReadonlyArray<OrderByItemNode>): AggregateFunctionNode;
|
|
19
23
|
cloneWithFilter(aggregateFunctionNode: AggregateFunctionNode, filter: OperationNode): AggregateFunctionNode;
|
|
20
24
|
cloneWithOrFilter(aggregateFunctionNode: AggregateFunctionNode, filter: OperationNode): AggregateFunctionNode;
|
|
21
25
|
cloneWithOver(aggregateFunctionNode: AggregateFunctionNode, over?: OverNode): AggregateFunctionNode;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/// <reference types="./aggregate-function-node.d.ts" />
|
|
2
2
|
import { freeze } from '../util/object-utils.js';
|
|
3
3
|
import { WhereNode } from './where-node.js';
|
|
4
|
+
import { OrderByNode } from './order-by-node.js';
|
|
4
5
|
/**
|
|
5
6
|
* @internal
|
|
6
7
|
*/
|
|
@@ -21,6 +22,14 @@ export const AggregateFunctionNode = freeze({
|
|
|
21
22
|
distinct: true,
|
|
22
23
|
});
|
|
23
24
|
},
|
|
25
|
+
cloneWithOrderBy(aggregateFunctionNode, orderItems) {
|
|
26
|
+
return freeze({
|
|
27
|
+
...aggregateFunctionNode,
|
|
28
|
+
orderBy: aggregateFunctionNode.orderBy
|
|
29
|
+
? OrderByNode.cloneWithItems(aggregateFunctionNode.orderBy, orderItems)
|
|
30
|
+
: OrderByNode.create(orderItems),
|
|
31
|
+
});
|
|
32
|
+
},
|
|
24
33
|
cloneWithFilter(aggregateFunctionNode, filter) {
|
|
25
34
|
return freeze({
|
|
26
35
|
...aggregateFunctionNode,
|
|
@@ -17,5 +17,5 @@ export interface AlterColumnNode extends OperationNode {
|
|
|
17
17
|
*/
|
|
18
18
|
export declare const AlterColumnNode: Readonly<{
|
|
19
19
|
is(node: OperationNode): node is AlterColumnNode;
|
|
20
|
-
create<T extends
|
|
20
|
+
create<T extends keyof AlterColumnNodeProps>(column: string, prop: T, value: Required<AlterColumnNodeProps>[T]): AlterColumnNode;
|
|
21
21
|
}>;
|
|
@@ -15,5 +15,5 @@ export declare const CaseNode: Readonly<{
|
|
|
15
15
|
create(value?: OperationNode): CaseNode;
|
|
16
16
|
cloneWithWhen(caseNode: CaseNode, when: WhenNode): CaseNode;
|
|
17
17
|
cloneWithThen(caseNode: CaseNode, then: OperationNode): CaseNode;
|
|
18
|
-
cloneWith(caseNode: CaseNode, props: Partial<Pick<CaseNode,
|
|
18
|
+
cloneWith(caseNode: CaseNode, props: Partial<Pick<CaseNode, "else" | "isStatement">>): CaseNode;
|
|
19
19
|
}>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { OperationNode } from './operation-node.js';
|
|
2
|
-
declare const SIMPLE_COLUMN_DATA_TYPES: readonly ["varchar", "char", "text", "integer", "int2", "int4", "int8", "smallint", "bigint", "boolean", "real", "double precision", "float4", "float8", "decimal", "numeric", "binary", "bytea", "date", "datetime", "time", "timetz", "timestamp", "timestamptz", "serial", "bigserial", "uuid", "json", "jsonb", "blob"];
|
|
2
|
+
declare const SIMPLE_COLUMN_DATA_TYPES: readonly ["varchar", "char", "text", "integer", "int2", "int4", "int8", "smallint", "bigint", "boolean", "real", "double precision", "float4", "float8", "decimal", "numeric", "binary", "bytea", "date", "datetime", "time", "timetz", "timestamp", "timestamptz", "serial", "bigserial", "uuid", "json", "jsonb", "blob", "varbinary", "int4range", "int4multirange", "int8range", "int8multirange", "numrange", "nummultirange", "tsrange", "tsmultirange", "tstzrange", "tstzmultirange", "daterange", "datemultirange"];
|
|
3
3
|
type SimpleColumnDataType = (typeof SIMPLE_COLUMN_DATA_TYPES)[number];
|
|
4
|
-
export type ColumnDataType = SimpleColumnDataType | `varchar(${number})` | `char(${number})` | `decimal(${number}, ${number})` | `numeric(${number}, ${number})` | `binary(${number})` | `datetime(${number})` | `time(${number})` | `timetz(${number})` | `timestamp(${number})` | `timestamptz(${number})`;
|
|
4
|
+
export type ColumnDataType = SimpleColumnDataType | `varchar(${number})` | `char(${number})` | `decimal(${number}, ${number})` | `numeric(${number}, ${number})` | `binary(${number})` | `datetime(${number})` | `time(${number})` | `timetz(${number})` | `timestamp(${number})` | `timestamptz(${number})` | `varbinary(${number})`;
|
|
5
5
|
export type DataTypeParams = Omit<DataTypeNode, 'kind' | 'dataType'>;
|
|
6
6
|
export interface DataTypeNode extends OperationNode {
|
|
7
7
|
readonly kind: 'DataTypeNode';
|
|
@@ -31,6 +31,19 @@ const SIMPLE_COLUMN_DATA_TYPES = [
|
|
|
31
31
|
'json',
|
|
32
32
|
'jsonb',
|
|
33
33
|
'blob',
|
|
34
|
+
'varbinary',
|
|
35
|
+
'int4range',
|
|
36
|
+
'int4multirange',
|
|
37
|
+
'int8range',
|
|
38
|
+
'int8multirange',
|
|
39
|
+
'numrange',
|
|
40
|
+
'nummultirange',
|
|
41
|
+
'tsrange',
|
|
42
|
+
'tsmultirange',
|
|
43
|
+
'tstzrange',
|
|
44
|
+
'tstzmultirange',
|
|
45
|
+
'daterange',
|
|
46
|
+
'datemultirange',
|
|
34
47
|
];
|
|
35
48
|
const COLUMN_DATA_TYPE_REGEX = [
|
|
36
49
|
/^varchar\(\d+\)$/,
|
|
@@ -40,9 +53,10 @@ const COLUMN_DATA_TYPE_REGEX = [
|
|
|
40
53
|
/^binary\(\d+\)$/,
|
|
41
54
|
/^datetime\(\d+\)$/,
|
|
42
55
|
/^time\(\d+\)$/,
|
|
43
|
-
/^
|
|
56
|
+
/^timetz\(\d+\)$/,
|
|
44
57
|
/^timestamp\(\d+\)$/,
|
|
45
58
|
/^timestamptz\(\d+\)$/,
|
|
59
|
+
/^varbinary\(\d+\)$/,
|
|
46
60
|
];
|
|
47
61
|
/**
|
|
48
62
|
* @internal
|
|
@@ -10,6 +10,7 @@ import { OrderByItemNode } from './order-by-item-node.js';
|
|
|
10
10
|
import { ExplainNode } from './explain-node.js';
|
|
11
11
|
import { UsingNode } from './using-node.js';
|
|
12
12
|
import { TopNode } from './top-node.js';
|
|
13
|
+
import { OutputNode } from './output-node.js';
|
|
13
14
|
export interface DeleteQueryNode extends OperationNode {
|
|
14
15
|
readonly kind: 'DeleteQueryNode';
|
|
15
16
|
readonly from: FromNode;
|
|
@@ -21,7 +22,9 @@ export interface DeleteQueryNode extends OperationNode {
|
|
|
21
22
|
readonly orderBy?: OrderByNode;
|
|
22
23
|
readonly limit?: LimitNode;
|
|
23
24
|
readonly explain?: ExplainNode;
|
|
25
|
+
readonly endModifiers?: ReadonlyArray<OperationNode>;
|
|
24
26
|
readonly top?: TopNode;
|
|
27
|
+
readonly output?: OutputNode;
|
|
25
28
|
}
|
|
26
29
|
/**
|
|
27
30
|
* @internal
|
|
@@ -19,10 +19,10 @@ export declare const ForeignKeyConstraintNode: Readonly<{
|
|
|
19
19
|
is(node: OperationNode): node is ForeignKeyConstraintNode;
|
|
20
20
|
create(sourceColumns: ReadonlyArray<ColumnNode>, targetTable: TableNode, targetColumns: ReadonlyArray<ColumnNode>, constraintName?: string): ForeignKeyConstraintNode;
|
|
21
21
|
cloneWith(node: ForeignKeyConstraintNode, props: ForeignKeyConstraintNodeProps): Readonly<{
|
|
22
|
-
name?: IdentifierNode
|
|
23
|
-
onDelete?:
|
|
24
|
-
onUpdate?:
|
|
25
|
-
kind:
|
|
22
|
+
name?: IdentifierNode;
|
|
23
|
+
onDelete?: OnModifyForeignAction;
|
|
24
|
+
onUpdate?: OnModifyForeignAction;
|
|
25
|
+
kind: "ForeignKeyConstraintNode";
|
|
26
26
|
columns: ReadonlyArray<ColumnNode>;
|
|
27
27
|
references: ReferencesNode;
|
|
28
28
|
}>;
|
|
@@ -9,5 +9,5 @@ export interface HavingNode extends OperationNode {
|
|
|
9
9
|
export declare const HavingNode: Readonly<{
|
|
10
10
|
is(node: OperationNode): node is HavingNode;
|
|
11
11
|
create(filter: OperationNode): HavingNode;
|
|
12
|
-
cloneWithOperation(havingNode: HavingNode, operator:
|
|
12
|
+
cloneWithOperation(havingNode: HavingNode, operator: "And" | "Or", operation: OperationNode): HavingNode;
|
|
13
13
|
}>;
|