kysely 0.9.2 → 0.9.3
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/dist/cjs/operation-node/operation-node-transformer.d.ts +2 -0
- package/dist/cjs/operation-node/operation-node-transformer.js +9 -0
- package/dist/cjs/operation-node/operation-node-visitor.d.ts +61 -59
- package/dist/cjs/operation-node/operation-node-visitor.js +1 -316
- package/dist/cjs/operation-node/operation-node.d.ts +1 -1
- package/dist/cjs/operation-node/select-query-node.d.ts +3 -0
- package/dist/cjs/operation-node/select-query-node.js +8 -0
- package/dist/cjs/operation-node/union-node.d.ts +16 -0
- package/dist/cjs/operation-node/union-node.js +19 -0
- package/dist/cjs/parser/insert-values-parser.d.ts +1 -1
- package/dist/cjs/parser/union-parser.d.ts +5 -0
- package/dist/cjs/parser/union-parser.js +13 -0
- package/dist/cjs/parser/value-parser.d.ts +1 -1
- package/dist/cjs/query-builder/query-builder.d.ts +30 -1
- package/dist/cjs/query-builder/query-builder.js +46 -0
- package/dist/cjs/query-compiler/default-query-compiler.d.ts +5 -0
- package/dist/cjs/query-compiler/default-query-compiler.js +18 -1
- package/dist/esm/operation-node/operation-node-transformer.d.ts +2 -0
- package/dist/esm/operation-node/operation-node-transformer.js +9 -0
- package/dist/esm/operation-node/operation-node-visitor.d.ts +61 -59
- package/dist/esm/operation-node/operation-node-visitor.js +1 -316
- package/dist/esm/operation-node/operation-node.d.ts +1 -1
- package/dist/esm/operation-node/select-query-node.d.ts +3 -0
- package/dist/esm/operation-node/select-query-node.js +8 -0
- package/dist/esm/operation-node/union-node.d.ts +16 -0
- package/dist/esm/operation-node/union-node.js +16 -0
- package/dist/esm/parser/insert-values-parser.d.ts +1 -1
- package/dist/esm/parser/union-parser.d.ts +5 -0
- package/dist/esm/parser/union-parser.js +9 -0
- package/dist/esm/parser/value-parser.d.ts +1 -1
- package/dist/esm/query-builder/query-builder.d.ts +30 -1
- package/dist/esm/query-builder/query-builder.js +46 -0
- package/dist/esm/query-compiler/default-query-compiler.d.ts +5 -0
- package/dist/esm/query-compiler/default-query-compiler.js +18 -1
- package/package.json +1 -1
|
@@ -57,6 +57,7 @@ import { ForeignKeyConstraintNode } from './foreign-key-constraint-node.js';
|
|
|
57
57
|
import { ColumnDefinitionNode } from './column-definition-node.js';
|
|
58
58
|
import { ModifyColumnNode } from './modify-column-node.js';
|
|
59
59
|
import { OnDuplicateKeyNode } from './on-duplicate-key-node.js';
|
|
60
|
+
import { UnionNode } from './union-node.js';
|
|
60
61
|
/**
|
|
61
62
|
* Transforms an operation node tree into another one.
|
|
62
63
|
*
|
|
@@ -129,6 +130,7 @@ export declare class OperationNodeTransformer {
|
|
|
129
130
|
protected transformPrimaryKeyConstraint(node: PrimaryKeyConstraintNode): PrimaryKeyConstraintNode;
|
|
130
131
|
protected transformUniqueConstraint(node: UniqueConstraintNode): UniqueConstraintNode;
|
|
131
132
|
protected transformForeignKeyConstraint(node: ForeignKeyConstraintNode): ForeignKeyConstraintNode;
|
|
133
|
+
protected transformUnion(node: UnionNode): UnionNode;
|
|
132
134
|
protected transformReferences(node: ReferencesNode): ReferencesNode;
|
|
133
135
|
protected transformCheckConstraint(node: CheckConstraintNode): CheckConstraintNode;
|
|
134
136
|
protected transformWith(node: WithNode): WithNode;
|
|
@@ -92,6 +92,7 @@ class OperationNodeTransformer {
|
|
|
92
92
|
AddConstraintNode: this.transformAddConstraint.bind(this),
|
|
93
93
|
DropConstraintNode: this.transformDropConstraint.bind(this),
|
|
94
94
|
ForeignKeyConstraintNode: this.transformForeignKeyConstraint.bind(this),
|
|
95
|
+
UnionNode: this.transformUnion.bind(this),
|
|
95
96
|
};
|
|
96
97
|
transformNode = (node) => {
|
|
97
98
|
if (!node) {
|
|
@@ -124,6 +125,7 @@ class OperationNodeTransformer {
|
|
|
124
125
|
offset: this.transformNode(node.offset),
|
|
125
126
|
with: this.transformNode(node.with),
|
|
126
127
|
having: this.transformNode(node.having),
|
|
128
|
+
union: this.transformNodeList(node.union),
|
|
127
129
|
};
|
|
128
130
|
}
|
|
129
131
|
transformSelection(node) {
|
|
@@ -403,6 +405,13 @@ class OperationNodeTransformer {
|
|
|
403
405
|
onUpdate: node.onUpdate,
|
|
404
406
|
};
|
|
405
407
|
}
|
|
408
|
+
transformUnion(node) {
|
|
409
|
+
return {
|
|
410
|
+
kind: 'UnionNode',
|
|
411
|
+
union: this.transformNode(node.union),
|
|
412
|
+
all: node.all,
|
|
413
|
+
};
|
|
414
|
+
}
|
|
406
415
|
transformReferences(node) {
|
|
407
416
|
return {
|
|
408
417
|
kind: 'ReferencesNode',
|
|
@@ -57,66 +57,68 @@ import { ForeignKeyConstraintNode } from './foreign-key-constraint-node.js';
|
|
|
57
57
|
import { ColumnDefinitionNode } from './column-definition-node.js';
|
|
58
58
|
import { ModifyColumnNode } from './modify-column-node.js';
|
|
59
59
|
import { OnDuplicateKeyNode } from './on-duplicate-key-node.js';
|
|
60
|
-
|
|
60
|
+
import { UnionNode } from './union-node.js';
|
|
61
|
+
export declare abstract class OperationNodeVisitor {
|
|
61
62
|
#private;
|
|
62
63
|
protected readonly nodeStack: OperationNode[];
|
|
63
64
|
protected readonly visitNode: (node: OperationNode) => void;
|
|
64
|
-
protected visitSelectQuery(node: SelectQueryNode): void;
|
|
65
|
-
protected visitSelection(node: SelectionNode): void;
|
|
66
|
-
protected visitColumn(node: ColumnNode): void;
|
|
67
|
-
protected visitAlias(node: AliasNode): void;
|
|
68
|
-
protected visitTable(node: TableNode): void;
|
|
69
|
-
protected visitFrom(node: FromNode): void;
|
|
70
|
-
protected visitReference(node: ReferenceNode): void;
|
|
71
|
-
protected visitFilter(node: FilterNode): void;
|
|
72
|
-
protected visitAnd(node: AndNode): void;
|
|
73
|
-
protected visitOr(node: OrNode): void;
|
|
74
|
-
protected visitValueList(node: ValueListNode): void;
|
|
75
|
-
protected visitParens(node: ParensNode): void;
|
|
76
|
-
protected visitJoin(node: JoinNode): void;
|
|
77
|
-
protected visitRaw(node: RawNode): void;
|
|
78
|
-
protected visitWhere(node: WhereNode): void;
|
|
79
|
-
protected visitInsertQuery(node: InsertQueryNode): void;
|
|
80
|
-
protected visitDeleteQuery(node: DeleteQueryNode): void;
|
|
81
|
-
protected visitReturning(node: ReturningNode): void;
|
|
82
|
-
protected visitCreateTable(node: CreateTableNode): void;
|
|
83
|
-
protected visitAddColumn(node: AddColumnNode): void;
|
|
84
|
-
protected visitColumnDefinition(node: ColumnDefinitionNode): void;
|
|
85
|
-
protected visitDropTable(node: DropTableNode): void;
|
|
86
|
-
protected visitOrderBy(node: OrderByNode): void;
|
|
87
|
-
protected visitOrderByItem(node: OrderByItemNode): void;
|
|
88
|
-
protected visitGroupBy(node: GroupByNode): void;
|
|
89
|
-
protected visitGroupByItem(node: GroupByItemNode): void;
|
|
90
|
-
protected visitUpdateQuery(node: UpdateQueryNode): void;
|
|
91
|
-
protected visitColumnUpdate(node: ColumnUpdateNode): void;
|
|
92
|
-
protected visitLimit(node: LimitNode): void;
|
|
93
|
-
protected visitOffset(node: OffsetNode): void;
|
|
94
|
-
protected visitOnConflict(node: OnConflictNode): void;
|
|
95
|
-
protected visitOnDuplicateKey(node: OnDuplicateKeyNode): void;
|
|
96
|
-
protected visitCreateIndex(node: CreateIndexNode): void;
|
|
97
|
-
protected
|
|
98
|
-
protected
|
|
99
|
-
protected visitPrimaryKeyConstraint(node: PrimaryKeyConstraintNode): void;
|
|
100
|
-
protected visitUniqueConstraint(node: UniqueConstraintNode): void;
|
|
101
|
-
protected visitReferences(node: ReferencesNode): void;
|
|
102
|
-
protected visitCheckConstraint(node: CheckConstraintNode): void;
|
|
103
|
-
protected visitWith(node: WithNode): void;
|
|
104
|
-
protected visitCommonTableExpression(node: CommonTableExpressionNode): void;
|
|
105
|
-
protected visitHaving(node: HavingNode): void;
|
|
106
|
-
protected visitCreateSchema(node: CreateSchemaNode): void;
|
|
107
|
-
protected visitDropSchema(node: DropSchemaNode): void;
|
|
108
|
-
protected visitAlterTable(node: AlterTableNode): void;
|
|
109
|
-
protected visitDropColumn(node: DropColumnNode): void;
|
|
110
|
-
protected visitRenameColumn(node: RenameColumnNode): void;
|
|
111
|
-
protected visitAlterColumn(node: AlterColumnNode): void;
|
|
112
|
-
protected visitModifyColumn(node: ModifyColumnNode): void;
|
|
113
|
-
protected visitAddConstraint(node: AddConstraintNode): void;
|
|
114
|
-
protected visitDropConstraint(node: DropConstraintNode): void;
|
|
115
|
-
protected visitForeignKeyConstraint(node: ForeignKeyConstraintNode): void;
|
|
116
|
-
protected
|
|
117
|
-
protected
|
|
118
|
-
protected
|
|
119
|
-
protected
|
|
120
|
-
protected
|
|
121
|
-
protected
|
|
65
|
+
protected abstract visitSelectQuery(node: SelectQueryNode): void;
|
|
66
|
+
protected abstract visitSelection(node: SelectionNode): void;
|
|
67
|
+
protected abstract visitColumn(node: ColumnNode): void;
|
|
68
|
+
protected abstract visitAlias(node: AliasNode): void;
|
|
69
|
+
protected abstract visitTable(node: TableNode): void;
|
|
70
|
+
protected abstract visitFrom(node: FromNode): void;
|
|
71
|
+
protected abstract visitReference(node: ReferenceNode): void;
|
|
72
|
+
protected abstract visitFilter(node: FilterNode): void;
|
|
73
|
+
protected abstract visitAnd(node: AndNode): void;
|
|
74
|
+
protected abstract visitOr(node: OrNode): void;
|
|
75
|
+
protected abstract visitValueList(node: ValueListNode): void;
|
|
76
|
+
protected abstract visitParens(node: ParensNode): void;
|
|
77
|
+
protected abstract visitJoin(node: JoinNode): void;
|
|
78
|
+
protected abstract visitRaw(node: RawNode): void;
|
|
79
|
+
protected abstract visitWhere(node: WhereNode): void;
|
|
80
|
+
protected abstract visitInsertQuery(node: InsertQueryNode): void;
|
|
81
|
+
protected abstract visitDeleteQuery(node: DeleteQueryNode): void;
|
|
82
|
+
protected abstract visitReturning(node: ReturningNode): void;
|
|
83
|
+
protected abstract visitCreateTable(node: CreateTableNode): void;
|
|
84
|
+
protected abstract visitAddColumn(node: AddColumnNode): void;
|
|
85
|
+
protected abstract visitColumnDefinition(node: ColumnDefinitionNode): void;
|
|
86
|
+
protected abstract visitDropTable(node: DropTableNode): void;
|
|
87
|
+
protected abstract visitOrderBy(node: OrderByNode): void;
|
|
88
|
+
protected abstract visitOrderByItem(node: OrderByItemNode): void;
|
|
89
|
+
protected abstract visitGroupBy(node: GroupByNode): void;
|
|
90
|
+
protected abstract visitGroupByItem(node: GroupByItemNode): void;
|
|
91
|
+
protected abstract visitUpdateQuery(node: UpdateQueryNode): void;
|
|
92
|
+
protected abstract visitColumnUpdate(node: ColumnUpdateNode): void;
|
|
93
|
+
protected abstract visitLimit(node: LimitNode): void;
|
|
94
|
+
protected abstract visitOffset(node: OffsetNode): void;
|
|
95
|
+
protected abstract visitOnConflict(node: OnConflictNode): void;
|
|
96
|
+
protected abstract visitOnDuplicateKey(node: OnDuplicateKeyNode): void;
|
|
97
|
+
protected abstract visitCreateIndex(node: CreateIndexNode): void;
|
|
98
|
+
protected abstract visitDropIndex(node: DropIndexNode): void;
|
|
99
|
+
protected abstract visitList(node: ListNode): void;
|
|
100
|
+
protected abstract visitPrimaryKeyConstraint(node: PrimaryKeyConstraintNode): void;
|
|
101
|
+
protected abstract visitUniqueConstraint(node: UniqueConstraintNode): void;
|
|
102
|
+
protected abstract visitReferences(node: ReferencesNode): void;
|
|
103
|
+
protected abstract visitCheckConstraint(node: CheckConstraintNode): void;
|
|
104
|
+
protected abstract visitWith(node: WithNode): void;
|
|
105
|
+
protected abstract visitCommonTableExpression(node: CommonTableExpressionNode): void;
|
|
106
|
+
protected abstract visitHaving(node: HavingNode): void;
|
|
107
|
+
protected abstract visitCreateSchema(node: CreateSchemaNode): void;
|
|
108
|
+
protected abstract visitDropSchema(node: DropSchemaNode): void;
|
|
109
|
+
protected abstract visitAlterTable(node: AlterTableNode): void;
|
|
110
|
+
protected abstract visitDropColumn(node: DropColumnNode): void;
|
|
111
|
+
protected abstract visitRenameColumn(node: RenameColumnNode): void;
|
|
112
|
+
protected abstract visitAlterColumn(node: AlterColumnNode): void;
|
|
113
|
+
protected abstract visitModifyColumn(node: ModifyColumnNode): void;
|
|
114
|
+
protected abstract visitAddConstraint(node: AddConstraintNode): void;
|
|
115
|
+
protected abstract visitDropConstraint(node: DropConstraintNode): void;
|
|
116
|
+
protected abstract visitForeignKeyConstraint(node: ForeignKeyConstraintNode): void;
|
|
117
|
+
protected abstract visitUnion(node: UnionNode): void;
|
|
118
|
+
protected abstract visitDataType(node: DataTypeNode): void;
|
|
119
|
+
protected abstract visitSelectAll(_: SelectAllNode): void;
|
|
120
|
+
protected abstract visitIdentifier(_: IdentifierNode): void;
|
|
121
|
+
protected abstract visitValue(_: ValueNode): void;
|
|
122
|
+
protected abstract visitPrimitiveValueList(_: PrimitiveValueListNode): void;
|
|
123
|
+
protected abstract visitOperator(node: OperatorNode): void;
|
|
122
124
|
}
|
|
@@ -62,327 +62,12 @@ class OperationNodeVisitor {
|
|
|
62
62
|
AddConstraintNode: this.visitAddConstraint.bind(this),
|
|
63
63
|
DropConstraintNode: this.visitDropConstraint.bind(this),
|
|
64
64
|
ForeignKeyConstraintNode: this.visitForeignKeyConstraint.bind(this),
|
|
65
|
+
UnionNode: this.visitUnion.bind(this),
|
|
65
66
|
};
|
|
66
67
|
visitNode = (node) => {
|
|
67
68
|
this.nodeStack.push(node);
|
|
68
69
|
this.#visitors[node.kind](node);
|
|
69
70
|
this.nodeStack.pop();
|
|
70
71
|
};
|
|
71
|
-
visitSelectQuery(node) {
|
|
72
|
-
if (node.with) {
|
|
73
|
-
this.visitNode(node.with);
|
|
74
|
-
}
|
|
75
|
-
if (node.distinctOnSelections) {
|
|
76
|
-
node.distinctOnSelections.forEach(this.visitNode);
|
|
77
|
-
}
|
|
78
|
-
if (node.selections) {
|
|
79
|
-
node.selections.forEach(this.visitNode);
|
|
80
|
-
}
|
|
81
|
-
this.visitNode(node.from);
|
|
82
|
-
if (node.joins) {
|
|
83
|
-
node.joins.forEach(this.visitNode);
|
|
84
|
-
}
|
|
85
|
-
if (node.where) {
|
|
86
|
-
this.visitNode(node.where);
|
|
87
|
-
}
|
|
88
|
-
if (node.groupBy) {
|
|
89
|
-
this.visitNode(node.groupBy);
|
|
90
|
-
}
|
|
91
|
-
if (node.having) {
|
|
92
|
-
this.visitNode(node.having);
|
|
93
|
-
}
|
|
94
|
-
if (node.orderBy) {
|
|
95
|
-
this.visitNode(node.orderBy);
|
|
96
|
-
}
|
|
97
|
-
if (node.limit) {
|
|
98
|
-
this.visitNode(node.limit);
|
|
99
|
-
}
|
|
100
|
-
if (node.offset) {
|
|
101
|
-
this.visitNode(node.offset);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
visitSelection(node) {
|
|
105
|
-
this.visitNode(node.selection);
|
|
106
|
-
}
|
|
107
|
-
visitColumn(node) {
|
|
108
|
-
this.visitNode(node.column);
|
|
109
|
-
}
|
|
110
|
-
visitAlias(node) {
|
|
111
|
-
this.visitNode(node.node);
|
|
112
|
-
}
|
|
113
|
-
visitTable(node) {
|
|
114
|
-
if (node.schema) {
|
|
115
|
-
this.visitNode(node.schema);
|
|
116
|
-
}
|
|
117
|
-
this.visitNode(node.table);
|
|
118
|
-
}
|
|
119
|
-
visitFrom(node) {
|
|
120
|
-
node.froms.forEach(this.visitNode);
|
|
121
|
-
}
|
|
122
|
-
visitReference(node) {
|
|
123
|
-
this.visitNode(node.column);
|
|
124
|
-
this.visitNode(node.table);
|
|
125
|
-
}
|
|
126
|
-
visitFilter(node) {
|
|
127
|
-
if (node.left) {
|
|
128
|
-
this.visitNode(node.left);
|
|
129
|
-
}
|
|
130
|
-
this.visitNode(node.op);
|
|
131
|
-
this.visitNode(node.right);
|
|
132
|
-
}
|
|
133
|
-
visitAnd(node) {
|
|
134
|
-
this.visitNode(node.left);
|
|
135
|
-
this.visitNode(node.right);
|
|
136
|
-
}
|
|
137
|
-
visitOr(node) {
|
|
138
|
-
this.visitNode(node.left);
|
|
139
|
-
this.visitNode(node.right);
|
|
140
|
-
}
|
|
141
|
-
visitValueList(node) {
|
|
142
|
-
node.values.forEach(this.visitNode);
|
|
143
|
-
}
|
|
144
|
-
visitParens(node) {
|
|
145
|
-
this.visitNode(node.node);
|
|
146
|
-
}
|
|
147
|
-
visitJoin(node) {
|
|
148
|
-
this.visitNode(node.table);
|
|
149
|
-
if (node.on) {
|
|
150
|
-
this.visitNode(node.on);
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
visitRaw(node) {
|
|
154
|
-
node.params.forEach(this.visitNode);
|
|
155
|
-
}
|
|
156
|
-
visitWhere(node) {
|
|
157
|
-
this.visitNode(node.where);
|
|
158
|
-
}
|
|
159
|
-
visitInsertQuery(node) {
|
|
160
|
-
if (node.with) {
|
|
161
|
-
this.visitNode(node.with);
|
|
162
|
-
}
|
|
163
|
-
this.visitNode(node.into);
|
|
164
|
-
if (node.columns) {
|
|
165
|
-
node.columns.forEach(this.visitNode);
|
|
166
|
-
}
|
|
167
|
-
if (node.values) {
|
|
168
|
-
node.values.forEach(this.visitNode);
|
|
169
|
-
}
|
|
170
|
-
if (node.returning) {
|
|
171
|
-
this.visitNode(node.returning);
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
visitDeleteQuery(node) {
|
|
175
|
-
if (node.with) {
|
|
176
|
-
this.visitNode(node.with);
|
|
177
|
-
}
|
|
178
|
-
this.visitNode(node.from);
|
|
179
|
-
if (node.joins) {
|
|
180
|
-
node.joins.forEach(this.visitNode);
|
|
181
|
-
}
|
|
182
|
-
if (node.where) {
|
|
183
|
-
this.visitNode(node.where);
|
|
184
|
-
}
|
|
185
|
-
if (node.returning) {
|
|
186
|
-
this.visitNode(node.returning);
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
visitReturning(node) {
|
|
190
|
-
node.selections.forEach(this.visitNode);
|
|
191
|
-
}
|
|
192
|
-
visitCreateTable(node) {
|
|
193
|
-
this.visitNode(node.table);
|
|
194
|
-
node.columns.forEach(this.visitNode);
|
|
195
|
-
if (node.constraints) {
|
|
196
|
-
node.constraints.forEach(this.visitNode);
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
visitAddColumn(node) {
|
|
200
|
-
this.visitNode(node.column);
|
|
201
|
-
}
|
|
202
|
-
visitColumnDefinition(node) {
|
|
203
|
-
this.visitNode(node.column);
|
|
204
|
-
this.visitNode(node.dataType);
|
|
205
|
-
if (node.defaultTo) {
|
|
206
|
-
this.visitNode(node.defaultTo);
|
|
207
|
-
}
|
|
208
|
-
if (node.references) {
|
|
209
|
-
this.visitNode(node.references);
|
|
210
|
-
}
|
|
211
|
-
if (node.check) {
|
|
212
|
-
this.visitNode(node.check);
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
visitDropTable(node) {
|
|
216
|
-
this.visitNode(node.table);
|
|
217
|
-
}
|
|
218
|
-
visitOrderBy(node) {
|
|
219
|
-
node.items.forEach(this.visitNode);
|
|
220
|
-
}
|
|
221
|
-
visitOrderByItem(node) {
|
|
222
|
-
this.visitNode(node.orderBy);
|
|
223
|
-
}
|
|
224
|
-
visitGroupBy(node) {
|
|
225
|
-
node.items.forEach(this.visitNode);
|
|
226
|
-
}
|
|
227
|
-
visitGroupByItem(node) {
|
|
228
|
-
this.visitNode(node.groupBy);
|
|
229
|
-
}
|
|
230
|
-
visitUpdateQuery(node) {
|
|
231
|
-
if (node.with) {
|
|
232
|
-
this.visitNode(node.with);
|
|
233
|
-
}
|
|
234
|
-
this.visitNode(node.table);
|
|
235
|
-
if (node.updates) {
|
|
236
|
-
node.updates.forEach(this.visitNode);
|
|
237
|
-
}
|
|
238
|
-
if (node.joins) {
|
|
239
|
-
node.joins.forEach(this.visitNode);
|
|
240
|
-
}
|
|
241
|
-
if (node.where) {
|
|
242
|
-
this.visitNode(node.where);
|
|
243
|
-
}
|
|
244
|
-
if (node.returning) {
|
|
245
|
-
this.visitNode(node.returning);
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
visitColumnUpdate(node) {
|
|
249
|
-
this.visitNode(node.column);
|
|
250
|
-
this.visitNode(node.value);
|
|
251
|
-
}
|
|
252
|
-
visitLimit(node) {
|
|
253
|
-
this.visitNode(node.limit);
|
|
254
|
-
}
|
|
255
|
-
visitOffset(node) {
|
|
256
|
-
this.visitNode(node.offset);
|
|
257
|
-
}
|
|
258
|
-
visitOnConflict(node) {
|
|
259
|
-
if (node.columns) {
|
|
260
|
-
node.columns.forEach(this.visitNode);
|
|
261
|
-
}
|
|
262
|
-
if (node.constraint) {
|
|
263
|
-
this.visitNode(node.constraint);
|
|
264
|
-
}
|
|
265
|
-
if (node.updates) {
|
|
266
|
-
node.updates.forEach(this.visitNode);
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
visitOnDuplicateKey(node) {
|
|
270
|
-
node.updates.forEach(this.visitNode);
|
|
271
|
-
}
|
|
272
|
-
visitCreateIndex(node) {
|
|
273
|
-
this.visitNode(node.name);
|
|
274
|
-
if (node.table) {
|
|
275
|
-
this.visitNode(node.table);
|
|
276
|
-
}
|
|
277
|
-
if (node.using) {
|
|
278
|
-
this.visitNode(node.using);
|
|
279
|
-
}
|
|
280
|
-
if (node.expression) {
|
|
281
|
-
this.visitNode(node.expression);
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
visitList(node) {
|
|
285
|
-
node.items.forEach(this.visitNode);
|
|
286
|
-
}
|
|
287
|
-
visitDropIndex(node) {
|
|
288
|
-
this.visitNode(node.name);
|
|
289
|
-
if (node.table) {
|
|
290
|
-
this.visitNode(node.table);
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
visitPrimaryKeyConstraint(node) {
|
|
294
|
-
if (node.name) {
|
|
295
|
-
this.visitNode(node.name);
|
|
296
|
-
}
|
|
297
|
-
node.columns.forEach(this.visitNode);
|
|
298
|
-
}
|
|
299
|
-
visitUniqueConstraint(node) {
|
|
300
|
-
if (node.name) {
|
|
301
|
-
this.visitNode(node.name);
|
|
302
|
-
}
|
|
303
|
-
node.columns.forEach(this.visitNode);
|
|
304
|
-
}
|
|
305
|
-
visitReferences(node) {
|
|
306
|
-
node.columns.forEach(this.visitNode);
|
|
307
|
-
this.visitNode(node.table);
|
|
308
|
-
}
|
|
309
|
-
visitCheckConstraint(node) {
|
|
310
|
-
if (node.name) {
|
|
311
|
-
this.visitNode(node.name);
|
|
312
|
-
}
|
|
313
|
-
this.visitNode(node.expression);
|
|
314
|
-
}
|
|
315
|
-
visitWith(node) {
|
|
316
|
-
node.expressions.forEach(this.visitNode);
|
|
317
|
-
}
|
|
318
|
-
visitCommonTableExpression(node) {
|
|
319
|
-
this.visitNode(node.name);
|
|
320
|
-
this.visitNode(node.expression);
|
|
321
|
-
}
|
|
322
|
-
visitHaving(node) {
|
|
323
|
-
this.visitNode(node.having);
|
|
324
|
-
}
|
|
325
|
-
visitCreateSchema(node) {
|
|
326
|
-
this.visitNode(node.schema);
|
|
327
|
-
}
|
|
328
|
-
visitDropSchema(node) {
|
|
329
|
-
this.visitNode(node.schema);
|
|
330
|
-
}
|
|
331
|
-
visitAlterTable(node) {
|
|
332
|
-
this.visitNode(node.table);
|
|
333
|
-
if (node.renameTo) {
|
|
334
|
-
this.visitNode(node.renameTo);
|
|
335
|
-
}
|
|
336
|
-
if (node.renameColumn) {
|
|
337
|
-
this.visitNode(node.renameColumn);
|
|
338
|
-
}
|
|
339
|
-
if (node.setSchema) {
|
|
340
|
-
this.visitNode(node.setSchema);
|
|
341
|
-
}
|
|
342
|
-
if (node.addColumn) {
|
|
343
|
-
this.visitNode(node.addColumn);
|
|
344
|
-
}
|
|
345
|
-
if (node.dropColumn) {
|
|
346
|
-
this.visitNode(node.dropColumn);
|
|
347
|
-
}
|
|
348
|
-
if (node.alterColumn) {
|
|
349
|
-
this.visitNode(node.alterColumn);
|
|
350
|
-
}
|
|
351
|
-
if (node.modifyColumn) {
|
|
352
|
-
this.visitNode(node.modifyColumn);
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
visitDropColumn(node) {
|
|
356
|
-
this.visitNode(node.column);
|
|
357
|
-
}
|
|
358
|
-
visitRenameColumn(node) {
|
|
359
|
-
this.visitNode(node.column);
|
|
360
|
-
this.visitNode(node.renameTo);
|
|
361
|
-
}
|
|
362
|
-
visitAlterColumn(node) {
|
|
363
|
-
this.visitNode(node.column);
|
|
364
|
-
}
|
|
365
|
-
visitModifyColumn(node) {
|
|
366
|
-
this.visitNode(node.column);
|
|
367
|
-
}
|
|
368
|
-
visitAddConstraint(node) {
|
|
369
|
-
this.visitNode(node.constraint);
|
|
370
|
-
}
|
|
371
|
-
visitDropConstraint(node) {
|
|
372
|
-
this.visitNode(node.constraintName);
|
|
373
|
-
}
|
|
374
|
-
visitForeignKeyConstraint(node) {
|
|
375
|
-
if (node.name) {
|
|
376
|
-
this.visitNode(node.name);
|
|
377
|
-
}
|
|
378
|
-
node.columns.forEach(this.visitNode);
|
|
379
|
-
this.visitNode(node.references);
|
|
380
|
-
}
|
|
381
|
-
visitDataType(node) { }
|
|
382
|
-
visitSelectAll(_) { }
|
|
383
|
-
visitIdentifier(_) { }
|
|
384
|
-
visitValue(_) { }
|
|
385
|
-
visitPrimitiveValueList(_) { }
|
|
386
|
-
visitOperator(node) { }
|
|
387
72
|
}
|
|
388
73
|
exports.OperationNodeVisitor = OperationNodeVisitor;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare type OperationNodeKind = 'IdentifierNode' | 'RawNode' | 'SelectQueryNode' | 'SelectionNode' | 'ReferenceNode' | 'ColumnNode' | 'TableNode' | 'AliasNode' | 'FromNode' | 'SelectAllNode' | 'FilterNode' | 'AndNode' | 'OrNode' | 'ParensNode' | 'ValueNode' | 'ValueListNode' | 'PrimitiveValueListNode' | 'JoinNode' | 'OperatorNode' | 'WhereNode' | 'InsertQueryNode' | 'DeleteQueryNode' | 'ReturningNode' | 'CreateTableNode' | 'ColumnDefinitionNode' | 'AddColumnNode' | 'DropTableNode' | 'DataTypeNode' | 'OrderByNode' | 'OrderByItemNode' | 'GroupByNode' | 'GroupByItemNode' | 'UpdateQueryNode' | 'ColumnUpdateNode' | 'LimitNode' | 'OffsetNode' | 'OnConflictNode' | 'OnDuplicateKeyNode' | 'CreateIndexNode' | 'DropIndexNode' | 'ListNode' | 'ReferencesNode' | 'PrimaryKeyConstraintNode' | 'UniqueConstraintNode' | 'CheckConstraintNode' | 'ForeignKeyConstraintNode' | 'WithNode' | 'CommonTableExpressionNode' | 'HavingNode' | 'CreateSchemaNode' | 'DropSchemaNode' | 'AlterTableNode' | 'ModifyColumnNode' | 'DropColumnNode' | 'RenameColumnNode' | 'AlterColumnNode' | 'AddConstraintNode' | 'DropConstraintNode';
|
|
1
|
+
export declare type OperationNodeKind = 'IdentifierNode' | 'RawNode' | 'SelectQueryNode' | 'SelectionNode' | 'ReferenceNode' | 'ColumnNode' | 'TableNode' | 'AliasNode' | 'FromNode' | 'SelectAllNode' | 'FilterNode' | 'AndNode' | 'OrNode' | 'ParensNode' | 'ValueNode' | 'ValueListNode' | 'PrimitiveValueListNode' | 'JoinNode' | 'OperatorNode' | 'WhereNode' | 'InsertQueryNode' | 'DeleteQueryNode' | 'ReturningNode' | 'CreateTableNode' | 'ColumnDefinitionNode' | 'AddColumnNode' | 'DropTableNode' | 'DataTypeNode' | 'OrderByNode' | 'OrderByItemNode' | 'GroupByNode' | 'GroupByItemNode' | 'UpdateQueryNode' | 'ColumnUpdateNode' | 'LimitNode' | 'OffsetNode' | 'OnConflictNode' | 'OnDuplicateKeyNode' | 'CreateIndexNode' | 'DropIndexNode' | 'ListNode' | 'ReferencesNode' | 'PrimaryKeyConstraintNode' | 'UniqueConstraintNode' | 'CheckConstraintNode' | 'ForeignKeyConstraintNode' | 'WithNode' | 'CommonTableExpressionNode' | 'HavingNode' | 'CreateSchemaNode' | 'DropSchemaNode' | 'AlterTableNode' | 'ModifyColumnNode' | 'DropColumnNode' | 'RenameColumnNode' | 'AlterColumnNode' | 'AddConstraintNode' | 'DropConstraintNode' | 'UnionNode';
|
|
2
2
|
export interface OperationNode {
|
|
3
3
|
readonly kind: OperationNodeKind;
|
|
4
4
|
}
|
|
@@ -12,6 +12,7 @@ import { OrderByNode } from './order-by-node.js';
|
|
|
12
12
|
import { SelectionNode } from './selection-node.js';
|
|
13
13
|
import { WhereNode } from './where-node.js';
|
|
14
14
|
import { WithNode } from './with-node.js';
|
|
15
|
+
import { UnionNode } from './union-node.js';
|
|
15
16
|
export declare type SelectModifier = 'ForUpdate' | 'ForNoKeyUpdate' | 'ForShare' | 'ForKeyShare' | 'NoWait' | 'SkipLocked';
|
|
16
17
|
export interface SelectQueryNode extends OperationNode {
|
|
17
18
|
readonly kind: 'SelectQueryNode';
|
|
@@ -28,6 +29,7 @@ export interface SelectQueryNode extends OperationNode {
|
|
|
28
29
|
readonly offset?: OffsetNode;
|
|
29
30
|
readonly with?: WithNode;
|
|
30
31
|
readonly having?: HavingNode;
|
|
32
|
+
readonly union?: ReadonlyArray<UnionNode>;
|
|
31
33
|
}
|
|
32
34
|
/**
|
|
33
35
|
* @internal
|
|
@@ -45,4 +47,5 @@ export declare const SelectQueryNode: Readonly<{
|
|
|
45
47
|
cloneWithHaving(selectNode: SelectQueryNode, filter: HavingNodeChild): SelectQueryNode;
|
|
46
48
|
cloneWithOrHaving(selectNode: SelectQueryNode, filter: HavingNodeChild): SelectQueryNode;
|
|
47
49
|
cloneWithDistinct(selectNode: SelectQueryNode): SelectQueryNode;
|
|
50
|
+
cloneWithUnion(selectNode: SelectQueryNode, union: UnionNode): SelectQueryNode;
|
|
48
51
|
}>;
|
|
@@ -94,4 +94,12 @@ exports.SelectQueryNode = (0, object_utils_js_1.freeze)({
|
|
|
94
94
|
isDistinct: true,
|
|
95
95
|
});
|
|
96
96
|
},
|
|
97
|
+
cloneWithUnion(selectNode, union) {
|
|
98
|
+
return (0, object_utils_js_1.freeze)({
|
|
99
|
+
...selectNode,
|
|
100
|
+
union: selectNode.union
|
|
101
|
+
? (0, object_utils_js_1.freeze)([...selectNode.union, union])
|
|
102
|
+
: (0, object_utils_js_1.freeze)([union]),
|
|
103
|
+
});
|
|
104
|
+
},
|
|
97
105
|
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { OperationNode } from './operation-node.js';
|
|
2
|
+
import { RawNode } from './raw-node.js';
|
|
3
|
+
import { SelectQueryNode } from './select-query-node.js';
|
|
4
|
+
export declare type UnionExpressionNode = SelectQueryNode | RawNode;
|
|
5
|
+
export interface UnionNode extends OperationNode {
|
|
6
|
+
readonly kind: 'UnionNode';
|
|
7
|
+
readonly union: UnionExpressionNode;
|
|
8
|
+
readonly all: boolean;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
13
|
+
export declare const UnionNode: Readonly<{
|
|
14
|
+
is(node: OperationNode): node is UnionNode;
|
|
15
|
+
create(union: UnionExpressionNode, all: boolean): UnionNode;
|
|
16
|
+
}>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UnionNode = void 0;
|
|
4
|
+
const object_utils_js_1 = require("../util/object-utils.js");
|
|
5
|
+
/**
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
8
|
+
exports.UnionNode = (0, object_utils_js_1.freeze)({
|
|
9
|
+
is(node) {
|
|
10
|
+
return node.kind === 'UnionNode';
|
|
11
|
+
},
|
|
12
|
+
create(union, all) {
|
|
13
|
+
return (0, object_utils_js_1.freeze)({
|
|
14
|
+
kind: 'UnionNode',
|
|
15
|
+
union,
|
|
16
|
+
all,
|
|
17
|
+
});
|
|
18
|
+
},
|
|
19
|
+
});
|
|
@@ -8,7 +8,7 @@ import { PrimitiveValue } from '../util/object-utils.js';
|
|
|
8
8
|
export declare type InsertObject<DB, TB extends keyof DB> = {
|
|
9
9
|
[C in keyof DB[TB]]: InsertValueExpression<DB[TB][C]>;
|
|
10
10
|
};
|
|
11
|
-
export declare type InsertObjectOrList<DB, TB extends keyof DB> = InsertObject<DB, TB> | InsertObject<DB, TB
|
|
11
|
+
export declare type InsertObjectOrList<DB, TB extends keyof DB> = InsertObject<DB, TB> | ReadonlyArray<InsertObject<DB, TB>>;
|
|
12
12
|
declare type InsertValueExpression<T> = T | AnyQueryBuilder | AnyRawBuilder | GeneratedPlaceholder;
|
|
13
13
|
export declare function parseInsertObjectOrList(args: InsertObjectOrList<any, any>): [ReadonlyArray<ColumnNode>, ReadonlyArray<InsertValuesNode>];
|
|
14
14
|
export declare function parseInsertValueExpression(value: InsertValueExpression<PrimitiveValue>): ValueNode | RawNode | SelectQueryNode;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { UnionNode } from '../operation-node/union-node.js';
|
|
2
|
+
import { QueryBuilder } from '../query-builder/query-builder.js';
|
|
3
|
+
import { RawBuilder } from '../raw-builder/raw-builder.js';
|
|
4
|
+
export declare type UnionExpression<DB, O> = QueryBuilder<DB, any, O> | RawBuilder<O>;
|
|
5
|
+
export declare function parseUnion(union: UnionExpression<any, any>, all: boolean): UnionNode;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseUnion = void 0;
|
|
4
|
+
const query_node_js_1 = require("../operation-node/query-node.js");
|
|
5
|
+
const union_node_js_1 = require("../operation-node/union-node.js");
|
|
6
|
+
function parseUnion(union, all) {
|
|
7
|
+
const node = union.toOperationNode();
|
|
8
|
+
if (query_node_js_1.QueryNode.isMutating(node)) {
|
|
9
|
+
throw new Error("can't combine insert, update or delete queries using union");
|
|
10
|
+
}
|
|
11
|
+
return union_node_js_1.UnionNode.create(node, all);
|
|
12
|
+
}
|
|
13
|
+
exports.parseUnion = parseUnion;
|
|
@@ -3,6 +3,6 @@ import { AnyQueryBuilder, AnyRawBuilder, QueryBuilderFactory, RawBuilderFactory
|
|
|
3
3
|
import { ExtractTypeFromReferenceExpression } from './reference-parser.js';
|
|
4
4
|
import { ParseContext } from './parse-context.js';
|
|
5
5
|
export declare type ValueExpression<DB, TB extends keyof DB, RE> = ExtractTypeFromReferenceExpression<DB, TB, RE> | AnyQueryBuilder | QueryBuilderFactory<DB, TB> | AnyRawBuilder | RawBuilderFactory<DB, TB>;
|
|
6
|
-
export declare type ValueExpressionOrList<DB, TB extends keyof DB, RE> = ValueExpression<DB, TB, RE> | ValueExpression<DB, TB, RE
|
|
6
|
+
export declare type ValueExpressionOrList<DB, TB extends keyof DB, RE> = ValueExpression<DB, TB, RE> | ReadonlyArray<ValueExpression<DB, TB, RE>>;
|
|
7
7
|
export declare function parseValueExpressionOrList(ctx: ParseContext, arg: ValueExpressionOrList<any, any, any>): ValueExpressionNode;
|
|
8
8
|
export declare function parseValueExpression(ctx: ParseContext, arg: ValueExpression<any, any, any>): ValueExpressionNode;
|