kysely 0.27.2 → 0.27.4
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 +1 -1
- package/README.md +7 -7
- package/dist/cjs/dialect/database-introspector.d.ts +1 -0
- package/dist/cjs/dialect/dialect-adapter-base.d.ts +2 -1
- package/dist/cjs/dialect/dialect-adapter-base.js +4 -1
- package/dist/cjs/dialect/dialect-adapter.d.ts +5 -0
- package/dist/cjs/dialect/mssql/mssql-adapter.d.ts +1 -5
- package/dist/cjs/dialect/mssql/mssql-adapter.js +2 -4
- package/dist/cjs/dialect/mssql/mssql-dialect-config.d.ts +46 -26
- package/dist/cjs/dialect/mssql/mssql-driver.d.ts +1 -0
- package/dist/cjs/dialect/mssql/mssql-driver.js +95 -36
- package/dist/cjs/dialect/mssql/mssql-introspector.js +13 -2
- package/dist/cjs/dialect/mssql/mssql-query-compiler.d.ts +4 -0
- package/dist/cjs/dialect/mssql/mssql-query-compiler.js +8 -0
- package/dist/cjs/dialect/mysql/mysql-introspector.js +2 -0
- package/dist/cjs/dialect/postgres/postgres-dialect-config.d.ts +1 -1
- package/dist/cjs/dialect/postgres/postgres-driver.js +2 -1
- package/dist/cjs/dialect/postgres/postgres-introspector.js +3 -1
- package/dist/cjs/dialect/sqlite/sqlite-introspector.js +1 -0
- package/dist/cjs/driver/database-connection.d.ts +4 -2
- package/dist/cjs/dynamic/dynamic-reference-builder.js +2 -2
- package/dist/cjs/dynamic/dynamic.d.ts +1 -1
- package/dist/cjs/dynamic/dynamic.js +1 -1
- package/dist/cjs/expression/expression-builder.d.ts +31 -5
- package/dist/cjs/expression/expression-builder.js +7 -3
- package/dist/cjs/expression/expression.js +2 -3
- package/dist/cjs/helpers/mssql.js +3 -4
- package/dist/cjs/helpers/mysql.d.ts +3 -3
- package/dist/cjs/helpers/mysql.js +6 -7
- package/dist/cjs/helpers/postgres.d.ts +4 -4
- package/dist/cjs/helpers/postgres.js +7 -8
- package/dist/cjs/helpers/sqlite.js +3 -4
- package/dist/cjs/index.d.ts +31 -18
- package/dist/cjs/index.js +30 -17
- package/dist/cjs/kysely.d.ts +1 -1
- package/dist/cjs/kysely.js +3 -3
- package/dist/cjs/operation-node/add-index-node.js +1 -1
- 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/cast-node.d.ts +13 -0
- package/dist/cjs/operation-node/cast-node.js +19 -0
- package/dist/cjs/operation-node/column-definition-node.d.ts +2 -0
- package/dist/cjs/operation-node/data-type-node.d.ts +5 -1
- package/dist/cjs/operation-node/data-type-node.js +56 -0
- package/dist/cjs/operation-node/delete-query-node.d.ts +6 -0
- package/dist/cjs/operation-node/delete-query-node.js +12 -0
- package/dist/cjs/operation-node/fetch-node.d.ts +15 -0
- package/dist/cjs/operation-node/fetch-node.js +19 -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 +6 -1
- package/dist/cjs/operation-node/insert-query-node.js +5 -0
- package/dist/cjs/operation-node/join-node.d.ts +1 -1
- package/dist/cjs/operation-node/matched-node.d.ts +13 -0
- package/dist/cjs/operation-node/matched-node.js +19 -0
- package/dist/cjs/operation-node/merge-query-node.d.ts +27 -0
- package/dist/cjs/operation-node/merge-query-node.js +45 -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 +12 -0
- package/dist/cjs/operation-node/operation-node-transformer.js +62 -0
- package/dist/cjs/operation-node/operation-node-visitor.d.ts +12 -0
- package/dist/cjs/operation-node/operation-node-visitor.js +6 -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 +17 -5
- package/dist/cjs/operation-node/query-node.js +24 -1
- package/dist/cjs/operation-node/select-query-node.d.ts +6 -0
- package/dist/cjs/operation-node/select-query-node.js +12 -0
- package/dist/cjs/operation-node/top-node.d.ts +14 -0
- package/dist/cjs/operation-node/top-node.js +19 -0
- package/dist/cjs/operation-node/update-query-node.d.ts +9 -1
- package/dist/cjs/operation-node/update-query-node.js +11 -0
- package/dist/cjs/operation-node/where-node.d.ts +1 -1
- package/dist/cjs/parser/binary-operation-parser.d.ts +1 -1
- package/dist/cjs/parser/binary-operation-parser.js +7 -8
- package/dist/cjs/parser/data-type-parser.js +8 -5
- 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.d.ts +2 -0
- package/dist/cjs/parser/fetch-parser.js +17 -0
- 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.d.ts +3 -3
- 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.d.ts +9 -0
- package/dist/cjs/parser/merge-parser.js +31 -0
- 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.d.ts +4 -3
- package/dist/cjs/parser/table-parser.js +4 -5
- package/dist/cjs/parser/top-parser.d.ts +2 -0
- package/dist/cjs/parser/top-parser.js +19 -0
- 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 +2 -2
- package/dist/cjs/plugin/camel-case/camel-case-plugin.js +2 -2
- package/dist/cjs/plugin/camel-case/camel-case.js +2 -3
- package/dist/cjs/plugin/parse-json-results/parse-json-results-plugin.d.ts +18 -0
- package/dist/cjs/plugin/parse-json-results/parse-json-results-plugin.js +19 -11
- package/dist/cjs/plugin/with-schema/with-schema-transformer.js +4 -0
- package/dist/cjs/query-builder/delete-query-builder.d.ts +188 -5
- package/dist/cjs/query-builder/delete-query-builder.js +139 -5
- package/dist/cjs/query-builder/function-module.d.ts +5 -5
- package/dist/cjs/query-builder/function-module.js +1 -2
- package/dist/cjs/query-builder/insert-query-builder.d.ts +166 -10
- package/dist/cjs/query-builder/insert-query-builder.js +107 -10
- package/dist/cjs/query-builder/merge-query-builder.d.ts +721 -0
- package/dist/cjs/query-builder/merge-query-builder.js +547 -0
- package/dist/cjs/query-builder/merge-result.d.ts +4 -0
- package/dist/cjs/query-builder/merge-result.js +10 -0
- package/dist/cjs/query-builder/no-result-error.js +2 -2
- package/dist/cjs/query-builder/on-conflict-builder.d.ts +2 -2
- package/dist/cjs/query-builder/output-interface.d.ts +95 -0
- package/dist/cjs/query-builder/output-interface.js +2 -0
- package/dist/cjs/query-builder/returning-interface.d.ts +2 -0
- package/dist/cjs/query-builder/select-query-builder.d.ts +177 -17
- package/dist/cjs/query-builder/select-query-builder.js +21 -2
- package/dist/cjs/query-builder/update-query-builder.d.ts +175 -10
- package/dist/cjs/query-builder/update-query-builder.js +119 -7
- 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 +1 -1
- package/dist/cjs/query-compiler/default-query-compiler.d.ts +12 -0
- package/dist/cjs/query-compiler/default-query-compiler.js +118 -10
- package/dist/cjs/query-compiler/query-compiler.d.ts +2 -1
- package/dist/cjs/query-creator.d.ts +96 -5
- package/dist/cjs/query-creator.js +63 -1
- package/dist/cjs/raw-builder/raw-builder.js +1 -2
- package/dist/cjs/raw-builder/sql.d.ts +5 -5
- package/dist/cjs/schema/alter-column-builder.js +3 -0
- package/dist/cjs/schema/alter-table-add-index-builder.d.ts +1 -1
- package/dist/cjs/schema/alter-table-add-index-builder.js +7 -3
- package/dist/cjs/schema/alter-table-builder.js +1 -2
- package/dist/cjs/schema/column-definition-builder.d.ts +18 -1
- package/dist/cjs/schema/column-definition-builder.js +22 -1
- package/dist/cjs/util/assert.js +2 -3
- package/dist/cjs/util/compilable.js +1 -2
- package/dist/cjs/util/infer-result.d.ts +2 -1
- 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.js +1 -2
- package/dist/cjs/util/stack-trace-utils.js +1 -2
- package/dist/cjs/util/type-utils.d.ts +3 -2
- package/dist/esm/dialect/database-introspector.d.ts +1 -0
- package/dist/esm/dialect/dialect-adapter-base.d.ts +2 -1
- package/dist/esm/dialect/dialect-adapter-base.js +4 -1
- package/dist/esm/dialect/dialect-adapter.d.ts +5 -0
- package/dist/esm/dialect/mssql/mssql-adapter.d.ts +1 -5
- package/dist/esm/dialect/mssql/mssql-adapter.js +2 -4
- package/dist/esm/dialect/mssql/mssql-dialect-config.d.ts +46 -26
- package/dist/esm/dialect/mssql/mssql-driver.d.ts +1 -0
- package/dist/esm/dialect/mssql/mssql-driver.js +95 -36
- package/dist/esm/dialect/mssql/mssql-introspector.js +13 -2
- package/dist/esm/dialect/mssql/mssql-query-compiler.d.ts +4 -0
- package/dist/esm/dialect/mssql/mssql-query-compiler.js +8 -0
- package/dist/esm/dialect/mysql/mysql-introspector.js +2 -0
- package/dist/esm/dialect/postgres/postgres-dialect-config.d.ts +1 -1
- package/dist/esm/dialect/postgres/postgres-driver.js +2 -1
- package/dist/esm/dialect/postgres/postgres-introspector.js +3 -1
- package/dist/esm/dialect/sqlite/sqlite-introspector.js +1 -0
- package/dist/esm/driver/database-connection.d.ts +4 -2
- package/dist/esm/dynamic/dynamic.d.ts +1 -1
- package/dist/esm/dynamic/dynamic.js +1 -1
- package/dist/esm/expression/expression-builder.d.ts +31 -5
- package/dist/esm/expression/expression-builder.js +5 -0
- package/dist/esm/helpers/mysql.d.ts +3 -3
- package/dist/esm/helpers/mysql.js +3 -3
- package/dist/esm/helpers/postgres.d.ts +4 -4
- package/dist/esm/helpers/postgres.js +4 -4
- package/dist/esm/index.d.ts +31 -18
- package/dist/esm/index.js +30 -17
- package/dist/esm/kysely.d.ts +1 -1
- package/dist/esm/kysely.js +1 -1
- package/dist/esm/operation-node/add-index-node.js +1 -1
- 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/cast-node.d.ts +13 -0
- package/dist/esm/operation-node/cast-node.js +17 -0
- package/dist/esm/operation-node/column-definition-node.d.ts +2 -0
- package/dist/esm/operation-node/data-type-node.d.ts +5 -1
- package/dist/esm/operation-node/data-type-node.js +55 -0
- package/dist/esm/operation-node/delete-query-node.d.ts +6 -0
- package/dist/esm/operation-node/delete-query-node.js +12 -0
- package/dist/esm/operation-node/fetch-node.d.ts +15 -0
- package/dist/esm/operation-node/fetch-node.js +17 -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 +6 -1
- package/dist/esm/operation-node/insert-query-node.js +5 -0
- package/dist/esm/operation-node/join-node.d.ts +1 -1
- package/dist/esm/operation-node/matched-node.d.ts +13 -0
- package/dist/esm/operation-node/matched-node.js +17 -0
- package/dist/esm/operation-node/merge-query-node.d.ts +27 -0
- package/dist/esm/operation-node/merge-query-node.js +43 -0
- package/dist/esm/operation-node/on-node.d.ts +1 -1
- package/dist/esm/operation-node/operation-node-transformer.d.ts +12 -0
- package/dist/esm/operation-node/operation-node-transformer.js +62 -0
- package/dist/esm/operation-node/operation-node-visitor.d.ts +12 -0
- package/dist/esm/operation-node/operation-node-visitor.js +6 -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 +17 -5
- package/dist/esm/operation-node/query-node.js +24 -1
- package/dist/esm/operation-node/select-query-node.d.ts +6 -0
- package/dist/esm/operation-node/select-query-node.js +12 -0
- package/dist/esm/operation-node/top-node.d.ts +14 -0
- package/dist/esm/operation-node/top-node.js +17 -0
- package/dist/esm/operation-node/update-query-node.d.ts +9 -1
- package/dist/esm/operation-node/update-query-node.js +11 -0
- package/dist/esm/operation-node/where-node.d.ts +1 -1
- package/dist/esm/parser/binary-operation-parser.d.ts +1 -1
- package/dist/esm/parser/binary-operation-parser.js +2 -2
- package/dist/esm/parser/data-type-parser.js +8 -4
- package/dist/esm/parser/fetch-parser.d.ts +2 -0
- package/dist/esm/parser/fetch-parser.js +15 -0
- package/dist/esm/parser/insert-values-parser.d.ts +3 -3
- package/dist/esm/parser/merge-parser.d.ts +9 -0
- package/dist/esm/parser/merge-parser.js +28 -0
- package/dist/esm/parser/returning-parser.d.ts +4 -3
- package/dist/esm/parser/table-parser.d.ts +4 -3
- package/dist/esm/parser/top-parser.d.ts +2 -0
- package/dist/esm/parser/top-parser.js +17 -0
- package/dist/esm/plugin/camel-case/camel-case-plugin.d.ts +2 -2
- package/dist/esm/plugin/camel-case/camel-case-plugin.js +2 -2
- package/dist/esm/plugin/parse-json-results/parse-json-results-plugin.d.ts +18 -0
- package/dist/esm/plugin/parse-json-results/parse-json-results-plugin.js +19 -11
- package/dist/esm/plugin/with-schema/with-schema-transformer.js +4 -0
- package/dist/esm/query-builder/delete-query-builder.d.ts +188 -5
- package/dist/esm/query-builder/delete-query-builder.js +139 -5
- package/dist/esm/query-builder/function-module.d.ts +5 -5
- package/dist/esm/query-builder/insert-query-builder.d.ts +166 -10
- package/dist/esm/query-builder/insert-query-builder.js +107 -10
- package/dist/esm/query-builder/merge-query-builder.d.ts +721 -0
- package/dist/esm/query-builder/merge-query-builder.js +541 -0
- package/dist/esm/query-builder/merge-result.d.ts +4 -0
- package/dist/esm/query-builder/merge-result.js +7 -0
- package/dist/esm/query-builder/on-conflict-builder.d.ts +2 -2
- package/dist/esm/query-builder/output-interface.d.ts +95 -0
- package/dist/esm/query-builder/output-interface.js +2 -0
- package/dist/esm/query-builder/returning-interface.d.ts +2 -0
- package/dist/esm/query-builder/select-query-builder.d.ts +177 -17
- package/dist/esm/query-builder/select-query-builder.js +20 -0
- package/dist/esm/query-builder/update-query-builder.d.ts +175 -10
- package/dist/esm/query-builder/update-query-builder.js +119 -7
- 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 +1 -1
- package/dist/esm/query-compiler/default-query-compiler.d.ts +12 -0
- package/dist/esm/query-compiler/default-query-compiler.js +118 -10
- package/dist/esm/query-compiler/query-compiler.d.ts +2 -1
- package/dist/esm/query-creator.d.ts +96 -5
- package/dist/esm/query-creator.js +64 -2
- package/dist/esm/raw-builder/sql.d.ts +5 -5
- package/dist/esm/schema/alter-column-builder.js +3 -0
- package/dist/esm/schema/alter-table-add-index-builder.d.ts +1 -1
- package/dist/esm/schema/alter-table-add-index-builder.js +8 -4
- package/dist/esm/schema/alter-table-builder.js +1 -2
- package/dist/esm/schema/column-definition-builder.d.ts +18 -1
- package/dist/esm/schema/column-definition-builder.js +22 -1
- package/dist/esm/util/infer-result.d.ts +2 -1
- package/dist/esm/util/object-utils.js +18 -5
- package/dist/esm/util/type-utils.d.ts +3 -2
- package/package.json +26 -24
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.DynamicReferenceBuilder = void 0;
|
|
4
|
+
exports.isDynamicReferenceBuilder = isDynamicReferenceBuilder;
|
|
4
5
|
const operation_node_source_js_1 = require("../operation-node/operation-node-source.js");
|
|
5
6
|
const reference_parser_js_1 = require("../parser/reference-parser.js");
|
|
6
7
|
const object_utils_js_1 = require("../util/object-utils.js");
|
|
@@ -33,4 +34,3 @@ function isDynamicReferenceBuilder(obj) {
|
|
|
33
34
|
(0, operation_node_source_js_1.isOperationNodeSource)(obj) &&
|
|
34
35
|
(0, object_utils_js_1.isString)(obj.dynamicReference));
|
|
35
36
|
}
|
|
36
|
-
exports.isDynamicReferenceBuilder = isDynamicReferenceBuilder;
|
|
@@ -5,7 +5,7 @@ export declare class DynamicModule {
|
|
|
5
5
|
*
|
|
6
6
|
* Kysely is built in a way that by default you can't refer to tables or columns
|
|
7
7
|
* that are not actually visible in the current query and context. This is all
|
|
8
|
-
* done by
|
|
8
|
+
* done by TypeScript at compile time, which means that you need to know the
|
|
9
9
|
* columns and tables at compile time. This is not always the case of course.
|
|
10
10
|
*
|
|
11
11
|
* This method is meant to be used in those cases where the column names
|
|
@@ -8,7 +8,7 @@ class DynamicModule {
|
|
|
8
8
|
*
|
|
9
9
|
* Kysely is built in a way that by default you can't refer to tables or columns
|
|
10
10
|
* that are not actually visible in the current query and context. This is all
|
|
11
|
-
* done by
|
|
11
|
+
* done by TypeScript at compile time, which means that you need to know the
|
|
12
12
|
* columns and tables at compile time. This is not always the case of course.
|
|
13
13
|
*
|
|
14
14
|
* This method is meant to be used in those cases where the column names
|
|
@@ -15,6 +15,7 @@ import { OperandExpression } from '../parser/expression-parser.js';
|
|
|
15
15
|
import { RefTuple2, RefTuple3, RefTuple4, RefTuple5, ValTuple2, ValTuple3, ValTuple4, ValTuple5 } from '../parser/tuple-parser.js';
|
|
16
16
|
import { Selectable } from '../util/column-type.js';
|
|
17
17
|
import { KyselyTypeError } from '../util/type-error.js';
|
|
18
|
+
import { DataTypeExpression } from '../parser/data-type-parser.js';
|
|
18
19
|
export interface ExpressionBuilder<DB, TB extends keyof DB> {
|
|
19
20
|
/**
|
|
20
21
|
* Creates a binary expression.
|
|
@@ -194,7 +195,7 @@ export interface ExpressionBuilder<DB, TB extends keyof DB> {
|
|
|
194
195
|
selectFrom<TE extends keyof DB & string>(from: TE[]): SelectQueryBuilder<DB, TB | ExtractTableAlias<DB, TE>, {}>;
|
|
195
196
|
selectFrom<TE extends TableExpression<DB, TB>>(from: TE[]): SelectQueryBuilder<From<DB, TE>, FromTables<DB, TB, TE>, {}>;
|
|
196
197
|
selectFrom<TE extends keyof DB & string>(from: TE): SelectQueryBuilder<DB, TB | ExtractTableAlias<DB, TE>, {}>;
|
|
197
|
-
selectFrom<TE extends AnyAliasedTable<DB>>(from: TE): SelectQueryBuilder<DB & PickTableWithAlias<DB, TE>, TB | ExtractTableAlias<DB, TE>, {}>;
|
|
198
|
+
selectFrom<TE extends AnyAliasedTable<DB>>(from: TE): SelectQueryBuilder<DB & PickTableWithAlias<DB, TE>, TB | ExtractTableAlias<DB & PickTableWithAlias<DB, TE>, TE>, {}>;
|
|
198
199
|
selectFrom<TE extends TableExpression<DB, TB>>(from: TE): SelectQueryBuilder<From<DB, TE>, FromTables<DB, TB, TE>, {}>;
|
|
199
200
|
/**
|
|
200
201
|
* Creates a `case` statement/operator.
|
|
@@ -218,7 +219,7 @@ export interface ExpressionBuilder<DB, TB extends keyof DB> {
|
|
|
218
219
|
* .when('gender', '=', 'female')
|
|
219
220
|
* .then(
|
|
220
221
|
* eb
|
|
221
|
-
* .case('
|
|
222
|
+
* .case('maritalStatus')
|
|
222
223
|
* .when('single')
|
|
223
224
|
* .then('Ms.')
|
|
224
225
|
* .else('Mrs.')
|
|
@@ -238,7 +239,7 @@ export interface ExpressionBuilder<DB, TB extends keyof DB> {
|
|
|
238
239
|
* case
|
|
239
240
|
* when "gender" = $1 then $2
|
|
240
241
|
* when "gender" = $3 then
|
|
241
|
-
* case "
|
|
242
|
+
* case "maritalStatus"
|
|
242
243
|
* when $4 then $5
|
|
243
244
|
* else $6
|
|
244
245
|
* end
|
|
@@ -292,7 +293,7 @@ export interface ExpressionBuilder<DB, TB extends keyof DB> {
|
|
|
292
293
|
*
|
|
293
294
|
* ```ts
|
|
294
295
|
* db.update('pet').set((eb) => ({
|
|
295
|
-
* name: sql
|
|
296
|
+
* name: sql<string>`concat(${eb.ref('pet.name')}, ${suffix})`
|
|
296
297
|
* }))
|
|
297
298
|
* ```
|
|
298
299
|
*
|
|
@@ -775,7 +776,7 @@ export interface ExpressionBuilder<DB, TB extends keyof DB> {
|
|
|
775
776
|
* ```ts
|
|
776
777
|
* db.selectFrom('person')
|
|
777
778
|
* .selectAll('person')
|
|
778
|
-
* .where((eb) => parens(
|
|
779
|
+
* .where((eb) => eb.parens(
|
|
779
780
|
* eb('age', '=', 1).or('age', '=', 2))
|
|
780
781
|
* ).and(
|
|
781
782
|
* eb('first_name', '=', 'Jennifer').or('first_name', '=', 'Arnold')
|
|
@@ -792,6 +793,31 @@ export interface ExpressionBuilder<DB, TB extends keyof DB> {
|
|
|
792
793
|
*/
|
|
793
794
|
parens<RE extends ReferenceExpression<DB, TB>, OP extends BinaryOperatorExpression, VE extends OperandValueExpressionOrList<DB, TB, RE>>(lhs: RE, op: OP, rhs: VE): ExpressionWrapper<DB, TB, OP extends ComparisonOperator ? SqlBool : ExtractTypeFromReferenceExpression<DB, TB, RE>>;
|
|
794
795
|
parens<T>(expr: Expression<T>): ExpressionWrapper<DB, TB, T>;
|
|
796
|
+
/**
|
|
797
|
+
* Creates a `cast(expr as dataType)` expression.
|
|
798
|
+
*
|
|
799
|
+
* Since Kysely can't know the mapping between JavaScript and database types,
|
|
800
|
+
* you need to provide both explicitly.
|
|
801
|
+
*
|
|
802
|
+
* ### Examples
|
|
803
|
+
*
|
|
804
|
+
* ```ts
|
|
805
|
+
* db.selectFrom('person')
|
|
806
|
+
* .select((eb) => [
|
|
807
|
+
* 'id',
|
|
808
|
+
* 'first_name',
|
|
809
|
+
* eb.cast<number>('age', 'integer').as('age')
|
|
810
|
+
* ])
|
|
811
|
+
* ```
|
|
812
|
+
*
|
|
813
|
+
* The generated SQL (PostgreSQL):
|
|
814
|
+
*
|
|
815
|
+
* ```sql
|
|
816
|
+
* select cast("age" as integer) as "age"
|
|
817
|
+
* from "person"
|
|
818
|
+
* ```
|
|
819
|
+
*/
|
|
820
|
+
cast<T, RE extends ReferenceExpression<DB, TB> = ReferenceExpression<DB, TB>>(expr: RE, dataType: DataTypeExpression): ExpressionWrapper<DB, TB, T>;
|
|
795
821
|
/**
|
|
796
822
|
* See {@link QueryCreator.withSchema}
|
|
797
823
|
*
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.createExpressionBuilder = createExpressionBuilder;
|
|
4
|
+
exports.expressionBuilder = expressionBuilder;
|
|
4
5
|
const select_query_builder_js_1 = require("../query-builder/select-query-builder.js");
|
|
5
6
|
const select_query_node_js_1 = require("../operation-node/select-query-node.js");
|
|
6
7
|
const table_parser_js_1 = require("../parser/table-parser.js");
|
|
@@ -23,6 +24,8 @@ const binary_operation_node_js_1 = require("../operation-node/binary-operation-n
|
|
|
23
24
|
const and_node_js_1 = require("../operation-node/and-node.js");
|
|
24
25
|
const tuple_node_js_1 = require("../operation-node/tuple-node.js");
|
|
25
26
|
const json_path_node_js_1 = require("../operation-node/json-path-node.js");
|
|
27
|
+
const data_type_parser_js_1 = require("../parser/data-type-parser.js");
|
|
28
|
+
const cast_node_js_1 = require("../operation-node/cast-node.js");
|
|
26
29
|
function createExpressionBuilder(executor = noop_query_executor_js_1.NOOP_QUERY_EXECUTOR) {
|
|
27
30
|
function binary(lhs, op, rhs) {
|
|
28
31
|
return new expression_wrapper_js_1.ExpressionWrapper((0, binary_operation_parser_js_1.parseValueBinaryOperation)(lhs, op, rhs));
|
|
@@ -109,6 +112,9 @@ function createExpressionBuilder(executor = noop_query_executor_js_1.NOOP_QUERY_
|
|
|
109
112
|
return new expression_wrapper_js_1.ExpressionWrapper(parens_node_js_1.ParensNode.create(node));
|
|
110
113
|
}
|
|
111
114
|
},
|
|
115
|
+
cast(expr, dataType) {
|
|
116
|
+
return new expression_wrapper_js_1.ExpressionWrapper(cast_node_js_1.CastNode.create((0, reference_parser_js_1.parseReferenceExpression)(expr), (0, data_type_parser_js_1.parseDataTypeExpression)(dataType)));
|
|
117
|
+
},
|
|
112
118
|
withSchema(schema) {
|
|
113
119
|
return createExpressionBuilder(executor.withPluginAtFront(new with_schema_plugin_js_1.WithSchemaPlugin(schema)));
|
|
114
120
|
},
|
|
@@ -117,8 +123,6 @@ function createExpressionBuilder(executor = noop_query_executor_js_1.NOOP_QUERY_
|
|
|
117
123
|
eb.eb = eb;
|
|
118
124
|
return eb;
|
|
119
125
|
}
|
|
120
|
-
exports.createExpressionBuilder = createExpressionBuilder;
|
|
121
126
|
function expressionBuilder(_) {
|
|
122
127
|
return createExpressionBuilder();
|
|
123
128
|
}
|
|
124
|
-
exports.expressionBuilder = expressionBuilder;
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.isExpression = isExpression;
|
|
4
|
+
exports.isAliasedExpression = isAliasedExpression;
|
|
4
5
|
const operation_node_source_js_1 = require("../operation-node/operation-node-source.js");
|
|
5
6
|
const object_utils_js_1 = require("../util/object-utils.js");
|
|
6
7
|
function isExpression(obj) {
|
|
7
8
|
return (0, object_utils_js_1.isObject)(obj) && 'expressionType' in obj && (0, operation_node_source_js_1.isOperationNodeSource)(obj);
|
|
8
9
|
}
|
|
9
|
-
exports.isExpression = isExpression;
|
|
10
10
|
function isAliasedExpression(obj) {
|
|
11
11
|
return ((0, object_utils_js_1.isObject)(obj) &&
|
|
12
12
|
'expression' in obj &&
|
|
13
13
|
(0, object_utils_js_1.isString)(obj.alias) &&
|
|
14
14
|
(0, operation_node_source_js_1.isOperationNodeSource)(obj));
|
|
15
15
|
}
|
|
16
|
-
exports.isAliasedExpression = isAliasedExpression;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.jsonArrayFrom = jsonArrayFrom;
|
|
4
|
+
exports.jsonObjectFrom = jsonObjectFrom;
|
|
5
|
+
exports.jsonBuildObject = jsonBuildObject;
|
|
4
6
|
const sql_js_1 = require("../raw-builder/sql.js");
|
|
5
7
|
/**
|
|
6
8
|
* An MS SQL Server helper for aggregating a subquery into a JSON array.
|
|
@@ -57,7 +59,6 @@ const sql_js_1 = require("../raw-builder/sql.js");
|
|
|
57
59
|
function jsonArrayFrom(expr) {
|
|
58
60
|
return (0, sql_js_1.sql) `coalesce((select * from ${expr} as agg for json path, include_null_values), '[]')`;
|
|
59
61
|
}
|
|
60
|
-
exports.jsonArrayFrom = jsonArrayFrom;
|
|
61
62
|
/**
|
|
62
63
|
* An MS SQL Server helper for turning a subquery into a JSON object.
|
|
63
64
|
*
|
|
@@ -113,7 +114,6 @@ exports.jsonArrayFrom = jsonArrayFrom;
|
|
|
113
114
|
function jsonObjectFrom(expr) {
|
|
114
115
|
return (0, sql_js_1.sql) `(select * from ${expr} as agg for json path, include_null_values, without_array_wrapper)`;
|
|
115
116
|
}
|
|
116
|
-
exports.jsonObjectFrom = jsonObjectFrom;
|
|
117
117
|
/**
|
|
118
118
|
* The MS SQL Server `json_query` function, single argument variant.
|
|
119
119
|
*
|
|
@@ -157,4 +157,3 @@ exports.jsonObjectFrom = jsonObjectFrom;
|
|
|
157
157
|
function jsonBuildObject(obj) {
|
|
158
158
|
return (0, sql_js_1.sql) `json_query('{${sql_js_1.sql.join(Object.keys(obj).map((k) => (0, sql_js_1.sql) `"${sql_js_1.sql.raw(k)}":"'+${obj[k]}+'"`), (0, sql_js_1.sql) `,`)}}')`;
|
|
159
159
|
}
|
|
160
|
-
exports.jsonBuildObject = jsonBuildObject;
|
|
@@ -6,7 +6,7 @@ import { Simplify } from '../util/type-utils.js';
|
|
|
6
6
|
* A MySQL helper for aggregating a subquery into a JSON array.
|
|
7
7
|
*
|
|
8
8
|
* NOTE: This helper is only guaranteed to fully work with the built-in `MysqlDialect`.
|
|
9
|
-
* While the produced SQL is compatible with all MySQL databases, some
|
|
9
|
+
* While the produced SQL is compatible with all MySQL databases, some third-party dialects
|
|
10
10
|
* may not parse the nested JSON into arrays. In these cases you can use the built in
|
|
11
11
|
* `ParseJSONResultsPlugin` to parse the results.
|
|
12
12
|
*
|
|
@@ -55,7 +55,7 @@ export declare function jsonArrayFrom<O>(expr: SelectQueryBuilderExpression<O>):
|
|
|
55
55
|
* The subquery must only return one row.
|
|
56
56
|
*
|
|
57
57
|
* NOTE: This helper is only guaranteed to fully work with the built-in `MysqlDialect`.
|
|
58
|
-
* While the produced SQL is compatible with all MySQL databases, some
|
|
58
|
+
* While the produced SQL is compatible with all MySQL databases, some third-party dialects
|
|
59
59
|
* may not parse the nested JSON into objects. In these cases you can use the built in
|
|
60
60
|
* `ParseJSONResultsPlugin` to parse the results.
|
|
61
61
|
*
|
|
@@ -102,7 +102,7 @@ export declare function jsonObjectFrom<O>(expr: SelectQueryBuilderExpression<O>)
|
|
|
102
102
|
* The MySQL `json_object` function.
|
|
103
103
|
*
|
|
104
104
|
* NOTE: This helper is only guaranteed to fully work with the built-in `MysqlDialect`.
|
|
105
|
-
* While the produced SQL is compatible with all MySQL databases, some
|
|
105
|
+
* While the produced SQL is compatible with all MySQL databases, some third-party dialects
|
|
106
106
|
* may not parse the nested JSON into objects. In these cases you can use the built in
|
|
107
107
|
* `ParseJSONResultsPlugin` to parse the results.
|
|
108
108
|
*
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.jsonArrayFrom = jsonArrayFrom;
|
|
4
|
+
exports.jsonObjectFrom = jsonObjectFrom;
|
|
5
|
+
exports.jsonBuildObject = jsonBuildObject;
|
|
4
6
|
const sql_js_1 = require("../raw-builder/sql.js");
|
|
5
7
|
const json_object_args_js_1 = require("../util/json-object-args.js");
|
|
6
8
|
/**
|
|
7
9
|
* A MySQL helper for aggregating a subquery into a JSON array.
|
|
8
10
|
*
|
|
9
11
|
* NOTE: This helper is only guaranteed to fully work with the built-in `MysqlDialect`.
|
|
10
|
-
* While the produced SQL is compatible with all MySQL databases, some
|
|
12
|
+
* While the produced SQL is compatible with all MySQL databases, some third-party dialects
|
|
11
13
|
* may not parse the nested JSON into arrays. In these cases you can use the built in
|
|
12
14
|
* `ParseJSONResultsPlugin` to parse the results.
|
|
13
15
|
*
|
|
@@ -52,14 +54,13 @@ const json_object_args_js_1 = require("../util/json-object-args.js");
|
|
|
52
54
|
function jsonArrayFrom(expr) {
|
|
53
55
|
return (0, sql_js_1.sql) `(select cast(coalesce(json_arrayagg(json_object(${sql_js_1.sql.join(getMysqlJsonObjectArgs(expr.toOperationNode(), 'agg'))})), '[]') as json) from ${expr} as agg)`;
|
|
54
56
|
}
|
|
55
|
-
exports.jsonArrayFrom = jsonArrayFrom;
|
|
56
57
|
/**
|
|
57
58
|
* A MySQL helper for turning a subquery into a JSON object.
|
|
58
59
|
*
|
|
59
60
|
* The subquery must only return one row.
|
|
60
61
|
*
|
|
61
62
|
* NOTE: This helper is only guaranteed to fully work with the built-in `MysqlDialect`.
|
|
62
|
-
* While the produced SQL is compatible with all MySQL databases, some
|
|
63
|
+
* While the produced SQL is compatible with all MySQL databases, some third-party dialects
|
|
63
64
|
* may not parse the nested JSON into objects. In these cases you can use the built in
|
|
64
65
|
* `ParseJSONResultsPlugin` to parse the results.
|
|
65
66
|
*
|
|
@@ -104,12 +105,11 @@ exports.jsonArrayFrom = jsonArrayFrom;
|
|
|
104
105
|
function jsonObjectFrom(expr) {
|
|
105
106
|
return (0, sql_js_1.sql) `(select json_object(${sql_js_1.sql.join(getMysqlJsonObjectArgs(expr.toOperationNode(), 'obj'))}) from ${expr} as obj)`;
|
|
106
107
|
}
|
|
107
|
-
exports.jsonObjectFrom = jsonObjectFrom;
|
|
108
108
|
/**
|
|
109
109
|
* The MySQL `json_object` function.
|
|
110
110
|
*
|
|
111
111
|
* NOTE: This helper is only guaranteed to fully work with the built-in `MysqlDialect`.
|
|
112
|
-
* While the produced SQL is compatible with all MySQL databases, some
|
|
112
|
+
* While the produced SQL is compatible with all MySQL databases, some third-party dialects
|
|
113
113
|
* may not parse the nested JSON into objects. In these cases you can use the built in
|
|
114
114
|
* `ParseJSONResultsPlugin` to parse the results.
|
|
115
115
|
*
|
|
@@ -148,7 +148,6 @@ exports.jsonObjectFrom = jsonObjectFrom;
|
|
|
148
148
|
function jsonBuildObject(obj) {
|
|
149
149
|
return (0, sql_js_1.sql) `json_object(${sql_js_1.sql.join(Object.keys(obj).flatMap((k) => [sql_js_1.sql.lit(k), obj[k]]))})`;
|
|
150
150
|
}
|
|
151
|
-
exports.jsonBuildObject = jsonBuildObject;
|
|
152
151
|
function getMysqlJsonObjectArgs(node, table) {
|
|
153
152
|
try {
|
|
154
153
|
return (0, json_object_args_js_1.getJsonObjectArgs)(node, table);
|
|
@@ -15,7 +15,7 @@ import { Simplify } from '../util/type-utils.js';
|
|
|
15
15
|
* Please keep in mind that the helpers under the `kysely/helpers` folder, including
|
|
16
16
|
* `jsonArrayFrom`, are not guaranteed to work with third party dialects. In order for
|
|
17
17
|
* them to work, the dialect must automatically parse the `json` data type into
|
|
18
|
-
*
|
|
18
|
+
* JavaScript JSON values like objects and arrays. Some dialects might simply return
|
|
19
19
|
* the data as a JSON string. In these cases you can use the built in `ParseJSONResultsPlugin`
|
|
20
20
|
* to parse the results.
|
|
21
21
|
*
|
|
@@ -65,9 +65,9 @@ export declare function jsonArrayFrom<O>(expr: Expression<O>): RawBuilder<Simpli
|
|
|
65
65
|
* use the `jsonObjectFrom` helper to fetch person's favorite pet along with the person's id.
|
|
66
66
|
*
|
|
67
67
|
* Please keep in mind that the helpers under the `kysely/helpers` folder, including
|
|
68
|
-
* `jsonObjectFrom`, are not guaranteed to work with
|
|
68
|
+
* `jsonObjectFrom`, are not guaranteed to work with third-party dialects. In order for
|
|
69
69
|
* them to work, the dialect must automatically parse the `json` data type into
|
|
70
|
-
*
|
|
70
|
+
* JavaScript JSON values like objects and arrays. Some dialects might simply return
|
|
71
71
|
* the data as a JSON string. In these cases you can use the built in `ParseJSONResultsPlugin`
|
|
72
72
|
* to parse the results.
|
|
73
73
|
*
|
|
@@ -107,7 +107,7 @@ export declare function jsonObjectFrom<O>(expr: Expression<O>): RawBuilder<Simpl
|
|
|
107
107
|
* The PostgreSQL `json_build_object` function.
|
|
108
108
|
*
|
|
109
109
|
* NOTE: This helper is only guaranteed to fully work with the built-in `PostgresDialect`.
|
|
110
|
-
* While the produced SQL is compatible with all PostgreSQL databases, some
|
|
110
|
+
* While the produced SQL is compatible with all PostgreSQL databases, some third-party dialects
|
|
111
111
|
* may not parse the nested JSON into objects. In these cases you can use the built in
|
|
112
112
|
* `ParseJSONResultsPlugin` to parse the results.
|
|
113
113
|
*
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.jsonArrayFrom = jsonArrayFrom;
|
|
4
|
+
exports.jsonObjectFrom = jsonObjectFrom;
|
|
5
|
+
exports.jsonBuildObject = jsonBuildObject;
|
|
4
6
|
const sql_js_1 = require("../raw-builder/sql.js");
|
|
5
7
|
/**
|
|
6
8
|
* A postgres helper for aggregating a subquery (or other expression) into a JSONB array.
|
|
@@ -16,7 +18,7 @@ const sql_js_1 = require("../raw-builder/sql.js");
|
|
|
16
18
|
* Please keep in mind that the helpers under the `kysely/helpers` folder, including
|
|
17
19
|
* `jsonArrayFrom`, are not guaranteed to work with third party dialects. In order for
|
|
18
20
|
* them to work, the dialect must automatically parse the `json` data type into
|
|
19
|
-
*
|
|
21
|
+
* JavaScript JSON values like objects and arrays. Some dialects might simply return
|
|
20
22
|
* the data as a JSON string. In these cases you can use the built in `ParseJSONResultsPlugin`
|
|
21
23
|
* to parse the results.
|
|
22
24
|
*
|
|
@@ -54,7 +56,6 @@ const sql_js_1 = require("../raw-builder/sql.js");
|
|
|
54
56
|
function jsonArrayFrom(expr) {
|
|
55
57
|
return (0, sql_js_1.sql) `(select coalesce(json_agg(agg), '[]') from ${expr} as agg)`;
|
|
56
58
|
}
|
|
57
|
-
exports.jsonArrayFrom = jsonArrayFrom;
|
|
58
59
|
/**
|
|
59
60
|
* A postgres helper for turning a subquery (or other expression) into a JSON object.
|
|
60
61
|
*
|
|
@@ -69,9 +70,9 @@ exports.jsonArrayFrom = jsonArrayFrom;
|
|
|
69
70
|
* use the `jsonObjectFrom` helper to fetch person's favorite pet along with the person's id.
|
|
70
71
|
*
|
|
71
72
|
* Please keep in mind that the helpers under the `kysely/helpers` folder, including
|
|
72
|
-
* `jsonObjectFrom`, are not guaranteed to work with
|
|
73
|
+
* `jsonObjectFrom`, are not guaranteed to work with third-party dialects. In order for
|
|
73
74
|
* them to work, the dialect must automatically parse the `json` data type into
|
|
74
|
-
*
|
|
75
|
+
* JavaScript JSON values like objects and arrays. Some dialects might simply return
|
|
75
76
|
* the data as a JSON string. In these cases you can use the built in `ParseJSONResultsPlugin`
|
|
76
77
|
* to parse the results.
|
|
77
78
|
*
|
|
@@ -109,12 +110,11 @@ exports.jsonArrayFrom = jsonArrayFrom;
|
|
|
109
110
|
function jsonObjectFrom(expr) {
|
|
110
111
|
return (0, sql_js_1.sql) `(select to_json(obj) from ${expr} as obj)`;
|
|
111
112
|
}
|
|
112
|
-
exports.jsonObjectFrom = jsonObjectFrom;
|
|
113
113
|
/**
|
|
114
114
|
* The PostgreSQL `json_build_object` function.
|
|
115
115
|
*
|
|
116
116
|
* NOTE: This helper is only guaranteed to fully work with the built-in `PostgresDialect`.
|
|
117
|
-
* While the produced SQL is compatible with all PostgreSQL databases, some
|
|
117
|
+
* While the produced SQL is compatible with all PostgreSQL databases, some third-party dialects
|
|
118
118
|
* may not parse the nested JSON into objects. In these cases you can use the built in
|
|
119
119
|
* `ParseJSONResultsPlugin` to parse the results.
|
|
120
120
|
*
|
|
@@ -153,4 +153,3 @@ exports.jsonObjectFrom = jsonObjectFrom;
|
|
|
153
153
|
function jsonBuildObject(obj) {
|
|
154
154
|
return (0, sql_js_1.sql) `json_build_object(${sql_js_1.sql.join(Object.keys(obj).flatMap((k) => [sql_js_1.sql.lit(k), obj[k]]))})`;
|
|
155
155
|
}
|
|
156
|
-
exports.jsonBuildObject = jsonBuildObject;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.jsonArrayFrom = jsonArrayFrom;
|
|
4
|
+
exports.jsonObjectFrom = jsonObjectFrom;
|
|
5
|
+
exports.jsonBuildObject = jsonBuildObject;
|
|
4
6
|
const sql_js_1 = require("../raw-builder/sql.js");
|
|
5
7
|
const json_object_args_js_1 = require("../util/json-object-args.js");
|
|
6
8
|
/**
|
|
@@ -59,7 +61,6 @@ const json_object_args_js_1 = require("../util/json-object-args.js");
|
|
|
59
61
|
function jsonArrayFrom(expr) {
|
|
60
62
|
return (0, sql_js_1.sql) `(select coalesce(json_group_array(json_object(${sql_js_1.sql.join(getSqliteJsonObjectArgs(expr.toOperationNode(), 'agg'))})), '[]') from ${expr} as agg)`;
|
|
61
63
|
}
|
|
62
|
-
exports.jsonArrayFrom = jsonArrayFrom;
|
|
63
64
|
/**
|
|
64
65
|
* A SQLite helper for turning a subquery into a JSON object.
|
|
65
66
|
*
|
|
@@ -118,7 +119,6 @@ exports.jsonArrayFrom = jsonArrayFrom;
|
|
|
118
119
|
function jsonObjectFrom(expr) {
|
|
119
120
|
return (0, sql_js_1.sql) `(select json_object(${sql_js_1.sql.join(getSqliteJsonObjectArgs(expr.toOperationNode(), 'obj'))}) from ${expr} as obj)`;
|
|
120
121
|
}
|
|
121
|
-
exports.jsonObjectFrom = jsonObjectFrom;
|
|
122
122
|
/**
|
|
123
123
|
* The SQLite `json_object` function.
|
|
124
124
|
*
|
|
@@ -169,7 +169,6 @@ exports.jsonObjectFrom = jsonObjectFrom;
|
|
|
169
169
|
function jsonBuildObject(obj) {
|
|
170
170
|
return (0, sql_js_1.sql) `json_object(${sql_js_1.sql.join(Object.keys(obj).flatMap((k) => [sql_js_1.sql.lit(k), obj[k]]))})`;
|
|
171
171
|
}
|
|
172
|
-
exports.jsonBuildObject = jsonBuildObject;
|
|
173
172
|
function getSqliteJsonObjectArgs(node, table) {
|
|
174
173
|
try {
|
|
175
174
|
return (0, json_object_args_js_1.getJsonObjectArgs)(node, table);
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export { ExpressionBuilder, expressionBuilder, } from './expression/expression-b
|
|
|
5
5
|
export * from './expression/expression-wrapper.js';
|
|
6
6
|
export * from './query-builder/where-interface.js';
|
|
7
7
|
export * from './query-builder/returning-interface.js';
|
|
8
|
+
export * from './query-builder/output-interface.js';
|
|
8
9
|
export * from './query-builder/having-interface.js';
|
|
9
10
|
export * from './query-builder/select-query-builder.js';
|
|
10
11
|
export * from './query-builder/insert-query-builder.js';
|
|
@@ -20,6 +21,8 @@ export * from './query-builder/on-conflict-builder.js';
|
|
|
20
21
|
export * from './query-builder/aggregate-function-builder.js';
|
|
21
22
|
export * from './query-builder/case-builder.js';
|
|
22
23
|
export * from './query-builder/json-path-builder.js';
|
|
24
|
+
export * from './query-builder/merge-query-builder.js';
|
|
25
|
+
export * from './query-builder/merge-result.js';
|
|
23
26
|
export * from './raw-builder/raw-builder.js';
|
|
24
27
|
export * from './raw-builder/sql.js';
|
|
25
28
|
export * from './query-executor/query-executor.js';
|
|
@@ -89,17 +92,21 @@ export * from './plugin/with-schema/with-schema-plugin.js';
|
|
|
89
92
|
export * from './plugin/parse-json-results/parse-json-results-plugin.js';
|
|
90
93
|
export * from './operation-node/add-column-node.js';
|
|
91
94
|
export * from './operation-node/add-constraint-node.js';
|
|
95
|
+
export * from './operation-node/add-index-node.js';
|
|
96
|
+
export * from './operation-node/aggregate-function-node.js';
|
|
92
97
|
export * from './operation-node/alias-node.js';
|
|
93
98
|
export * from './operation-node/alter-column-node.js';
|
|
94
99
|
export * from './operation-node/alter-table-node.js';
|
|
95
100
|
export * from './operation-node/and-node.js';
|
|
101
|
+
export * from './operation-node/binary-operation-node.js';
|
|
96
102
|
export * from './operation-node/case-node.js';
|
|
103
|
+
export * from './operation-node/cast-node.js';
|
|
97
104
|
export * from './operation-node/check-constraint-node.js';
|
|
98
105
|
export * from './operation-node/column-definition-node.js';
|
|
99
106
|
export * from './operation-node/column-node.js';
|
|
100
107
|
export * from './operation-node/column-update-node.js';
|
|
101
|
-
export * from './operation-node/common-table-expression-node.js';
|
|
102
108
|
export * from './operation-node/common-table-expression-name-node.js';
|
|
109
|
+
export * from './operation-node/common-table-expression-node.js';
|
|
103
110
|
export * from './operation-node/constraint-node.js';
|
|
104
111
|
export * from './operation-node/create-index-node.js';
|
|
105
112
|
export * from './operation-node/create-schema-node.js';
|
|
@@ -107,6 +114,7 @@ export * from './operation-node/create-table-node.js';
|
|
|
107
114
|
export * from './operation-node/create-type-node.js';
|
|
108
115
|
export * from './operation-node/create-view-node.js';
|
|
109
116
|
export * from './operation-node/data-type-node.js';
|
|
117
|
+
export * from './operation-node/default-insert-value-node.js';
|
|
110
118
|
export * from './operation-node/default-value-node.js';
|
|
111
119
|
export * from './operation-node/delete-query-node.js';
|
|
112
120
|
export * from './operation-node/drop-column-node.js';
|
|
@@ -116,8 +124,11 @@ export * from './operation-node/drop-schema-node.js';
|
|
|
116
124
|
export * from './operation-node/drop-table-node.js';
|
|
117
125
|
export * from './operation-node/drop-type-node.js';
|
|
118
126
|
export * from './operation-node/drop-view-node.js';
|
|
127
|
+
export * from './operation-node/explain-node.js';
|
|
128
|
+
export * from './operation-node/fetch-node.js';
|
|
119
129
|
export * from './operation-node/foreign-key-constraint-node.js';
|
|
120
130
|
export * from './operation-node/from-node.js';
|
|
131
|
+
export * from './operation-node/function-node.js';
|
|
121
132
|
export * from './operation-node/generated-node.js';
|
|
122
133
|
export * from './operation-node/group-by-item-node.js';
|
|
123
134
|
export * from './operation-node/group-by-node.js';
|
|
@@ -125,8 +136,14 @@ export * from './operation-node/having-node.js';
|
|
|
125
136
|
export * from './operation-node/identifier-node.js';
|
|
126
137
|
export * from './operation-node/insert-query-node.js';
|
|
127
138
|
export * from './operation-node/join-node.js';
|
|
139
|
+
export * from './operation-node/json-operator-chain-node.js';
|
|
140
|
+
export * from './operation-node/json-path-leg-node.js';
|
|
141
|
+
export * from './operation-node/json-path-node.js';
|
|
142
|
+
export * from './operation-node/json-reference-node.js';
|
|
128
143
|
export * from './operation-node/limit-node.js';
|
|
129
144
|
export * from './operation-node/list-node.js';
|
|
145
|
+
export * from './operation-node/matched-node.js';
|
|
146
|
+
export * from './operation-node/merge-query-node.js';
|
|
130
147
|
export * from './operation-node/modify-column-node.js';
|
|
131
148
|
export * from './operation-node/offset-node.js';
|
|
132
149
|
export * from './operation-node/on-conflict-node.js';
|
|
@@ -140,7 +157,11 @@ export * from './operation-node/operator-node.js';
|
|
|
140
157
|
export * from './operation-node/or-node.js';
|
|
141
158
|
export * from './operation-node/order-by-item-node.js';
|
|
142
159
|
export * from './operation-node/order-by-node.js';
|
|
160
|
+
export * from './operation-node/output-node.js';
|
|
161
|
+
export * from './operation-node/over-node.js';
|
|
143
162
|
export * from './operation-node/parens-node.js';
|
|
163
|
+
export * from './operation-node/partition-by-item-node.js';
|
|
164
|
+
export * from './operation-node/partition-by-node.js';
|
|
144
165
|
export * from './operation-node/primary-constraint-node.js';
|
|
145
166
|
export * from './operation-node/primitive-value-list-node.js';
|
|
146
167
|
export * from './operation-node/query-node.js';
|
|
@@ -149,34 +170,26 @@ export * from './operation-node/reference-node.js';
|
|
|
149
170
|
export * from './operation-node/references-node.js';
|
|
150
171
|
export * from './operation-node/rename-column-node.js';
|
|
151
172
|
export * from './operation-node/returning-node.js';
|
|
173
|
+
export * from './operation-node/schemable-identifier-node.js';
|
|
152
174
|
export * from './operation-node/select-all-node.js';
|
|
153
|
-
export * from './operation-node/select-
|
|
175
|
+
export * from './operation-node/select-modifier-node.js';
|
|
154
176
|
export * from './operation-node/select-query-node.js';
|
|
155
177
|
export * from './operation-node/selection-node.js';
|
|
178
|
+
export * from './operation-node/set-operation-node.js';
|
|
179
|
+
export * from './operation-node/simple-reference-expression-node.js';
|
|
156
180
|
export * from './operation-node/table-node.js';
|
|
181
|
+
export * from './operation-node/top-node.js';
|
|
182
|
+
export * from './operation-node/tuple-node.js';
|
|
183
|
+
export * from './operation-node/unary-operation-node.js';
|
|
157
184
|
export * from './operation-node/unique-constraint-node.js';
|
|
158
185
|
export * from './operation-node/update-query-node.js';
|
|
186
|
+
export * from './operation-node/using-node.js';
|
|
159
187
|
export * from './operation-node/value-list-node.js';
|
|
160
188
|
export * from './operation-node/value-node.js';
|
|
161
189
|
export * from './operation-node/values-node.js';
|
|
162
190
|
export * from './operation-node/when-node.js';
|
|
163
191
|
export * from './operation-node/where-node.js';
|
|
164
192
|
export * from './operation-node/with-node.js';
|
|
165
|
-
export * from './operation-node/explain-node.js';
|
|
166
|
-
export * from './operation-node/default-insert-value-node.js';
|
|
167
|
-
export * from './operation-node/aggregate-function-node.js';
|
|
168
|
-
export * from './operation-node/over-node.js';
|
|
169
|
-
export * from './operation-node/partition-by-node.js';
|
|
170
|
-
export * from './operation-node/partition-by-item-node.js';
|
|
171
|
-
export * from './operation-node/set-operation-node.js';
|
|
172
|
-
export * from './operation-node/binary-operation-node.js';
|
|
173
|
-
export * from './operation-node/unary-operation-node.js';
|
|
174
|
-
export * from './operation-node/using-node.js';
|
|
175
|
-
export * from './operation-node/json-reference-node.js';
|
|
176
|
-
export * from './operation-node/json-path-leg-node.js';
|
|
177
|
-
export * from './operation-node/json-path-node.js';
|
|
178
|
-
export * from './operation-node/json-operator-chain-node.js';
|
|
179
|
-
export * from './operation-node/tuple-node.js';
|
|
180
193
|
export * from './util/column-type.js';
|
|
181
194
|
export * from './util/compilable.js';
|
|
182
195
|
export * from './util/explainable.js';
|
|
@@ -188,7 +201,7 @@ export { logOnce } from './util/log-once.js';
|
|
|
188
201
|
export { SelectExpression, SelectCallback, SelectArg, Selection, CallbackSelection, } from './parser/select-parser.js';
|
|
189
202
|
export { ReferenceExpression, ReferenceExpressionOrList, SimpleReferenceExpression, StringReference, ExtractTypeFromStringReference, ExtractTypeFromReferenceExpression, } from './parser/reference-parser.js';
|
|
190
203
|
export { ValueExpression, ValueExpressionOrList, } from './parser/value-parser.js';
|
|
191
|
-
export { TableExpression, TableExpressionOrList, } from './parser/table-parser.js';
|
|
204
|
+
export { SimpleTableReference, TableExpression, TableExpressionOrList, } from './parser/table-parser.js';
|
|
192
205
|
export { JoinReferenceExpression, JoinCallbackExpression, } from './parser/join-parser.js';
|
|
193
206
|
export { InsertObject } from './parser/insert-values-parser.js';
|
|
194
207
|
export { UpdateObject } from './parser/update-set-parser.js';
|