kysely 0.2.4 → 0.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/lib/dialect/postgres/postgres-dialect.js +5 -4
- package/lib/index.d.ts +66 -2
- package/lib/index.js +66 -2
- package/lib/kysely.d.ts +15 -14
- package/lib/kysely.js +17 -16
- package/lib/migration/migration.js +2 -2
- package/lib/operation-node/add-column-node.d.ts +6 -19
- package/lib/operation-node/add-column-node.js +5 -14
- package/lib/operation-node/add-constraint-node.d.ts +4 -4
- package/lib/operation-node/add-constraint-node.js +3 -0
- package/lib/operation-node/alias-node.d.ts +4 -2
- package/lib/operation-node/alias-node.js +3 -0
- package/lib/operation-node/alter-column-node.d.ts +6 -1
- package/lib/operation-node/alter-column-node.js +11 -2
- package/lib/operation-node/alter-table-node.d.ts +5 -0
- package/lib/operation-node/alter-table-node.js +9 -0
- package/lib/operation-node/and-node.d.ts +3 -0
- package/lib/operation-node/and-node.js +3 -0
- package/lib/operation-node/check-constraint-node.d.ts +3 -0
- package/lib/operation-node/check-constraint-node.js +3 -0
- package/lib/operation-node/column-definition-node.d.ts +29 -0
- package/lib/operation-node/column-definition-node.js +30 -0
- package/lib/operation-node/column-node.d.ts +3 -0
- package/lib/operation-node/column-node.js +3 -0
- package/lib/operation-node/column-update-node.d.ts +3 -0
- package/lib/operation-node/column-update-node.js +3 -0
- package/lib/operation-node/common-table-expression-node.d.ts +3 -0
- package/lib/operation-node/common-table-expression-node.js +3 -0
- package/lib/operation-node/constraint-node.d.ts +5 -0
- package/lib/operation-node/constraint-node.js +2 -0
- package/lib/operation-node/create-index-node.d.ts +3 -0
- package/lib/operation-node/create-index-node.js +3 -0
- package/lib/operation-node/create-schema-node.d.ts +3 -0
- package/lib/operation-node/create-schema-node.js +3 -0
- package/lib/operation-node/create-table-node.d.ts +9 -9
- package/lib/operation-node/create-table-node.js +23 -5
- package/lib/operation-node/data-type-node.d.ts +3 -0
- package/lib/operation-node/data-type-node.js +3 -0
- package/lib/operation-node/delete-query-node.d.ts +3 -0
- package/lib/operation-node/delete-query-node.js +3 -0
- package/lib/operation-node/drop-column-node.d.ts +3 -0
- package/lib/operation-node/drop-column-node.js +3 -0
- package/lib/operation-node/drop-constraint-node.d.ts +3 -0
- package/lib/operation-node/drop-constraint-node.js +3 -0
- package/lib/operation-node/drop-index-node.d.ts +3 -0
- package/lib/operation-node/drop-index-node.js +3 -0
- package/lib/operation-node/drop-schema-node.d.ts +3 -0
- package/lib/operation-node/drop-schema-node.js +3 -0
- package/lib/operation-node/drop-table-node.d.ts +5 -2
- package/lib/operation-node/drop-table-node.js +3 -0
- package/lib/operation-node/filter-node.d.ts +3 -0
- package/lib/operation-node/filter-node.js +3 -0
- package/lib/operation-node/foreign-key-constraint-node.d.ts +5 -1
- package/lib/operation-node/foreign-key-constraint-node.js +6 -2
- package/lib/operation-node/from-node.d.ts +3 -0
- package/lib/operation-node/from-node.js +3 -0
- package/lib/operation-node/group-by-item-node.d.ts +3 -0
- package/lib/operation-node/group-by-item-node.js +3 -0
- package/lib/operation-node/group-by-node.d.ts +3 -0
- package/lib/operation-node/group-by-node.js +3 -0
- package/lib/operation-node/having-node.d.ts +3 -0
- package/lib/operation-node/having-node.js +3 -0
- package/lib/operation-node/identifier-node.d.ts +3 -0
- package/lib/operation-node/identifier-node.js +3 -0
- package/lib/operation-node/insert-query-node.d.ts +3 -0
- package/lib/operation-node/insert-query-node.js +3 -0
- package/lib/operation-node/join-node.d.ts +3 -0
- package/lib/operation-node/join-node.js +3 -0
- package/lib/operation-node/limit-node.d.ts +3 -0
- package/lib/operation-node/limit-node.js +3 -0
- package/lib/operation-node/list-node.d.ts +3 -0
- package/lib/operation-node/list-node.js +3 -0
- package/lib/operation-node/offset-node.d.ts +3 -0
- package/lib/operation-node/offset-node.js +3 -0
- package/lib/operation-node/on-conflict-node.d.ts +3 -0
- package/lib/operation-node/on-conflict-node.js +3 -0
- package/lib/operation-node/operation-node-transformer.d.ts +2 -0
- package/lib/operation-node/operation-node-transformer.js +12 -6
- package/lib/operation-node/operation-node-visitor.d.ts +2 -0
- package/lib/operation-node/operation-node-visitor.js +12 -1
- package/lib/operation-node/operation-node.d.ts +1 -1
- package/lib/operation-node/operator-node.d.ts +3 -0
- package/lib/operation-node/operator-node.js +3 -0
- package/lib/operation-node/or-node.d.ts +3 -0
- package/lib/operation-node/or-node.js +3 -0
- package/lib/operation-node/order-by-item-node.d.ts +3 -0
- package/lib/operation-node/order-by-item-node.js +3 -0
- package/lib/operation-node/order-by-node.d.ts +3 -0
- package/lib/operation-node/order-by-node.js +3 -0
- package/lib/operation-node/parens-node.d.ts +3 -0
- package/lib/operation-node/parens-node.js +3 -0
- package/lib/operation-node/primary-constraint-node.d.ts +3 -0
- package/lib/operation-node/primary-constraint-node.js +3 -0
- package/lib/operation-node/primitive-value-list-node.d.ts +3 -0
- package/lib/operation-node/primitive-value-list-node.js +3 -0
- package/lib/operation-node/query-node.d.ts +3 -0
- package/lib/operation-node/query-node.js +3 -0
- package/lib/operation-node/raw-node.d.ts +3 -0
- package/lib/operation-node/raw-node.js +3 -0
- package/lib/operation-node/reference-node.d.ts +3 -0
- package/lib/operation-node/reference-node.js +3 -0
- package/lib/operation-node/references-node.d.ts +5 -2
- package/lib/operation-node/references-node.js +5 -2
- package/lib/operation-node/rename-column-node.d.ts +4 -1
- package/lib/operation-node/rename-column-node.js +5 -2
- package/lib/operation-node/returning-node.d.ts +3 -0
- package/lib/operation-node/returning-node.js +3 -0
- package/lib/operation-node/select-all-node.d.ts +3 -0
- package/lib/operation-node/select-all-node.js +3 -0
- package/lib/operation-node/select-query-node.d.ts +3 -0
- package/lib/operation-node/select-query-node.js +3 -0
- package/lib/operation-node/selection-node.d.ts +3 -0
- package/lib/operation-node/selection-node.js +3 -0
- package/lib/operation-node/table-node.d.ts +3 -0
- package/lib/operation-node/table-node.js +3 -0
- package/lib/operation-node/unique-constraint-node.d.ts +3 -0
- package/lib/operation-node/unique-constraint-node.js +3 -0
- package/lib/operation-node/update-query-node.d.ts +3 -0
- package/lib/operation-node/update-query-node.js +3 -0
- package/lib/operation-node/value-list-node.d.ts +3 -0
- package/lib/operation-node/value-list-node.js +3 -0
- package/lib/operation-node/value-node.d.ts +3 -0
- package/lib/operation-node/value-node.js +3 -0
- package/lib/operation-node/where-node.d.ts +3 -0
- package/lib/operation-node/where-node.js +3 -0
- package/lib/operation-node/with-node.d.ts +3 -0
- package/lib/operation-node/with-node.js +3 -0
- package/lib/parser/with-parser.js +1 -1
- package/lib/query-builder/query-builder.d.ts +9 -9
- package/lib/query-builder/query-builder.js +6 -6
- package/lib/query-builder/sub-query-builder.d.ts +1 -1
- package/lib/query-builder/sub-query-builder.js +1 -1
- package/lib/query-compiler/default-query-compiler.d.ts +3 -1
- package/lib/query-compiler/default-query-compiler.js +10 -9
- package/lib/query-compiler/query-compiler.d.ts +2 -1
- package/lib/query-creator.d.ts +2 -2
- package/lib/query-creator.js +1 -1
- package/lib/{util → query-executor}/query-executor.d.ts +0 -0
- package/lib/{util → query-executor}/query-executor.js +1 -1
- package/lib/raw-builder/raw-builder.d.ts +2 -2
- package/lib/raw-builder/raw-builder.js +4 -4
- package/lib/schema/alter-table-builder.d.ts +64 -0
- package/lib/schema/alter-table-builder.js +236 -0
- package/lib/schema/{add-column-builder.d.ts → column-definition-builder.d.ts} +23 -13
- package/lib/schema/column-definition-builder.js +66 -0
- package/lib/schema/create-index-builder.d.ts +2 -2
- package/lib/schema/create-index-builder.js +3 -3
- package/lib/schema/create-schema-builder.d.ts +2 -2
- package/lib/schema/create-schema-builder.js +3 -3
- package/lib/schema/create-table-builder.d.ts +20 -6
- package/lib/schema/create-table-builder.js +27 -8
- package/lib/schema/drop-index-builder.d.ts +2 -2
- package/lib/schema/drop-index-builder.js +3 -3
- package/lib/schema/drop-schema-builder.d.ts +2 -2
- package/lib/schema/drop-schema-builder.js +3 -3
- package/lib/schema/drop-table-builder.d.ts +2 -2
- package/lib/schema/drop-table-builder.js +3 -3
- package/lib/schema/schema.d.ts +17 -3
- package/lib/schema/schema.js +22 -2
- package/lib/transformers/with-schema-transformer.d.ts +2 -0
- package/lib/transformers/with-schema-transformer.js +3 -0
- package/lib/util/object-utils.d.ts +1 -0
- package/lib/util/object-utils.js +13 -1
- package/package.json +2 -2
- package/lib/schema/add-column-builder.js +0 -116
|
@@ -5,6 +5,9 @@ export interface TableNode extends OperationNode {
|
|
|
5
5
|
readonly schema?: IdentifierNode;
|
|
6
6
|
readonly table: IdentifierNode;
|
|
7
7
|
}
|
|
8
|
+
/**
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
8
11
|
export declare const tableNode: Readonly<{
|
|
9
12
|
is(node: OperationNode): node is TableNode;
|
|
10
13
|
create(table: string): TableNode;
|
|
@@ -3,6 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.tableNode = void 0;
|
|
4
4
|
const object_utils_1 = require("../util/object-utils");
|
|
5
5
|
const identifier_node_1 = require("./identifier-node");
|
|
6
|
+
/**
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
6
9
|
exports.tableNode = object_utils_1.freeze({
|
|
7
10
|
is(node) {
|
|
8
11
|
return node.kind === 'TableNode';
|
|
@@ -6,6 +6,9 @@ export interface UniqueConstraintNode extends OperationNode {
|
|
|
6
6
|
readonly columns: ReadonlyArray<ColumnNode>;
|
|
7
7
|
readonly name?: IdentifierNode;
|
|
8
8
|
}
|
|
9
|
+
/**
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
9
12
|
export declare const uniqueConstraintNode: Readonly<{
|
|
10
13
|
is(node: OperationNode): node is UniqueConstraintNode;
|
|
11
14
|
create(columns: string[], constraintName?: string | undefined): UniqueConstraintNode;
|
|
@@ -4,6 +4,9 @@ exports.uniqueConstraintNode = void 0;
|
|
|
4
4
|
const object_utils_1 = require("../util/object-utils");
|
|
5
5
|
const column_node_1 = require("./column-node");
|
|
6
6
|
const identifier_node_1 = require("./identifier-node");
|
|
7
|
+
/**
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
7
10
|
exports.uniqueConstraintNode = object_utils_1.freeze({
|
|
8
11
|
is(node) {
|
|
9
12
|
return node.kind === 'UniqueConstraintNode';
|
|
@@ -17,6 +17,9 @@ export interface UpdateQueryNode extends OperationNode {
|
|
|
17
17
|
readonly returning?: ReturningNode;
|
|
18
18
|
readonly with?: WithNode;
|
|
19
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* @internal
|
|
22
|
+
*/
|
|
20
23
|
export declare const updateQueryNode: Readonly<{
|
|
21
24
|
is(node: OperationNode): node is UpdateQueryNode;
|
|
22
25
|
create(table: TableExpressionNode, withNode?: WithNode | undefined): UpdateQueryNode;
|
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.updateQueryNode = void 0;
|
|
4
4
|
const object_utils_1 = require("../util/object-utils");
|
|
5
|
+
/**
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
5
8
|
exports.updateQueryNode = object_utils_1.freeze({
|
|
6
9
|
is(node) {
|
|
7
10
|
return node.kind === 'UpdateQueryNode';
|
|
@@ -8,6 +8,9 @@ export interface ValueListNode extends OperationNode {
|
|
|
8
8
|
readonly kind: 'ValueListNode';
|
|
9
9
|
readonly values: ReadonlyArray<ListNodeItem>;
|
|
10
10
|
}
|
|
11
|
+
/**
|
|
12
|
+
* @internal
|
|
13
|
+
*/
|
|
11
14
|
export declare const valueListNode: Readonly<{
|
|
12
15
|
is(node: OperationNode): node is ValueListNode;
|
|
13
16
|
create(values: ReadonlyArray<ListNodeItem>): ValueListNode;
|
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.valueListNode = void 0;
|
|
4
4
|
const object_utils_1 = require("../util/object-utils");
|
|
5
|
+
/**
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
5
8
|
exports.valueListNode = object_utils_1.freeze({
|
|
6
9
|
is(node) {
|
|
7
10
|
return node.kind === 'ValueListNode';
|
|
@@ -5,6 +5,9 @@ export interface ValueNode extends OperationNode {
|
|
|
5
5
|
readonly value: PrimitiveValue;
|
|
6
6
|
readonly immediate?: boolean;
|
|
7
7
|
}
|
|
8
|
+
/**
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
8
11
|
export declare const valueNode: Readonly<{
|
|
9
12
|
is(node: OperationNode): node is ValueNode;
|
|
10
13
|
create(value: PrimitiveValue): ValueNode;
|
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.valueNode = void 0;
|
|
4
4
|
const object_utils_1 = require("../util/object-utils");
|
|
5
|
+
/**
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
5
8
|
exports.valueNode = object_utils_1.freeze({
|
|
6
9
|
is(node) {
|
|
7
10
|
return node.kind === 'ValueNode';
|
|
@@ -8,6 +8,9 @@ export interface WhereNode extends OperationNode {
|
|
|
8
8
|
readonly kind: 'WhereNode';
|
|
9
9
|
readonly where: WhereChildNode;
|
|
10
10
|
}
|
|
11
|
+
/**
|
|
12
|
+
* @internal
|
|
13
|
+
*/
|
|
11
14
|
export declare const whereNode: Readonly<{
|
|
12
15
|
is(node: OperationNode): node is WhereNode;
|
|
13
16
|
create(filter: WhereChildNode): WhereNode;
|
|
@@ -4,6 +4,9 @@ exports.whereNode = void 0;
|
|
|
4
4
|
const object_utils_1 = require("../util/object-utils");
|
|
5
5
|
const and_node_1 = require("./and-node");
|
|
6
6
|
const or_node_1 = require("./or-node");
|
|
7
|
+
/**
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
7
10
|
exports.whereNode = object_utils_1.freeze({
|
|
8
11
|
is(node) {
|
|
9
12
|
return node.kind === 'WhereNode';
|
|
@@ -4,6 +4,9 @@ export interface WithNode extends OperationNode {
|
|
|
4
4
|
readonly kind: 'WithNode';
|
|
5
5
|
readonly expressions: ReadonlyArray<CommonTableExpressionNode>;
|
|
6
6
|
}
|
|
7
|
+
/**
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
7
10
|
export declare const withNode: Readonly<{
|
|
8
11
|
is(node: OperationNode): node is WithNode;
|
|
9
12
|
create(expression: CommonTableExpressionNode): WithNode;
|
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.withNode = void 0;
|
|
4
4
|
const object_utils_1 = require("../util/object-utils");
|
|
5
|
+
/**
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
5
8
|
exports.withNode = object_utils_1.freeze({
|
|
6
9
|
is(node) {
|
|
7
10
|
return node.kind === 'WithNode';
|
|
@@ -4,7 +4,7 @@ exports.parseCommonTableExpression = void 0;
|
|
|
4
4
|
const identifier_node_1 = require("../operation-node/identifier-node");
|
|
5
5
|
const common_table_expression_node_1 = require("../operation-node/common-table-expression-node");
|
|
6
6
|
const query_creator_1 = require("../query-creator");
|
|
7
|
-
const query_executor_1 = require("../
|
|
7
|
+
const query_executor_1 = require("../query-executor/query-executor");
|
|
8
8
|
function parseCommonTableExpression(name, expression) {
|
|
9
9
|
const builder = expression(new query_creator_1.QueryCreator(new query_executor_1.NeverExecutingQueryExecutor()));
|
|
10
10
|
return common_table_expression_node_1.commonTableExpressionNode.create(identifier_node_1.identifierNode.create(name), builder.toOperationNode());
|
|
@@ -14,7 +14,7 @@ import { AnyColumn, ManyResultRowType, SingleResultRowType } from './type-utils'
|
|
|
14
14
|
import { OrderByExpression } from '../parser/order-by-parser';
|
|
15
15
|
import { MutationObject } from '../parser/mutation-parser';
|
|
16
16
|
import { Compilable } from '../util/compilable';
|
|
17
|
-
import { QueryExecutor } from '../
|
|
17
|
+
import { QueryExecutor } from '../query-executor/query-executor';
|
|
18
18
|
/**
|
|
19
19
|
* The main query builder class.
|
|
20
20
|
*
|
|
@@ -32,7 +32,7 @@ import { QueryExecutor } from '../util/query-executor';
|
|
|
32
32
|
*/
|
|
33
33
|
export declare class QueryBuilder<DB, TB extends keyof DB, O = {}> implements OperationNodeSource, Compilable {
|
|
34
34
|
#private;
|
|
35
|
-
constructor(
|
|
35
|
+
constructor(args: QueryBuilderConstructorArgs);
|
|
36
36
|
/**
|
|
37
37
|
* Adds a `where` clause to the query.
|
|
38
38
|
*
|
|
@@ -579,7 +579,7 @@ export declare class QueryBuilder<DB, TB extends keyof DB, O = {}> implements Op
|
|
|
579
579
|
* person.id
|
|
580
580
|
* ```
|
|
581
581
|
*/
|
|
582
|
-
select<S extends SelectExpression<DB, TB>>(selections: S
|
|
582
|
+
select<S extends SelectExpression<DB, TB>>(selections: ReadonlyArray<S>): QueryBuilderWithSelection<DB, TB, O, S>;
|
|
583
583
|
select<S extends SelectExpression<DB, TB>>(selection: S): QueryBuilderWithSelection<DB, TB, O, S>;
|
|
584
584
|
/**
|
|
585
585
|
* Adds `distinct on` selections to the select clause.
|
|
@@ -603,7 +603,7 @@ export declare class QueryBuilder<DB, TB extends keyof DB, O = {}> implements Op
|
|
|
603
603
|
* where "pet"."name" = $1
|
|
604
604
|
* ```
|
|
605
605
|
*/
|
|
606
|
-
distinctOn<S extends SelectExpression<DB, TB>>(selections: S
|
|
606
|
+
distinctOn<S extends SelectExpression<DB, TB>>(selections: ReadonlyArray<S>): QueryBuilder<DB, TB, O>;
|
|
607
607
|
distinctOn<S extends SelectExpression<DB, TB>>(selection: S): QueryBuilder<DB, TB, O>;
|
|
608
608
|
/**
|
|
609
609
|
*
|
|
@@ -675,7 +675,7 @@ export declare class QueryBuilder<DB, TB extends keyof DB, O = {}> implements Op
|
|
|
675
675
|
* select "person".*, "pet".* from "person", "pet"
|
|
676
676
|
* ```
|
|
677
677
|
*/
|
|
678
|
-
selectAll<T extends TB>(table: T
|
|
678
|
+
selectAll<T extends TB>(table: ReadonlyArray<T>): SelectAllQueryBuilder<DB, TB, O, T>;
|
|
679
679
|
selectAll<T extends TB>(table: T): SelectAllQueryBuilder<DB, TB, O, T>;
|
|
680
680
|
selectAll<T extends TB>(): SelectAllQueryBuilder<DB, TB, O, T>;
|
|
681
681
|
/**
|
|
@@ -944,7 +944,7 @@ export declare class QueryBuilder<DB, TB extends keyof DB, O = {}> implements Op
|
|
|
944
944
|
* ```
|
|
945
945
|
*/
|
|
946
946
|
onConflictDoNothing(column: AnyColumn<DB, TB>): QueryBuilder<DB, TB, O>;
|
|
947
|
-
onConflictDoNothing(columns: AnyColumn<DB, TB
|
|
947
|
+
onConflictDoNothing(columns: ReadonlyArray<AnyColumn<DB, TB>>): QueryBuilder<DB, TB, O>;
|
|
948
948
|
/**
|
|
949
949
|
* Ignores an insert if the column (or columns) given as the first
|
|
950
950
|
* argument conflicts with the current rows in the database and
|
|
@@ -988,7 +988,7 @@ export declare class QueryBuilder<DB, TB extends keyof DB, O = {}> implements Op
|
|
|
988
988
|
* ```
|
|
989
989
|
*/
|
|
990
990
|
onConflictUpdate(column: AnyColumn<DB, TB>, updates: MutationObject<DB, TB>): QueryBuilder<DB, TB, O>;
|
|
991
|
-
onConflictUpdate(columns: AnyColumn<DB, TB
|
|
991
|
+
onConflictUpdate(columns: ReadonlyArray<AnyColumn<DB, TB>>, updates: MutationObject<DB, TB>): QueryBuilder<DB, TB, O>;
|
|
992
992
|
/**
|
|
993
993
|
* Sets the values to update for an `updateTable` query.
|
|
994
994
|
*
|
|
@@ -1127,7 +1127,7 @@ export declare class QueryBuilder<DB, TB extends keyof DB, O = {}> implements Op
|
|
|
1127
1127
|
* .executeTakeFirst()
|
|
1128
1128
|
* ```
|
|
1129
1129
|
*/
|
|
1130
|
-
returning<S extends SelectExpression<DB, TB>>(selections: S
|
|
1130
|
+
returning<S extends SelectExpression<DB, TB>>(selections: ReadonlyArray<S>): QueryBuilderWithReturning<DB, TB, O, S>;
|
|
1131
1131
|
returning<S extends SelectExpression<DB, TB>>(selection: S): QueryBuilderWithReturning<DB, TB, O, S>;
|
|
1132
1132
|
/**
|
|
1133
1133
|
* Adds a `returning *` to an insert/update/delete query on databases
|
|
@@ -1319,7 +1319,7 @@ export declare class QueryBuilder<DB, TB extends keyof DB, O = {}> implements Op
|
|
|
1319
1319
|
* group by "first_name"
|
|
1320
1320
|
* ```
|
|
1321
1321
|
*/
|
|
1322
|
-
groupBy(orderBy: ReferenceExpression<DB, TB
|
|
1322
|
+
groupBy(orderBy: ReadonlyArray<ReferenceExpression<DB, TB>>): QueryBuilder<DB, TB, O>;
|
|
1323
1323
|
groupBy(orderBy: ReferenceExpression<DB, TB>): QueryBuilder<DB, TB, O>;
|
|
1324
1324
|
/**
|
|
1325
1325
|
* Adds a limit clause to the query.
|
|
@@ -18,7 +18,7 @@ const prevent_await_1 = require("../util/prevent-await");
|
|
|
18
18
|
const limit_node_1 = require("../operation-node/limit-node");
|
|
19
19
|
const offset_node_1 = require("../operation-node/offset-node");
|
|
20
20
|
const object_utils_1 = require("../util/object-utils");
|
|
21
|
-
const query_executor_1 = require("../
|
|
21
|
+
const query_executor_1 = require("../query-executor/query-executor");
|
|
22
22
|
/**
|
|
23
23
|
* The main query builder class.
|
|
24
24
|
*
|
|
@@ -37,9 +37,9 @@ const query_executor_1 = require("../util/query-executor");
|
|
|
37
37
|
class QueryBuilder {
|
|
38
38
|
#queryNode;
|
|
39
39
|
#executor;
|
|
40
|
-
constructor(
|
|
41
|
-
this.#queryNode = queryNode;
|
|
42
|
-
this.#executor = executor;
|
|
40
|
+
constructor(args) {
|
|
41
|
+
this.#queryNode = args.queryNode;
|
|
42
|
+
this.#executor = args.executor;
|
|
43
43
|
}
|
|
44
44
|
where(...args) {
|
|
45
45
|
ensureCanHaveWhereClause(this.#queryNode);
|
|
@@ -427,14 +427,14 @@ class QueryBuilder {
|
|
|
427
427
|
ensureCanHaveOnConflict(this.#queryNode);
|
|
428
428
|
return new QueryBuilder({
|
|
429
429
|
executor: this.#executor,
|
|
430
|
-
queryNode: insert_query_node_1.insertQueryNode.cloneWithOnConflictDoNothing(this.#queryNode, object_utils_1.
|
|
430
|
+
queryNode: insert_query_node_1.insertQueryNode.cloneWithOnConflictDoNothing(this.#queryNode, object_utils_1.asReadonlyArray(columns).map(reference_parser_1.parseColumnName)),
|
|
431
431
|
});
|
|
432
432
|
}
|
|
433
433
|
onConflictUpdate(columns, updates) {
|
|
434
434
|
ensureCanHaveOnConflict(this.#queryNode);
|
|
435
435
|
return new QueryBuilder({
|
|
436
436
|
executor: this.#executor,
|
|
437
|
-
queryNode: insert_query_node_1.insertQueryNode.cloneWithOnConflictUpdate(this.#queryNode, object_utils_1.
|
|
437
|
+
queryNode: insert_query_node_1.insertQueryNode.cloneWithOnConflictUpdate(this.#queryNode, object_utils_1.asReadonlyArray(columns).map(reference_parser_1.parseColumnName), update_set_parser_1.parseUpdateObject(updates)),
|
|
438
438
|
});
|
|
439
439
|
}
|
|
440
440
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { NeverExecutingQueryExecutor } from '../
|
|
1
|
+
import { NeverExecutingQueryExecutor } from '../query-executor/query-executor';
|
|
2
2
|
import { TableExpression, QueryBuilderWithTable } from '../parser/table-parser';
|
|
3
3
|
export declare class SubQueryBuilder<DB, TB extends keyof DB> {
|
|
4
4
|
#private;
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.SubQueryBuilder = void 0;
|
|
4
4
|
const query_builder_1 = require("./query-builder");
|
|
5
5
|
const select_query_node_1 = require("../operation-node/select-query-node");
|
|
6
|
-
const query_executor_1 = require("../
|
|
6
|
+
const query_executor_1 = require("../query-executor/query-executor");
|
|
7
7
|
const table_parser_1 = require("../parser/table-parser");
|
|
8
8
|
const with_schema_transformer_1 = require("../transformers/with-schema-transformer");
|
|
9
9
|
class SubQueryBuilder {
|
|
@@ -57,6 +57,7 @@ import { AlterColumnNode } from '../operation-node/alter-column-node';
|
|
|
57
57
|
import { AddConstraintNode } from '../operation-node/add-constraint-node';
|
|
58
58
|
import { DropConstraintNode } from '../operation-node/drop-constraint-node';
|
|
59
59
|
import { ForeignKeyConstraintNode } from '../operation-node/foreign-key-constraint-node';
|
|
60
|
+
import { ColumnDefinitionNode } from '../operation-node/column-definition-node';
|
|
60
61
|
export declare class DefaultQueryCompiler extends OperationNodeVisitor implements QueryCompiler {
|
|
61
62
|
#private;
|
|
62
63
|
compileQuery(node: CompileEntryPointNode): CompiledQuery;
|
|
@@ -88,7 +89,7 @@ export declare class DefaultQueryCompiler extends OperationNodeVisitor implement
|
|
|
88
89
|
protected visitOperator(node: OperatorNode): void;
|
|
89
90
|
protected visitTable(node: TableNode): void;
|
|
90
91
|
protected visitCreateTable(node: CreateTableNode): void;
|
|
91
|
-
protected
|
|
92
|
+
protected visitColumnDefinition(node: ColumnDefinitionNode): void;
|
|
92
93
|
protected visitReferences(node: ReferencesNode): void;
|
|
93
94
|
protected visitDropTable(node: DropTableNode): void;
|
|
94
95
|
protected visitDataType(node: DataTypeNode): void;
|
|
@@ -113,6 +114,7 @@ export declare class DefaultQueryCompiler extends OperationNodeVisitor implement
|
|
|
113
114
|
protected visitWith(node: WithNode): void;
|
|
114
115
|
protected visitCommonTableExpression(node: CommonTableExpressionNode): void;
|
|
115
116
|
protected visitAlterTable(node: AlterTableNode): void;
|
|
117
|
+
protected visitAddColumn(node: AddColumnNode): void;
|
|
116
118
|
protected visitRenameColumn(node: RenameColumnNode): void;
|
|
117
119
|
protected visitDropColumn(node: DropColumnNode): void;
|
|
118
120
|
protected visitAlterColumn(node: AlterColumnNode): void;
|
|
@@ -275,15 +275,10 @@ class DefaultQueryCompiler extends operation_node_visitor_1.OperationNodeVisitor
|
|
|
275
275
|
}
|
|
276
276
|
this.visitNode(node.table);
|
|
277
277
|
this.append(' (');
|
|
278
|
-
this.compileList([
|
|
279
|
-
...node.columns,
|
|
280
|
-
...(node.primaryKeyConstraint ? [node.primaryKeyConstraint] : []),
|
|
281
|
-
...(node.uniqueConstraints ?? []),
|
|
282
|
-
...(node.checkConstraints ?? []),
|
|
283
|
-
]);
|
|
278
|
+
this.compileList([...node.columns, ...(node.constraints ?? [])]);
|
|
284
279
|
this.append(')');
|
|
285
280
|
}
|
|
286
|
-
|
|
281
|
+
visitColumnDefinition(node) {
|
|
287
282
|
this.visitNode(node.column);
|
|
288
283
|
this.append(' ');
|
|
289
284
|
if (node.isAutoIncrementing) {
|
|
@@ -325,7 +320,7 @@ class DefaultQueryCompiler extends operation_node_visitor_1.OperationNodeVisitor
|
|
|
325
320
|
this.append('references ');
|
|
326
321
|
this.visitNode(node.table);
|
|
327
322
|
this.append(' (');
|
|
328
|
-
this.
|
|
323
|
+
this.compileList(node.columns);
|
|
329
324
|
this.append(')');
|
|
330
325
|
if (node.onDelete) {
|
|
331
326
|
this.append(' on delete ');
|
|
@@ -499,7 +494,9 @@ class DefaultQueryCompiler extends operation_node_visitor_1.OperationNodeVisitor
|
|
|
499
494
|
this.visitNode(node.name);
|
|
500
495
|
this.append(' ');
|
|
501
496
|
}
|
|
502
|
-
this.append('foreign key ');
|
|
497
|
+
this.append('foreign key (');
|
|
498
|
+
this.compileList(node.columns);
|
|
499
|
+
this.append(') ');
|
|
503
500
|
this.visitNode(node.references);
|
|
504
501
|
}
|
|
505
502
|
visitList(node) {
|
|
@@ -545,6 +542,10 @@ class DefaultQueryCompiler extends operation_node_visitor_1.OperationNodeVisitor
|
|
|
545
542
|
this.visitNode(node.alterColumn);
|
|
546
543
|
}
|
|
547
544
|
}
|
|
545
|
+
visitAddColumn(node) {
|
|
546
|
+
this.append('add column ');
|
|
547
|
+
this.visitNode(node.column);
|
|
548
|
+
}
|
|
548
549
|
visitRenameColumn(node) {
|
|
549
550
|
this.append('rename column ');
|
|
550
551
|
this.visitNode(node.column);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { AlterTableNode } from '../operation-node/alter-table-node';
|
|
1
2
|
import { CreateIndexNode } from '../operation-node/create-index-node';
|
|
2
3
|
import { CreateSchemaNode } from '../operation-node/create-schema-node';
|
|
3
4
|
import { CreateTableNode } from '../operation-node/create-table-node';
|
|
@@ -7,7 +8,7 @@ import { DropTableNode } from '../operation-node/drop-table-node';
|
|
|
7
8
|
import { QueryNode } from '../operation-node/query-node';
|
|
8
9
|
import { RawNode } from '../operation-node/raw-node';
|
|
9
10
|
import { CompiledQuery } from './compiled-query';
|
|
10
|
-
export declare type CompileEntryPointNode = QueryNode | CreateTableNode | CreateIndexNode | DropTableNode | DropIndexNode | CreateSchemaNode | DropSchemaNode | RawNode;
|
|
11
|
+
export declare type CompileEntryPointNode = QueryNode | CreateTableNode | CreateIndexNode | AlterTableNode | DropTableNode | DropIndexNode | CreateSchemaNode | DropSchemaNode | RawNode;
|
|
11
12
|
export interface QueryCompiler {
|
|
12
13
|
compileQuery(node: CompileEntryPointNode): CompiledQuery;
|
|
13
14
|
}
|
package/lib/query-creator.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { QueryBuilder } from './query-builder/query-builder';
|
|
2
2
|
import { QueryBuilderWithTable, TableExpression, TableReference } from './parser/table-parser';
|
|
3
3
|
import { InsertResultTypeTag, DeleteResultTypeTag, UpdateResultTypeTag } from './query-builder/type-utils';
|
|
4
|
-
import { QueryExecutor } from './
|
|
4
|
+
import { QueryExecutor } from './query-executor/query-executor';
|
|
5
5
|
import { RawBuilder } from './raw-builder/raw-builder';
|
|
6
6
|
import { CommonTableExpression, QueryCreatorWithCommonTableExpression } from './parser/with-parser';
|
|
7
7
|
import { WithNode } from './operation-node/with-node';
|
|
@@ -238,7 +238,7 @@ export declare class QueryCreator<DB> {
|
|
|
238
238
|
* ```
|
|
239
239
|
*
|
|
240
240
|
* @example
|
|
241
|
-
* `withSchema` is smart enough to not add schema for aliases
|
|
241
|
+
* `withSchema` is smart enough to not add schema for aliases,
|
|
242
242
|
* common table expressions or other places where the schema
|
|
243
243
|
* doesn't belong to:
|
|
244
244
|
*
|
package/lib/query-creator.js
CHANGED
|
@@ -163,7 +163,7 @@ class QueryCreator {
|
|
|
163
163
|
* ```
|
|
164
164
|
*
|
|
165
165
|
* @example
|
|
166
|
-
* `withSchema` is smart enough to not add schema for aliases
|
|
166
|
+
* `withSchema` is smart enough to not add schema for aliases,
|
|
167
167
|
* common table expressions or other places where the schema
|
|
168
168
|
* doesn't belong to:
|
|
169
169
|
*
|
|
File without changes
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.NeverExecutingQueryExecutor = exports.DefaultQueryExecutor = exports.QueryExecutor = void 0;
|
|
4
|
-
const object_utils_1 = require("
|
|
4
|
+
const object_utils_1 = require("../util/object-utils");
|
|
5
5
|
class QueryExecutor {
|
|
6
6
|
#transformers;
|
|
7
7
|
constructor(transformers = []) {
|
|
@@ -3,10 +3,10 @@ import { AliasNode } from '../operation-node/alias-node';
|
|
|
3
3
|
import { OperationNodeSource } from '../operation-node/operation-node-source';
|
|
4
4
|
import { RawNode } from '../operation-node/raw-node';
|
|
5
5
|
import { CompiledQuery } from '../query-compiler/compiled-query';
|
|
6
|
-
import { QueryExecutor } from '../
|
|
6
|
+
import { QueryExecutor } from '../query-executor/query-executor';
|
|
7
7
|
export declare class RawBuilder<O = unknown> implements OperationNodeSource {
|
|
8
8
|
#private;
|
|
9
|
-
constructor(
|
|
9
|
+
constructor(args: RawBuilderConstructorArgs);
|
|
10
10
|
toOperationNode(): RawNode;
|
|
11
11
|
as<A extends string>(alias: A): AliasedRawBuilder<O, A>;
|
|
12
12
|
compile(): CompiledQuery;
|
|
@@ -11,10 +11,10 @@ class RawBuilder {
|
|
|
11
11
|
#sql;
|
|
12
12
|
#params;
|
|
13
13
|
#executor;
|
|
14
|
-
constructor(
|
|
15
|
-
this.#sql = sql;
|
|
16
|
-
this.#params = params;
|
|
17
|
-
this.#executor = executor;
|
|
14
|
+
constructor(args) {
|
|
15
|
+
this.#sql = args.sql;
|
|
16
|
+
this.#params = args.params;
|
|
17
|
+
this.#executor = args.executor;
|
|
18
18
|
}
|
|
19
19
|
toOperationNode() {
|
|
20
20
|
const bindingRegex = /(\?\??)/g;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { ColumnDefinitionBuilder, ColumnDefinitionBuilderInterface } from '..';
|
|
2
|
+
import { AlterColumnNode } from '../operation-node/alter-column-node';
|
|
3
|
+
import { AlterTableNode } from '../operation-node/alter-table-node';
|
|
4
|
+
import { ColumnDataType } from '../operation-node/data-type-node';
|
|
5
|
+
import { OperationNodeSource } from '../operation-node/operation-node-source';
|
|
6
|
+
import { OnDelete } from '../operation-node/references-node';
|
|
7
|
+
import { CompiledQuery } from '../query-compiler/compiled-query';
|
|
8
|
+
import { RawBuilder } from '../raw-builder/raw-builder';
|
|
9
|
+
import { Compilable } from '../util/compilable';
|
|
10
|
+
import { PrimitiveValue } from '../util/object-utils';
|
|
11
|
+
import { QueryExecutor } from '../query-executor/query-executor';
|
|
12
|
+
export declare class AlterTableBuilder {
|
|
13
|
+
#private;
|
|
14
|
+
constructor(args: AlterTableBuilderConstructorArgs);
|
|
15
|
+
renameTo(newTableName: string): AlterTableExecutor;
|
|
16
|
+
setSchema(newSchema: string): AlterTableExecutor;
|
|
17
|
+
alterColumn(column: string): AlterColumnBuilder;
|
|
18
|
+
dropColumn(column: string): AlterTableExecutor;
|
|
19
|
+
renameColumn(column: string, newColumn: string): AlterTableExecutor;
|
|
20
|
+
addColumn(columnName: string, dataType: ColumnDataType | RawBuilder): AlterTableAddColumnBuilder;
|
|
21
|
+
}
|
|
22
|
+
export declare class AlterColumnBuilder {
|
|
23
|
+
#private;
|
|
24
|
+
constructor(args: AlterColumnBuilderConstructorArgs);
|
|
25
|
+
setDataType(dataType: ColumnDataType): AlterTableExecutor;
|
|
26
|
+
setDefault(value: PrimitiveValue | RawBuilder<any>): AlterTableExecutor;
|
|
27
|
+
dropDefault(): AlterTableExecutor;
|
|
28
|
+
setNotNull(): AlterTableExecutor;
|
|
29
|
+
dropNotNull(): AlterTableExecutor;
|
|
30
|
+
}
|
|
31
|
+
export declare class AlterTableExecutor implements OperationNodeSource, Compilable {
|
|
32
|
+
#private;
|
|
33
|
+
constructor(args: AlterTableExecutorConstructorArgs);
|
|
34
|
+
toOperationNode(): AlterTableNode;
|
|
35
|
+
compile(): CompiledQuery;
|
|
36
|
+
execute(): Promise<void>;
|
|
37
|
+
}
|
|
38
|
+
export declare class AlterTableAddColumnBuilder implements ColumnDefinitionBuilderInterface<AlterTableAddColumnBuilder> {
|
|
39
|
+
#private;
|
|
40
|
+
constructor(args: AlterTableAddColumnBuilderConstructorArgs);
|
|
41
|
+
increments(): AlterTableAddColumnBuilder;
|
|
42
|
+
primaryKey(): AlterTableAddColumnBuilder;
|
|
43
|
+
references(ref: string): AlterTableAddColumnBuilder;
|
|
44
|
+
onDelete(onDelete: OnDelete): AlterTableAddColumnBuilder;
|
|
45
|
+
unique(): AlterTableAddColumnBuilder;
|
|
46
|
+
notNull(): AlterTableAddColumnBuilder;
|
|
47
|
+
defaultTo(value: PrimitiveValue | RawBuilder<any>): AlterTableAddColumnBuilder;
|
|
48
|
+
check(sql: string): AlterTableAddColumnBuilder;
|
|
49
|
+
toOperationNode(): AlterTableNode;
|
|
50
|
+
compile(): CompiledQuery;
|
|
51
|
+
execute(): Promise<void>;
|
|
52
|
+
}
|
|
53
|
+
export interface AlterTableBuilderConstructorArgs {
|
|
54
|
+
alterTableNode: AlterTableNode;
|
|
55
|
+
executor: QueryExecutor;
|
|
56
|
+
}
|
|
57
|
+
export interface AlterColumnBuilderConstructorArgs extends AlterTableBuilderConstructorArgs {
|
|
58
|
+
alterColumnNode: AlterColumnNode;
|
|
59
|
+
}
|
|
60
|
+
export interface AlterTableExecutorConstructorArgs extends AlterTableBuilderConstructorArgs {
|
|
61
|
+
}
|
|
62
|
+
export interface AlterTableAddColumnBuilderConstructorArgs extends AlterTableBuilderConstructorArgs {
|
|
63
|
+
columnBuilder: ColumnDefinitionBuilder;
|
|
64
|
+
}
|