@simplysm/orm-common 13.0.69 → 13.0.71
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 +54 -1447
- package/dist/create-db-context.d.ts +10 -10
- package/dist/create-db-context.js +9 -9
- package/dist/create-db-context.js.map +1 -1
- package/dist/ddl/column-ddl.d.ts +4 -4
- package/dist/ddl/initialize.d.ts +17 -17
- package/dist/ddl/initialize.js +2 -2
- package/dist/ddl/initialize.js.map +1 -1
- package/dist/ddl/relation-ddl.d.ts +6 -6
- package/dist/ddl/schema-ddl.d.ts +4 -4
- package/dist/ddl/table-ddl.d.ts +24 -24
- package/dist/ddl/table-ddl.js +4 -4
- package/dist/ddl/table-ddl.js.map +1 -1
- package/dist/errors/db-transaction-error.d.ts +15 -15
- package/dist/errors/db-transaction-error.d.ts.map +1 -1
- package/dist/exec/executable.d.ts +23 -23
- package/dist/exec/executable.js +3 -3
- package/dist/exec/executable.js.map +1 -1
- package/dist/exec/queryable.d.ts +160 -160
- package/dist/exec/queryable.js +119 -119
- package/dist/exec/queryable.js.map +1 -1
- package/dist/exec/search-parser.d.ts +37 -37
- package/dist/exec/search-parser.d.ts.map +1 -1
- package/dist/expr/expr-unit.d.ts +4 -4
- package/dist/expr/expr.d.ts +257 -257
- package/dist/expr/expr.js +265 -265
- package/dist/expr/expr.js.map +1 -1
- package/dist/query-builder/base/expr-renderer-base.d.ts +9 -9
- package/dist/query-builder/base/expr-renderer-base.js +2 -2
- package/dist/query-builder/base/expr-renderer-base.js.map +1 -1
- package/dist/query-builder/base/query-builder-base.d.ts +26 -26
- package/dist/query-builder/base/query-builder-base.d.ts.map +1 -1
- package/dist/query-builder/base/query-builder-base.js +22 -22
- package/dist/query-builder/base/query-builder-base.js.map +1 -1
- package/dist/query-builder/mssql/mssql-expr-renderer.d.ts +4 -4
- package/dist/query-builder/mssql/mssql-expr-renderer.d.ts.map +1 -1
- package/dist/query-builder/mssql/mssql-expr-renderer.js +18 -18
- package/dist/query-builder/mssql/mssql-expr-renderer.js.map +1 -1
- package/dist/query-builder/mssql/mssql-query-builder.d.ts +2 -2
- package/dist/query-builder/mssql/mssql-query-builder.d.ts.map +1 -1
- package/dist/query-builder/mssql/mssql-query-builder.js +11 -11
- package/dist/query-builder/mssql/mssql-query-builder.js.map +1 -1
- package/dist/query-builder/mysql/mysql-expr-renderer.d.ts +4 -4
- package/dist/query-builder/mysql/mysql-expr-renderer.d.ts.map +1 -1
- package/dist/query-builder/mysql/mysql-expr-renderer.js +17 -17
- package/dist/query-builder/mysql/mysql-expr-renderer.js.map +1 -1
- package/dist/query-builder/mysql/mysql-query-builder.d.ts +8 -8
- package/dist/query-builder/mysql/mysql-query-builder.d.ts.map +1 -1
- package/dist/query-builder/mysql/mysql-query-builder.js +5 -5
- package/dist/query-builder/mysql/mysql-query-builder.js.map +1 -1
- package/dist/query-builder/postgresql/postgresql-expr-renderer.d.ts +4 -4
- package/dist/query-builder/postgresql/postgresql-expr-renderer.d.ts.map +1 -1
- package/dist/query-builder/postgresql/postgresql-expr-renderer.js +17 -17
- package/dist/query-builder/postgresql/postgresql-expr-renderer.js.map +1 -1
- package/dist/query-builder/postgresql/postgresql-query-builder.d.ts +5 -5
- package/dist/query-builder/postgresql/postgresql-query-builder.d.ts.map +1 -1
- package/dist/query-builder/postgresql/postgresql-query-builder.js +8 -8
- package/dist/query-builder/postgresql/postgresql-query-builder.js.map +1 -1
- package/dist/query-builder/query-builder.d.ts +1 -1
- package/dist/schema/factory/column-builder.d.ts +79 -79
- package/dist/schema/factory/column-builder.js +42 -42
- package/dist/schema/factory/index-builder.d.ts +39 -39
- package/dist/schema/factory/index-builder.js +26 -26
- package/dist/schema/factory/relation-builder.d.ts +99 -99
- package/dist/schema/factory/relation-builder.d.ts.map +1 -1
- package/dist/schema/factory/relation-builder.js +38 -38
- package/dist/schema/procedure-builder.d.ts +49 -49
- package/dist/schema/procedure-builder.d.ts.map +1 -1
- package/dist/schema/procedure-builder.js +33 -33
- package/dist/schema/table-builder.d.ts +59 -59
- package/dist/schema/table-builder.d.ts.map +1 -1
- package/dist/schema/table-builder.js +43 -43
- package/dist/schema/view-builder.d.ts +49 -49
- package/dist/schema/view-builder.d.ts.map +1 -1
- package/dist/schema/view-builder.js +32 -32
- package/dist/types/column.d.ts +22 -22
- package/dist/types/column.js +1 -1
- package/dist/types/column.js.map +1 -1
- package/dist/types/db.d.ts +40 -40
- package/dist/types/expr.d.ts +59 -59
- package/dist/types/expr.d.ts.map +1 -1
- package/dist/types/query-def.d.ts +44 -44
- package/dist/types/query-def.d.ts.map +1 -1
- package/dist/utils/result-parser.d.ts +11 -11
- package/dist/utils/result-parser.js +3 -3
- package/dist/utils/result-parser.js.map +1 -1
- package/package.json +5 -5
- package/src/create-db-context.ts +20 -20
- package/src/ddl/column-ddl.ts +4 -4
- package/src/ddl/initialize.ts +259 -259
- package/src/ddl/relation-ddl.ts +89 -89
- package/src/ddl/schema-ddl.ts +4 -4
- package/src/ddl/table-ddl.ts +189 -189
- package/src/errors/db-transaction-error.ts +13 -13
- package/src/exec/executable.ts +25 -25
- package/src/exec/queryable.ts +2033 -2033
- package/src/exec/search-parser.ts +57 -57
- package/src/expr/expr-unit.ts +4 -4
- package/src/expr/expr.ts +2140 -2140
- package/src/query-builder/base/expr-renderer-base.ts +237 -237
- package/src/query-builder/base/query-builder-base.ts +213 -213
- package/src/query-builder/mssql/mssql-expr-renderer.ts +607 -607
- package/src/query-builder/mssql/mssql-query-builder.ts +650 -650
- package/src/query-builder/mysql/mysql-expr-renderer.ts +613 -613
- package/src/query-builder/mysql/mysql-query-builder.ts +759 -759
- package/src/query-builder/postgresql/postgresql-expr-renderer.ts +611 -611
- package/src/query-builder/postgresql/postgresql-query-builder.ts +686 -686
- package/src/query-builder/query-builder.ts +19 -19
- package/src/schema/factory/column-builder.ts +423 -423
- package/src/schema/factory/index-builder.ts +164 -164
- package/src/schema/factory/relation-builder.ts +453 -453
- package/src/schema/procedure-builder.ts +232 -232
- package/src/schema/table-builder.ts +319 -319
- package/src/schema/view-builder.ts +221 -221
- package/src/types/column.ts +188 -188
- package/src/types/db.ts +208 -208
- package/src/types/expr.ts +697 -697
- package/src/types/query-def.ts +513 -513
- package/src/utils/result-parser.ts +458 -458
- package/tests/db-context/create-db-context.spec.ts +224 -0
- package/tests/db-context/define-db-context.spec.ts +68 -0
- package/tests/ddl/basic.expected.ts +341 -0
- package/tests/ddl/basic.spec.ts +714 -0
- package/tests/ddl/column-builder.expected.ts +310 -0
- package/tests/ddl/column-builder.spec.ts +637 -0
- package/tests/ddl/index-builder.expected.ts +38 -0
- package/tests/ddl/index-builder.spec.ts +202 -0
- package/tests/ddl/procedure-builder.expected.ts +52 -0
- package/tests/ddl/procedure-builder.spec.ts +234 -0
- package/tests/ddl/relation-builder.expected.ts +36 -0
- package/tests/ddl/relation-builder.spec.ts +372 -0
- package/tests/ddl/table-builder.expected.ts +113 -0
- package/tests/ddl/table-builder.spec.ts +433 -0
- package/tests/ddl/view-builder.expected.ts +38 -0
- package/tests/ddl/view-builder.spec.ts +176 -0
- package/tests/dml/delete.expected.ts +96 -0
- package/tests/dml/delete.spec.ts +160 -0
- package/tests/dml/insert.expected.ts +192 -0
- package/tests/dml/insert.spec.ts +288 -0
- package/tests/dml/update.expected.ts +176 -0
- package/tests/dml/update.spec.ts +318 -0
- package/tests/dml/upsert.expected.ts +215 -0
- package/tests/dml/upsert.spec.ts +242 -0
- package/tests/errors/queryable-errors.spec.ts +177 -0
- package/tests/escape.spec.ts +100 -0
- package/tests/examples/pivot.expected.ts +211 -0
- package/tests/examples/pivot.spec.ts +533 -0
- package/tests/examples/sampling.expected.ts +69 -0
- package/tests/examples/sampling.spec.ts +105 -0
- package/tests/examples/unpivot.expected.ts +120 -0
- package/tests/examples/unpivot.spec.ts +226 -0
- package/tests/exec/search-parser.spec.ts +283 -0
- package/tests/executable/basic.expected.ts +18 -0
- package/tests/executable/basic.spec.ts +54 -0
- package/tests/expr/comparison.expected.ts +282 -0
- package/tests/expr/comparison.spec.ts +400 -0
- package/tests/expr/conditional.expected.ts +134 -0
- package/tests/expr/conditional.spec.ts +276 -0
- package/tests/expr/date.expected.ts +332 -0
- package/tests/expr/date.spec.ts +526 -0
- package/tests/expr/math.expected.ts +62 -0
- package/tests/expr/math.spec.ts +106 -0
- package/tests/expr/string.expected.ts +218 -0
- package/tests/expr/string.spec.ts +356 -0
- package/tests/expr/utility.expected.ts +147 -0
- package/tests/expr/utility.spec.ts +182 -0
- package/tests/select/basic.expected.ts +322 -0
- package/tests/select/basic.spec.ts +502 -0
- package/tests/select/filter.expected.ts +357 -0
- package/tests/select/filter.spec.ts +1068 -0
- package/tests/select/group.expected.ts +169 -0
- package/tests/select/group.spec.ts +244 -0
- package/tests/select/join.expected.ts +582 -0
- package/tests/select/join.spec.ts +805 -0
- package/tests/select/order.expected.ts +150 -0
- package/tests/select/order.spec.ts +189 -0
- package/tests/select/recursive-cte.expected.ts +244 -0
- package/tests/select/recursive-cte.spec.ts +514 -0
- package/tests/select/result-meta.spec.ts +270 -0
- package/tests/select/subquery.expected.ts +363 -0
- package/tests/select/subquery.spec.ts +537 -0
- package/tests/select/view.expected.ts +155 -0
- package/tests/select/view.spec.ts +235 -0
- package/tests/select/window.expected.ts +345 -0
- package/tests/select/window.spec.ts +618 -0
- package/tests/setup/MockExecutor.ts +18 -0
- package/tests/setup/TestDbContext.ts +59 -0
- package/tests/setup/models/Company.ts +13 -0
- package/tests/setup/models/Employee.ts +10 -0
- package/tests/setup/models/MonthlySales.ts +11 -0
- package/tests/setup/models/Post.ts +16 -0
- package/tests/setup/models/Sales.ts +10 -0
- package/tests/setup/models/User.ts +19 -0
- package/tests/setup/procedure/GetAllUsers.ts +9 -0
- package/tests/setup/procedure/GetUserById.ts +12 -0
- package/tests/setup/test-utils.ts +72 -0
- package/tests/setup/views/ActiveUsers.ts +8 -0
- package/tests/setup/views/UserSummary.ts +11 -0
- package/tests/types/nullable-queryable-record.spec.ts +145 -0
- package/tests/utils/result-parser-perf.spec.ts +210 -0
- package/tests/utils/result-parser.spec.ts +701 -0
- package/docs/expressions.md +0 -172
- package/docs/queries.md +0 -444
- package/docs/schema.md +0 -245
package/src/types/expr.ts
CHANGED
|
@@ -1,697 +1,697 @@
|
|
|
1
|
-
import type { ColumnPrimitive, DataType } from "./column";
|
|
2
|
-
import type { SelectQueryDef } from "./query-def";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* dateDiff, dateAdd 등
|
|
8
|
-
*/
|
|
9
|
-
export type DateSeparator = "year" | "month" | "day" | "hour" | "minute" | "second";
|
|
10
|
-
|
|
11
|
-
//#region ==========
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* @property path -
|
|
17
|
-
*/
|
|
18
|
-
export interface ExprColumn {
|
|
19
|
-
type: "column";
|
|
20
|
-
path: string[];
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* 리터럴
|
|
25
|
-
*
|
|
26
|
-
* @property value -
|
|
27
|
-
*/
|
|
28
|
-
export interface ExprValue {
|
|
29
|
-
type: "value";
|
|
30
|
-
value: ColumnPrimitive;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Raw SQL
|
|
35
|
-
*
|
|
36
|
-
* @property sql - SQL 문자열 (파라미터는 {0}, {1}로 표시)
|
|
37
|
-
* @property params - 파라미터
|
|
38
|
-
*/
|
|
39
|
-
export interface ExprRaw {
|
|
40
|
-
type: "raw";
|
|
41
|
-
sql: string;
|
|
42
|
-
params: Expr[];
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
//#endregion
|
|
46
|
-
|
|
47
|
-
//#region ==========
|
|
48
|
-
|
|
49
|
-
/** 동등
|
|
50
|
-
export interface ExprEq {
|
|
51
|
-
type: "eq";
|
|
52
|
-
source: Expr;
|
|
53
|
-
target: Expr;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
export interface ExprGt {
|
|
58
|
-
type: "gt";
|
|
59
|
-
source: Expr;
|
|
60
|
-
target: Expr;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
export interface ExprLt {
|
|
65
|
-
type: "lt";
|
|
66
|
-
source: Expr;
|
|
67
|
-
target: Expr;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
export interface ExprGte {
|
|
72
|
-
type: "gte";
|
|
73
|
-
source: Expr;
|
|
74
|
-
target: Expr;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
export interface ExprLte {
|
|
79
|
-
type: "lte";
|
|
80
|
-
source: Expr;
|
|
81
|
-
target: Expr;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
export interface ExprBetween {
|
|
86
|
-
type: "between";
|
|
87
|
-
source: Expr;
|
|
88
|
-
from?: Expr;
|
|
89
|
-
to?: Expr;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
/** NULL 검사 (IS NULL) */
|
|
93
|
-
export interface ExprIsNull {
|
|
94
|
-
type: "null";
|
|
95
|
-
arg: Expr;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
export interface ExprLike {
|
|
100
|
-
type: "like";
|
|
101
|
-
source: Expr;
|
|
102
|
-
pattern: Expr;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
export interface ExprRegexp {
|
|
107
|
-
type: "regexp";
|
|
108
|
-
source: Expr;
|
|
109
|
-
pattern: Expr;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
export interface ExprIn {
|
|
114
|
-
type: "in";
|
|
115
|
-
source: Expr;
|
|
116
|
-
values: Expr[];
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
export interface ExprInQuery {
|
|
121
|
-
type: "inQuery";
|
|
122
|
-
source: Expr;
|
|
123
|
-
query: SelectQueryDef;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
export interface ExprExists {
|
|
128
|
-
type: "exists";
|
|
129
|
-
query: SelectQueryDef;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
//#endregion
|
|
133
|
-
|
|
134
|
-
//#region ==========
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
export interface ExprNot {
|
|
138
|
-
type: "not";
|
|
139
|
-
arg: WhereExpr;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
/**
|
|
143
|
-
export interface ExprAnd {
|
|
144
|
-
type: "and";
|
|
145
|
-
conditions: WhereExpr[];
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
export interface ExprOr {
|
|
150
|
-
type: "or";
|
|
151
|
-
conditions: WhereExpr[];
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
//#endregion
|
|
155
|
-
|
|
156
|
-
//#region ==========
|
|
157
|
-
|
|
158
|
-
/** 문자열 연결 (CONCAT) */
|
|
159
|
-
export interface ExprConcat {
|
|
160
|
-
type: "concat";
|
|
161
|
-
args: Expr[];
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
/** 왼쪽 N자 추출 (LEFT) */
|
|
165
|
-
export interface ExprLeft {
|
|
166
|
-
type: "left";
|
|
167
|
-
source: Expr;
|
|
168
|
-
length: Expr;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
/** 오른쪽 N자 추출 (RIGHT) */
|
|
172
|
-
export interface ExprRight {
|
|
173
|
-
type: "right";
|
|
174
|
-
source: Expr;
|
|
175
|
-
length: Expr;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
/** 좌우 공백
|
|
179
|
-
export interface ExprTrim {
|
|
180
|
-
type: "trim";
|
|
181
|
-
arg: Expr;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
/** 왼쪽 패딩 (LPAD) */
|
|
185
|
-
export interface ExprPadStart {
|
|
186
|
-
type: "padStart";
|
|
187
|
-
source: Expr;
|
|
188
|
-
length: Expr;
|
|
189
|
-
fillString: Expr;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
/** 문자열 치환 (REPLACE) */
|
|
193
|
-
export interface ExprReplace {
|
|
194
|
-
type: "replace";
|
|
195
|
-
source: Expr;
|
|
196
|
-
from: Expr;
|
|
197
|
-
to: Expr;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
/** 대문자
|
|
201
|
-
export interface ExprUpper {
|
|
202
|
-
type: "upper";
|
|
203
|
-
arg: Expr;
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
/** 소문자
|
|
207
|
-
export interface ExprLower {
|
|
208
|
-
type: "lower";
|
|
209
|
-
arg: Expr;
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
/** 문자 길이 (CHAR_LENGTH) */
|
|
213
|
-
export interface ExprLength {
|
|
214
|
-
type: "length";
|
|
215
|
-
arg: Expr;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
/** 바이트 길이 (LENGTH/DATALENGTH) */
|
|
219
|
-
export interface ExprByteLength {
|
|
220
|
-
type: "byteLength";
|
|
221
|
-
arg: Expr;
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
/**
|
|
225
|
-
export interface ExprSubstring {
|
|
226
|
-
type: "substring";
|
|
227
|
-
source: Expr;
|
|
228
|
-
start: Expr;
|
|
229
|
-
length?: Expr;
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
/** 문자열 위치 (LOCATE/CHARINDEX/POSITION) */
|
|
233
|
-
export interface ExprIndexOf {
|
|
234
|
-
type: "indexOf";
|
|
235
|
-
source: Expr;
|
|
236
|
-
search: Expr;
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
//#endregion
|
|
240
|
-
|
|
241
|
-
//#region ==========
|
|
242
|
-
|
|
243
|
-
/** 절대값 (ABS) */
|
|
244
|
-
export interface ExprAbs {
|
|
245
|
-
type: "abs";
|
|
246
|
-
arg: Expr;
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
/** 반올림 (ROUND) */
|
|
250
|
-
export interface ExprRound {
|
|
251
|
-
type: "round";
|
|
252
|
-
arg: Expr;
|
|
253
|
-
digits: number;
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
/** 올림 (CEIL) */
|
|
257
|
-
export interface ExprCeil {
|
|
258
|
-
type: "ceil";
|
|
259
|
-
arg: Expr;
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
/** 내림 (FLOOR) */
|
|
263
|
-
export interface ExprFloor {
|
|
264
|
-
type: "floor";
|
|
265
|
-
arg: Expr;
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
//#endregion
|
|
269
|
-
|
|
270
|
-
//#region ==========
|
|
271
|
-
|
|
272
|
-
/** 연도 추출 (YEAR) */
|
|
273
|
-
export interface ExprYear {
|
|
274
|
-
type: "year";
|
|
275
|
-
arg: Expr;
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
/** 월 추출 (MONTH) */
|
|
279
|
-
export interface ExprMonth {
|
|
280
|
-
type: "month";
|
|
281
|
-
arg: Expr;
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
/** 일 추출 (DAY) */
|
|
285
|
-
export interface ExprDay {
|
|
286
|
-
type: "day";
|
|
287
|
-
arg: Expr;
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
/** 시간 추출 (HOUR) */
|
|
291
|
-
export interface ExprHour {
|
|
292
|
-
type: "hour";
|
|
293
|
-
arg: Expr;
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
/** 분 추출 (MINUTE) */
|
|
297
|
-
export interface ExprMinute {
|
|
298
|
-
type: "minute";
|
|
299
|
-
arg: Expr;
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
/** 초 추출 (SECOND) */
|
|
303
|
-
export interface ExprSecond {
|
|
304
|
-
type: "second";
|
|
305
|
-
arg: Expr;
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
/** ISO 주차 (WEEK) */
|
|
309
|
-
export interface ExprIsoWeek {
|
|
310
|
-
type: "isoWeek";
|
|
311
|
-
arg: Expr;
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
/** ISO 주 시작일 */
|
|
315
|
-
export interface ExprIsoWeekStartDate {
|
|
316
|
-
type: "isoWeekStartDate";
|
|
317
|
-
arg: Expr;
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
/** ISO 연월 (YYYYMM 형식) */
|
|
321
|
-
export interface ExprIsoYearMonth {
|
|
322
|
-
type: "isoYearMonth";
|
|
323
|
-
arg: Expr;
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
/**
|
|
327
|
-
export interface ExprDateDiff {
|
|
328
|
-
type: "dateDiff";
|
|
329
|
-
separator: DateSeparator;
|
|
330
|
-
from: Expr;
|
|
331
|
-
to: Expr;
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
/**
|
|
335
|
-
export interface ExprDateAdd {
|
|
336
|
-
type: "dateAdd";
|
|
337
|
-
separator: DateSeparator;
|
|
338
|
-
source: Expr;
|
|
339
|
-
value: Expr;
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
/**
|
|
343
|
-
export interface ExprFormatDate {
|
|
344
|
-
type: "formatDate";
|
|
345
|
-
source: Expr;
|
|
346
|
-
format: string;
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
//#endregion
|
|
350
|
-
|
|
351
|
-
//#region ==========
|
|
352
|
-
|
|
353
|
-
/** NULL 대체 (COALESCE - 첫 번째 non-null
|
|
354
|
-
export interface ExprIfNull {
|
|
355
|
-
type: "ifNull";
|
|
356
|
-
args: Expr[];
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
/** 조건부 NULL (NULLIF - source === value 이면 NULL) */
|
|
360
|
-
export interface ExprNullIf {
|
|
361
|
-
type: "nullIf";
|
|
362
|
-
source: Expr;
|
|
363
|
-
value: Expr;
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
/** 조건을 값으로
|
|
367
|
-
export interface ExprIs {
|
|
368
|
-
type: "is";
|
|
369
|
-
condition: WhereExpr;
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
/** CASE WHEN
|
|
373
|
-
export interface ExprSwitch {
|
|
374
|
-
type: "switch";
|
|
375
|
-
cases: { when: WhereExpr; then: Expr }[];
|
|
376
|
-
else: Expr;
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
/** IF
|
|
380
|
-
export interface ExprIf {
|
|
381
|
-
type: "if";
|
|
382
|
-
condition: WhereExpr;
|
|
383
|
-
then: Expr;
|
|
384
|
-
else?: Expr;
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
//#endregion
|
|
388
|
-
|
|
389
|
-
//#region ==========
|
|
390
|
-
|
|
391
|
-
/** 레코드 수 (COUNT) */
|
|
392
|
-
export interface ExprCount {
|
|
393
|
-
type: "count";
|
|
394
|
-
arg?: Expr;
|
|
395
|
-
distinct?: boolean;
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
/** 합계 (SUM) */
|
|
399
|
-
export interface ExprSum {
|
|
400
|
-
type: "sum";
|
|
401
|
-
arg: Expr;
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
/** 평균 (AVG) */
|
|
405
|
-
export interface ExprAvg {
|
|
406
|
-
type: "avg";
|
|
407
|
-
arg: Expr;
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
/** 최대값 (MAX) */
|
|
411
|
-
export interface ExprMax {
|
|
412
|
-
type: "max";
|
|
413
|
-
arg: Expr;
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
/** 최소값 (MIN) */
|
|
417
|
-
export interface ExprMin {
|
|
418
|
-
type: "min";
|
|
419
|
-
arg: Expr;
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
//#endregion
|
|
423
|
-
|
|
424
|
-
//#region ==========
|
|
425
|
-
|
|
426
|
-
/** 최대값
|
|
427
|
-
export interface ExprGreatest {
|
|
428
|
-
type: "greatest";
|
|
429
|
-
args: Expr[];
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
/** 최소값
|
|
433
|
-
export interface ExprLeast {
|
|
434
|
-
type: "least";
|
|
435
|
-
args: Expr[];
|
|
436
|
-
}
|
|
437
|
-
|
|
438
|
-
/**
|
|
439
|
-
export interface ExprRowNum {
|
|
440
|
-
type: "rowNum";
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
/** 난수 (RAND/RANDOM) */
|
|
444
|
-
export interface ExprRandom {
|
|
445
|
-
type: "random";
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
/**
|
|
449
|
-
export interface ExprCast {
|
|
450
|
-
type: "cast";
|
|
451
|
-
source: Expr;
|
|
452
|
-
targetType: DataType;
|
|
453
|
-
}
|
|
454
|
-
|
|
455
|
-
//#endregion
|
|
456
|
-
|
|
457
|
-
//#region ========== Window Functions ==========
|
|
458
|
-
|
|
459
|
-
// Window Function Types
|
|
460
|
-
|
|
461
|
-
/** ROW_NUMBER() */
|
|
462
|
-
export interface WinFnRowNumber {
|
|
463
|
-
type: "rowNumber";
|
|
464
|
-
}
|
|
465
|
-
|
|
466
|
-
/** RANK() */
|
|
467
|
-
export interface WinFnRank {
|
|
468
|
-
type: "rank";
|
|
469
|
-
}
|
|
470
|
-
|
|
471
|
-
/** DENSE_RANK() */
|
|
472
|
-
export interface WinFnDenseRank {
|
|
473
|
-
type: "denseRank";
|
|
474
|
-
}
|
|
475
|
-
|
|
476
|
-
/** NTILE(n) */
|
|
477
|
-
export interface WinFnNtile {
|
|
478
|
-
type: "ntile";
|
|
479
|
-
n: number;
|
|
480
|
-
}
|
|
481
|
-
|
|
482
|
-
/** LAG() - 이전
|
|
483
|
-
export interface WinFnLag {
|
|
484
|
-
type: "lag";
|
|
485
|
-
column: Expr;
|
|
486
|
-
offset?: number;
|
|
487
|
-
default?: Expr;
|
|
488
|
-
}
|
|
489
|
-
|
|
490
|
-
/** LEAD() - 다음
|
|
491
|
-
export interface WinFnLead {
|
|
492
|
-
type: "lead";
|
|
493
|
-
column: Expr;
|
|
494
|
-
offset?: number;
|
|
495
|
-
default?: Expr;
|
|
496
|
-
}
|
|
497
|
-
|
|
498
|
-
/** FIRST_VALUE() */
|
|
499
|
-
export interface WinFnFirstValue {
|
|
500
|
-
type: "firstValue";
|
|
501
|
-
column: Expr;
|
|
502
|
-
}
|
|
503
|
-
|
|
504
|
-
/** LAST_VALUE() */
|
|
505
|
-
export interface WinFnLastValue {
|
|
506
|
-
type: "lastValue";
|
|
507
|
-
column: Expr;
|
|
508
|
-
}
|
|
509
|
-
|
|
510
|
-
/**
|
|
511
|
-
export interface WinFnSum {
|
|
512
|
-
type: "sum";
|
|
513
|
-
column: Expr;
|
|
514
|
-
}
|
|
515
|
-
|
|
516
|
-
/**
|
|
517
|
-
export interface WinFnAvg {
|
|
518
|
-
type: "avg";
|
|
519
|
-
column: Expr;
|
|
520
|
-
}
|
|
521
|
-
|
|
522
|
-
/**
|
|
523
|
-
export interface WinFnCount {
|
|
524
|
-
type: "count";
|
|
525
|
-
column?: Expr;
|
|
526
|
-
}
|
|
527
|
-
|
|
528
|
-
/**
|
|
529
|
-
export interface WinFnMin {
|
|
530
|
-
type: "min";
|
|
531
|
-
column: Expr;
|
|
532
|
-
}
|
|
533
|
-
|
|
534
|
-
/**
|
|
535
|
-
export interface WinFnMax {
|
|
536
|
-
type: "max";
|
|
537
|
-
column: Expr;
|
|
538
|
-
}
|
|
539
|
-
|
|
540
|
-
/**
|
|
541
|
-
*
|
|
542
|
-
*
|
|
543
|
-
* 순위, 탐색,
|
|
544
|
-
*/
|
|
545
|
-
export type WinFn =
|
|
546
|
-
| WinFnRowNumber
|
|
547
|
-
| WinFnRank
|
|
548
|
-
| WinFnDenseRank
|
|
549
|
-
| WinFnNtile
|
|
550
|
-
| WinFnLag
|
|
551
|
-
| WinFnLead
|
|
552
|
-
| WinFnFirstValue
|
|
553
|
-
| WinFnLastValue
|
|
554
|
-
| WinFnSum
|
|
555
|
-
| WinFnAvg
|
|
556
|
-
| WinFnCount
|
|
557
|
-
| WinFnMin
|
|
558
|
-
| WinFnMax;
|
|
559
|
-
|
|
560
|
-
/**
|
|
561
|
-
*
|
|
562
|
-
*
|
|
563
|
-
* @property partitionBy - PARTITION BY
|
|
564
|
-
* @property orderBy - ORDER BY [
|
|
565
|
-
*/
|
|
566
|
-
export interface WinSpec {
|
|
567
|
-
partitionBy?: Expr[];
|
|
568
|
-
orderBy?: [Expr, ("ASC" | "DESC")?][];
|
|
569
|
-
}
|
|
570
|
-
|
|
571
|
-
/**
|
|
572
|
-
*
|
|
573
|
-
*
|
|
574
|
-
*
|
|
575
|
-
*/
|
|
576
|
-
export interface ExprWindow {
|
|
577
|
-
type: "window";
|
|
578
|
-
fn: WinFn;
|
|
579
|
-
spec: WinSpec;
|
|
580
|
-
}
|
|
581
|
-
|
|
582
|
-
//#endregion
|
|
583
|
-
|
|
584
|
-
//#region ==========
|
|
585
|
-
|
|
586
|
-
/** 스칼라
|
|
587
|
-
export interface ExprSubquery {
|
|
588
|
-
type: "subquery";
|
|
589
|
-
queryDef: SelectQueryDef;
|
|
590
|
-
}
|
|
591
|
-
|
|
592
|
-
//#endregion
|
|
593
|
-
|
|
594
|
-
//#region ========== Union Types ==========
|
|
595
|
-
|
|
596
|
-
/**
|
|
597
|
-
* WHERE 절에 사용되는
|
|
598
|
-
*
|
|
599
|
-
*
|
|
600
|
-
* where(), having()
|
|
601
|
-
*/
|
|
602
|
-
export type WhereExpr =
|
|
603
|
-
// Comparison
|
|
604
|
-
| ExprEq
|
|
605
|
-
| ExprGt
|
|
606
|
-
| ExprLt
|
|
607
|
-
| ExprGte
|
|
608
|
-
| ExprLte
|
|
609
|
-
| ExprBetween
|
|
610
|
-
| ExprIsNull
|
|
611
|
-
| ExprLike
|
|
612
|
-
| ExprRegexp
|
|
613
|
-
| ExprIn
|
|
614
|
-
| ExprInQuery
|
|
615
|
-
| ExprExists
|
|
616
|
-
|
|
617
|
-
// Logical
|
|
618
|
-
| ExprNot
|
|
619
|
-
| ExprAnd
|
|
620
|
-
| ExprOr;
|
|
621
|
-
|
|
622
|
-
/**
|
|
623
|
-
* 모든
|
|
624
|
-
*
|
|
625
|
-
*
|
|
626
|
-
* select(), orderBy()
|
|
627
|
-
*
|
|
628
|
-
* @see {@link WhereExpr} WHERE 절 전용
|
|
629
|
-
*/
|
|
630
|
-
export type Expr =
|
|
631
|
-
// Value
|
|
632
|
-
| ExprColumn
|
|
633
|
-
| ExprValue
|
|
634
|
-
| ExprRaw
|
|
635
|
-
|
|
636
|
-
// String
|
|
637
|
-
| ExprConcat
|
|
638
|
-
| ExprLeft
|
|
639
|
-
| ExprRight
|
|
640
|
-
| ExprTrim
|
|
641
|
-
| ExprPadStart
|
|
642
|
-
| ExprReplace
|
|
643
|
-
| ExprUpper
|
|
644
|
-
| ExprLower
|
|
645
|
-
| ExprLength
|
|
646
|
-
| ExprByteLength
|
|
647
|
-
| ExprSubstring
|
|
648
|
-
| ExprIndexOf
|
|
649
|
-
|
|
650
|
-
// Numeric
|
|
651
|
-
| ExprAbs
|
|
652
|
-
| ExprRound
|
|
653
|
-
| ExprCeil
|
|
654
|
-
| ExprFloor
|
|
655
|
-
|
|
656
|
-
// Date
|
|
657
|
-
| ExprYear
|
|
658
|
-
| ExprMonth
|
|
659
|
-
| ExprDay
|
|
660
|
-
| ExprHour
|
|
661
|
-
| ExprMinute
|
|
662
|
-
| ExprSecond
|
|
663
|
-
| ExprIsoWeek
|
|
664
|
-
| ExprIsoWeekStartDate
|
|
665
|
-
| ExprIsoYearMonth
|
|
666
|
-
| ExprDateDiff
|
|
667
|
-
| ExprDateAdd
|
|
668
|
-
| ExprFormatDate
|
|
669
|
-
|
|
670
|
-
// Condition
|
|
671
|
-
| ExprIfNull
|
|
672
|
-
| ExprNullIf
|
|
673
|
-
| ExprIs
|
|
674
|
-
| ExprSwitch
|
|
675
|
-
| ExprIf
|
|
676
|
-
|
|
677
|
-
// Aggregate
|
|
678
|
-
| ExprCount
|
|
679
|
-
| ExprSum
|
|
680
|
-
| ExprAvg
|
|
681
|
-
| ExprMax
|
|
682
|
-
| ExprMin
|
|
683
|
-
|
|
684
|
-
// Other
|
|
685
|
-
| ExprGreatest
|
|
686
|
-
| ExprLeast
|
|
687
|
-
| ExprRowNum
|
|
688
|
-
| ExprRandom
|
|
689
|
-
| ExprCast
|
|
690
|
-
|
|
691
|
-
// Window
|
|
692
|
-
| ExprWindow
|
|
693
|
-
|
|
694
|
-
// System
|
|
695
|
-
| ExprSubquery;
|
|
696
|
-
|
|
697
|
-
//#endregion
|
|
1
|
+
import type { ColumnPrimitive, DataType } from "./column";
|
|
2
|
+
import type { SelectQueryDef } from "./query-def";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Date 연산 단위
|
|
6
|
+
*
|
|
7
|
+
* dateDiff, dateAdd 등 Date functionused in
|
|
8
|
+
*/
|
|
9
|
+
export type DateSeparator = "year" | "month" | "day" | "hour" | "minute" | "second";
|
|
10
|
+
|
|
11
|
+
//#region ========== value expression ==========
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* column 참조 expression
|
|
15
|
+
*
|
|
16
|
+
* @property path - Column 경로 (table별칭.column명 등)
|
|
17
|
+
*/
|
|
18
|
+
export interface ExprColumn {
|
|
19
|
+
type: "column";
|
|
20
|
+
path: string[];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* 리터럴 value expression
|
|
25
|
+
*
|
|
26
|
+
* @property value - Column 프리미티브 value
|
|
27
|
+
*/
|
|
28
|
+
export interface ExprValue {
|
|
29
|
+
type: "value";
|
|
30
|
+
value: ColumnPrimitive;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Raw SQL expression
|
|
35
|
+
*
|
|
36
|
+
* @property sql - SQL 문자열 (파라미터는 {0}, {1}로 표시)
|
|
37
|
+
* @property params - 파라미터 expression array
|
|
38
|
+
*/
|
|
39
|
+
export interface ExprRaw {
|
|
40
|
+
type: "raw";
|
|
41
|
+
sql: string;
|
|
42
|
+
params: Expr[];
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
//#endregion
|
|
46
|
+
|
|
47
|
+
//#region ========== comparison 연산 (WHERE용) ==========
|
|
48
|
+
|
|
49
|
+
/** 동등 comparison (=) - NULL-safe */
|
|
50
|
+
export interface ExprEq {
|
|
51
|
+
type: "eq";
|
|
52
|
+
source: Expr;
|
|
53
|
+
target: Expr;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** Greater than comparison (>) */
|
|
57
|
+
export interface ExprGt {
|
|
58
|
+
type: "gt";
|
|
59
|
+
source: Expr;
|
|
60
|
+
target: Expr;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** Less than comparison (<) */
|
|
64
|
+
export interface ExprLt {
|
|
65
|
+
type: "lt";
|
|
66
|
+
source: Expr;
|
|
67
|
+
target: Expr;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** Greater than or equal comparison (>=) */
|
|
71
|
+
export interface ExprGte {
|
|
72
|
+
type: "gte";
|
|
73
|
+
source: Expr;
|
|
74
|
+
target: Expr;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** Less than or equal comparison (<=) */
|
|
78
|
+
export interface ExprLte {
|
|
79
|
+
type: "lte";
|
|
80
|
+
source: Expr;
|
|
81
|
+
target: Expr;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** range comparison (BETWEEN from AND to) */
|
|
85
|
+
export interface ExprBetween {
|
|
86
|
+
type: "between";
|
|
87
|
+
source: Expr;
|
|
88
|
+
from?: Expr;
|
|
89
|
+
to?: Expr;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** NULL 검사 (IS NULL) */
|
|
93
|
+
export interface ExprIsNull {
|
|
94
|
+
type: "null";
|
|
95
|
+
arg: Expr;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** pattern 매칭 (LIKE) */
|
|
99
|
+
export interface ExprLike {
|
|
100
|
+
type: "like";
|
|
101
|
+
source: Expr;
|
|
102
|
+
pattern: Expr;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/** regular expression 매칭 (REGEXP) */
|
|
106
|
+
export interface ExprRegexp {
|
|
107
|
+
type: "regexp";
|
|
108
|
+
source: Expr;
|
|
109
|
+
pattern: Expr;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/** value 목록 include 검사 (IN) */
|
|
113
|
+
export interface ExprIn {
|
|
114
|
+
type: "in";
|
|
115
|
+
source: Expr;
|
|
116
|
+
values: Expr[];
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/** Subquery result include 검사 (IN subquery) */
|
|
120
|
+
export interface ExprInQuery {
|
|
121
|
+
type: "inQuery";
|
|
122
|
+
source: Expr;
|
|
123
|
+
query: SelectQueryDef;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/** Subquery 존재 검사 (EXISTS) */
|
|
127
|
+
export interface ExprExists {
|
|
128
|
+
type: "exists";
|
|
129
|
+
query: SelectQueryDef;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
//#endregion
|
|
133
|
+
|
|
134
|
+
//#region ========== logic 연산 ==========
|
|
135
|
+
|
|
136
|
+
/** logic 부정 (NOT) */
|
|
137
|
+
export interface ExprNot {
|
|
138
|
+
type: "not";
|
|
139
|
+
arg: WhereExpr;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/** logic 곱 (AND) */
|
|
143
|
+
export interface ExprAnd {
|
|
144
|
+
type: "and";
|
|
145
|
+
conditions: WhereExpr[];
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/** logic 합 (OR) */
|
|
149
|
+
export interface ExprOr {
|
|
150
|
+
type: "or";
|
|
151
|
+
conditions: WhereExpr[];
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
//#endregion
|
|
155
|
+
|
|
156
|
+
//#region ========== String function ==========
|
|
157
|
+
|
|
158
|
+
/** 문자열 연결 (CONCAT) */
|
|
159
|
+
export interface ExprConcat {
|
|
160
|
+
type: "concat";
|
|
161
|
+
args: Expr[];
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/** 왼쪽 N자 추출 (LEFT) */
|
|
165
|
+
export interface ExprLeft {
|
|
166
|
+
type: "left";
|
|
167
|
+
source: Expr;
|
|
168
|
+
length: Expr;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/** 오른쪽 N자 추출 (RIGHT) */
|
|
172
|
+
export interface ExprRight {
|
|
173
|
+
type: "right";
|
|
174
|
+
source: Expr;
|
|
175
|
+
length: Expr;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/** 좌우 공백 Remove (TRIM) */
|
|
179
|
+
export interface ExprTrim {
|
|
180
|
+
type: "trim";
|
|
181
|
+
arg: Expr;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/** 왼쪽 패딩 (LPAD) */
|
|
185
|
+
export interface ExprPadStart {
|
|
186
|
+
type: "padStart";
|
|
187
|
+
source: Expr;
|
|
188
|
+
length: Expr;
|
|
189
|
+
fillString: Expr;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/** 문자열 치환 (REPLACE) */
|
|
193
|
+
export interface ExprReplace {
|
|
194
|
+
type: "replace";
|
|
195
|
+
source: Expr;
|
|
196
|
+
from: Expr;
|
|
197
|
+
to: Expr;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/** 대문자 Transform (UPPER) */
|
|
201
|
+
export interface ExprUpper {
|
|
202
|
+
type: "upper";
|
|
203
|
+
arg: Expr;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/** 소문자 Transform (LOWER) */
|
|
207
|
+
export interface ExprLower {
|
|
208
|
+
type: "lower";
|
|
209
|
+
arg: Expr;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/** 문자 길이 (CHAR_LENGTH) */
|
|
213
|
+
export interface ExprLength {
|
|
214
|
+
type: "length";
|
|
215
|
+
arg: Expr;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/** 바이트 길이 (LENGTH/DATALENGTH) */
|
|
219
|
+
export interface ExprByteLength {
|
|
220
|
+
type: "byteLength";
|
|
221
|
+
arg: Expr;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/** part 문자열 (SUBSTRING) */
|
|
225
|
+
export interface ExprSubstring {
|
|
226
|
+
type: "substring";
|
|
227
|
+
source: Expr;
|
|
228
|
+
start: Expr;
|
|
229
|
+
length?: Expr;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/** 문자열 위치 (LOCATE/CHARINDEX/POSITION) */
|
|
233
|
+
export interface ExprIndexOf {
|
|
234
|
+
type: "indexOf";
|
|
235
|
+
source: Expr;
|
|
236
|
+
search: Expr;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
//#endregion
|
|
240
|
+
|
|
241
|
+
//#region ========== Number function ==========
|
|
242
|
+
|
|
243
|
+
/** 절대값 (ABS) */
|
|
244
|
+
export interface ExprAbs {
|
|
245
|
+
type: "abs";
|
|
246
|
+
arg: Expr;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/** 반올림 (ROUND) */
|
|
250
|
+
export interface ExprRound {
|
|
251
|
+
type: "round";
|
|
252
|
+
arg: Expr;
|
|
253
|
+
digits: number;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/** 올림 (CEIL) */
|
|
257
|
+
export interface ExprCeil {
|
|
258
|
+
type: "ceil";
|
|
259
|
+
arg: Expr;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/** 내림 (FLOOR) */
|
|
263
|
+
export interface ExprFloor {
|
|
264
|
+
type: "floor";
|
|
265
|
+
arg: Expr;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
//#endregion
|
|
269
|
+
|
|
270
|
+
//#region ========== Date function ==========
|
|
271
|
+
|
|
272
|
+
/** 연도 추출 (YEAR) */
|
|
273
|
+
export interface ExprYear {
|
|
274
|
+
type: "year";
|
|
275
|
+
arg: Expr;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
/** 월 추출 (MONTH) */
|
|
279
|
+
export interface ExprMonth {
|
|
280
|
+
type: "month";
|
|
281
|
+
arg: Expr;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/** 일 추출 (DAY) */
|
|
285
|
+
export interface ExprDay {
|
|
286
|
+
type: "day";
|
|
287
|
+
arg: Expr;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/** 시간 추출 (HOUR) */
|
|
291
|
+
export interface ExprHour {
|
|
292
|
+
type: "hour";
|
|
293
|
+
arg: Expr;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
/** 분 추출 (MINUTE) */
|
|
297
|
+
export interface ExprMinute {
|
|
298
|
+
type: "minute";
|
|
299
|
+
arg: Expr;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
/** 초 추출 (SECOND) */
|
|
303
|
+
export interface ExprSecond {
|
|
304
|
+
type: "second";
|
|
305
|
+
arg: Expr;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
/** ISO 주차 (WEEK) */
|
|
309
|
+
export interface ExprIsoWeek {
|
|
310
|
+
type: "isoWeek";
|
|
311
|
+
arg: Expr;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
/** ISO 주 시작일 */
|
|
315
|
+
export interface ExprIsoWeekStartDate {
|
|
316
|
+
type: "isoWeekStartDate";
|
|
317
|
+
arg: Expr;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
/** ISO 연월 (YYYYMM 형식) */
|
|
321
|
+
export interface ExprIsoYearMonth {
|
|
322
|
+
type: "isoYearMonth";
|
|
323
|
+
arg: Expr;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
/** Date 차이 (DATEDIFF) */
|
|
327
|
+
export interface ExprDateDiff {
|
|
328
|
+
type: "dateDiff";
|
|
329
|
+
separator: DateSeparator;
|
|
330
|
+
from: Expr;
|
|
331
|
+
to: Expr;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
/** Date 연산 (DATEADD) */
|
|
335
|
+
export interface ExprDateAdd {
|
|
336
|
+
type: "dateAdd";
|
|
337
|
+
separator: DateSeparator;
|
|
338
|
+
source: Expr;
|
|
339
|
+
value: Expr;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
/** Date 포맷 (FORMAT/DATE_FORMAT) */
|
|
343
|
+
export interface ExprFormatDate {
|
|
344
|
+
type: "formatDate";
|
|
345
|
+
source: Expr;
|
|
346
|
+
format: string;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
//#endregion
|
|
350
|
+
|
|
351
|
+
//#region ========== condition ==========
|
|
352
|
+
|
|
353
|
+
/** NULL 대체 (COALESCE - 첫 번째 non-null return) */
|
|
354
|
+
export interface ExprIfNull {
|
|
355
|
+
type: "ifNull";
|
|
356
|
+
args: Expr[];
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
/** 조건부 NULL (NULLIF - source === value 이면 NULL) */
|
|
360
|
+
export interface ExprNullIf {
|
|
361
|
+
type: "nullIf";
|
|
362
|
+
source: Expr;
|
|
363
|
+
value: Expr;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
/** 조건을 값으로 Transform (boolean → 0/1) */
|
|
367
|
+
export interface ExprIs {
|
|
368
|
+
type: "is";
|
|
369
|
+
condition: WhereExpr;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
/** CASE WHEN expression */
|
|
373
|
+
export interface ExprSwitch {
|
|
374
|
+
type: "switch";
|
|
375
|
+
cases: { when: WhereExpr; then: Expr }[];
|
|
376
|
+
else: Expr;
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
/** IF expression (IIF/IF) */
|
|
380
|
+
export interface ExprIf {
|
|
381
|
+
type: "if";
|
|
382
|
+
condition: WhereExpr;
|
|
383
|
+
then: Expr;
|
|
384
|
+
else?: Expr;
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
//#endregion
|
|
388
|
+
|
|
389
|
+
//#region ========== aggregation ==========
|
|
390
|
+
|
|
391
|
+
/** 레코드 수 (COUNT) */
|
|
392
|
+
export interface ExprCount {
|
|
393
|
+
type: "count";
|
|
394
|
+
arg?: Expr;
|
|
395
|
+
distinct?: boolean;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
/** 합계 (SUM) */
|
|
399
|
+
export interface ExprSum {
|
|
400
|
+
type: "sum";
|
|
401
|
+
arg: Expr;
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
/** 평균 (AVG) */
|
|
405
|
+
export interface ExprAvg {
|
|
406
|
+
type: "avg";
|
|
407
|
+
arg: Expr;
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
/** 최대값 (MAX) */
|
|
411
|
+
export interface ExprMax {
|
|
412
|
+
type: "max";
|
|
413
|
+
arg: Expr;
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
/** 최소값 (MIN) */
|
|
417
|
+
export interface ExprMin {
|
|
418
|
+
type: "min";
|
|
419
|
+
arg: Expr;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
//#endregion
|
|
423
|
+
|
|
424
|
+
//#region ========== Other ==========
|
|
425
|
+
|
|
426
|
+
/** 최대값 selection (GREATEST) */
|
|
427
|
+
export interface ExprGreatest {
|
|
428
|
+
type: "greatest";
|
|
429
|
+
args: Expr[];
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
/** 최소값 selection (LEAST) */
|
|
433
|
+
export interface ExprLeast {
|
|
434
|
+
type: "least";
|
|
435
|
+
args: Expr[];
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
/** row 번호 (ROW_NUMBER 단순 Version) */
|
|
439
|
+
export interface ExprRowNum {
|
|
440
|
+
type: "rowNum";
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
/** 난수 (RAND/RANDOM) */
|
|
444
|
+
export interface ExprRandom {
|
|
445
|
+
type: "random";
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
/** type transformation (CAST) */
|
|
449
|
+
export interface ExprCast {
|
|
450
|
+
type: "cast";
|
|
451
|
+
source: Expr;
|
|
452
|
+
targetType: DataType;
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
//#endregion
|
|
456
|
+
|
|
457
|
+
//#region ========== Window Functions ==========
|
|
458
|
+
|
|
459
|
+
// Window Function Types
|
|
460
|
+
|
|
461
|
+
/** ROW_NUMBER() */
|
|
462
|
+
export interface WinFnRowNumber {
|
|
463
|
+
type: "rowNumber";
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
/** RANK() */
|
|
467
|
+
export interface WinFnRank {
|
|
468
|
+
type: "rank";
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
/** DENSE_RANK() */
|
|
472
|
+
export interface WinFnDenseRank {
|
|
473
|
+
type: "denseRank";
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
/** NTILE(n) */
|
|
477
|
+
export interface WinFnNtile {
|
|
478
|
+
type: "ntile";
|
|
479
|
+
n: number;
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
/** LAG() - 이전 row value */
|
|
483
|
+
export interface WinFnLag {
|
|
484
|
+
type: "lag";
|
|
485
|
+
column: Expr;
|
|
486
|
+
offset?: number;
|
|
487
|
+
default?: Expr;
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
/** LEAD() - 다음 row value */
|
|
491
|
+
export interface WinFnLead {
|
|
492
|
+
type: "lead";
|
|
493
|
+
column: Expr;
|
|
494
|
+
offset?: number;
|
|
495
|
+
default?: Expr;
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
/** FIRST_VALUE() */
|
|
499
|
+
export interface WinFnFirstValue {
|
|
500
|
+
type: "firstValue";
|
|
501
|
+
column: Expr;
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
/** LAST_VALUE() */
|
|
505
|
+
export interface WinFnLastValue {
|
|
506
|
+
type: "lastValue";
|
|
507
|
+
column: Expr;
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
/** Window SUM */
|
|
511
|
+
export interface WinFnSum {
|
|
512
|
+
type: "sum";
|
|
513
|
+
column: Expr;
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
/** Window AVG */
|
|
517
|
+
export interface WinFnAvg {
|
|
518
|
+
type: "avg";
|
|
519
|
+
column: Expr;
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
/** Window COUNT */
|
|
523
|
+
export interface WinFnCount {
|
|
524
|
+
type: "count";
|
|
525
|
+
column?: Expr;
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
/** Window MIN */
|
|
529
|
+
export interface WinFnMin {
|
|
530
|
+
type: "min";
|
|
531
|
+
column: Expr;
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
/** Window MAX */
|
|
535
|
+
export interface WinFnMax {
|
|
536
|
+
type: "max";
|
|
537
|
+
column: Expr;
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
/**
|
|
541
|
+
* Window function union type
|
|
542
|
+
*
|
|
543
|
+
* 순위, 탐색, aggregation Window function
|
|
544
|
+
*/
|
|
545
|
+
export type WinFn =
|
|
546
|
+
| WinFnRowNumber
|
|
547
|
+
| WinFnRank
|
|
548
|
+
| WinFnDenseRank
|
|
549
|
+
| WinFnNtile
|
|
550
|
+
| WinFnLag
|
|
551
|
+
| WinFnLead
|
|
552
|
+
| WinFnFirstValue
|
|
553
|
+
| WinFnLastValue
|
|
554
|
+
| WinFnSum
|
|
555
|
+
| WinFnAvg
|
|
556
|
+
| WinFnCount
|
|
557
|
+
| WinFnMin
|
|
558
|
+
| WinFnMax;
|
|
559
|
+
|
|
560
|
+
/**
|
|
561
|
+
* Window 스펙 (OVER 절)
|
|
562
|
+
*
|
|
563
|
+
* @property partitionBy - PARTITION BY expression 목록
|
|
564
|
+
* @property orderBy - ORDER BY [column, 방향] 목록
|
|
565
|
+
*/
|
|
566
|
+
export interface WinSpec {
|
|
567
|
+
partitionBy?: Expr[];
|
|
568
|
+
orderBy?: [Expr, ("ASC" | "DESC")?][];
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
/**
|
|
572
|
+
* Window expression
|
|
573
|
+
*
|
|
574
|
+
* Window function + Window 스펙 composition
|
|
575
|
+
*/
|
|
576
|
+
export interface ExprWindow {
|
|
577
|
+
type: "window";
|
|
578
|
+
fn: WinFn;
|
|
579
|
+
spec: WinSpec;
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
//#endregion
|
|
583
|
+
|
|
584
|
+
//#region ========== System ==========
|
|
585
|
+
|
|
586
|
+
/** 스칼라 Subquery */
|
|
587
|
+
export interface ExprSubquery {
|
|
588
|
+
type: "subquery";
|
|
589
|
+
queryDef: SelectQueryDef;
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
//#endregion
|
|
593
|
+
|
|
594
|
+
//#region ========== Union Types ==========
|
|
595
|
+
|
|
596
|
+
/**
|
|
597
|
+
* WHERE 절에 사용되는 expression (boolean return)
|
|
598
|
+
*
|
|
599
|
+
* comparison 연산 + logic 연산의 union type
|
|
600
|
+
* where(), having() 등used in
|
|
601
|
+
*/
|
|
602
|
+
export type WhereExpr =
|
|
603
|
+
// Comparison
|
|
604
|
+
| ExprEq
|
|
605
|
+
| ExprGt
|
|
606
|
+
| ExprLt
|
|
607
|
+
| ExprGte
|
|
608
|
+
| ExprLte
|
|
609
|
+
| ExprBetween
|
|
610
|
+
| ExprIsNull
|
|
611
|
+
| ExprLike
|
|
612
|
+
| ExprRegexp
|
|
613
|
+
| ExprIn
|
|
614
|
+
| ExprInQuery
|
|
615
|
+
| ExprExists
|
|
616
|
+
|
|
617
|
+
// Logical
|
|
618
|
+
| ExprNot
|
|
619
|
+
| ExprAnd
|
|
620
|
+
| ExprOr;
|
|
621
|
+
|
|
622
|
+
/**
|
|
623
|
+
* 모든 expression union type
|
|
624
|
+
*
|
|
625
|
+
* value, 문자열, Number, Date, condition, aggregation, Window 등 모든 expression
|
|
626
|
+
* select(), orderBy() 등used in
|
|
627
|
+
*
|
|
628
|
+
* @see {@link WhereExpr} WHERE 절 전용 expression
|
|
629
|
+
*/
|
|
630
|
+
export type Expr =
|
|
631
|
+
// Value
|
|
632
|
+
| ExprColumn
|
|
633
|
+
| ExprValue
|
|
634
|
+
| ExprRaw
|
|
635
|
+
|
|
636
|
+
// String
|
|
637
|
+
| ExprConcat
|
|
638
|
+
| ExprLeft
|
|
639
|
+
| ExprRight
|
|
640
|
+
| ExprTrim
|
|
641
|
+
| ExprPadStart
|
|
642
|
+
| ExprReplace
|
|
643
|
+
| ExprUpper
|
|
644
|
+
| ExprLower
|
|
645
|
+
| ExprLength
|
|
646
|
+
| ExprByteLength
|
|
647
|
+
| ExprSubstring
|
|
648
|
+
| ExprIndexOf
|
|
649
|
+
|
|
650
|
+
// Numeric
|
|
651
|
+
| ExprAbs
|
|
652
|
+
| ExprRound
|
|
653
|
+
| ExprCeil
|
|
654
|
+
| ExprFloor
|
|
655
|
+
|
|
656
|
+
// Date
|
|
657
|
+
| ExprYear
|
|
658
|
+
| ExprMonth
|
|
659
|
+
| ExprDay
|
|
660
|
+
| ExprHour
|
|
661
|
+
| ExprMinute
|
|
662
|
+
| ExprSecond
|
|
663
|
+
| ExprIsoWeek
|
|
664
|
+
| ExprIsoWeekStartDate
|
|
665
|
+
| ExprIsoYearMonth
|
|
666
|
+
| ExprDateDiff
|
|
667
|
+
| ExprDateAdd
|
|
668
|
+
| ExprFormatDate
|
|
669
|
+
|
|
670
|
+
// Condition
|
|
671
|
+
| ExprIfNull
|
|
672
|
+
| ExprNullIf
|
|
673
|
+
| ExprIs
|
|
674
|
+
| ExprSwitch
|
|
675
|
+
| ExprIf
|
|
676
|
+
|
|
677
|
+
// Aggregate
|
|
678
|
+
| ExprCount
|
|
679
|
+
| ExprSum
|
|
680
|
+
| ExprAvg
|
|
681
|
+
| ExprMax
|
|
682
|
+
| ExprMin
|
|
683
|
+
|
|
684
|
+
// Other
|
|
685
|
+
| ExprGreatest
|
|
686
|
+
| ExprLeast
|
|
687
|
+
| ExprRowNum
|
|
688
|
+
| ExprRandom
|
|
689
|
+
| ExprCast
|
|
690
|
+
|
|
691
|
+
// Window
|
|
692
|
+
| ExprWindow
|
|
693
|
+
|
|
694
|
+
// System
|
|
695
|
+
| ExprSubquery;
|
|
696
|
+
|
|
697
|
+
//#endregion
|