kysely 0.27.3 → 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/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/postgres/postgres-introspector.js +1 -1
- package/dist/cjs/driver/database-connection.d.ts +3 -1
- 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 +2 -2
- package/dist/cjs/expression/expression-builder.js +2 -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 +28 -21
- package/dist/cjs/index.js +28 -21
- package/dist/cjs/kysely.d.ts +1 -1
- package/dist/cjs/kysely.js +3 -3
- package/dist/cjs/operation-node/alter-column-node.d.ts +1 -1
- package/dist/cjs/operation-node/case-node.d.ts +1 -1
- package/dist/cjs/operation-node/column-definition-node.d.ts +1 -0
- package/dist/cjs/operation-node/data-type-node.d.ts +2 -2
- package/dist/cjs/operation-node/data-type-node.js +5 -3
- package/dist/cjs/operation-node/delete-query-node.d.ts +2 -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 +2 -0
- package/dist/cjs/operation-node/merge-query-node.d.ts +2 -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 +2 -0
- package/dist/cjs/operation-node/operation-node-transformer.js +12 -0
- package/dist/cjs/operation-node/operation-node-visitor.d.ts +2 -0
- package/dist/cjs/operation-node/operation-node-visitor.js +1 -0
- package/dist/cjs/operation-node/operation-node.d.ts +1 -1
- package/dist/cjs/operation-node/operator-node.d.ts +3 -3
- package/dist/cjs/operation-node/operator-node.js +8 -6
- package/dist/cjs/operation-node/output-node.d.ts +13 -0
- package/dist/cjs/operation-node/output-node.js +26 -0
- package/dist/cjs/operation-node/query-node.d.ts +11 -6
- package/dist/cjs/operation-node/query-node.js +9 -0
- package/dist/cjs/operation-node/select-query-node.d.ts +1 -0
- package/dist/cjs/operation-node/select-query-node.js +6 -0
- package/dist/cjs/operation-node/update-query-node.d.ts +2 -0
- package/dist/cjs/operation-node/where-node.d.ts +1 -1
- package/dist/cjs/parser/binary-operation-parser.js +5 -6
- package/dist/cjs/parser/data-type-parser.js +1 -2
- package/dist/cjs/parser/default-value-parser.js +1 -2
- package/dist/cjs/parser/expression-parser.js +3 -4
- package/dist/cjs/parser/fetch-parser.js +1 -2
- package/dist/cjs/parser/group-by-parser.js +1 -2
- package/dist/cjs/parser/identifier-parser.js +1 -2
- package/dist/cjs/parser/insert-values-parser.js +1 -2
- package/dist/cjs/parser/join-parser.js +1 -2
- package/dist/cjs/parser/merge-parser.js +2 -3
- package/dist/cjs/parser/on-commit-action-parse.js +1 -2
- package/dist/cjs/parser/on-modify-action-parser.js +1 -2
- package/dist/cjs/parser/order-by-parser.js +3 -4
- package/dist/cjs/parser/parse-utils.js +4 -5
- package/dist/cjs/parser/partition-by-parser.js +1 -2
- package/dist/cjs/parser/reference-parser.js +8 -9
- package/dist/cjs/parser/returning-parser.d.ts +4 -3
- package/dist/cjs/parser/select-parser.js +2 -3
- package/dist/cjs/parser/set-operation-parser.js +1 -2
- package/dist/cjs/parser/table-parser.js +4 -5
- package/dist/cjs/parser/top-parser.js +1 -2
- package/dist/cjs/parser/unary-operation-parser.js +3 -4
- package/dist/cjs/parser/update-set-parser.js +2 -3
- package/dist/cjs/parser/value-parser.js +4 -5
- package/dist/cjs/parser/with-parser.js +1 -2
- package/dist/cjs/plugin/camel-case/camel-case-plugin.d.ts +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/query-builder/delete-query-builder.d.ts +89 -5
- package/dist/cjs/query-builder/delete-query-builder.js +19 -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 +95 -10
- package/dist/cjs/query-builder/insert-query-builder.js +25 -10
- package/dist/cjs/query-builder/merge-query-builder.d.ts +167 -3
- package/dist/cjs/query-builder/merge-query-builder.js +30 -1
- 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 +76 -11
- package/dist/cjs/query-builder/select-query-builder.js +7 -2
- package/dist/cjs/query-builder/update-query-builder.d.ts +95 -10
- package/dist/cjs/query-builder/update-query-builder.js +21 -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 +2 -0
- package/dist/cjs/query-compiler/default-query-compiler.js +25 -1
- package/dist/cjs/query-creator.d.ts +56 -3
- package/dist/cjs/query-creator.js +54 -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 +1 -1
- package/dist/cjs/schema/alter-table-builder.js +1 -2
- package/dist/cjs/schema/column-definition-builder.d.ts +5 -0
- package/dist/cjs/schema/column-definition-builder.js +7 -0
- package/dist/cjs/util/assert.js +2 -3
- package/dist/cjs/util/compilable.js +1 -2
- package/dist/cjs/util/json-object-args.js +1 -2
- package/dist/cjs/util/log-once.js +1 -2
- package/dist/cjs/util/object-utils.js +38 -26
- package/dist/cjs/util/performance-now.js +1 -2
- package/dist/cjs/util/prevent-await.js +1 -2
- package/dist/cjs/util/query-id.js +1 -2
- package/dist/cjs/util/random-string.js +1 -2
- package/dist/cjs/util/require-all-props.js +1 -2
- package/dist/cjs/util/stack-trace-utils.js +1 -2
- 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/postgres/postgres-introspector.js +1 -1
- package/dist/esm/driver/database-connection.d.ts +3 -1
- 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 +2 -2
- 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 +28 -21
- package/dist/esm/index.js +28 -21
- package/dist/esm/kysely.d.ts +1 -1
- package/dist/esm/kysely.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/column-definition-node.d.ts +1 -0
- package/dist/esm/operation-node/data-type-node.d.ts +2 -2
- package/dist/esm/operation-node/data-type-node.js +3 -1
- package/dist/esm/operation-node/delete-query-node.d.ts +2 -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 +2 -0
- package/dist/esm/operation-node/merge-query-node.d.ts +2 -0
- package/dist/esm/operation-node/on-node.d.ts +1 -1
- package/dist/esm/operation-node/operation-node-transformer.d.ts +2 -0
- package/dist/esm/operation-node/operation-node-transformer.js +12 -0
- package/dist/esm/operation-node/operation-node-visitor.d.ts +2 -0
- package/dist/esm/operation-node/operation-node-visitor.js +1 -0
- package/dist/esm/operation-node/operation-node.d.ts +1 -1
- package/dist/esm/operation-node/operator-node.d.ts +3 -3
- package/dist/esm/operation-node/operator-node.js +2 -0
- package/dist/esm/operation-node/output-node.d.ts +13 -0
- package/dist/esm/operation-node/output-node.js +24 -0
- package/dist/esm/operation-node/query-node.d.ts +11 -6
- package/dist/esm/operation-node/query-node.js +9 -0
- package/dist/esm/operation-node/select-query-node.d.ts +1 -0
- package/dist/esm/operation-node/select-query-node.js +6 -0
- package/dist/esm/operation-node/update-query-node.d.ts +2 -0
- package/dist/esm/operation-node/where-node.d.ts +1 -1
- package/dist/esm/parser/returning-parser.d.ts +4 -3
- package/dist/esm/plugin/camel-case/camel-case-plugin.d.ts +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/query-builder/delete-query-builder.d.ts +89 -5
- package/dist/esm/query-builder/delete-query-builder.js +19 -5
- package/dist/esm/query-builder/function-module.d.ts +5 -5
- package/dist/esm/query-builder/insert-query-builder.d.ts +95 -10
- package/dist/esm/query-builder/insert-query-builder.js +25 -10
- package/dist/esm/query-builder/merge-query-builder.d.ts +167 -3
- package/dist/esm/query-builder/merge-query-builder.js +30 -1
- 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 +76 -11
- package/dist/esm/query-builder/select-query-builder.js +6 -0
- package/dist/esm/query-builder/update-query-builder.d.ts +95 -10
- package/dist/esm/query-builder/update-query-builder.js +21 -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 +2 -0
- package/dist/esm/query-compiler/default-query-compiler.js +25 -1
- package/dist/esm/query-creator.d.ts +56 -3
- package/dist/esm/query-creator.js +54 -1
- 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 +1 -1
- package/dist/esm/schema/alter-table-builder.js +1 -2
- package/dist/esm/schema/column-definition-builder.d.ts +5 -0
- package/dist/esm/schema/column-definition-builder.js +7 -0
- package/dist/esm/util/object-utils.js +18 -5
- package/package.json +7 -6
package/CONTRIBUTING.md
CHANGED
|
@@ -15,7 +15,7 @@ There are quite a few guidelines to keep in mind:
|
|
|
15
15
|
|
|
16
16
|
* Kysely should have zero dependencies.
|
|
17
17
|
|
|
18
|
-
* Kysely should work in all
|
|
18
|
+
* Kysely should work in all JavaScript environments (node.js, deno & modern browsers),
|
|
19
19
|
even though the main focus is node.js.
|
|
20
20
|
|
|
21
21
|
* Everything is immutable.
|
package/README.md
CHANGED
|
@@ -5,16 +5,16 @@
|
|
|
5
5
|
[](https://github.com/kysely-org/kysely/blob/master/LICENSE)
|
|
6
6
|
[](https://github.com/kysely-org/kysely/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc)
|
|
7
7
|
[](https://github.com/kysely-org/kysely/pulls?q=is%3Apr+is%3Aopen+sort%3Aupdated-desc)
|
|
8
|
-
[](https://snyk.io/advisor/npm-package/kysely)
|
|
9
8
|
[](https://www.npmjs.com/package/kysely)
|
|
10
9
|
[](https://bundlephobia.com/package/kysely)
|
|
11
10
|
[](https://twitter.com/kysely_)
|
|
12
11
|
|
|
13
12
|
# [Kysely](https://kysely.dev)
|
|
14
13
|
|
|
15
|
-
Kysely (pronounce “Key-Seh-Lee”) is a type-safe and autocompletion-friendly
|
|
16
|
-
Inspired by [
|
|
17
|
-
runs on all other
|
|
14
|
+
Kysely (pronounce “Key-Seh-Lee”) is a type-safe and autocompletion-friendly [TypeScript](https://www.typescriptlang.org/) [SQL](https://en.wikipedia.org/wiki/SQL) query builder.
|
|
15
|
+
Inspired by [Knex.js](http://knexjs.org/). Mainly developed for [Node.js](https://nodejs.org/en/) but also
|
|
16
|
+
runs on all other [JavaScript](https://developer.mozilla.org/en-US/docs/Web/JavaScript) environments like [Deno](https://deno.com/), [Bun](https://bun.sh/), [Cloudflare Workers](https://workers.cloudflare.com/)
|
|
17
|
+
and web browsers.
|
|
18
18
|
|
|
19
19
|

|
|
20
20
|
|
|
@@ -22,7 +22,7 @@ Kysely makes sure you only refer to tables and columns that are visible to the p
|
|
|
22
22
|
you're writing. The result type only has the selected columns with correct types and aliases. As an
|
|
23
23
|
added bonus you get autocompletion for all that stuff.
|
|
24
24
|
|
|
25
|
-
As shown in the gif above, through the pure magic of modern
|
|
25
|
+
As shown in the gif above, through the pure magic of modern TypeScript, Kysely is even able to parse
|
|
26
26
|
the alias given to `pet.name` and add the `pet_name` column to the result row type. Kysely is able to infer
|
|
27
27
|
column names, aliases and types from selected subqueries, joined subqueries, `with` statements and pretty
|
|
28
28
|
much anything you can think of.
|
|
@@ -35,12 +35,12 @@ All API documentation is written in the typing files and you can simply hover ov
|
|
|
35
35
|
or method you're using to see it in your IDE. The same documentation is also hosted [here](https://kysely-org.github.io/kysely-apidoc/).
|
|
36
36
|
|
|
37
37
|
If you start using Kysely and can't find something you'd want to use, please open an issue or join our
|
|
38
|
-
[
|
|
38
|
+
[Discord server](https://discord.gg/xyBJ3GwvAm).
|
|
39
39
|
|
|
40
40
|
# Getting started
|
|
41
41
|
|
|
42
42
|
Please visit our documentation site [kysely.dev](https://kysely.dev) to get started. We also have a comprehensive
|
|
43
|
-
API documentation hosted [here](https://kysely-org.github.io/kysely-apidoc/) but you can access the same
|
|
43
|
+
API documentation hosted [here](https://kysely-org.github.io/kysely-apidoc/), but you can access the same
|
|
44
44
|
documentation in your IDE by hovering over a class/method/property/whatever.
|
|
45
45
|
|
|
46
46
|
# Contributors
|
|
@@ -2,7 +2,7 @@ import { Kysely } from '../kysely.js';
|
|
|
2
2
|
import { DialectAdapter, MigrationLockOptions } from './dialect-adapter.js';
|
|
3
3
|
/**
|
|
4
4
|
* A basic implementation of `DialectAdapter` with sensible default values.
|
|
5
|
-
*
|
|
5
|
+
* Third-party dialects can extend this instead of implementing the `DialectAdapter`
|
|
6
6
|
* interface from scratch. That way all new settings will get default values when
|
|
7
7
|
* they are added and there will be less breaking changes.
|
|
8
8
|
*/
|
|
@@ -26,6 +26,7 @@ export declare abstract class DialectAdapterBase implements DialectAdapter {
|
|
|
26
26
|
* updates and deletes.
|
|
27
27
|
*/
|
|
28
28
|
get supportsReturning(): boolean;
|
|
29
|
+
get supportsOutput(): boolean;
|
|
29
30
|
/**
|
|
30
31
|
* This method is used to acquire a lock for the migrations so that
|
|
31
32
|
* it's not possible for two migration operations to run in parallel.
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.DialectAdapterBase = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* A basic implementation of `DialectAdapter` with sensible default values.
|
|
6
|
-
*
|
|
6
|
+
* Third-party dialects can extend this instead of implementing the `DialectAdapter`
|
|
7
7
|
* interface from scratch. That way all new settings will get default values when
|
|
8
8
|
* they are added and there will be less breaking changes.
|
|
9
9
|
*/
|
|
@@ -17,5 +17,8 @@ class DialectAdapterBase {
|
|
|
17
17
|
get supportsReturning() {
|
|
18
18
|
return false;
|
|
19
19
|
}
|
|
20
|
+
get supportsOutput() {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
20
23
|
}
|
|
21
24
|
exports.DialectAdapterBase = DialectAdapterBase;
|
|
@@ -27,6 +27,11 @@ export interface DialectAdapter {
|
|
|
27
27
|
* updates and deletes.
|
|
28
28
|
*/
|
|
29
29
|
readonly supportsReturning: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Whether or not this dialect supports the `output` clause in inserts
|
|
32
|
+
* updates and deletes.
|
|
33
|
+
*/
|
|
34
|
+
readonly supportsOutput?: boolean;
|
|
30
35
|
/**
|
|
31
36
|
* This method is used to acquire a lock for the migrations so that
|
|
32
37
|
* it's not possible for two migration operations to run in parallel.
|
|
@@ -15,11 +15,7 @@ export declare class MssqlAdapter extends DialectAdapterBase {
|
|
|
15
15
|
* If this is true, migrations are executed inside a transaction.
|
|
16
16
|
*/
|
|
17
17
|
get supportsTransactionalDdl(): boolean;
|
|
18
|
-
|
|
19
|
-
* Whether or not this dialect supports the `returning` in inserts
|
|
20
|
-
* updates and deletes.
|
|
21
|
-
*/
|
|
22
|
-
get supportsReturning(): boolean;
|
|
18
|
+
get supportsOutput(): boolean;
|
|
23
19
|
/**
|
|
24
20
|
* This method is used to acquire a lock for the migrations so that
|
|
25
21
|
* it's not possible for two migration operations to run in parallel.
|
|
@@ -11,10 +11,8 @@ class MssqlAdapter extends dialect_adapter_base_js_1.DialectAdapterBase {
|
|
|
11
11
|
get supportsTransactionalDdl() {
|
|
12
12
|
return true;
|
|
13
13
|
}
|
|
14
|
-
get
|
|
15
|
-
|
|
16
|
-
// we need to figure this out when we'll introduce support for it.
|
|
17
|
-
return false;
|
|
14
|
+
get supportsOutput() {
|
|
15
|
+
return true;
|
|
18
16
|
}
|
|
19
17
|
async acquireMigrationLock(db) {
|
|
20
18
|
// Acquire a transaction-level exclusive lock on the migrations table.
|
|
@@ -50,39 +50,59 @@ export interface MssqlDialectConfig {
|
|
|
50
50
|
export interface Tedious {
|
|
51
51
|
connectionFactory: () => TediousConnection | Promise<TediousConnection>;
|
|
52
52
|
ISOLATION_LEVEL: TediousIsolationLevel;
|
|
53
|
-
Request:
|
|
53
|
+
Request: TediousRequestClass;
|
|
54
54
|
TYPES: TediousTypes;
|
|
55
55
|
}
|
|
56
|
-
export type TediousIsolationLevel = Record<'NO_CHANGE' | 'READ_UNCOMMITTED' | 'READ_COMMITTED' | 'REPEATABLE_READ' | 'SERIALIZABLE' | 'SNAPSHOT', number>;
|
|
57
|
-
export type TediousTypes = Record<'BigInt' | 'Binary' | 'Bit' | 'Char' | 'Date' | 'DateTime' | 'DateTime2' | 'DateTimeOffset' | 'Decimal' | 'Float' | 'Image' | 'Int' | 'Money' | 'NChar' | 'NText' | 'Null' | 'Numeric' | 'NVarChar' | 'Real' | 'SmallDateTime' | 'SmallInt' | 'SmallMoney' | 'Text' | 'Time' | 'TinyInt' | 'TVP' | 'UDT' | 'UniqueIdentifier' | 'VarBinary' | 'VarChar' | 'Xml', {
|
|
58
|
-
name: string;
|
|
59
|
-
type: string;
|
|
60
|
-
}>;
|
|
61
|
-
export interface TediousType {
|
|
62
|
-
name: string;
|
|
63
|
-
type: string;
|
|
64
|
-
}
|
|
65
56
|
export interface TediousConnection {
|
|
66
|
-
beginTransaction(callback: (error?: Error) => void,
|
|
67
|
-
cancel():
|
|
57
|
+
beginTransaction(callback: (error?: Error | null, transactionDescriptor?: any) => void, name?: string, isolationLevel?: number): void;
|
|
58
|
+
cancel(): boolean;
|
|
68
59
|
close(): void;
|
|
69
|
-
commitTransaction(callback: (error?: Error) => void): void;
|
|
70
|
-
connect(callback
|
|
60
|
+
commitTransaction(callback: (error?: Error | null) => void, name?: string): void;
|
|
61
|
+
connect(callback?: (error?: Error) => void): void;
|
|
71
62
|
execSql(request: TediousRequest): void;
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
63
|
+
off(event: 'error', listener: (error: unknown) => void): this;
|
|
64
|
+
off(event: string, listener: (...args: any[]) => void): this;
|
|
65
|
+
on(event: 'error', listener: (error: unknown) => void): this;
|
|
66
|
+
on(event: string, listener: (...args: any[]) => void): this;
|
|
67
|
+
once(event: 'end', listener: () => void): this;
|
|
68
|
+
once(event: string, listener: (...args: any[]) => void): this;
|
|
69
|
+
reset(callback: (error?: Error | null) => void): void;
|
|
70
|
+
rollbackTransaction(callback: (error?: Error | null) => void, name?: string): void;
|
|
71
|
+
saveTransaction(callback: (error?: Error | null) => void, name: string): void;
|
|
72
|
+
}
|
|
73
|
+
export type TediousIsolationLevel = Record<string, number>;
|
|
74
|
+
export interface TediousRequestClass {
|
|
75
|
+
new (sqlTextOrProcedure: string | undefined, callback: (error?: Error | null, rowCount?: number, rows?: any) => void, options?: {
|
|
76
|
+
statementColumnEncryptionSetting?: any;
|
|
77
|
+
}): TediousRequest;
|
|
75
78
|
}
|
|
76
79
|
export declare class TediousRequest {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
length?: number
|
|
80
|
-
precision?: number
|
|
81
|
-
scale?: number
|
|
82
|
-
}): void;
|
|
83
|
-
off(event: 'row', listener: (
|
|
84
|
-
|
|
85
|
-
|
|
80
|
+
addParameter(name: string, dataType: TediousDataType, value?: unknown, options?: Readonly<{
|
|
81
|
+
output?: boolean;
|
|
82
|
+
length?: number;
|
|
83
|
+
precision?: number;
|
|
84
|
+
scale?: number;
|
|
85
|
+
}> | null): void;
|
|
86
|
+
off(event: 'row', listener: (columns: any) => void): this;
|
|
87
|
+
off(event: string, listener: (...args: any[]) => void): this;
|
|
88
|
+
on(event: 'row', listener: (columns: any) => void): this;
|
|
89
|
+
on(event: string, listener: (...args: any[]) => void): this;
|
|
90
|
+
once(event: 'requestCompleted', listener: () => void): this;
|
|
91
|
+
once(event: string, listener: (...args: any[]) => void): this;
|
|
92
|
+
pause(): void;
|
|
93
|
+
resume(): void;
|
|
94
|
+
}
|
|
95
|
+
export interface TediousTypes {
|
|
96
|
+
NVarChar: TediousDataType;
|
|
97
|
+
BigInt: TediousDataType;
|
|
98
|
+
Int: TediousDataType;
|
|
99
|
+
Float: TediousDataType;
|
|
100
|
+
Bit: TediousDataType;
|
|
101
|
+
DateTime: TediousDataType;
|
|
102
|
+
VarBinary: TediousDataType;
|
|
103
|
+
[x: string]: TediousDataType;
|
|
104
|
+
}
|
|
105
|
+
export interface TediousDataType {
|
|
86
106
|
}
|
|
87
107
|
export interface TediousColumnValue {
|
|
88
108
|
metadata: {
|
|
@@ -44,6 +44,7 @@ declare class MssqlConnection implements DatabaseConnection {
|
|
|
44
44
|
constructor(connection: TediousConnection, tedious: Tedious);
|
|
45
45
|
beginTransaction(settings: TransactionSettings): Promise<void>;
|
|
46
46
|
commitTransaction(): Promise<void>;
|
|
47
|
+
connect(): Promise<this>;
|
|
47
48
|
executeQuery<O>(compiledQuery: CompiledQuery): Promise<QueryResult<O>>;
|
|
48
49
|
rollbackTransaction(): Promise<void>;
|
|
49
50
|
streamQuery<O>(compiledQuery: CompiledQuery, chunkSize: number): AsyncIterableIterator<QueryResult<O>>;
|
|
@@ -17,13 +17,7 @@ class MssqlDriver {
|
|
|
17
17
|
...this.#config.tarn.options,
|
|
18
18
|
create: async () => {
|
|
19
19
|
const connection = await this.#config.tedious.connectionFactory();
|
|
20
|
-
await new
|
|
21
|
-
if (error)
|
|
22
|
-
reject(error);
|
|
23
|
-
else
|
|
24
|
-
resolve(undefined);
|
|
25
|
-
}));
|
|
26
|
-
return new MssqlConnection(connection, this.#config.tedious);
|
|
20
|
+
return await new MssqlConnection(connection, this.#config.tedious).connect();
|
|
27
21
|
},
|
|
28
22
|
destroy: async (connection) => {
|
|
29
23
|
await connection[PRIVATE_DESTROY_METHOD]();
|
|
@@ -63,6 +57,10 @@ class MssqlConnection {
|
|
|
63
57
|
constructor(connection, tedious) {
|
|
64
58
|
this.#connection = connection;
|
|
65
59
|
this.#tedious = tedious;
|
|
60
|
+
this.#connection.on('error', console.error);
|
|
61
|
+
this.#connection.once('end', () => {
|
|
62
|
+
this.#connection.off('error', console.error);
|
|
63
|
+
});
|
|
66
64
|
}
|
|
67
65
|
async beginTransaction(settings) {
|
|
68
66
|
const { isolationLevel } = settings;
|
|
@@ -83,10 +81,28 @@ class MssqlConnection {
|
|
|
83
81
|
resolve(undefined);
|
|
84
82
|
}));
|
|
85
83
|
}
|
|
84
|
+
async connect() {
|
|
85
|
+
await new Promise((resolve, reject) => {
|
|
86
|
+
this.#connection.connect((error) => {
|
|
87
|
+
if (error) {
|
|
88
|
+
console.error(error);
|
|
89
|
+
reject(error);
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
resolve(undefined);
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
return this;
|
|
97
|
+
}
|
|
86
98
|
async executeQuery(compiledQuery) {
|
|
87
99
|
try {
|
|
88
100
|
const deferred = new deferred_js_1.Deferred();
|
|
89
|
-
const request = new MssqlRequest(
|
|
101
|
+
const request = new MssqlRequest({
|
|
102
|
+
compiledQuery,
|
|
103
|
+
tedious: this.#tedious,
|
|
104
|
+
onDone: deferred,
|
|
105
|
+
});
|
|
90
106
|
this.#connection.execSql(request.request);
|
|
91
107
|
const { rowCount, rows } = await deferred.promise;
|
|
92
108
|
return {
|
|
@@ -110,11 +126,15 @@ class MssqlConnection {
|
|
|
110
126
|
if (!Number.isInteger(chunkSize) || chunkSize <= 0) {
|
|
111
127
|
throw new Error('chunkSize must be a positive integer');
|
|
112
128
|
}
|
|
113
|
-
const request = new MssqlRequest(
|
|
129
|
+
const request = new MssqlRequest({
|
|
130
|
+
compiledQuery,
|
|
131
|
+
streamChunkSize: chunkSize,
|
|
132
|
+
tedious: this.#tedious,
|
|
133
|
+
});
|
|
114
134
|
this.#connection.execSql(request.request);
|
|
115
135
|
try {
|
|
116
136
|
while (true) {
|
|
117
|
-
const rows = await request.readChunk(
|
|
137
|
+
const rows = await request.readChunk();
|
|
118
138
|
if (rows.length === 0) {
|
|
119
139
|
break;
|
|
120
140
|
}
|
|
@@ -125,13 +145,17 @@ class MssqlConnection {
|
|
|
125
145
|
}
|
|
126
146
|
}
|
|
127
147
|
finally {
|
|
128
|
-
this.#
|
|
148
|
+
await this.#cancelRequest(request);
|
|
129
149
|
}
|
|
130
150
|
}
|
|
131
151
|
async validate() {
|
|
132
152
|
try {
|
|
133
153
|
const deferred = new deferred_js_1.Deferred();
|
|
134
|
-
const request = new MssqlRequest(
|
|
154
|
+
const request = new MssqlRequest({
|
|
155
|
+
compiledQuery: compiled_query_js_1.CompiledQuery.raw('select 1'),
|
|
156
|
+
onDone: deferred,
|
|
157
|
+
tedious: this.#tedious,
|
|
158
|
+
});
|
|
135
159
|
this.#connection.execSql(request.request);
|
|
136
160
|
await deferred.promise;
|
|
137
161
|
return true;
|
|
@@ -155,6 +179,16 @@ class MssqlConnection {
|
|
|
155
179
|
}
|
|
156
180
|
return tediousIsolationLevel;
|
|
157
181
|
}
|
|
182
|
+
#cancelRequest(request) {
|
|
183
|
+
return new Promise((resolve) => {
|
|
184
|
+
request.request.once('requestCompleted', resolve);
|
|
185
|
+
const wasCanceled = this.#connection.cancel();
|
|
186
|
+
if (!wasCanceled) {
|
|
187
|
+
request.request.off('requestCompleted', resolve);
|
|
188
|
+
resolve(undefined);
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
}
|
|
158
192
|
[PRIVATE_RELEASE_METHOD]() {
|
|
159
193
|
return new Promise((resolve, reject) => {
|
|
160
194
|
this.#connection.reset((error) => {
|
|
@@ -177,42 +211,62 @@ class MssqlConnection {
|
|
|
177
211
|
class MssqlRequest {
|
|
178
212
|
#request;
|
|
179
213
|
#rows;
|
|
214
|
+
#streamChunkSize;
|
|
215
|
+
#subscribers;
|
|
180
216
|
#tedious;
|
|
181
|
-
#completed;
|
|
182
217
|
#error;
|
|
183
218
|
#rowCount;
|
|
184
|
-
constructor(
|
|
185
|
-
|
|
219
|
+
constructor(props) {
|
|
220
|
+
const { compiledQuery, onDone, streamChunkSize, tedious } = props;
|
|
186
221
|
this.#rows = [];
|
|
222
|
+
this.#streamChunkSize = streamChunkSize;
|
|
223
|
+
this.#subscribers = {};
|
|
187
224
|
this.#tedious = tedious;
|
|
188
|
-
|
|
189
|
-
|
|
225
|
+
if (onDone) {
|
|
226
|
+
const subscriptionKey = 'onDone';
|
|
227
|
+
this.#subscribers[subscriptionKey] = (event, error) => {
|
|
228
|
+
if (event === 'chunkReady') {
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
delete this.#subscribers[subscriptionKey];
|
|
232
|
+
if (event === 'error') {
|
|
233
|
+
onDone.reject(error);
|
|
234
|
+
}
|
|
235
|
+
else {
|
|
236
|
+
onDone.resolve({
|
|
237
|
+
rowCount: this.#rowCount,
|
|
238
|
+
rows: this.#rows,
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
this.#request = new this.#tedious.Request(compiledQuery.sql, (err, rowCount) => {
|
|
190
244
|
if (err) {
|
|
191
|
-
this.#error
|
|
192
|
-
onDone?.reject(this.#error);
|
|
245
|
+
Object.values(this.#subscribers).forEach((subscriber) => subscriber('error', err instanceof AggregateError ? err.errors : err));
|
|
193
246
|
}
|
|
194
247
|
else {
|
|
195
248
|
this.#rowCount = rowCount;
|
|
196
249
|
}
|
|
197
250
|
});
|
|
198
|
-
this.#addParametersToRequest(parameters);
|
|
199
|
-
this.#attachListeners(
|
|
251
|
+
this.#addParametersToRequest(compiledQuery.parameters);
|
|
252
|
+
this.#attachListeners();
|
|
200
253
|
}
|
|
201
254
|
get request() {
|
|
202
255
|
return this.#request;
|
|
203
256
|
}
|
|
204
|
-
readChunk(
|
|
257
|
+
readChunk() {
|
|
258
|
+
const subscriptionKey = this.readChunk.name;
|
|
205
259
|
return new Promise((resolve, reject) => {
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
reject(
|
|
260
|
+
this.#subscribers[subscriptionKey] = (event, error) => {
|
|
261
|
+
delete this.#subscribers[subscriptionKey];
|
|
262
|
+
if (event === 'error') {
|
|
263
|
+
reject(error);
|
|
210
264
|
}
|
|
211
|
-
else
|
|
212
|
-
|
|
213
|
-
resolve(this.#rows.splice(0, chunkSize));
|
|
265
|
+
else {
|
|
266
|
+
resolve(this.#rows.splice(0, this.#streamChunkSize));
|
|
214
267
|
}
|
|
215
|
-
}
|
|
268
|
+
};
|
|
269
|
+
this.#request.resume();
|
|
216
270
|
});
|
|
217
271
|
}
|
|
218
272
|
#addParametersToRequest(parameters) {
|
|
@@ -221,22 +275,27 @@ class MssqlRequest {
|
|
|
221
275
|
this.#request.addParameter(String(i + 1), this.#getTediousDataType(parameter), parameter);
|
|
222
276
|
}
|
|
223
277
|
}
|
|
224
|
-
#attachListeners(
|
|
278
|
+
#attachListeners() {
|
|
279
|
+
const pauseAndEmitChunkReady = this.#streamChunkSize
|
|
280
|
+
? () => {
|
|
281
|
+
if (this.#streamChunkSize <= this.#rows.length) {
|
|
282
|
+
this.#request.pause();
|
|
283
|
+
Object.values(this.#subscribers).forEach((subscriber) => subscriber('chunkReady'));
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
: () => { };
|
|
225
287
|
const rowListener = (columns) => {
|
|
226
288
|
const row = {};
|
|
227
289
|
for (const column of columns) {
|
|
228
290
|
row[column.metadata.colName] = column.value;
|
|
229
291
|
}
|
|
230
292
|
this.#rows.push(row);
|
|
293
|
+
pauseAndEmitChunkReady();
|
|
231
294
|
};
|
|
232
295
|
this.#request.on('row', rowListener);
|
|
233
296
|
this.#request.once('requestCompleted', () => {
|
|
234
|
-
this.#
|
|
297
|
+
Object.values(this.#subscribers).forEach((subscriber) => subscriber('completed'));
|
|
235
298
|
this.#request.off('row', rowListener);
|
|
236
|
-
onDone?.resolve({
|
|
237
|
-
rowCount: this.#rowCount,
|
|
238
|
-
rows: this.#rows,
|
|
239
|
-
});
|
|
240
299
|
});
|
|
241
300
|
}
|
|
242
301
|
#getTediousDataType(value) {
|
|
@@ -51,7 +51,7 @@ class PostgresIntrospector {
|
|
|
51
51
|
.as('auto_incrementing'),
|
|
52
52
|
])
|
|
53
53
|
// r == normal table
|
|
54
|
-
.where((eb) => eb.or([eb('c.relkind', '=', 'r'), eb('c.relkind', '=', 'v')]))
|
|
54
|
+
.where((eb) => eb.or([eb('c.relkind', '=', 'r'), eb('c.relkind', '=', 'v'), eb('c.relkind', '=', 'p')]))
|
|
55
55
|
.where('ns.nspname', '!~', '^pg_')
|
|
56
56
|
.where('ns.nspname', '!=', 'information_schema')
|
|
57
57
|
// No system columns
|
|
@@ -21,7 +21,9 @@ export interface QueryResult<O> {
|
|
|
21
21
|
/**
|
|
22
22
|
* This is defined for update queries and contains the number of rows
|
|
23
23
|
* the query changed.
|
|
24
|
-
*
|
|
24
|
+
*
|
|
25
|
+
* This is **optional** and only provided in dialects such as MySQL.
|
|
26
|
+
* You would probably use {@link numAffectedRows} in most cases.
|
|
25
27
|
*/
|
|
26
28
|
readonly numChangedRows?: bigint;
|
|
27
29
|
/**
|
|
@@ -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
|
|
@@ -293,7 +293,7 @@ export interface ExpressionBuilder<DB, TB extends keyof DB> {
|
|
|
293
293
|
*
|
|
294
294
|
* ```ts
|
|
295
295
|
* db.update('pet').set((eb) => ({
|
|
296
|
-
* name: sql
|
|
296
|
+
* name: sql<string>`concat(${eb.ref('pet.name')}, ${suffix})`
|
|
297
297
|
* }))
|
|
298
298
|
* ```
|
|
299
299
|
*
|
|
@@ -796,7 +796,7 @@ export interface ExpressionBuilder<DB, TB extends keyof DB> {
|
|
|
796
796
|
/**
|
|
797
797
|
* Creates a `cast(expr as dataType)` expression.
|
|
798
798
|
*
|
|
799
|
-
* Since Kysely can't know the mapping between
|
|
799
|
+
* Since Kysely can't know the mapping between JavaScript and database types,
|
|
800
800
|
* you need to provide both explicitly.
|
|
801
801
|
*
|
|
802
802
|
* ### Examples
|
|
@@ -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");
|
|
@@ -122,8 +123,6 @@ function createExpressionBuilder(executor = noop_query_executor_js_1.NOOP_QUERY_
|
|
|
122
123
|
eb.eb = eb;
|
|
123
124
|
return eb;
|
|
124
125
|
}
|
|
125
|
-
exports.createExpressionBuilder = createExpressionBuilder;
|
|
126
126
|
function expressionBuilder(_) {
|
|
127
127
|
return createExpressionBuilder();
|
|
128
128
|
}
|
|
129
|
-
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
|
*
|