@simplysm/orm-common 13.0.100 → 14.0.1
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/create-db-context.d.ts +10 -10
- package/dist/create-db-context.js +312 -276
- package/dist/create-db-context.js.map +1 -6
- package/dist/ddl/column-ddl.d.ts +4 -4
- package/dist/ddl/column-ddl.js +41 -35
- package/dist/ddl/column-ddl.js.map +1 -6
- package/dist/ddl/initialize.d.ts +17 -17
- package/dist/ddl/initialize.js +200 -142
- package/dist/ddl/initialize.js.map +1 -6
- package/dist/ddl/relation-ddl.d.ts +6 -6
- package/dist/ddl/relation-ddl.js +55 -48
- package/dist/ddl/relation-ddl.js.map +1 -6
- package/dist/ddl/schema-ddl.d.ts +4 -4
- package/dist/ddl/schema-ddl.js +21 -15
- package/dist/ddl/schema-ddl.js.map +1 -6
- package/dist/ddl/table-ddl.d.ts +20 -20
- package/dist/ddl/table-ddl.js +139 -93
- package/dist/ddl/table-ddl.js.map +1 -6
- package/dist/define-db-context.js +10 -13
- package/dist/define-db-context.js.map +1 -6
- package/dist/errors/db-transaction-error.d.ts +15 -15
- package/dist/errors/db-transaction-error.d.ts.map +1 -1
- package/dist/errors/db-transaction-error.js +53 -19
- package/dist/errors/db-transaction-error.js.map +1 -6
- package/dist/exec/executable.d.ts +23 -23
- package/dist/exec/executable.js +94 -40
- package/dist/exec/executable.js.map +1 -6
- package/dist/exec/queryable.d.ts +97 -97
- package/dist/exec/queryable.js +1310 -1204
- package/dist/exec/queryable.js.map +1 -6
- package/dist/exec/search-parser.d.ts +31 -31
- package/dist/exec/search-parser.d.ts.map +1 -1
- package/dist/exec/search-parser.js +158 -59
- package/dist/exec/search-parser.js.map +1 -6
- package/dist/expr/expr-unit.d.ts +4 -4
- package/dist/expr/expr-unit.js +24 -18
- package/dist/expr/expr-unit.js.map +1 -6
- package/dist/expr/expr.d.ts +6 -6
- package/dist/expr/expr.js +1872 -1844
- package/dist/expr/expr.js.map +1 -6
- package/dist/index.js +23 -1
- package/dist/index.js.map +1 -6
- package/dist/models/system-migration.js +7 -7
- package/dist/models/system-migration.js.map +1 -6
- package/dist/query-builder/base/expr-renderer-base.d.ts +10 -10
- package/dist/query-builder/base/expr-renderer-base.js +27 -21
- package/dist/query-builder/base/expr-renderer-base.js.map +1 -6
- package/dist/query-builder/base/query-builder-base.d.ts +21 -21
- package/dist/query-builder/base/query-builder-base.d.ts.map +1 -1
- package/dist/query-builder/base/query-builder-base.js +90 -80
- package/dist/query-builder/base/query-builder-base.js.map +1 -6
- 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 +447 -420
- package/dist/query-builder/mssql/mssql-expr-renderer.js.map +1 -6
- package/dist/query-builder/mssql/mssql-query-builder.js +483 -443
- package/dist/query-builder/mssql/mssql-query-builder.js.map +1 -6
- 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 +451 -419
- package/dist/query-builder/mysql/mysql-expr-renderer.js.map +1 -6
- package/dist/query-builder/mysql/mysql-query-builder.js +570 -479
- package/dist/query-builder/mysql/mysql-query-builder.js.map +1 -6
- 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 +449 -422
- package/dist/query-builder/postgresql/postgresql-expr-renderer.js.map +1 -6
- package/dist/query-builder/postgresql/postgresql-query-builder.js +511 -460
- package/dist/query-builder/postgresql/postgresql-query-builder.js.map +1 -6
- package/dist/query-builder/query-builder.d.ts +1 -1
- package/dist/query-builder/query-builder.js +13 -13
- package/dist/query-builder/query-builder.js.map +1 -6
- package/dist/schema/factory/column-builder.d.ts +84 -84
- package/dist/schema/factory/column-builder.js +248 -185
- package/dist/schema/factory/column-builder.js.map +1 -6
- package/dist/schema/factory/index-builder.d.ts +38 -38
- package/dist/schema/factory/index-builder.js +144 -85
- package/dist/schema/factory/index-builder.js.map +1 -6
- package/dist/schema/factory/relation-builder.d.ts +91 -91
- package/dist/schema/factory/relation-builder.d.ts.map +1 -1
- package/dist/schema/factory/relation-builder.js +274 -136
- package/dist/schema/factory/relation-builder.js.map +1 -6
- package/dist/schema/procedure-builder.d.ts +51 -51
- package/dist/schema/procedure-builder.d.ts.map +1 -1
- package/dist/schema/procedure-builder.js +205 -131
- package/dist/schema/procedure-builder.js.map +1 -6
- package/dist/schema/table-builder.d.ts +55 -55
- package/dist/schema/table-builder.d.ts.map +1 -1
- package/dist/schema/table-builder.js +274 -205
- package/dist/schema/table-builder.js.map +1 -6
- package/dist/schema/view-builder.d.ts +44 -44
- package/dist/schema/view-builder.d.ts.map +1 -1
- package/dist/schema/view-builder.js +189 -116
- package/dist/schema/view-builder.js.map +1 -6
- package/dist/types/column.js +60 -30
- package/dist/types/column.js.map +1 -6
- package/dist/types/db-context-def.d.ts +9 -9
- package/dist/types/db-context-def.js +2 -1
- package/dist/types/db-context-def.js.map +1 -6
- package/dist/types/db.d.ts +47 -47
- package/dist/types/db.js +15 -5
- package/dist/types/db.js.map +1 -6
- package/dist/types/expr.d.ts +81 -81
- package/dist/types/expr.d.ts.map +1 -1
- package/dist/types/expr.js +3 -1
- package/dist/types/expr.js.map +1 -6
- package/dist/types/query-def.d.ts +46 -46
- package/dist/types/query-def.d.ts.map +1 -1
- package/dist/types/query-def.js +31 -24
- package/dist/types/query-def.js.map +1 -6
- package/dist/utils/result-parser.js +362 -221
- package/dist/utils/result-parser.js.map +1 -6
- package/package.json +5 -7
- package/src/create-db-context.ts +31 -31
- package/src/ddl/column-ddl.ts +4 -4
- package/src/ddl/initialize.ts +38 -38
- package/src/ddl/relation-ddl.ts +6 -6
- package/src/ddl/schema-ddl.ts +4 -4
- package/src/ddl/table-ddl.ts +24 -24
- package/src/errors/db-transaction-error.ts +13 -13
- package/src/exec/executable.ts +25 -25
- package/src/exec/queryable.ts +134 -134
- package/src/exec/search-parser.ts +50 -50
- package/src/expr/expr-unit.ts +4 -4
- package/src/expr/expr.ts +13 -13
- package/src/index.ts +8 -8
- package/src/models/system-migration.ts +1 -1
- package/src/query-builder/base/expr-renderer-base.ts +21 -21
- package/src/query-builder/base/query-builder-base.ts +33 -33
- package/src/query-builder/mssql/mssql-expr-renderer.ts +11 -11
- package/src/query-builder/mssql/mssql-query-builder.ts +11 -11
- package/src/query-builder/mysql/mysql-expr-renderer.ts +15 -15
- package/src/query-builder/mysql/mysql-query-builder.ts +3 -3
- package/src/query-builder/postgresql/postgresql-expr-renderer.ts +9 -9
- package/src/query-builder/postgresql/postgresql-query-builder.ts +7 -7
- package/src/query-builder/query-builder.ts +1 -1
- package/src/schema/factory/column-builder.ts +86 -86
- package/src/schema/factory/index-builder.ts +38 -38
- package/src/schema/factory/relation-builder.ts +93 -93
- package/src/schema/procedure-builder.ts +52 -52
- package/src/schema/table-builder.ts +56 -56
- package/src/schema/view-builder.ts +45 -45
- package/src/types/column.ts +1 -1
- package/src/types/db-context-def.ts +15 -15
- package/src/types/db.ts +50 -50
- package/src/types/expr.ts +103 -103
- package/src/types/query-def.ts +50 -50
- package/src/utils/result-parser.ts +39 -39
- package/README.md +0 -192
- package/docs/core.md +0 -234
- package/docs/expression.md +0 -234
- package/docs/query-builder.md +0 -93
- package/docs/queryable.md +0 -198
- package/docs/schema-builders.md +0 -463
- package/docs/types.md +0 -445
- package/docs/utilities.md +0 -27
- package/tests/db-context/create-db-context.spec.ts +0 -193
- package/tests/db-context/define-db-context.spec.ts +0 -17
- package/tests/ddl/basic.expected.ts +0 -341
- package/tests/ddl/basic.spec.ts +0 -557
- package/tests/ddl/column-builder.expected.ts +0 -310
- package/tests/ddl/column-builder.spec.ts +0 -525
- package/tests/ddl/index-builder.expected.ts +0 -38
- package/tests/ddl/index-builder.spec.ts +0 -148
- package/tests/ddl/procedure-builder.expected.ts +0 -52
- package/tests/ddl/procedure-builder.spec.ts +0 -128
- package/tests/ddl/relation-builder.expected.ts +0 -36
- package/tests/ddl/relation-builder.spec.ts +0 -171
- package/tests/ddl/table-builder.expected.ts +0 -113
- package/tests/ddl/table-builder.spec.ts +0 -399
- package/tests/ddl/view-builder.expected.ts +0 -38
- package/tests/ddl/view-builder.spec.ts +0 -116
- package/tests/dml/delete.expected.ts +0 -96
- package/tests/dml/delete.spec.ts +0 -127
- package/tests/dml/insert.expected.ts +0 -192
- package/tests/dml/insert.spec.ts +0 -210
- package/tests/dml/update.expected.ts +0 -176
- package/tests/dml/update.spec.ts +0 -222
- package/tests/dml/upsert.expected.ts +0 -215
- package/tests/dml/upsert.spec.ts +0 -190
- package/tests/errors/queryable-errors.spec.ts +0 -126
- package/tests/escape.spec.ts +0 -59
- package/tests/examples/pivot.expected.ts +0 -211
- package/tests/examples/pivot.spec.ts +0 -200
- package/tests/examples/sampling.expected.ts +0 -69
- package/tests/examples/sampling.spec.ts +0 -42
- package/tests/examples/unpivot.expected.ts +0 -120
- package/tests/examples/unpivot.spec.ts +0 -161
- package/tests/exec/search-parser.spec.ts +0 -267
- package/tests/executable/basic.expected.ts +0 -18
- package/tests/executable/basic.spec.ts +0 -54
- package/tests/expr/comparison.expected.ts +0 -282
- package/tests/expr/comparison.spec.ts +0 -334
- package/tests/expr/conditional.expected.ts +0 -134
- package/tests/expr/conditional.spec.ts +0 -249
- package/tests/expr/date.expected.ts +0 -332
- package/tests/expr/date.spec.ts +0 -459
- package/tests/expr/math.expected.ts +0 -62
- package/tests/expr/math.spec.ts +0 -59
- package/tests/expr/string.expected.ts +0 -218
- package/tests/expr/string.spec.ts +0 -300
- package/tests/expr/utility.expected.ts +0 -147
- package/tests/expr/utility.spec.ts +0 -155
- package/tests/select/basic.expected.ts +0 -322
- package/tests/select/basic.spec.ts +0 -433
- package/tests/select/filter.expected.ts +0 -357
- package/tests/select/filter.spec.ts +0 -954
- package/tests/select/group.expected.ts +0 -169
- package/tests/select/group.spec.ts +0 -159
- package/tests/select/join.expected.ts +0 -582
- package/tests/select/join.spec.ts +0 -692
- package/tests/select/order.expected.ts +0 -150
- package/tests/select/order.spec.ts +0 -140
- package/tests/select/recursive-cte.expected.ts +0 -244
- package/tests/select/recursive-cte.spec.ts +0 -514
- package/tests/select/result-meta.spec.ts +0 -270
- package/tests/select/subquery.expected.ts +0 -363
- package/tests/select/subquery.spec.ts +0 -441
- package/tests/select/view.expected.ts +0 -155
- package/tests/select/view.spec.ts +0 -235
- package/tests/select/window.expected.ts +0 -345
- package/tests/select/window.spec.ts +0 -433
- package/tests/setup/MockExecutor.ts +0 -18
- package/tests/setup/TestDbContext.ts +0 -59
- package/tests/setup/models/Company.ts +0 -13
- package/tests/setup/models/Employee.ts +0 -10
- package/tests/setup/models/MonthlySales.ts +0 -11
- package/tests/setup/models/Post.ts +0 -16
- package/tests/setup/models/Sales.ts +0 -10
- package/tests/setup/models/User.ts +0 -19
- package/tests/setup/procedure/GetAllUsers.ts +0 -9
- package/tests/setup/procedure/GetUserById.ts +0 -12
- package/tests/setup/test-utils.ts +0 -72
- package/tests/setup/views/ActiveUsers.ts +0 -8
- package/tests/setup/views/UserSummary.ts +0 -11
- package/tests/types/nullable-queryable-record.spec.ts +0 -97
- package/tests/utils/result-parser-perf.spec.ts +0 -143
- package/tests/utils/result-parser.spec.ts +0 -667
package/src/types/expr.ts
CHANGED
|
@@ -2,18 +2,18 @@ import type { ColumnPrimitive, DataType } from "./column";
|
|
|
2
2
|
import type { SelectQueryDef } from "./query-def";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* 날짜 연산 단위
|
|
6
6
|
*
|
|
7
|
-
*
|
|
7
|
+
* dateDiff, dateAdd 등 날짜 함수에서 사용
|
|
8
8
|
*/
|
|
9
9
|
export type DateUnit = "year" | "month" | "day" | "hour" | "minute" | "second";
|
|
10
10
|
|
|
11
|
-
//#region ==========
|
|
11
|
+
//#region ========== 값 expression ==========
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
|
-
* Column
|
|
14
|
+
* Column 참조 expression
|
|
15
15
|
*
|
|
16
|
-
* @property path - Column
|
|
16
|
+
* @property path - Column 경로 (예: tableAlias.columnName)
|
|
17
17
|
*/
|
|
18
18
|
export interface ExprColumn {
|
|
19
19
|
type: "column";
|
|
@@ -21,9 +21,9 @@ export interface ExprColumn {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
|
-
*
|
|
24
|
+
* 리터럴 값 expression
|
|
25
25
|
*
|
|
26
|
-
* @property value - Column
|
|
26
|
+
* @property value - Column 원시 값
|
|
27
27
|
*/
|
|
28
28
|
export interface ExprValue {
|
|
29
29
|
type: "value";
|
|
@@ -33,8 +33,8 @@ export interface ExprValue {
|
|
|
33
33
|
/**
|
|
34
34
|
* Raw SQL expression
|
|
35
35
|
*
|
|
36
|
-
* @property sql - SQL
|
|
37
|
-
* @property params -
|
|
36
|
+
* @property sql - SQL 문자열 (파라미터는 {0}, {1}로 표기)
|
|
37
|
+
* @property params - 파라미터 expression 배열
|
|
38
38
|
*/
|
|
39
39
|
export interface ExprRaw {
|
|
40
40
|
type: "raw";
|
|
@@ -44,44 +44,44 @@ export interface ExprRaw {
|
|
|
44
44
|
|
|
45
45
|
//#endregion
|
|
46
46
|
|
|
47
|
-
//#region ==========
|
|
47
|
+
//#region ========== 비교 연산 (WHERE용) ==========
|
|
48
48
|
|
|
49
|
-
/**
|
|
49
|
+
/** 동등 비교 (=) - NULL 안전 */
|
|
50
50
|
export interface ExprEq {
|
|
51
51
|
type: "eq";
|
|
52
52
|
source: Expr;
|
|
53
53
|
target: Expr;
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
/**
|
|
56
|
+
/** 초과 비교 (>) */
|
|
57
57
|
export interface ExprGt {
|
|
58
58
|
type: "gt";
|
|
59
59
|
source: Expr;
|
|
60
60
|
target: Expr;
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
/**
|
|
63
|
+
/** 미만 비교 (<) */
|
|
64
64
|
export interface ExprLt {
|
|
65
65
|
type: "lt";
|
|
66
66
|
source: Expr;
|
|
67
67
|
target: Expr;
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
/**
|
|
70
|
+
/** 이상 비교 (>=) */
|
|
71
71
|
export interface ExprGte {
|
|
72
72
|
type: "gte";
|
|
73
73
|
source: Expr;
|
|
74
74
|
target: Expr;
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
/**
|
|
77
|
+
/** 이하 비교 (<=) */
|
|
78
78
|
export interface ExprLte {
|
|
79
79
|
type: "lte";
|
|
80
80
|
source: Expr;
|
|
81
81
|
target: Expr;
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
/**
|
|
84
|
+
/** 범위 비교 (BETWEEN from AND to) */
|
|
85
85
|
export interface ExprBetween {
|
|
86
86
|
type: "between";
|
|
87
87
|
source: Expr;
|
|
@@ -89,41 +89,41 @@ export interface ExprBetween {
|
|
|
89
89
|
to?: Expr;
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
-
/** NULL
|
|
92
|
+
/** NULL 검사 (IS NULL) */
|
|
93
93
|
export interface ExprIsNull {
|
|
94
94
|
type: "null";
|
|
95
95
|
arg: Expr;
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
-
/**
|
|
98
|
+
/** 패턴 매칭 (LIKE) */
|
|
99
99
|
export interface ExprLike {
|
|
100
100
|
type: "like";
|
|
101
101
|
source: Expr;
|
|
102
102
|
pattern: Expr;
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
-
/**
|
|
105
|
+
/** 정규식 매칭 (REGEXP) */
|
|
106
106
|
export interface ExprRegexp {
|
|
107
107
|
type: "regexp";
|
|
108
108
|
source: Expr;
|
|
109
109
|
pattern: Expr;
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
-
/**
|
|
112
|
+
/** 값 목록 포함 검사 (IN) */
|
|
113
113
|
export interface ExprIn {
|
|
114
114
|
type: "in";
|
|
115
115
|
source: Expr;
|
|
116
116
|
values: Expr[];
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
-
/** Subquery
|
|
119
|
+
/** Subquery 결과 포함 검사 (IN subquery) */
|
|
120
120
|
export interface ExprInQuery {
|
|
121
121
|
type: "inQuery";
|
|
122
122
|
source: Expr;
|
|
123
123
|
query: SelectQueryDef;
|
|
124
124
|
}
|
|
125
125
|
|
|
126
|
-
/** Subquery
|
|
126
|
+
/** Subquery 존재 검사 (EXISTS) */
|
|
127
127
|
export interface ExprExists {
|
|
128
128
|
type: "exists";
|
|
129
129
|
query: SelectQueryDef;
|
|
@@ -131,21 +131,21 @@ export interface ExprExists {
|
|
|
131
131
|
|
|
132
132
|
//#endregion
|
|
133
133
|
|
|
134
|
-
//#region ==========
|
|
134
|
+
//#region ========== 논리 연산 ==========
|
|
135
135
|
|
|
136
|
-
/**
|
|
136
|
+
/** 논리 부정 (NOT) */
|
|
137
137
|
export interface ExprNot {
|
|
138
138
|
type: "not";
|
|
139
139
|
arg: WhereExpr;
|
|
140
140
|
}
|
|
141
141
|
|
|
142
|
-
/**
|
|
142
|
+
/** 논리곱 (AND) */
|
|
143
143
|
export interface ExprAnd {
|
|
144
144
|
type: "and";
|
|
145
145
|
conditions: WhereExpr[];
|
|
146
146
|
}
|
|
147
147
|
|
|
148
|
-
/**
|
|
148
|
+
/** 논리합 (OR) */
|
|
149
149
|
export interface ExprOr {
|
|
150
150
|
type: "or";
|
|
151
151
|
conditions: WhereExpr[];
|
|
@@ -153,35 +153,35 @@ export interface ExprOr {
|
|
|
153
153
|
|
|
154
154
|
//#endregion
|
|
155
155
|
|
|
156
|
-
//#region ==========
|
|
156
|
+
//#region ========== 문자열 함수 ==========
|
|
157
157
|
|
|
158
|
-
/**
|
|
158
|
+
/** 문자열 연결 (CONCAT) */
|
|
159
159
|
export interface ExprConcat {
|
|
160
160
|
type: "concat";
|
|
161
161
|
args: Expr[];
|
|
162
162
|
}
|
|
163
163
|
|
|
164
|
-
/**
|
|
164
|
+
/** 왼쪽 N자 추출 (LEFT) */
|
|
165
165
|
export interface ExprLeft {
|
|
166
166
|
type: "left";
|
|
167
167
|
source: Expr;
|
|
168
168
|
length: Expr;
|
|
169
169
|
}
|
|
170
170
|
|
|
171
|
-
/**
|
|
171
|
+
/** 오른쪽 N자 추출 (RIGHT) */
|
|
172
172
|
export interface ExprRight {
|
|
173
173
|
type: "right";
|
|
174
174
|
source: Expr;
|
|
175
175
|
length: Expr;
|
|
176
176
|
}
|
|
177
177
|
|
|
178
|
-
/**
|
|
178
|
+
/** 앞뒤 공백 제거 (TRIM) */
|
|
179
179
|
export interface ExprTrim {
|
|
180
180
|
type: "trim";
|
|
181
181
|
arg: Expr;
|
|
182
182
|
}
|
|
183
183
|
|
|
184
|
-
/**
|
|
184
|
+
/** 왼쪽 패딩 (LPAD) */
|
|
185
185
|
export interface ExprPadStart {
|
|
186
186
|
type: "padStart";
|
|
187
187
|
source: Expr;
|
|
@@ -189,7 +189,7 @@ export interface ExprPadStart {
|
|
|
189
189
|
fillString: Expr;
|
|
190
190
|
}
|
|
191
191
|
|
|
192
|
-
/**
|
|
192
|
+
/** 문자열 치환 (REPLACE) */
|
|
193
193
|
export interface ExprReplace {
|
|
194
194
|
type: "replace";
|
|
195
195
|
source: Expr;
|
|
@@ -197,31 +197,31 @@ export interface ExprReplace {
|
|
|
197
197
|
to: Expr;
|
|
198
198
|
}
|
|
199
199
|
|
|
200
|
-
/**
|
|
200
|
+
/** 대문자 변환 (UPPER) */
|
|
201
201
|
export interface ExprUpper {
|
|
202
202
|
type: "upper";
|
|
203
203
|
arg: Expr;
|
|
204
204
|
}
|
|
205
205
|
|
|
206
|
-
/**
|
|
206
|
+
/** 소문자 변환 (LOWER) */
|
|
207
207
|
export interface ExprLower {
|
|
208
208
|
type: "lower";
|
|
209
209
|
arg: Expr;
|
|
210
210
|
}
|
|
211
211
|
|
|
212
|
-
/**
|
|
212
|
+
/** 문자 길이 (CHAR_LENGTH) */
|
|
213
213
|
export interface ExprLength {
|
|
214
214
|
type: "length";
|
|
215
215
|
arg: Expr;
|
|
216
216
|
}
|
|
217
217
|
|
|
218
|
-
/**
|
|
218
|
+
/** 바이트 길이 (LENGTH/DATALENGTH) */
|
|
219
219
|
export interface ExprByteLength {
|
|
220
220
|
type: "byteLength";
|
|
221
221
|
arg: Expr;
|
|
222
222
|
}
|
|
223
223
|
|
|
224
|
-
/**
|
|
224
|
+
/** 부분 문자열 (SUBSTRING) */
|
|
225
225
|
export interface ExprSubstring {
|
|
226
226
|
type: "substring";
|
|
227
227
|
source: Expr;
|
|
@@ -229,7 +229,7 @@ export interface ExprSubstring {
|
|
|
229
229
|
length?: Expr;
|
|
230
230
|
}
|
|
231
231
|
|
|
232
|
-
/**
|
|
232
|
+
/** 문자열 위치 (LOCATE/CHARINDEX/POSITION) */
|
|
233
233
|
export interface ExprIndexOf {
|
|
234
234
|
type: "indexOf";
|
|
235
235
|
source: Expr;
|
|
@@ -238,28 +238,28 @@ export interface ExprIndexOf {
|
|
|
238
238
|
|
|
239
239
|
//#endregion
|
|
240
240
|
|
|
241
|
-
//#region ==========
|
|
241
|
+
//#region ========== 숫자 함수 ==========
|
|
242
242
|
|
|
243
|
-
/**
|
|
243
|
+
/** 절대값 (ABS) */
|
|
244
244
|
export interface ExprAbs {
|
|
245
245
|
type: "abs";
|
|
246
246
|
arg: Expr;
|
|
247
247
|
}
|
|
248
248
|
|
|
249
|
-
/**
|
|
249
|
+
/** 반올림 (ROUND) */
|
|
250
250
|
export interface ExprRound {
|
|
251
251
|
type: "round";
|
|
252
252
|
arg: Expr;
|
|
253
253
|
digits: number;
|
|
254
254
|
}
|
|
255
255
|
|
|
256
|
-
/**
|
|
256
|
+
/** 올림 (CEIL) */
|
|
257
257
|
export interface ExprCeil {
|
|
258
258
|
type: "ceil";
|
|
259
259
|
arg: Expr;
|
|
260
260
|
}
|
|
261
261
|
|
|
262
|
-
/**
|
|
262
|
+
/** 내림 (FLOOR) */
|
|
263
263
|
export interface ExprFloor {
|
|
264
264
|
type: "floor";
|
|
265
265
|
arg: Expr;
|
|
@@ -267,63 +267,63 @@ export interface ExprFloor {
|
|
|
267
267
|
|
|
268
268
|
//#endregion
|
|
269
269
|
|
|
270
|
-
//#region ==========
|
|
270
|
+
//#region ========== 날짜 함수 ==========
|
|
271
271
|
|
|
272
|
-
/**
|
|
272
|
+
/** 연도 추출 (YEAR) */
|
|
273
273
|
export interface ExprYear {
|
|
274
274
|
type: "year";
|
|
275
275
|
arg: Expr;
|
|
276
276
|
}
|
|
277
277
|
|
|
278
|
-
/**
|
|
278
|
+
/** 월 추출 (MONTH) */
|
|
279
279
|
export interface ExprMonth {
|
|
280
280
|
type: "month";
|
|
281
281
|
arg: Expr;
|
|
282
282
|
}
|
|
283
283
|
|
|
284
|
-
/**
|
|
284
|
+
/** 일 추출 (DAY) */
|
|
285
285
|
export interface ExprDay {
|
|
286
286
|
type: "day";
|
|
287
287
|
arg: Expr;
|
|
288
288
|
}
|
|
289
289
|
|
|
290
|
-
/**
|
|
290
|
+
/** 시 추출 (HOUR) */
|
|
291
291
|
export interface ExprHour {
|
|
292
292
|
type: "hour";
|
|
293
293
|
arg: Expr;
|
|
294
294
|
}
|
|
295
295
|
|
|
296
|
-
/**
|
|
296
|
+
/** 분 추출 (MINUTE) */
|
|
297
297
|
export interface ExprMinute {
|
|
298
298
|
type: "minute";
|
|
299
299
|
arg: Expr;
|
|
300
300
|
}
|
|
301
301
|
|
|
302
|
-
/**
|
|
302
|
+
/** 초 추출 (SECOND) */
|
|
303
303
|
export interface ExprSecond {
|
|
304
304
|
type: "second";
|
|
305
305
|
arg: Expr;
|
|
306
306
|
}
|
|
307
307
|
|
|
308
|
-
/** ISO
|
|
308
|
+
/** ISO 주 번호 (WEEK) */
|
|
309
309
|
export interface ExprIsoWeek {
|
|
310
310
|
type: "isoWeek";
|
|
311
311
|
arg: Expr;
|
|
312
312
|
}
|
|
313
313
|
|
|
314
|
-
/** ISO
|
|
314
|
+
/** ISO 주 시작일 */
|
|
315
315
|
export interface ExprIsoWeekStartDate {
|
|
316
316
|
type: "isoWeekStartDate";
|
|
317
317
|
arg: Expr;
|
|
318
318
|
}
|
|
319
319
|
|
|
320
|
-
/** ISO
|
|
320
|
+
/** ISO 연월 (YYYYMM 형식) */
|
|
321
321
|
export interface ExprIsoYearMonth {
|
|
322
322
|
type: "isoYearMonth";
|
|
323
323
|
arg: Expr;
|
|
324
324
|
}
|
|
325
325
|
|
|
326
|
-
/**
|
|
326
|
+
/** 날짜 차이 (DATEDIFF) */
|
|
327
327
|
export interface ExprDateDiff {
|
|
328
328
|
type: "dateDiff";
|
|
329
329
|
unit: DateUnit;
|
|
@@ -331,7 +331,7 @@ export interface ExprDateDiff {
|
|
|
331
331
|
to: Expr;
|
|
332
332
|
}
|
|
333
333
|
|
|
334
|
-
/**
|
|
334
|
+
/** 날짜 연산 (DATEADD) */
|
|
335
335
|
export interface ExprDateAdd {
|
|
336
336
|
type: "dateAdd";
|
|
337
337
|
unit: DateUnit;
|
|
@@ -339,7 +339,7 @@ export interface ExprDateAdd {
|
|
|
339
339
|
value: Expr;
|
|
340
340
|
}
|
|
341
341
|
|
|
342
|
-
/**
|
|
342
|
+
/** 날짜 포맷 (FORMAT/DATE_FORMAT) */
|
|
343
343
|
export interface ExprFormatDate {
|
|
344
344
|
type: "formatDate";
|
|
345
345
|
source: Expr;
|
|
@@ -348,22 +348,22 @@ export interface ExprFormatDate {
|
|
|
348
348
|
|
|
349
349
|
//#endregion
|
|
350
350
|
|
|
351
|
-
//#region ==========
|
|
351
|
+
//#region ========== 조건부 ==========
|
|
352
352
|
|
|
353
|
-
/** NULL
|
|
353
|
+
/** NULL 대체 (COALESCE - 첫 번째 non-null 반환) */
|
|
354
354
|
export interface ExprCoalesce {
|
|
355
355
|
type: "coalesce";
|
|
356
356
|
args: Expr[];
|
|
357
357
|
}
|
|
358
358
|
|
|
359
|
-
/**
|
|
359
|
+
/** 조건부 NULL (NULLIF - source === value이면 NULL 반환) */
|
|
360
360
|
export interface ExprNullIf {
|
|
361
361
|
type: "nullIf";
|
|
362
362
|
source: Expr;
|
|
363
363
|
value: Expr;
|
|
364
364
|
}
|
|
365
365
|
|
|
366
|
-
/**
|
|
366
|
+
/** 조건을 값으로 변환 (boolean -> 0/1) */
|
|
367
367
|
export interface ExprIs {
|
|
368
368
|
type: "is";
|
|
369
369
|
condition: WhereExpr;
|
|
@@ -376,7 +376,7 @@ export interface ExprSwitch {
|
|
|
376
376
|
else: Expr;
|
|
377
377
|
}
|
|
378
378
|
|
|
379
|
-
/** IF expression (IIF/IF) */
|
|
379
|
+
/** IF expression (IIF/IF) - 조건 분기 */
|
|
380
380
|
export interface ExprIf {
|
|
381
381
|
type: "if";
|
|
382
382
|
condition: WhereExpr;
|
|
@@ -386,34 +386,34 @@ export interface ExprIf {
|
|
|
386
386
|
|
|
387
387
|
//#endregion
|
|
388
388
|
|
|
389
|
-
//#region ==========
|
|
389
|
+
//#region ========== 집계 ==========
|
|
390
390
|
|
|
391
|
-
/**
|
|
391
|
+
/** 레코드 수 (COUNT) */
|
|
392
392
|
export interface ExprCount {
|
|
393
393
|
type: "count";
|
|
394
394
|
arg?: Expr;
|
|
395
395
|
distinct?: boolean;
|
|
396
396
|
}
|
|
397
397
|
|
|
398
|
-
/**
|
|
398
|
+
/** 합계 (SUM) */
|
|
399
399
|
export interface ExprSum {
|
|
400
400
|
type: "sum";
|
|
401
401
|
arg: Expr;
|
|
402
402
|
}
|
|
403
403
|
|
|
404
|
-
/**
|
|
404
|
+
/** 평균 (AVG) */
|
|
405
405
|
export interface ExprAvg {
|
|
406
406
|
type: "avg";
|
|
407
407
|
arg: Expr;
|
|
408
408
|
}
|
|
409
409
|
|
|
410
|
-
/**
|
|
410
|
+
/** 최대값 (MAX) */
|
|
411
411
|
export interface ExprMax {
|
|
412
412
|
type: "max";
|
|
413
413
|
arg: Expr;
|
|
414
414
|
}
|
|
415
415
|
|
|
416
|
-
/**
|
|
416
|
+
/** 최소값 (MIN) */
|
|
417
417
|
export interface ExprMin {
|
|
418
418
|
type: "min";
|
|
419
419
|
arg: Expr;
|
|
@@ -421,31 +421,31 @@ export interface ExprMin {
|
|
|
421
421
|
|
|
422
422
|
//#endregion
|
|
423
423
|
|
|
424
|
-
//#region ==========
|
|
424
|
+
//#region ========== 기타 ==========
|
|
425
425
|
|
|
426
|
-
/**
|
|
426
|
+
/** 최대값 선택 (GREATEST) */
|
|
427
427
|
export interface ExprGreatest {
|
|
428
428
|
type: "greatest";
|
|
429
429
|
args: Expr[];
|
|
430
430
|
}
|
|
431
431
|
|
|
432
|
-
/**
|
|
432
|
+
/** 최소값 선택 (LEAST) */
|
|
433
433
|
export interface ExprLeast {
|
|
434
434
|
type: "least";
|
|
435
435
|
args: Expr[];
|
|
436
436
|
}
|
|
437
437
|
|
|
438
|
-
/**
|
|
438
|
+
/** 행 번호 (단순 ROW_NUMBER 버전) */
|
|
439
439
|
export interface ExprRowNum {
|
|
440
440
|
type: "rowNum";
|
|
441
441
|
}
|
|
442
442
|
|
|
443
|
-
/**
|
|
443
|
+
/** 난수 (RAND/RANDOM) */
|
|
444
444
|
export interface ExprRandom {
|
|
445
445
|
type: "random";
|
|
446
446
|
}
|
|
447
447
|
|
|
448
|
-
/**
|
|
448
|
+
/** 타입 변환 (CAST) */
|
|
449
449
|
export interface ExprCast {
|
|
450
450
|
type: "cast";
|
|
451
451
|
source: Expr;
|
|
@@ -454,9 +454,9 @@ export interface ExprCast {
|
|
|
454
454
|
|
|
455
455
|
//#endregion
|
|
456
456
|
|
|
457
|
-
//#region ========== Window
|
|
457
|
+
//#region ========== Window 함수 ==========
|
|
458
458
|
|
|
459
|
-
// Window
|
|
459
|
+
// Window 함수 타입
|
|
460
460
|
|
|
461
461
|
/** ROW_NUMBER() */
|
|
462
462
|
export interface WinFnRowNumber {
|
|
@@ -479,7 +479,7 @@ export interface WinFnNtile {
|
|
|
479
479
|
n: number;
|
|
480
480
|
}
|
|
481
481
|
|
|
482
|
-
/** LAG() -
|
|
482
|
+
/** LAG() - 이전 행 값 */
|
|
483
483
|
export interface WinFnLag {
|
|
484
484
|
type: "lag";
|
|
485
485
|
column: Expr;
|
|
@@ -487,7 +487,7 @@ export interface WinFnLag {
|
|
|
487
487
|
default?: Expr;
|
|
488
488
|
}
|
|
489
489
|
|
|
490
|
-
/** LEAD() -
|
|
490
|
+
/** LEAD() - 다음 행 값 */
|
|
491
491
|
export interface WinFnLead {
|
|
492
492
|
type: "lead";
|
|
493
493
|
column: Expr;
|
|
@@ -538,9 +538,9 @@ export interface WinFnMax {
|
|
|
538
538
|
}
|
|
539
539
|
|
|
540
540
|
/**
|
|
541
|
-
* Window
|
|
541
|
+
* Window 함수 union 타입
|
|
542
542
|
*
|
|
543
|
-
*
|
|
543
|
+
* 순위, 탐색, 집계 Window 함수
|
|
544
544
|
*/
|
|
545
545
|
export type WinFn =
|
|
546
546
|
| WinFnRowNumber
|
|
@@ -558,10 +558,10 @@ export type WinFn =
|
|
|
558
558
|
| WinFnMax;
|
|
559
559
|
|
|
560
560
|
/**
|
|
561
|
-
* Window
|
|
561
|
+
* Window 명세 (OVER 절)
|
|
562
562
|
*
|
|
563
|
-
* @property partitionBy - PARTITION BY expression
|
|
564
|
-
* @property orderBy - ORDER BY [column, direction]
|
|
563
|
+
* @property partitionBy - PARTITION BY expression 목록
|
|
564
|
+
* @property orderBy - ORDER BY [column, direction] 목록
|
|
565
565
|
*/
|
|
566
566
|
export interface WinSpec {
|
|
567
567
|
partitionBy?: Expr[];
|
|
@@ -571,7 +571,7 @@ export interface WinSpec {
|
|
|
571
571
|
/**
|
|
572
572
|
* Window expression
|
|
573
573
|
*
|
|
574
|
-
* Window
|
|
574
|
+
* Window 함수 + Window 명세 조합
|
|
575
575
|
*/
|
|
576
576
|
export interface ExprWindow {
|
|
577
577
|
type: "window";
|
|
@@ -583,7 +583,7 @@ export interface ExprWindow {
|
|
|
583
583
|
|
|
584
584
|
//#region ========== System ==========
|
|
585
585
|
|
|
586
|
-
/**
|
|
586
|
+
/** 스칼라 Subquery */
|
|
587
587
|
export interface ExprSubquery {
|
|
588
588
|
type: "subquery";
|
|
589
589
|
queryDef: SelectQueryDef;
|
|
@@ -591,16 +591,16 @@ export interface ExprSubquery {
|
|
|
591
591
|
|
|
592
592
|
//#endregion
|
|
593
593
|
|
|
594
|
-
//#region ========== Union
|
|
594
|
+
//#region ========== Union 타입 ==========
|
|
595
595
|
|
|
596
596
|
/**
|
|
597
|
-
*
|
|
597
|
+
* WHERE 절에서 사용되는 expression (boolean 반환)
|
|
598
598
|
*
|
|
599
|
-
*
|
|
600
|
-
*
|
|
599
|
+
* 비교 연산 + 논리 연산의 union 타입
|
|
600
|
+
* where(), having() 등에서 사용
|
|
601
601
|
*/
|
|
602
602
|
export type WhereExpr =
|
|
603
|
-
//
|
|
603
|
+
// 비교
|
|
604
604
|
| ExprEq
|
|
605
605
|
| ExprGt
|
|
606
606
|
| ExprLt
|
|
@@ -614,26 +614,26 @@ export type WhereExpr =
|
|
|
614
614
|
| ExprInQuery
|
|
615
615
|
| ExprExists
|
|
616
616
|
|
|
617
|
-
//
|
|
617
|
+
// 논리
|
|
618
618
|
| ExprNot
|
|
619
619
|
| ExprAnd
|
|
620
620
|
| ExprOr;
|
|
621
621
|
|
|
622
622
|
/**
|
|
623
|
-
*
|
|
623
|
+
* 전체 expression union 타입
|
|
624
624
|
*
|
|
625
|
-
*
|
|
626
|
-
*
|
|
625
|
+
* 값, 문자열, 숫자, 날짜, 조건부, 집계, window 등 모든 expression 포함
|
|
626
|
+
* select(), orderBy() 등에서 사용
|
|
627
627
|
*
|
|
628
|
-
* @see {@link WhereExpr} WHERE
|
|
628
|
+
* @see {@link WhereExpr} WHERE 절 전용 expression
|
|
629
629
|
*/
|
|
630
630
|
export type Expr =
|
|
631
|
-
//
|
|
631
|
+
// 값
|
|
632
632
|
| ExprColumn
|
|
633
633
|
| ExprValue
|
|
634
634
|
| ExprRaw
|
|
635
635
|
|
|
636
|
-
//
|
|
636
|
+
// 문자열
|
|
637
637
|
| ExprConcat
|
|
638
638
|
| ExprLeft
|
|
639
639
|
| ExprRight
|
|
@@ -647,13 +647,13 @@ export type Expr =
|
|
|
647
647
|
| ExprSubstring
|
|
648
648
|
| ExprIndexOf
|
|
649
649
|
|
|
650
|
-
//
|
|
650
|
+
// 숫자
|
|
651
651
|
| ExprAbs
|
|
652
652
|
| ExprRound
|
|
653
653
|
| ExprCeil
|
|
654
654
|
| ExprFloor
|
|
655
655
|
|
|
656
|
-
//
|
|
656
|
+
// 날짜
|
|
657
657
|
| ExprYear
|
|
658
658
|
| ExprMonth
|
|
659
659
|
| ExprDay
|
|
@@ -667,21 +667,21 @@ export type Expr =
|
|
|
667
667
|
| ExprDateAdd
|
|
668
668
|
| ExprFormatDate
|
|
669
669
|
|
|
670
|
-
//
|
|
670
|
+
// 조건
|
|
671
671
|
| ExprCoalesce
|
|
672
672
|
| ExprNullIf
|
|
673
673
|
| ExprIs
|
|
674
674
|
| ExprSwitch
|
|
675
675
|
| ExprIf
|
|
676
676
|
|
|
677
|
-
//
|
|
677
|
+
// 집계
|
|
678
678
|
| ExprCount
|
|
679
679
|
| ExprSum
|
|
680
680
|
| ExprAvg
|
|
681
681
|
| ExprMax
|
|
682
682
|
| ExprMin
|
|
683
683
|
|
|
684
|
-
//
|
|
684
|
+
// 기타
|
|
685
685
|
| ExprGreatest
|
|
686
686
|
| ExprLeast
|
|
687
687
|
| ExprRowNum
|
|
@@ -691,7 +691,7 @@ export type Expr =
|
|
|
691
691
|
// Window
|
|
692
692
|
| ExprWindow
|
|
693
693
|
|
|
694
|
-
//
|
|
694
|
+
// 시스템
|
|
695
695
|
| ExprSubquery;
|
|
696
696
|
|
|
697
697
|
//#endregion
|