kysely 0.22.0 → 0.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CONTRIBUTING.md +70 -0
- package/README.md +25 -2
- package/dist/cjs/dialect/database-introspector.d.ts +4 -0
- package/dist/cjs/dialect/mysql/mysql-driver.js +6 -3
- package/dist/cjs/dialect/postgres/postgres-adapter.js +1 -1
- package/dist/cjs/dialect/postgres/postgres-driver.js +7 -2
- package/dist/cjs/dialect/postgres/postgres-introspector.js +8 -0
- package/dist/cjs/dialect/sqlite/sqlite-driver.js +4 -3
- package/dist/cjs/dialect/sqlite/sqlite-introspector.js +1 -0
- package/dist/cjs/driver/database-connection.d.ts +6 -2
- package/dist/cjs/dynamic/dynamic-reference-builder.d.ts +2 -3
- package/dist/cjs/dynamic/dynamic-reference-builder.js +1 -1
- package/dist/cjs/expression/expression.d.ts +100 -0
- package/dist/cjs/expression/expression.js +16 -0
- package/dist/cjs/index.d.ts +10 -6
- package/dist/cjs/index.js +8 -2
- package/dist/cjs/migration/file-migration-provider.js +5 -3
- package/dist/cjs/operation-node/aggregate-function-node.d.ts +7 -4
- package/dist/cjs/operation-node/aggregate-function-node.js +17 -0
- package/dist/cjs/operation-node/alias-node.d.ts +3 -11
- package/dist/cjs/operation-node/alter-column-node.d.ts +1 -2
- package/dist/cjs/operation-node/alter-table-node.d.ts +5 -7
- package/dist/cjs/operation-node/alter-table-node.js +9 -1
- package/dist/cjs/operation-node/and-node.d.ts +3 -4
- package/dist/cjs/operation-node/binary-operation-node.d.ts +14 -0
- package/dist/cjs/operation-node/binary-operation-node.js +20 -0
- package/dist/cjs/operation-node/check-constraint-node.d.ts +2 -3
- package/dist/cjs/operation-node/column-definition-node.d.ts +6 -5
- package/dist/cjs/operation-node/column-definition-node.js +16 -0
- package/dist/cjs/operation-node/column-update-node.d.ts +2 -3
- package/dist/cjs/operation-node/common-table-expression-node.d.ts +2 -4
- package/dist/cjs/operation-node/create-index-node.d.ts +1 -3
- package/dist/cjs/operation-node/create-table-node.d.ts +4 -5
- package/dist/cjs/operation-node/create-type-node.d.ts +1 -1
- package/dist/cjs/operation-node/create-type-node.js +1 -2
- package/dist/cjs/operation-node/default-value-node.d.ts +2 -4
- package/dist/cjs/operation-node/delete-query-node.d.ts +1 -2
- package/dist/cjs/operation-node/drop-type-node.d.ts +1 -1
- package/dist/cjs/operation-node/drop-type-node.js +1 -2
- package/dist/cjs/operation-node/explain-node.d.ts +2 -4
- package/dist/cjs/operation-node/explain-node.js +1 -1
- package/dist/cjs/operation-node/from-node.d.ts +3 -4
- package/dist/cjs/operation-node/generated-node.d.ts +2 -3
- package/dist/cjs/operation-node/group-by-item-node.d.ts +2 -3
- package/dist/cjs/operation-node/having-node.d.ts +3 -4
- package/dist/cjs/operation-node/having-node.js +4 -4
- package/dist/cjs/operation-node/insert-query-node.d.ts +1 -5
- package/dist/cjs/operation-node/join-node.d.ts +5 -9
- package/dist/cjs/operation-node/join-node.js +6 -6
- package/dist/cjs/operation-node/on-conflict-node.d.ts +5 -7
- package/dist/cjs/operation-node/on-conflict-node.js +12 -12
- package/dist/cjs/operation-node/on-node.d.ts +3 -4
- package/dist/cjs/operation-node/on-node.js +4 -4
- package/dist/cjs/operation-node/operation-node-transformer.d.ts +4 -2
- package/dist/cjs/operation-node/operation-node-transformer.js +22 -15
- package/dist/cjs/operation-node/operation-node-visitor.d.ts +4 -2
- package/dist/cjs/operation-node/operation-node-visitor.js +2 -1
- package/dist/cjs/operation-node/operation-node.d.ts +1 -1
- package/dist/cjs/operation-node/operator-node.d.ts +5 -3
- package/dist/cjs/operation-node/operator-node.js +3 -5
- package/dist/cjs/operation-node/or-node.d.ts +3 -4
- package/dist/cjs/operation-node/order-by-item-node.d.ts +3 -5
- package/dist/cjs/operation-node/parens-node.d.ts +2 -3
- package/dist/cjs/operation-node/partition-by-item-node.d.ts +3 -4
- package/dist/cjs/operation-node/query-node.d.ts +2 -3
- package/dist/cjs/operation-node/query-node.js +6 -6
- package/dist/cjs/operation-node/select-modifier-node.d.ts +2 -3
- package/dist/cjs/operation-node/select-modifier-node.js +1 -1
- package/dist/cjs/operation-node/select-query-node.d.ts +5 -6
- package/dist/cjs/operation-node/select-query-node.js +10 -10
- package/dist/cjs/operation-node/selection-node.d.ts +2 -3
- package/dist/cjs/operation-node/set-operation-node.d.ts +2 -5
- package/dist/cjs/operation-node/simple-reference-expression-node.d.ts +3 -0
- package/dist/cjs/operation-node/{operation-node-utils.js → simple-reference-expression-node.js} +0 -0
- package/dist/cjs/operation-node/unary-operation-node.d.ts +13 -0
- package/dist/cjs/operation-node/unary-operation-node.js +19 -0
- package/dist/cjs/operation-node/update-query-node.d.ts +3 -4
- package/dist/cjs/operation-node/value-list-node.d.ts +2 -9
- package/dist/cjs/operation-node/where-node.d.ts +3 -4
- package/dist/cjs/operation-node/where-node.js +4 -4
- package/dist/cjs/parser/binary-operation-parser.d.ts +20 -0
- package/dist/cjs/parser/binary-operation-parser.js +99 -0
- package/dist/cjs/parser/coalesce-parser.d.ts +4 -0
- package/dist/cjs/parser/coalesce-parser.js +11 -0
- package/dist/cjs/parser/data-type-parser.d.ts +5 -5
- package/dist/cjs/parser/default-value-parser.d.ts +4 -5
- package/dist/cjs/parser/default-value-parser.js +2 -2
- package/dist/cjs/parser/expression-parser.d.ts +10 -0
- package/dist/cjs/parser/{complex-expression-parser.js → expression-parser.js} +9 -8
- package/dist/cjs/parser/identifier-parser.d.ts +2 -0
- package/dist/cjs/parser/identifier-parser.js +23 -0
- package/dist/cjs/parser/insert-values-parser.d.ts +1 -1
- package/dist/cjs/parser/insert-values-parser.js +2 -2
- package/dist/cjs/parser/join-parser.js +2 -2
- package/dist/cjs/parser/order-by-parser.d.ts +2 -2
- package/dist/cjs/parser/reference-parser.d.ts +14 -14
- package/dist/cjs/parser/reference-parser.js +12 -9
- package/dist/cjs/parser/select-parser.d.ts +6 -7
- package/dist/cjs/parser/select-parser.js +2 -2
- package/dist/cjs/parser/set-operation-parser.d.ts +2 -4
- package/dist/cjs/parser/table-parser.d.ts +11 -12
- package/dist/cjs/parser/table-parser.js +2 -2
- package/dist/cjs/parser/unary-operation-parser.d.ts +5 -0
- package/dist/cjs/parser/unary-operation-parser.js +17 -0
- package/dist/cjs/parser/update-set-parser.d.ts +1 -1
- package/dist/cjs/parser/value-parser.d.ts +5 -9
- package/dist/cjs/parser/value-parser.js +4 -4
- package/dist/cjs/parser/with-parser.d.ts +3 -4
- package/dist/cjs/plugin/camel-case/camel-case-plugin.js +1 -1
- package/dist/cjs/query-builder/aggregate-function-builder.d.ts +245 -14
- package/dist/cjs/query-builder/aggregate-function-builder.js +164 -12
- package/dist/cjs/query-builder/delete-query-builder.d.ts +20 -20
- package/dist/cjs/query-builder/delete-query-builder.js +19 -16
- package/dist/cjs/query-builder/function-module.d.ts +123 -22
- package/dist/cjs/query-builder/function-module.js +91 -48
- package/dist/cjs/query-builder/having-interface.d.ts +9 -8
- package/dist/cjs/query-builder/insert-query-builder.d.ts +7 -6
- package/dist/cjs/query-builder/insert-query-builder.js +11 -9
- package/dist/cjs/query-builder/insert-result.d.ts +8 -1
- package/dist/cjs/query-builder/insert-result.js +12 -1
- package/dist/cjs/query-builder/join-builder.d.ts +9 -8
- package/dist/cjs/query-builder/join-builder.js +10 -9
- package/dist/cjs/query-builder/on-conflict-builder.d.ts +25 -24
- package/dist/cjs/query-builder/on-conflict-builder.js +18 -17
- package/dist/cjs/query-builder/select-query-builder.d.ts +82 -51
- package/dist/cjs/query-builder/select-query-builder.js +39 -37
- package/dist/cjs/query-builder/update-query-builder.d.ts +20 -20
- package/dist/cjs/query-builder/update-query-builder.js +19 -16
- package/dist/cjs/query-builder/where-interface.d.ts +12 -11
- package/dist/cjs/query-compiler/compiled-query.d.ts +1 -1
- package/dist/cjs/query-compiler/default-query-compiler.d.ts +5 -3
- package/dist/cjs/query-compiler/default-query-compiler.js +37 -33
- package/dist/cjs/query-executor/query-executor-base.js +16 -1
- package/dist/cjs/raw-builder/raw-builder.d.ts +49 -13
- package/dist/cjs/raw-builder/raw-builder.js +24 -14
- package/dist/cjs/raw-builder/sql.d.ts +4 -4
- package/dist/cjs/schema/alter-column-builder.d.ts +28 -0
- package/dist/cjs/schema/alter-column-builder.js +55 -0
- package/dist/cjs/schema/alter-table-builder.d.ts +39 -341
- package/dist/cjs/schema/alter-table-builder.js +65 -280
- package/dist/cjs/schema/column-definition-builder.d.ts +43 -155
- package/dist/cjs/schema/column-definition-builder.js +189 -0
- package/dist/cjs/schema/create-index-builder.d.ts +2 -2
- package/dist/cjs/schema/create-table-builder.d.ts +38 -5
- package/dist/cjs/schema/create-table-builder.js +36 -1
- package/dist/cjs/schema/create-view-builder.d.ts +3 -2
- package/dist/cjs/schema/schema.d.ts +2 -2
- package/dist/cjs/schema/schema.js +6 -5
- package/dist/cjs/util/compilable.d.ts +2 -2
- package/dist/cjs/util/explainable.d.ts +2 -2
- package/dist/cjs/util/infer-result.d.ts +46 -0
- package/dist/cjs/util/infer-result.js +2 -0
- package/dist/cjs/util/log-once.d.ts +5 -0
- package/dist/cjs/util/log-once.js +16 -0
- package/dist/cjs/util/object-utils.d.ts +1 -0
- package/dist/cjs/util/object-utils.js +5 -1
- package/dist/cjs/util/type-utils.d.ts +3 -17
- package/dist/esm/dialect/database-introspector.d.ts +4 -0
- package/dist/esm/dialect/mysql/mysql-driver.js +6 -3
- package/dist/esm/dialect/postgres/postgres-adapter.js +1 -1
- package/dist/esm/dialect/postgres/postgres-driver.js +7 -2
- package/dist/esm/dialect/postgres/postgres-introspector.js +8 -0
- package/dist/esm/dialect/sqlite/sqlite-driver.js +4 -3
- package/dist/esm/dialect/sqlite/sqlite-introspector.js +1 -0
- package/dist/esm/driver/database-connection.d.ts +6 -2
- package/dist/esm/dynamic/dynamic-reference-builder.d.ts +2 -3
- package/dist/esm/dynamic/dynamic-reference-builder.js +2 -2
- package/dist/esm/expression/expression.d.ts +100 -0
- package/dist/esm/expression/expression.js +12 -0
- package/dist/esm/index.d.ts +10 -6
- package/dist/esm/index.js +6 -2
- package/dist/esm/migration/file-migration-provider.js +5 -3
- package/dist/esm/operation-node/aggregate-function-node.d.ts +7 -4
- package/dist/esm/operation-node/aggregate-function-node.js +17 -0
- package/dist/esm/operation-node/alias-node.d.ts +3 -11
- package/dist/esm/operation-node/alter-column-node.d.ts +1 -2
- package/dist/esm/operation-node/alter-table-node.d.ts +5 -7
- package/dist/esm/operation-node/alter-table-node.js +9 -1
- package/dist/esm/operation-node/and-node.d.ts +3 -4
- package/dist/esm/operation-node/binary-operation-node.d.ts +14 -0
- package/dist/esm/operation-node/binary-operation-node.js +18 -0
- package/dist/esm/operation-node/check-constraint-node.d.ts +2 -3
- package/dist/esm/operation-node/column-definition-node.d.ts +6 -5
- package/dist/esm/operation-node/column-definition-node.js +16 -0
- package/dist/esm/operation-node/column-update-node.d.ts +2 -3
- package/dist/esm/operation-node/common-table-expression-node.d.ts +2 -4
- package/dist/esm/operation-node/create-index-node.d.ts +1 -3
- package/dist/esm/operation-node/create-table-node.d.ts +4 -5
- package/dist/esm/operation-node/create-type-node.d.ts +1 -1
- package/dist/esm/operation-node/create-type-node.js +1 -2
- package/dist/esm/operation-node/default-value-node.d.ts +2 -4
- package/dist/esm/operation-node/delete-query-node.d.ts +1 -2
- package/dist/esm/operation-node/drop-type-node.d.ts +1 -1
- package/dist/esm/operation-node/drop-type-node.js +1 -2
- package/dist/esm/operation-node/explain-node.d.ts +2 -4
- package/dist/esm/operation-node/explain-node.js +1 -1
- package/dist/esm/operation-node/from-node.d.ts +3 -4
- package/dist/esm/operation-node/generated-node.d.ts +2 -3
- package/dist/esm/operation-node/group-by-item-node.d.ts +2 -3
- package/dist/esm/operation-node/having-node.d.ts +3 -4
- package/dist/esm/operation-node/having-node.js +4 -4
- package/dist/esm/operation-node/insert-query-node.d.ts +1 -5
- package/dist/esm/operation-node/join-node.d.ts +5 -9
- package/dist/esm/operation-node/join-node.js +6 -6
- package/dist/esm/operation-node/on-conflict-node.d.ts +5 -7
- package/dist/esm/operation-node/on-conflict-node.js +12 -12
- package/dist/esm/operation-node/on-node.d.ts +3 -4
- package/dist/esm/operation-node/on-node.js +4 -4
- package/dist/esm/operation-node/operation-node-transformer.d.ts +4 -2
- package/dist/esm/operation-node/operation-node-transformer.js +22 -15
- package/dist/esm/operation-node/operation-node-visitor.d.ts +4 -2
- package/dist/esm/operation-node/operation-node-visitor.js +2 -1
- package/dist/esm/operation-node/operation-node.d.ts +1 -1
- package/dist/esm/operation-node/operator-node.d.ts +5 -3
- package/dist/esm/operation-node/operator-node.js +2 -4
- package/dist/esm/operation-node/or-node.d.ts +3 -4
- package/dist/esm/operation-node/order-by-item-node.d.ts +3 -5
- package/dist/esm/operation-node/parens-node.d.ts +2 -3
- package/dist/esm/operation-node/partition-by-item-node.d.ts +3 -4
- package/dist/esm/operation-node/query-node.d.ts +2 -3
- package/dist/esm/operation-node/query-node.js +6 -6
- package/dist/esm/operation-node/select-modifier-node.d.ts +2 -3
- package/dist/esm/operation-node/select-modifier-node.js +1 -1
- package/dist/esm/operation-node/select-query-node.d.ts +5 -6
- package/dist/esm/operation-node/select-query-node.js +10 -10
- package/dist/esm/operation-node/selection-node.d.ts +2 -3
- package/dist/esm/operation-node/set-operation-node.d.ts +2 -5
- package/dist/esm/operation-node/simple-reference-expression-node.d.ts +3 -0
- package/dist/esm/operation-node/simple-reference-expression-node.js +2 -0
- package/dist/esm/operation-node/unary-operation-node.d.ts +13 -0
- package/dist/esm/operation-node/unary-operation-node.js +17 -0
- package/dist/esm/operation-node/update-query-node.d.ts +3 -4
- package/dist/esm/operation-node/value-list-node.d.ts +2 -9
- package/dist/esm/operation-node/where-node.d.ts +3 -4
- package/dist/esm/operation-node/where-node.js +4 -4
- package/dist/esm/parser/binary-operation-parser.d.ts +20 -0
- package/dist/esm/parser/binary-operation-parser.js +92 -0
- package/dist/esm/parser/coalesce-parser.d.ts +4 -0
- package/dist/esm/parser/coalesce-parser.js +8 -0
- package/dist/esm/parser/data-type-parser.d.ts +5 -5
- package/dist/esm/parser/default-value-parser.d.ts +4 -5
- package/dist/esm/parser/default-value-parser.js +2 -2
- package/dist/esm/parser/expression-parser.d.ts +10 -0
- package/dist/esm/parser/{complex-expression-parser.js → expression-parser.js} +6 -5
- package/dist/esm/parser/identifier-parser.d.ts +2 -0
- package/dist/esm/parser/identifier-parser.js +20 -0
- package/dist/esm/parser/insert-values-parser.d.ts +1 -1
- package/dist/esm/parser/insert-values-parser.js +2 -2
- package/dist/esm/parser/join-parser.js +2 -2
- package/dist/esm/parser/order-by-parser.d.ts +2 -2
- package/dist/esm/parser/reference-parser.d.ts +14 -14
- package/dist/esm/parser/reference-parser.js +10 -8
- package/dist/esm/parser/select-parser.d.ts +6 -7
- package/dist/esm/parser/select-parser.js +2 -2
- package/dist/esm/parser/set-operation-parser.d.ts +2 -4
- package/dist/esm/parser/table-parser.d.ts +11 -12
- package/dist/esm/parser/table-parser.js +2 -2
- package/dist/esm/parser/unary-operation-parser.d.ts +5 -0
- package/dist/esm/parser/unary-operation-parser.js +13 -0
- package/dist/esm/parser/update-set-parser.d.ts +1 -1
- package/dist/esm/parser/value-parser.d.ts +5 -9
- package/dist/esm/parser/value-parser.js +4 -4
- package/dist/esm/parser/with-parser.d.ts +3 -4
- package/dist/esm/plugin/camel-case/camel-case-plugin.js +2 -2
- package/dist/esm/query-builder/aggregate-function-builder.d.ts +245 -14
- package/dist/esm/query-builder/aggregate-function-builder.js +164 -12
- package/dist/esm/query-builder/delete-query-builder.d.ts +20 -20
- package/dist/esm/query-builder/delete-query-builder.js +19 -16
- package/dist/esm/query-builder/function-module.d.ts +123 -22
- package/dist/esm/query-builder/function-module.js +92 -49
- package/dist/esm/query-builder/having-interface.d.ts +9 -8
- package/dist/esm/query-builder/insert-query-builder.d.ts +7 -6
- package/dist/esm/query-builder/insert-query-builder.js +11 -9
- package/dist/esm/query-builder/insert-result.d.ts +8 -1
- package/dist/esm/query-builder/insert-result.js +12 -1
- package/dist/esm/query-builder/join-builder.d.ts +9 -8
- package/dist/esm/query-builder/join-builder.js +10 -9
- package/dist/esm/query-builder/on-conflict-builder.d.ts +25 -24
- package/dist/esm/query-builder/on-conflict-builder.js +18 -17
- package/dist/esm/query-builder/select-query-builder.d.ts +82 -51
- package/dist/esm/query-builder/select-query-builder.js +38 -36
- package/dist/esm/query-builder/update-query-builder.d.ts +20 -20
- package/dist/esm/query-builder/update-query-builder.js +19 -16
- package/dist/esm/query-builder/where-interface.d.ts +12 -11
- package/dist/esm/query-compiler/compiled-query.d.ts +1 -1
- package/dist/esm/query-compiler/default-query-compiler.d.ts +5 -3
- package/dist/esm/query-compiler/default-query-compiler.js +38 -34
- package/dist/esm/query-executor/query-executor-base.js +16 -1
- package/dist/esm/raw-builder/raw-builder.d.ts +49 -13
- package/dist/esm/raw-builder/raw-builder.js +23 -14
- package/dist/esm/raw-builder/sql.d.ts +4 -4
- package/dist/esm/schema/alter-column-builder.d.ts +28 -0
- package/dist/esm/schema/alter-column-builder.js +51 -0
- package/dist/esm/schema/alter-table-builder.d.ts +39 -341
- package/dist/esm/schema/alter-table-builder.js +61 -274
- package/dist/esm/schema/column-definition-builder.d.ts +43 -155
- package/dist/esm/schema/column-definition-builder.js +189 -0
- package/dist/esm/schema/create-index-builder.d.ts +2 -2
- package/dist/esm/schema/create-table-builder.d.ts +38 -5
- package/dist/esm/schema/create-table-builder.js +36 -1
- package/dist/esm/schema/create-view-builder.d.ts +3 -2
- package/dist/esm/schema/schema.d.ts +2 -2
- package/dist/esm/schema/schema.js +6 -5
- package/dist/esm/util/compilable.d.ts +2 -2
- package/dist/esm/util/explainable.d.ts +2 -2
- package/dist/esm/util/infer-result.d.ts +46 -0
- package/dist/esm/util/infer-result.js +2 -0
- package/dist/esm/util/log-once.d.ts +5 -0
- package/dist/esm/util/log-once.js +13 -0
- package/dist/esm/util/object-utils.d.ts +1 -0
- package/dist/esm/util/object-utils.js +3 -0
- package/dist/esm/util/type-utils.d.ts +3 -17
- package/package.json +1 -1
- package/dist/cjs/operation-node/filter-node.d.ts +0 -18
- package/dist/cjs/operation-node/filter-node.js +0 -20
- package/dist/cjs/operation-node/operation-node-utils.d.ts +0 -18
- package/dist/cjs/parser/complex-expression-parser.d.ts +0 -12
- package/dist/cjs/parser/filter-parser.d.ts +0 -24
- package/dist/cjs/parser/filter-parser.js +0 -109
- package/dist/esm/operation-node/filter-node.d.ts +0 -18
- package/dist/esm/operation-node/filter-node.js +0 -18
- package/dist/esm/operation-node/operation-node-utils.d.ts +0 -18
- package/dist/esm/operation-node/operation-node-utils.js +0 -2
- package/dist/esm/parser/complex-expression-parser.d.ts +0 -12
- package/dist/esm/parser/filter-parser.d.ts +0 -24
- package/dist/esm/parser/filter-parser.js +0 -100
package/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
Would love to contribute to Kysely?
|
|
2
|
+
|
|
3
|
+
Awesome! We are not very organized yet. We don't have a plan or a roadmap.
|
|
4
|
+
|
|
5
|
+
Probably the best way to get going is to watch the issue list.
|
|
6
|
+
An issue with a `greenlit` label, has been acknowledged by the team and is ready for development.
|
|
7
|
+
Find such an issue you'd like to tackle and ask to be assigned to it in the comment section.
|
|
8
|
+
Feel free to open an issue if you found a bug or a missing feature you'd like to work on,
|
|
9
|
+
and there aren't any issues mentioning it.
|
|
10
|
+
|
|
11
|
+
If you start working on something larger, it's a good idea to create a draft (WIP) PR at
|
|
12
|
+
an early stage so that we can guide you to the right direction.
|
|
13
|
+
|
|
14
|
+
There are quite a few guidelines to keep in mind:
|
|
15
|
+
|
|
16
|
+
* Kysely should have zero dependencies.
|
|
17
|
+
|
|
18
|
+
* Kysely should work in all javascript environments (node.js, deno & modern browsers),
|
|
19
|
+
even though the main focus is node.js.
|
|
20
|
+
|
|
21
|
+
* Everything is immutable.
|
|
22
|
+
|
|
23
|
+
* The API should be as close to writing raw SQL as possible while still providing
|
|
24
|
+
type safety.
|
|
25
|
+
|
|
26
|
+
* Everything outside of dialect implementations is dialect-agnostic.
|
|
27
|
+
|
|
28
|
+
* Everything is tested.
|
|
29
|
+
|
|
30
|
+
* Functionality - No mocks. Everything is tested against real database instances.
|
|
31
|
+
No partial testing. If a sql "thing" is supported by some databases, test it
|
|
32
|
+
against all of them.
|
|
33
|
+
|
|
34
|
+
* Types - We're a type-safe package, you get the idea.
|
|
35
|
+
|
|
36
|
+
* Everything consumer-facing should be documented.
|
|
37
|
+
|
|
38
|
+
* Everything is type-safe. Things that cannot be implemented in a way that is safe
|
|
39
|
+
for all cases, are best left for consumers to implement.
|
|
40
|
+
|
|
41
|
+
* Most features should have escape hatches.
|
|
42
|
+
|
|
43
|
+
# Getting started
|
|
44
|
+
|
|
45
|
+
1. fork kysely.
|
|
46
|
+
|
|
47
|
+
2. clone your fork.
|
|
48
|
+
|
|
49
|
+
3. install node.js (preferable latest LTS).
|
|
50
|
+
|
|
51
|
+
4. run `npm i` in your terminal to install dev dependencies.
|
|
52
|
+
|
|
53
|
+
5. create a branch.
|
|
54
|
+
|
|
55
|
+
6. create a draft pull request. link the relevant issue by refering to it in the
|
|
56
|
+
PR's description. E.g. `closes #123` will link the PR to issue/pull request #123.
|
|
57
|
+
|
|
58
|
+
7. implement your changes.
|
|
59
|
+
|
|
60
|
+
# Testing
|
|
61
|
+
|
|
62
|
+
1. write functionality tests in `test/node`.
|
|
63
|
+
|
|
64
|
+
2. write typings tests in `test/typings/test-d`
|
|
65
|
+
|
|
66
|
+
3. install docker.
|
|
67
|
+
|
|
68
|
+
4. run `docker-compose up` in your terminal to spin up database instances.
|
|
69
|
+
|
|
70
|
+
5. run `npm test` in your terminal to run tests.
|
package/README.md
CHANGED
|
@@ -24,6 +24,9 @@ Of course there are cases where things cannot be typed at compile time, and Kyse
|
|
|
24
24
|
hatches for these situations. See the [sql template tag](https://koskimas.github.io/kysely/interfaces/Sql.html)
|
|
25
25
|
and the [DynamicModule](https://koskimas.github.io/kysely/classes/DynamicModule.html#ref) for more info.
|
|
26
26
|
|
|
27
|
+
All API documentation is written in the typing files and you can simply `cmd-click` on the module, class
|
|
28
|
+
or method you're using to see it. The same documentation is also hosted [here](https://github.com/koskimas/kysely).
|
|
29
|
+
|
|
27
30
|
If you start using Kysely and can't find something you'd want to use, please open an issue or join our
|
|
28
31
|
[discord server](https://discord.gg/xyBJ3GwvAm).
|
|
29
32
|
|
|
@@ -41,6 +44,7 @@ You can find a more thorough introduction [here](https://www.jakso.me/blog/kysel
|
|
|
41
44
|
- [Update queries](#update-queries)
|
|
42
45
|
- [Insert queries](#insert-queries)
|
|
43
46
|
- [Delete queries](#delete-queries)
|
|
47
|
+
- [Recipes](#recipes)
|
|
44
48
|
- [Migrations](#migrations)
|
|
45
49
|
- [PostgreSQL migration example](#postgresql-migration-example)
|
|
46
50
|
- [MySQL migration example](#mysql-migration-example)
|
|
@@ -66,10 +70,13 @@ npm install kysely better-sqlite3
|
|
|
66
70
|
More dialects will be added soon. Kysely also has a simple interface
|
|
67
71
|
for [3rd party dialects](https://koskimas.github.io/kysely/interfaces/Dialect.html).
|
|
68
72
|
|
|
69
|
-
### 3rd party dialects
|
|
73
|
+
### 3rd party dialects
|
|
70
74
|
|
|
71
75
|
- [AWS Data API](https://github.com/serverless-stack/kysely-data-api)
|
|
72
76
|
- [PlanetScale Serverless Driver](https://github.com/depot/kysely-planetscale)
|
|
77
|
+
- [SingleStore Data API](https://github.com/igalklebanov/kysely-singlestore)
|
|
78
|
+
- [D1](https://github.com/aidenwallis/kysely-d1)
|
|
79
|
+
- [SurrealDB](https://github.com/igalklebanov/kysely-surrealdb)
|
|
73
80
|
|
|
74
81
|
# Minimal example
|
|
75
82
|
|
|
@@ -246,6 +253,17 @@ documentation.
|
|
|
246
253
|
See the [deleteFrom method](https://koskimas.github.io/kysely/classes/Kysely.html#deleteFrom)
|
|
247
254
|
documentation.
|
|
248
255
|
|
|
256
|
+
# Recipes
|
|
257
|
+
|
|
258
|
+
The [recipes](https://github.com/koskimas/kysely/tree/master/recipes) folder contains a bunch of small tutorials
|
|
259
|
+
or "recipes" for common use cases.
|
|
260
|
+
|
|
261
|
+
* [Conditional selects](https://github.com/koskimas/kysely/tree/master/recipes/conditional-selects.md)
|
|
262
|
+
* [Deduplicate joins](https://github.com/koskimas/kysely/tree/master/recipes/deduplicate-joins.md)
|
|
263
|
+
* [Extending kysely](https://github.com/koskimas/kysely/tree/master/recipes/extending-kysely.md)
|
|
264
|
+
* [Raw SQL](https://github.com/koskimas/kysely/tree/master/recipes/raw-sql.md)
|
|
265
|
+
* [Schemas](https://github.com/koskimas/kysely/tree/master/recipes/schemas.md)
|
|
266
|
+
|
|
249
267
|
# Migrations
|
|
250
268
|
|
|
251
269
|
Migration files should look like this:
|
|
@@ -285,7 +303,7 @@ when you instantiate one.
|
|
|
285
303
|
### PostgreSQL migration example
|
|
286
304
|
|
|
287
305
|
```ts
|
|
288
|
-
import { Kysely } from 'kysely'
|
|
306
|
+
import { Kysely, sql } from 'kysely'
|
|
289
307
|
|
|
290
308
|
export async function up(db: Kysely<any>): Promise<void> {
|
|
291
309
|
await db.schema
|
|
@@ -294,6 +312,7 @@ export async function up(db: Kysely<any>): Promise<void> {
|
|
|
294
312
|
.addColumn('first_name', 'varchar', (col) => col.notNull())
|
|
295
313
|
.addColumn('last_name', 'varchar')
|
|
296
314
|
.addColumn('gender', 'varchar(50)', (col) => col.notNull())
|
|
315
|
+
.addColumn('created_at', 'timestamp', (col) => col.defaultTo(sql`now()`).notNull())
|
|
297
316
|
.execute()
|
|
298
317
|
|
|
299
318
|
await db.schema
|
|
@@ -544,3 +563,7 @@ in knex. Bringing the type system and the changes to knex would mean very signif
|
|
|
544
563
|
that aren't possible at this point of the project. Knex was also originally written for javascript and
|
|
545
564
|
the typescript typings were added afterwards. That always leads to compromises in the types. Designing
|
|
546
565
|
a library for typescript from the ground up produces much better and simpler types.
|
|
566
|
+
|
|
567
|
+
# How to contribute to Kysely
|
|
568
|
+
|
|
569
|
+
See [CONTRIBUTING.md](./CONTRIBUTING.md).
|
|
@@ -49,6 +49,10 @@ export interface ColumnMetadata {
|
|
|
49
49
|
* on PostgreSQL, `INTEGER` on SQLite and `int` on MySQL.
|
|
50
50
|
*/
|
|
51
51
|
readonly dataType: string;
|
|
52
|
+
/**
|
|
53
|
+
* The schema this column's data type was created in.
|
|
54
|
+
*/
|
|
55
|
+
readonly dataTypeSchema?: string;
|
|
52
56
|
readonly isAutoIncrementing: boolean;
|
|
53
57
|
readonly isNullable: boolean;
|
|
54
58
|
readonly hasDefaultValue: boolean;
|
|
@@ -87,15 +87,18 @@ class MysqlConnection {
|
|
|
87
87
|
const result = await this.#executeQuery(compiledQuery);
|
|
88
88
|
if (isOkPacket(result)) {
|
|
89
89
|
const { insertId, affectedRows } = result;
|
|
90
|
+
const numAffectedRows = affectedRows !== undefined && affectedRows !== null
|
|
91
|
+
? BigInt(affectedRows)
|
|
92
|
+
: undefined;
|
|
90
93
|
return {
|
|
91
94
|
insertId: insertId !== undefined &&
|
|
92
95
|
insertId !== null &&
|
|
93
96
|
insertId.toString() !== '0'
|
|
94
97
|
? BigInt(insertId)
|
|
95
98
|
: undefined,
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
+
// TODO: remove.
|
|
100
|
+
numUpdatedOrDeletedRows: numAffectedRows,
|
|
101
|
+
numAffectedRows,
|
|
99
102
|
rows: [],
|
|
100
103
|
};
|
|
101
104
|
}
|
|
@@ -4,7 +4,7 @@ exports.PostgresAdapter = void 0;
|
|
|
4
4
|
const sql_js_1 = require("../../raw-builder/sql.js");
|
|
5
5
|
const dialect_adapter_base_js_1 = require("../dialect-adapter-base.js");
|
|
6
6
|
// Random id for our transaction lock.
|
|
7
|
-
const LOCK_ID =
|
|
7
|
+
const LOCK_ID = BigInt('3853314791062309107');
|
|
8
8
|
class PostgresAdapter extends dialect_adapter_base_js_1.DialectAdapterBase {
|
|
9
9
|
get supportsTransactionalDdl() {
|
|
10
10
|
return true;
|
|
@@ -72,9 +72,14 @@ class PostgresConnection {
|
|
|
72
72
|
const result = await this.#client.query(compiledQuery.sql, [
|
|
73
73
|
...compiledQuery.parameters,
|
|
74
74
|
]);
|
|
75
|
-
if (result.command === '
|
|
75
|
+
if (result.command === 'INSERT' ||
|
|
76
|
+
result.command === 'UPDATE' ||
|
|
77
|
+
result.command === 'DELETE') {
|
|
78
|
+
const numAffectedRows = BigInt(result.rowCount);
|
|
76
79
|
return {
|
|
77
|
-
|
|
80
|
+
// TODO: remove.
|
|
81
|
+
numUpdatedOrDeletedRows: numAffectedRows,
|
|
82
|
+
numAffectedRows,
|
|
78
83
|
rows: result.rows ?? [],
|
|
79
84
|
};
|
|
80
85
|
}
|
|
@@ -19,10 +19,16 @@ class PostgresIntrospector {
|
|
|
19
19
|
}
|
|
20
20
|
async getTables(options = { withInternalKyselyTables: false }) {
|
|
21
21
|
let query = this.#db
|
|
22
|
+
// column
|
|
22
23
|
.selectFrom('pg_catalog.pg_attribute as a')
|
|
24
|
+
// table
|
|
23
25
|
.innerJoin('pg_catalog.pg_class as c', 'a.attrelid', 'c.oid')
|
|
26
|
+
// table schema
|
|
24
27
|
.innerJoin('pg_catalog.pg_namespace as ns', 'c.relnamespace', 'ns.oid')
|
|
28
|
+
// column data type
|
|
25
29
|
.innerJoin('pg_catalog.pg_type as typ', 'a.atttypid', 'typ.oid')
|
|
30
|
+
// column data type schema
|
|
31
|
+
.innerJoin('pg_catalog.pg_namespace as dtns', 'typ.typnamespace', 'dtns.oid')
|
|
26
32
|
.select([
|
|
27
33
|
'a.attname as column',
|
|
28
34
|
'a.attnotnull as not_null',
|
|
@@ -30,6 +36,7 @@ class PostgresIntrospector {
|
|
|
30
36
|
'c.relname as table',
|
|
31
37
|
'ns.nspname as schema',
|
|
32
38
|
'typ.typname as type',
|
|
39
|
+
'dtns.nspname as type_schema',
|
|
33
40
|
// Detect if the column is auto incrementing by finding the sequence
|
|
34
41
|
// that is created for `serial` and `bigserial` columns.
|
|
35
42
|
this.#db
|
|
@@ -79,6 +86,7 @@ class PostgresIntrospector {
|
|
|
79
86
|
table.columns.push((0, object_utils_js_1.freeze)({
|
|
80
87
|
name: it.column,
|
|
81
88
|
dataType: it.type,
|
|
89
|
+
dataTypeSchema: it.type_schema,
|
|
82
90
|
isNullable: !it.not_null,
|
|
83
91
|
isAutoIncrementing: !!it.auto_incrementing,
|
|
84
92
|
hasDefaultValue: it.has_default,
|
|
@@ -58,10 +58,11 @@ class SqliteConnection {
|
|
|
58
58
|
}
|
|
59
59
|
else {
|
|
60
60
|
const { changes, lastInsertRowid } = stmt.run(parameters);
|
|
61
|
+
const numAffectedRows = changes !== undefined && changes !== null ? BigInt(changes) : undefined;
|
|
61
62
|
return Promise.resolve({
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
// TODO: remove.
|
|
64
|
+
numUpdatedOrDeletedRows: numAffectedRows,
|
|
65
|
+
numAffectedRows,
|
|
65
66
|
insertId: lastInsertRowid !== undefined && lastInsertRowid !== null
|
|
66
67
|
? BigInt(lastInsertRowid)
|
|
67
68
|
: undefined,
|
|
@@ -10,10 +10,14 @@ export interface DatabaseConnection {
|
|
|
10
10
|
}
|
|
11
11
|
export interface QueryResult<O> {
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
14
|
-
* the number of rows the query updated/deleted.
|
|
13
|
+
* @deprecated use {@link QueryResult.numAffectedRows} instead.
|
|
15
14
|
*/
|
|
16
15
|
readonly numUpdatedOrDeletedRows?: bigint;
|
|
16
|
+
/**
|
|
17
|
+
* This is defined for insert, update and delete queries and contains
|
|
18
|
+
* the number of rows the query inserted/updated/deleted.
|
|
19
|
+
*/
|
|
20
|
+
readonly numAffectedRows?: bigint;
|
|
17
21
|
/**
|
|
18
22
|
* This is defined for insert queries on dialects that return
|
|
19
23
|
* the auto incrementing primary key from an insert.
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { ColumnNode } from '../operation-node/column-node.js';
|
|
2
1
|
import { OperationNodeSource } from '../operation-node/operation-node-source.js';
|
|
3
|
-
import {
|
|
2
|
+
import { SimpleReferenceExpressionNode } from '../operation-node/simple-reference-expression-node.js';
|
|
4
3
|
export declare class DynamicReferenceBuilder<R extends string = never> implements OperationNodeSource {
|
|
5
4
|
#private;
|
|
6
5
|
get dynamicReference(): string;
|
|
@@ -14,6 +13,6 @@ export declare class DynamicReferenceBuilder<R extends string = never> implement
|
|
|
14
13
|
*/
|
|
15
14
|
protected get refType(): R;
|
|
16
15
|
constructor(reference: string);
|
|
17
|
-
toOperationNode():
|
|
16
|
+
toOperationNode(): SimpleReferenceExpressionNode;
|
|
18
17
|
}
|
|
19
18
|
export declare function isDynamicReferenceBuilder(obj: unknown): obj is DynamicReferenceBuilder<any>;
|
|
@@ -24,7 +24,7 @@ class DynamicReferenceBuilder {
|
|
|
24
24
|
this.#dynamicReference = reference;
|
|
25
25
|
}
|
|
26
26
|
toOperationNode() {
|
|
27
|
-
return (0, reference_parser_js_1.
|
|
27
|
+
return (0, reference_parser_js_1.parseSimpleReferenceExpression)(this.#dynamicReference);
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
exports.DynamicReferenceBuilder = DynamicReferenceBuilder;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { AliasNode } from '../operation-node/alias-node.js';
|
|
2
|
+
import { OperationNodeSource } from '../operation-node/operation-node-source.js';
|
|
3
|
+
import { OperationNode } from '../operation-node/operation-node.js';
|
|
4
|
+
/**
|
|
5
|
+
* `Expression` represents an arbitrary SQL expression with a type.
|
|
6
|
+
*
|
|
7
|
+
* Most Kysely methods accept instances of `Expression` and most classes like `SelectQueryBuilder`
|
|
8
|
+
* and the return value of the {@link sql} template tag implement it.
|
|
9
|
+
*
|
|
10
|
+
* ```ts
|
|
11
|
+
* const exp1: Expression<string> = sql<string>`CONCAT('hello', ' ', 'world')`
|
|
12
|
+
* const exp2: Expression<{ first_name: string }> = db.selectFrom('person').select('first_name')
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* You can implement the `Expression` interface to create your own type-safe utilities for Kysely.
|
|
16
|
+
*/
|
|
17
|
+
export interface Expression<T> extends OperationNodeSource {
|
|
18
|
+
/**
|
|
19
|
+
* All expressions need to have this getter for complicated type-related reasons.
|
|
20
|
+
* Simply add this getter for your expression and always return `undefined` from it:
|
|
21
|
+
*
|
|
22
|
+
* ```ts
|
|
23
|
+
* class SomeExpression<T> implements Expression<T> {
|
|
24
|
+
* get expressionType(): T | undefined {
|
|
25
|
+
* return undefined
|
|
26
|
+
* }
|
|
27
|
+
* }
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* The getter is needed to make the expression assignable to another expression only
|
|
31
|
+
* if the types `T` are assignable. Without this property (or some other property
|
|
32
|
+
* that references `T`), you could assing `Expression<string>` to `Expression<number>`.
|
|
33
|
+
*/
|
|
34
|
+
get expressionType(): T | undefined;
|
|
35
|
+
/**
|
|
36
|
+
* Creates the OperationNode that describes how to compile this expression into SQL.
|
|
37
|
+
*
|
|
38
|
+
* If you are creating a custom expression, it's often easiest to use the {@link sql}
|
|
39
|
+
* template tag to build the node:
|
|
40
|
+
*
|
|
41
|
+
* ```ts
|
|
42
|
+
* class SomeExpression<T> implements Expression<T> {
|
|
43
|
+
* toOperationNode(): OperationNode {
|
|
44
|
+
* return sql`some sql here`.toOperationNode()
|
|
45
|
+
* }
|
|
46
|
+
* }
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
toOperationNode(): OperationNode;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Just like `Expression<T>` but also holds an alias type `A`.
|
|
53
|
+
*
|
|
54
|
+
* `AliasedExpression<T, A>` can be used in places where, in addition to the value type `T`, you
|
|
55
|
+
* also need a name `A` for that value. For example anything you can pass into the `select` method
|
|
56
|
+
* needs to implement an `AliasedExpression<T, A>`. `A` becomes the name of the selected expression
|
|
57
|
+
* in the result and `T` becomes its type.
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
*
|
|
61
|
+
* ```ts
|
|
62
|
+
* class SomeAliasedExpression<T, A extends string> implements AliasedExpression<T, A> {
|
|
63
|
+
* #expression: Expression<T>
|
|
64
|
+
* #alias: A
|
|
65
|
+
*
|
|
66
|
+
* constructor(expression: Expression<T>, alias: A) {
|
|
67
|
+
* this.#expression = expression
|
|
68
|
+
* this.#alias = alias
|
|
69
|
+
* }
|
|
70
|
+
*
|
|
71
|
+
* get expression(): Expression<T> {
|
|
72
|
+
* return this.#expression
|
|
73
|
+
* }
|
|
74
|
+
*
|
|
75
|
+
* get alias(): A {
|
|
76
|
+
* return this.#alias
|
|
77
|
+
* }
|
|
78
|
+
*
|
|
79
|
+
* toOperationNode(): AliasNode {
|
|
80
|
+
* return AliasNode.create(this.#expression.toOperationNode(), IdentifierNode.create(this.#alias))
|
|
81
|
+
* }
|
|
82
|
+
* }
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
85
|
+
export interface AliasedExpression<T, A extends string> extends OperationNodeSource {
|
|
86
|
+
/**
|
|
87
|
+
* Returns the aliased expression.
|
|
88
|
+
*/
|
|
89
|
+
get expression(): Expression<T>;
|
|
90
|
+
/**
|
|
91
|
+
* Returns the alias.
|
|
92
|
+
*/
|
|
93
|
+
get alias(): A;
|
|
94
|
+
/**
|
|
95
|
+
* Creates the OperationNode that describes how to compile this expression into SQL.
|
|
96
|
+
*/
|
|
97
|
+
toOperationNode(): AliasNode;
|
|
98
|
+
}
|
|
99
|
+
export declare function isExpression(obj: unknown): obj is Expression<any>;
|
|
100
|
+
export declare function isAliasedExpression(obj: unknown): obj is AliasedExpression<any, any>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isAliasedExpression = exports.isExpression = void 0;
|
|
4
|
+
const operation_node_source_js_1 = require("../operation-node/operation-node-source.js");
|
|
5
|
+
const object_utils_js_1 = require("../util/object-utils.js");
|
|
6
|
+
function isExpression(obj) {
|
|
7
|
+
return (0, object_utils_js_1.isObject)(obj) && 'expressionType' in obj && (0, operation_node_source_js_1.isOperationNodeSource)(obj);
|
|
8
|
+
}
|
|
9
|
+
exports.isExpression = isExpression;
|
|
10
|
+
function isAliasedExpression(obj) {
|
|
11
|
+
return ((0, object_utils_js_1.isObject)(obj) &&
|
|
12
|
+
'expression' in obj &&
|
|
13
|
+
(0, object_utils_js_1.isString)(obj.alias) &&
|
|
14
|
+
(0, operation_node_source_js_1.isOperationNodeSource)(obj));
|
|
15
|
+
}
|
|
16
|
+
exports.isAliasedExpression = isAliasedExpression;
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export * from './kysely.js';
|
|
2
2
|
export * from './query-creator.js';
|
|
3
|
+
export * from './expression/expression.js';
|
|
3
4
|
export * from './query-builder/where-interface.js';
|
|
4
5
|
export * from './query-builder/returning-interface.js';
|
|
5
6
|
export * from './query-builder/having-interface.js';
|
|
@@ -38,6 +39,7 @@ export * from './schema/foreign-key-constraint-builder.js';
|
|
|
38
39
|
export * from './schema/alter-table-builder.js';
|
|
39
40
|
export * from './schema/create-view-builder.js';
|
|
40
41
|
export * from './schema/drop-view-builder.js';
|
|
42
|
+
export * from './schema/alter-column-builder.js';
|
|
41
43
|
export * from './dynamic/dynamic.js';
|
|
42
44
|
export * from './driver/driver.js';
|
|
43
45
|
export * from './driver/database-connection.js';
|
|
@@ -103,7 +105,6 @@ export * from './operation-node/drop-schema-node.js';
|
|
|
103
105
|
export * from './operation-node/drop-table-node.js';
|
|
104
106
|
export * from './operation-node/drop-type-node.js';
|
|
105
107
|
export * from './operation-node/drop-view-node.js';
|
|
106
|
-
export * from './operation-node/filter-node.js';
|
|
107
108
|
export * from './operation-node/foreign-key-constraint-node.js';
|
|
108
109
|
export * from './operation-node/from-node.js';
|
|
109
110
|
export * from './operation-node/generated-node.js';
|
|
@@ -122,7 +123,6 @@ export * from './operation-node/on-duplicate-key-node.js';
|
|
|
122
123
|
export * from './operation-node/on-node.js';
|
|
123
124
|
export * from './operation-node/operation-node-source.js';
|
|
124
125
|
export * from './operation-node/operation-node-transformer.js';
|
|
125
|
-
export * from './operation-node/operation-node-utils.js';
|
|
126
126
|
export * from './operation-node/operation-node-visitor.js';
|
|
127
127
|
export * from './operation-node/operation-node.js';
|
|
128
128
|
export * from './operation-node/operator-node.js';
|
|
@@ -157,18 +157,22 @@ export * from './operation-node/over-node.js';
|
|
|
157
157
|
export * from './operation-node/partition-by-node.js';
|
|
158
158
|
export * from './operation-node/partition-by-item-node.js';
|
|
159
159
|
export * from './operation-node/set-operation-node.js';
|
|
160
|
+
export * from './operation-node/binary-operation-node.js';
|
|
161
|
+
export * from './operation-node/unary-operation-node.js';
|
|
160
162
|
export * from './util/column-type.js';
|
|
161
163
|
export * from './util/compilable.js';
|
|
162
164
|
export * from './util/explainable.js';
|
|
163
165
|
export * from './util/log.js';
|
|
164
|
-
export { AnyColumn,
|
|
166
|
+
export { AnyAliasedColumn, AnyAliasedColumnWithTable, AnyColumn, AnyColumnWithTable, AnySelectQueryBuilder, Equals, UnknownRow, } from './util/type-utils.js';
|
|
167
|
+
export * from './util/infer-result.js';
|
|
168
|
+
export { logOnce } from './util/log-once.js';
|
|
165
169
|
export { SelectExpression, SelectExpressionOrList, Selection, } from './parser/select-parser.js';
|
|
166
|
-
export { ReferenceExpression, ReferenceExpressionOrList, StringReference, } from './parser/reference-parser.js';
|
|
170
|
+
export { ReferenceExpression, ReferenceExpressionOrList, SimpleReferenceExpression, StringReference, ExtractTypeFromStringReference, ExtractTypeFromReferenceExpression, } from './parser/reference-parser.js';
|
|
167
171
|
export { ValueExpression, ValueExpressionOrList, } from './parser/value-parser.js';
|
|
168
|
-
export { FilterValueExpression, FilterValueExpressionOrList, ExistsExpression, FilterOperator, } from './parser/filter-parser.js';
|
|
169
172
|
export { TableExpression, TableExpressionOrList, } from './parser/table-parser.js';
|
|
170
173
|
export { JoinReferenceExpression, JoinCallbackExpression, } from './parser/join-parser.js';
|
|
171
174
|
export { InsertObject } from './parser/insert-values-parser.js';
|
|
172
175
|
export { MutationObject } from './parser/update-set-parser.js';
|
|
173
176
|
export { OrderByExpression, OrderByDirectionExpression, } from './parser/order-by-parser.js';
|
|
174
|
-
export {
|
|
177
|
+
export { ComparisonOperatorExpression, OperandValueExpression, OperandValueExpressionOrList, } from './parser/binary-operation-parser.js';
|
|
178
|
+
export { ExistsExpression } from './parser/unary-operation-parser.js';
|
package/dist/cjs/index.js
CHANGED
|
@@ -14,8 +14,10 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.logOnce = void 0;
|
|
17
18
|
__exportStar(require("./kysely.js"), exports);
|
|
18
19
|
__exportStar(require("./query-creator.js"), exports);
|
|
20
|
+
__exportStar(require("./expression/expression.js"), exports);
|
|
19
21
|
__exportStar(require("./query-builder/where-interface.js"), exports);
|
|
20
22
|
__exportStar(require("./query-builder/returning-interface.js"), exports);
|
|
21
23
|
__exportStar(require("./query-builder/having-interface.js"), exports);
|
|
@@ -54,6 +56,7 @@ __exportStar(require("./schema/foreign-key-constraint-builder.js"), exports);
|
|
|
54
56
|
__exportStar(require("./schema/alter-table-builder.js"), exports);
|
|
55
57
|
__exportStar(require("./schema/create-view-builder.js"), exports);
|
|
56
58
|
__exportStar(require("./schema/drop-view-builder.js"), exports);
|
|
59
|
+
__exportStar(require("./schema/alter-column-builder.js"), exports);
|
|
57
60
|
__exportStar(require("./dynamic/dynamic.js"), exports);
|
|
58
61
|
__exportStar(require("./driver/driver.js"), exports);
|
|
59
62
|
__exportStar(require("./driver/database-connection.js"), exports);
|
|
@@ -119,7 +122,6 @@ __exportStar(require("./operation-node/drop-schema-node.js"), exports);
|
|
|
119
122
|
__exportStar(require("./operation-node/drop-table-node.js"), exports);
|
|
120
123
|
__exportStar(require("./operation-node/drop-type-node.js"), exports);
|
|
121
124
|
__exportStar(require("./operation-node/drop-view-node.js"), exports);
|
|
122
|
-
__exportStar(require("./operation-node/filter-node.js"), exports);
|
|
123
125
|
__exportStar(require("./operation-node/foreign-key-constraint-node.js"), exports);
|
|
124
126
|
__exportStar(require("./operation-node/from-node.js"), exports);
|
|
125
127
|
__exportStar(require("./operation-node/generated-node.js"), exports);
|
|
@@ -138,7 +140,6 @@ __exportStar(require("./operation-node/on-duplicate-key-node.js"), exports);
|
|
|
138
140
|
__exportStar(require("./operation-node/on-node.js"), exports);
|
|
139
141
|
__exportStar(require("./operation-node/operation-node-source.js"), exports);
|
|
140
142
|
__exportStar(require("./operation-node/operation-node-transformer.js"), exports);
|
|
141
|
-
__exportStar(require("./operation-node/operation-node-utils.js"), exports);
|
|
142
143
|
__exportStar(require("./operation-node/operation-node-visitor.js"), exports);
|
|
143
144
|
__exportStar(require("./operation-node/operation-node.js"), exports);
|
|
144
145
|
__exportStar(require("./operation-node/operator-node.js"), exports);
|
|
@@ -173,7 +174,12 @@ __exportStar(require("./operation-node/over-node.js"), exports);
|
|
|
173
174
|
__exportStar(require("./operation-node/partition-by-node.js"), exports);
|
|
174
175
|
__exportStar(require("./operation-node/partition-by-item-node.js"), exports);
|
|
175
176
|
__exportStar(require("./operation-node/set-operation-node.js"), exports);
|
|
177
|
+
__exportStar(require("./operation-node/binary-operation-node.js"), exports);
|
|
178
|
+
__exportStar(require("./operation-node/unary-operation-node.js"), exports);
|
|
176
179
|
__exportStar(require("./util/column-type.js"), exports);
|
|
177
180
|
__exportStar(require("./util/compilable.js"), exports);
|
|
178
181
|
__exportStar(require("./util/explainable.js"), exports);
|
|
179
182
|
__exportStar(require("./util/log.js"), exports);
|
|
183
|
+
__exportStar(require("./util/infer-result.js"), exports);
|
|
184
|
+
var log_once_js_1 = require("./util/log-once.js");
|
|
185
|
+
Object.defineProperty(exports, "logOnce", { enumerable: true, get: function () { return log_once_js_1.logOnce; } });
|
|
@@ -27,11 +27,13 @@ class FileMigrationProvider {
|
|
|
27
27
|
const migrations = {};
|
|
28
28
|
const files = await this.#props.fs.readdir(this.#props.migrationFolder);
|
|
29
29
|
for (const fileName of files) {
|
|
30
|
-
if (
|
|
31
|
-
!fileName.endsWith('.d.ts'))
|
|
30
|
+
if (fileName.endsWith('.js') ||
|
|
31
|
+
(fileName.endsWith('.ts') && !fileName.endsWith('.d.ts')) ||
|
|
32
|
+
fileName.endsWith('.mjs') ||
|
|
33
|
+
(fileName.endsWith('.mts') && !fileName.endsWith('.d.mts'))) {
|
|
32
34
|
const migration = await Promise.resolve().then(() => require(
|
|
33
35
|
/* webpackIgnore: true */ this.#props.path.join(this.#props.migrationFolder, fileName)));
|
|
34
|
-
const migrationKey = fileName.substring(0, fileName.
|
|
36
|
+
const migrationKey = fileName.substring(0, fileName.lastIndexOf('.'));
|
|
35
37
|
// Handle esModuleInterop export's `default` prop...
|
|
36
38
|
if (isMigration(migration?.default)) {
|
|
37
39
|
migrations[migrationKey] = migration.default;
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import { ColumnNode } from './column-node.js';
|
|
2
1
|
import { OperationNode } from './operation-node.js';
|
|
3
2
|
import { OverNode } from './over-node.js';
|
|
4
|
-
import {
|
|
3
|
+
import { SimpleReferenceExpressionNode } from './simple-reference-expression-node.js';
|
|
4
|
+
import { WhereNode } from './where-node.js';
|
|
5
5
|
declare type AggregateFunction = 'avg' | 'count' | 'max' | 'min' | 'sum';
|
|
6
6
|
export interface AggregateFunctionNode extends OperationNode {
|
|
7
7
|
readonly kind: 'AggregateFunctionNode';
|
|
8
8
|
readonly func: AggregateFunction;
|
|
9
|
-
readonly column:
|
|
9
|
+
readonly column: SimpleReferenceExpressionNode;
|
|
10
10
|
readonly distinct?: boolean;
|
|
11
|
+
readonly filter?: WhereNode;
|
|
11
12
|
readonly over?: OverNode;
|
|
12
13
|
}
|
|
13
14
|
/**
|
|
@@ -15,8 +16,10 @@ export interface AggregateFunctionNode extends OperationNode {
|
|
|
15
16
|
*/
|
|
16
17
|
export declare const AggregateFunctionNode: Readonly<{
|
|
17
18
|
is(node: OperationNode): node is AggregateFunctionNode;
|
|
18
|
-
create(aggregateFunction: AggregateFunction, column:
|
|
19
|
+
create(aggregateFunction: AggregateFunction, column: SimpleReferenceExpressionNode): AggregateFunctionNode;
|
|
19
20
|
cloneWithDistinct(aggregateFunctionNode: AggregateFunctionNode): AggregateFunctionNode;
|
|
21
|
+
cloneWithFilter(aggregateFunctionNode: AggregateFunctionNode, filter: OperationNode): AggregateFunctionNode;
|
|
22
|
+
cloneWithOrFilter(aggregateFunctionNode: AggregateFunctionNode, filter: OperationNode): AggregateFunctionNode;
|
|
20
23
|
cloneWithOver(aggregateFunctionNode: AggregateFunctionNode, over?: OverNode): AggregateFunctionNode;
|
|
21
24
|
}>;
|
|
22
25
|
export {};
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AggregateFunctionNode = void 0;
|
|
4
4
|
const object_utils_js_1 = require("../util/object-utils.js");
|
|
5
|
+
const where_node_js_1 = require("./where-node.js");
|
|
5
6
|
/**
|
|
6
7
|
* @internal
|
|
7
8
|
*/
|
|
@@ -22,6 +23,22 @@ exports.AggregateFunctionNode = (0, object_utils_js_1.freeze)({
|
|
|
22
23
|
distinct: true,
|
|
23
24
|
});
|
|
24
25
|
},
|
|
26
|
+
cloneWithFilter(aggregateFunctionNode, filter) {
|
|
27
|
+
return (0, object_utils_js_1.freeze)({
|
|
28
|
+
...aggregateFunctionNode,
|
|
29
|
+
filter: aggregateFunctionNode.filter
|
|
30
|
+
? where_node_js_1.WhereNode.cloneWithOperation(aggregateFunctionNode.filter, 'And', filter)
|
|
31
|
+
: where_node_js_1.WhereNode.create(filter),
|
|
32
|
+
});
|
|
33
|
+
},
|
|
34
|
+
cloneWithOrFilter(aggregateFunctionNode, filter) {
|
|
35
|
+
return (0, object_utils_js_1.freeze)({
|
|
36
|
+
...aggregateFunctionNode,
|
|
37
|
+
filter: aggregateFunctionNode.filter
|
|
38
|
+
? where_node_js_1.WhereNode.cloneWithOperation(aggregateFunctionNode.filter, 'Or', filter)
|
|
39
|
+
: where_node_js_1.WhereNode.create(filter),
|
|
40
|
+
});
|
|
41
|
+
},
|
|
25
42
|
cloneWithOver(aggregateFunctionNode, over) {
|
|
26
43
|
return (0, object_utils_js_1.freeze)({
|
|
27
44
|
...aggregateFunctionNode,
|
|
@@ -1,21 +1,13 @@
|
|
|
1
|
-
import { AggregateFunctionNode } from './aggregate-function-node.js';
|
|
2
|
-
import { ColumnNode } from './column-node.js';
|
|
3
|
-
import { IdentifierNode } from './identifier-node.js';
|
|
4
1
|
import { OperationNode } from './operation-node.js';
|
|
5
|
-
import { RawNode } from './raw-node.js';
|
|
6
|
-
import { ReferenceNode } from './reference-node.js';
|
|
7
|
-
import { SelectQueryNode } from './select-query-node.js';
|
|
8
|
-
import { TableNode } from './table-node.js';
|
|
9
|
-
export declare type AliasNodeChild = ColumnNode | ReferenceNode | TableNode | SelectQueryNode | RawNode | AggregateFunctionNode;
|
|
10
2
|
export interface AliasNode extends OperationNode {
|
|
11
3
|
readonly kind: 'AliasNode';
|
|
12
|
-
readonly node:
|
|
13
|
-
readonly alias:
|
|
4
|
+
readonly node: OperationNode;
|
|
5
|
+
readonly alias: OperationNode;
|
|
14
6
|
}
|
|
15
7
|
/**
|
|
16
8
|
* @internal
|
|
17
9
|
*/
|
|
18
10
|
export declare const AliasNode: Readonly<{
|
|
19
11
|
is(node: OperationNode): node is AliasNode;
|
|
20
|
-
create(node:
|
|
12
|
+
create(node: OperationNode, alias: OperationNode): AliasNode;
|
|
21
13
|
}>;
|