sonamu 0.7.4 → 0.7.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/config.d.ts +1 -4
- package/dist/api/config.d.ts.map +1 -1
- package/dist/api/config.js +1 -1
- package/dist/api/sonamu.d.ts +2 -0
- package/dist/api/sonamu.d.ts.map +1 -1
- package/dist/api/sonamu.js +19 -47
- package/dist/bin/cli.js +6 -6
- package/dist/database/base-model.d.ts +1 -1
- package/dist/database/base-model.d.ts.map +1 -1
- package/dist/database/base-model.js +15 -4
- package/dist/database/code-generator.d.ts.map +1 -1
- package/dist/database/code-generator.js +3 -3
- package/dist/database/db.d.ts.map +1 -1
- package/dist/database/db.js +1 -1
- package/dist/database/puri-wrapper.d.ts +11 -11
- package/dist/database/puri-wrapper.d.ts.map +1 -1
- package/dist/database/puri-wrapper.js +7 -11
- package/dist/database/puri.d.ts +36 -17
- package/dist/database/puri.d.ts.map +1 -1
- package/dist/database/puri.js +54 -7
- package/dist/database/puri.types.d.ts +54 -17
- package/dist/database/puri.types.d.ts.map +1 -1
- package/dist/database/puri.types.js +2 -4
- package/dist/database/puri.types.test-d.js +129 -0
- package/dist/database/upsert-builder.d.ts +16 -10
- package/dist/database/upsert-builder.d.ts.map +1 -1
- package/dist/database/upsert-builder.js +10 -19
- package/dist/entity/entity-manager.d.ts +113 -22
- package/dist/entity/entity-manager.d.ts.map +1 -1
- package/dist/entity/entity-manager.js +1 -1
- package/dist/entity/entity.d.ts +34 -0
- package/dist/entity/entity.d.ts.map +1 -1
- package/dist/entity/entity.js +110 -37
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -2
- package/dist/migration/code-generation.d.ts.map +1 -1
- package/dist/migration/code-generation.js +341 -149
- package/dist/migration/migration-set.d.ts.map +1 -1
- package/dist/migration/migration-set.js +21 -5
- package/dist/migration/migrator.d.ts.map +1 -1
- package/dist/migration/migrator.js +7 -1
- package/dist/migration/postgresql-schema-reader.d.ts +11 -1
- package/dist/migration/postgresql-schema-reader.d.ts.map +1 -1
- package/dist/migration/postgresql-schema-reader.js +111 -10
- package/dist/syncer/syncer.d.ts.map +1 -1
- package/dist/syncer/syncer.js +4 -3
- package/dist/template/implementations/generated.template.d.ts.map +1 -1
- package/dist/template/implementations/generated.template.js +12 -2
- package/dist/template/implementations/generated_sso.template.d.ts +3 -3
- package/dist/template/implementations/generated_sso.template.d.ts.map +1 -1
- package/dist/template/implementations/generated_sso.template.js +50 -2
- package/dist/template/implementations/model.template.js +6 -6
- package/dist/template/implementations/model_test.template.js +4 -4
- package/dist/template/implementations/view_enums_dropdown.template.js +2 -2
- package/dist/template/implementations/view_enums_select.template.js +2 -2
- package/dist/template/implementations/view_form.template.d.ts.map +1 -1
- package/dist/template/implementations/view_form.template.js +12 -9
- package/dist/template/implementations/view_id_async_select.template.js +4 -4
- package/dist/template/implementations/view_list.template.d.ts.map +1 -1
- package/dist/template/implementations/view_list.template.js +12 -9
- package/dist/template/implementations/view_search_input.template.js +2 -2
- package/dist/template/template.js +2 -2
- package/dist/template/zod-converter.d.ts.map +1 -1
- package/dist/template/zod-converter.js +17 -2
- package/dist/testing/fixture-manager.d.ts +2 -1
- package/dist/testing/fixture-manager.d.ts.map +1 -1
- package/dist/testing/fixture-manager.js +29 -29
- package/dist/types/types.d.ts +593 -68
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/types.js +113 -9
- package/dist/vector/chunking.d.ts +25 -0
- package/dist/vector/chunking.d.ts.map +1 -0
- package/dist/vector/chunking.js +97 -0
- package/dist/vector/config.d.ts +12 -0
- package/dist/vector/config.d.ts.map +1 -0
- package/dist/vector/config.js +83 -0
- package/dist/vector/embedding.d.ts +42 -0
- package/dist/vector/embedding.d.ts.map +1 -0
- package/dist/vector/embedding.js +147 -0
- package/dist/vector/types.d.ts +105 -0
- package/dist/vector/types.d.ts.map +1 -0
- package/dist/vector/types.js +5 -0
- package/dist/vector/vector-search.d.ts +47 -0
- package/dist/vector/vector-search.d.ts.map +1 -0
- package/dist/vector/vector-search.js +176 -0
- package/package.json +9 -8
- package/src/api/config.ts +0 -4
- package/src/api/sonamu.ts +21 -36
- package/src/bin/cli.ts +5 -5
- package/src/database/base-model.ts +20 -11
- package/src/database/code-generator.ts +6 -2
- package/src/database/db.ts +1 -0
- package/src/database/puri-wrapper.ts +22 -16
- package/src/database/puri.ts +150 -27
- package/src/database/puri.types.test-d.ts +457 -0
- package/src/database/puri.types.ts +231 -33
- package/src/database/upsert-builder.ts +43 -34
- package/src/entity/entity-manager.ts +2 -2
- package/src/entity/entity.ts +134 -44
- package/src/index.ts +6 -0
- package/src/migration/code-generation.ts +377 -174
- package/src/migration/migration-set.ts +22 -3
- package/src/migration/migrator.ts +6 -0
- package/src/migration/postgresql-schema-reader.ts +121 -21
- package/src/syncer/syncer.ts +3 -2
- package/src/template/implementations/generated.template.ts +51 -9
- package/src/template/implementations/generated_sso.template.ts +71 -2
- package/src/template/implementations/model.template.ts +5 -5
- package/src/template/implementations/model_test.template.ts +3 -3
- package/src/template/implementations/view_enums_dropdown.template.ts +1 -1
- package/src/template/implementations/view_enums_select.template.ts +1 -1
- package/src/template/implementations/view_form.template.ts +11 -8
- package/src/template/implementations/view_id_async_select.template.ts +3 -3
- package/src/template/implementations/view_list.template.ts +11 -8
- package/src/template/implementations/view_search_input.template.ts +1 -1
- package/src/template/template.ts +1 -1
- package/src/template/zod-converter.ts +20 -0
- package/src/testing/fixture-manager.ts +31 -30
- package/src/types/types.ts +226 -48
- package/src/vector/chunking.ts +115 -0
- package/src/vector/config.ts +68 -0
- package/src/vector/embedding.ts +193 -0
- package/src/vector/types.ts +122 -0
- package/src/vector/vector-search.ts +261 -0
- package/dist/template/implementations/view_enums_buttonset.template.d.ts +0 -17
- package/dist/template/implementations/view_enums_buttonset.template.d.ts.map +0 -1
- package/dist/template/implementations/view_enums_buttonset.template.js +0 -31
- package/dist/template/implementations/view_list_columns.template.d.ts +0 -17
- package/dist/template/implementations/view_list_columns.template.d.ts.map +0 -1
- package/dist/template/implementations/view_list_columns.template.js +0 -49
- package/src/template/implementations/view_enums_buttonset.template.ts +0 -34
- package/src/template/implementations/view_list_columns.template.ts +0 -53
package/src/database/puri.ts
CHANGED
|
@@ -14,13 +14,18 @@ import type {
|
|
|
14
14
|
FulltextColumns,
|
|
15
15
|
InsertData,
|
|
16
16
|
InsertResult,
|
|
17
|
+
LeftJoinedMarker,
|
|
18
|
+
LeftJoinMarkerFor,
|
|
19
|
+
NumericColumns,
|
|
17
20
|
OnConflictAction,
|
|
18
21
|
ParseSelectObject,
|
|
19
22
|
ResultAvailableColumns,
|
|
23
|
+
SelectAllResult,
|
|
20
24
|
SelectObject,
|
|
21
25
|
SingleTableValue,
|
|
22
26
|
SqlExpression,
|
|
23
27
|
WhereCondition,
|
|
28
|
+
WhereOperator,
|
|
24
29
|
} from "./puri.types";
|
|
25
30
|
import type { ClearStatements } from "./puri-subset.types";
|
|
26
31
|
|
|
@@ -47,7 +52,7 @@ export class Puri<TSchema, TTables extends Record<string, any>, TResult> {
|
|
|
47
52
|
if (typeof spec === "string") {
|
|
48
53
|
this.knexQuery = this.knex(spec).from({ [alias]: spec });
|
|
49
54
|
} else if (spec instanceof Puri) {
|
|
50
|
-
const subqueryBuilder = spec.
|
|
55
|
+
const subqueryBuilder = spec.rawQuery();
|
|
51
56
|
this.knexQuery = this.knex.from(subqueryBuilder.as(alias));
|
|
52
57
|
} else {
|
|
53
58
|
throw new Error("Invalid table specification");
|
|
@@ -133,9 +138,12 @@ export class Puri<TSchema, TTables extends Record<string, any>, TResult> {
|
|
|
133
138
|
select<TSelect extends SelectObject<TTables>>(
|
|
134
139
|
selectObj: TSelect,
|
|
135
140
|
): Puri<TSchema, TTables, ParseSelectObject<TTables, TSelect>> {
|
|
141
|
+
// 중첩 객체를 flat하게 변환
|
|
142
|
+
const flatSelect = this.flattenSelect(selectObj);
|
|
143
|
+
|
|
136
144
|
const selectClauses: (string | Knex.Raw)[] = [];
|
|
137
145
|
|
|
138
|
-
for (const [alias, columnOrFunction] of Object.entries(
|
|
146
|
+
for (const [alias, columnOrFunction] of Object.entries(flatSelect)) {
|
|
139
147
|
if (typeof columnOrFunction === "object" && columnOrFunction._type === "sql_expression") {
|
|
140
148
|
// SQL 함수인 경우
|
|
141
149
|
selectClauses.push(this.knex.raw(`${columnOrFunction._sql} as ${alias}`));
|
|
@@ -156,15 +164,58 @@ export class Puri<TSchema, TTables extends Record<string, any>, TResult> {
|
|
|
156
164
|
return this as any;
|
|
157
165
|
}
|
|
158
166
|
|
|
167
|
+
/**
|
|
168
|
+
* 중첩 객체를 flat 객체로 변환
|
|
169
|
+
* 예: { parent: { id: "parent.id", name: "parent.name" } }
|
|
170
|
+
* → { parent__id: "parent.id", parent__name: "parent.name" }
|
|
171
|
+
*/
|
|
172
|
+
private flattenSelect(selectObj: Record<string, any>, prefix = ""): Record<string, any> {
|
|
173
|
+
const flatSelect: Record<string, any> = {};
|
|
174
|
+
|
|
175
|
+
for (const [key, value] of Object.entries(selectObj)) {
|
|
176
|
+
const fullKey = prefix ? `${prefix}__${key}` : key;
|
|
177
|
+
|
|
178
|
+
if (typeof value === "object" && value !== null && !("_type" in value)) {
|
|
179
|
+
// 중첩 객체인 경우 - 재귀 처리
|
|
180
|
+
const nested = this.flattenSelect(value, fullKey);
|
|
181
|
+
Object.assign(flatSelect, nested);
|
|
182
|
+
} else {
|
|
183
|
+
// 일반 값인 경우 (컬럼 경로 또는 SqlExpression)
|
|
184
|
+
flatSelect[fullKey] = value;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
return flatSelect;
|
|
189
|
+
}
|
|
190
|
+
|
|
159
191
|
// SELECT (select는 overwrite, appendSelect는 append)
|
|
160
192
|
appendSelect<TSelect extends SelectObject<TTables>>(
|
|
161
193
|
selectObj: TSelect,
|
|
162
194
|
): Puri<TSchema, TTables, TResult & ParseSelectObject<TTables, TSelect>> {
|
|
163
|
-
|
|
195
|
+
// 중첩 객체를 flat하게 변환
|
|
196
|
+
const flatSelect = this.flattenSelect(selectObj);
|
|
197
|
+
|
|
198
|
+
const selectClauses: (string | Knex.Raw)[] = [];
|
|
199
|
+
|
|
200
|
+
for (const [alias, columnOrFunction] of Object.entries(flatSelect)) {
|
|
201
|
+
if (typeof columnOrFunction === "object" && columnOrFunction._type === "sql_expression") {
|
|
202
|
+
selectClauses.push(this.knex.raw(`${columnOrFunction._sql} as ${alias}`));
|
|
203
|
+
} else {
|
|
204
|
+
const columnPath = columnOrFunction as string;
|
|
205
|
+
if (alias === columnPath) {
|
|
206
|
+
selectClauses.push(columnPath);
|
|
207
|
+
} else {
|
|
208
|
+
selectClauses.push(`${columnPath} as ${alias}`);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
this.knexQuery.select(selectClauses);
|
|
214
|
+
return this as any;
|
|
164
215
|
}
|
|
165
216
|
|
|
166
217
|
// SELECT *
|
|
167
|
-
selectAll():
|
|
218
|
+
selectAll(): Puri<TSchema, TTables, SelectAllResult<TTables>> {
|
|
168
219
|
this.knexQuery.select("*");
|
|
169
220
|
return this as any;
|
|
170
221
|
}
|
|
@@ -243,46 +294,47 @@ export class Puri<TSchema, TTables extends Record<string, any>, TResult> {
|
|
|
243
294
|
tableSpec: { [K in TJoinAlias]: Puri<TSchema, any, TSubResult> },
|
|
244
295
|
left: AvailableColumns<TTables>,
|
|
245
296
|
right: `${TJoinAlias}.${ColumnKeys<TSubResult>}`,
|
|
246
|
-
): Puri<
|
|
247
|
-
TSchema,
|
|
248
|
-
TTables & Record<TJoinAlias, TSubResult>, // 서브쿼리의 TResult
|
|
249
|
-
TResult
|
|
250
|
-
>;
|
|
297
|
+
): Puri<TSchema, TTables & Record<TJoinAlias, TSubResult & LeftJoinedMarker>, TResult>; // 서브쿼리의 TResult
|
|
251
298
|
// LEFT JOIN: 테이블 + Alias
|
|
252
|
-
|
|
299
|
+
// FK nullable 여부에 따라 자동으로 LeftJoinedMarker 결정
|
|
300
|
+
leftJoin<
|
|
301
|
+
TJoinTable extends keyof TSchema,
|
|
302
|
+
TJoinAlias extends string,
|
|
303
|
+
TLeft extends AvailableColumns<TTables>,
|
|
304
|
+
>(
|
|
253
305
|
tableSpec: { [K in TJoinAlias]: TJoinTable },
|
|
254
|
-
left:
|
|
306
|
+
left: TLeft,
|
|
255
307
|
right: `${TJoinAlias}.${ColumnKeys<TSchema[TJoinTable]>}`,
|
|
256
308
|
): Puri<
|
|
257
309
|
TSchema,
|
|
258
|
-
TTables & Record<TJoinAlias, TSchema[TJoinTable]
|
|
310
|
+
TTables & Record<TJoinAlias, TSchema[TJoinTable] & LeftJoinMarkerFor<TTables, TLeft>>,
|
|
259
311
|
TResult
|
|
260
312
|
>;
|
|
261
313
|
// LEFT JOIN: 테이블명
|
|
262
|
-
leftJoin<TJoinTable extends keyof TSchema
|
|
314
|
+
leftJoin<TJoinTable extends keyof TSchema, TLeft extends AvailableColumns<TTables>>(
|
|
263
315
|
tableName: TJoinTable,
|
|
264
|
-
left:
|
|
316
|
+
left: TLeft,
|
|
265
317
|
right: `${TJoinTable & string}.${ColumnKeys<TSchema[TJoinTable]>}`,
|
|
266
318
|
): Puri<
|
|
267
319
|
TSchema,
|
|
268
|
-
TTables & Record<TJoinTable, TSchema[TJoinTable]
|
|
320
|
+
TTables & Record<TJoinTable, TSchema[TJoinTable] & LeftJoinMarkerFor<TTables, TLeft>>,
|
|
269
321
|
TResult
|
|
270
322
|
>;
|
|
271
323
|
// LEFT JOIN: 서브쿼리 + Alias + 콜백
|
|
272
324
|
leftJoin<TJoinAlias extends string, TSubResult>(
|
|
273
325
|
tableSpec: { [K in TJoinAlias]: Puri<TSchema, any, TSubResult> },
|
|
274
326
|
callback: (j: JoinClauseGroup<TTables, Record<TJoinAlias, TSubResult>>) => void,
|
|
275
|
-
): Puri<TSchema, TTables & Record<TJoinAlias, TSubResult>, TResult>;
|
|
327
|
+
): Puri<TSchema, TTables & Record<TJoinAlias, TSubResult & LeftJoinedMarker>, TResult>;
|
|
276
328
|
// LEFT JOIN: 테이블 + Alias + 콜백
|
|
277
329
|
leftJoin<TJoinTable extends keyof TSchema, TJoinAlias extends string>(
|
|
278
330
|
tableSpec: { [K in TJoinAlias]: TJoinTable },
|
|
279
331
|
callback: (j: JoinClauseGroup<TTables, Record<TJoinAlias, TSchema[TJoinTable]>>) => void,
|
|
280
|
-
): Puri<TSchema, TTables & Record<TJoinAlias, TSchema[TJoinTable]>, TResult>;
|
|
332
|
+
): Puri<TSchema, TTables & Record<TJoinAlias, TSchema[TJoinTable] & LeftJoinedMarker>, TResult>;
|
|
281
333
|
// LEFT JOIN: 테이블명 + 콜백
|
|
282
334
|
leftJoin<TJoinTable extends keyof TSchema>(
|
|
283
335
|
tableName: TJoinTable,
|
|
284
336
|
callback: (j: JoinClauseGroup<TTables, Record<TJoinTable, TSchema[TJoinTable]>>) => void,
|
|
285
|
-
): Puri<TSchema, TTables & Record<TJoinTable, TSchema[TJoinTable]>, TResult>;
|
|
337
|
+
): Puri<TSchema, TTables & Record<TJoinTable, TSchema[TJoinTable] & LeftJoinedMarker>, TResult>;
|
|
286
338
|
// LEFT JOIN 실제 구현
|
|
287
339
|
leftJoin(tableNameOrSpec: any, ...args: any[]): any {
|
|
288
340
|
return this.__commonJoin("leftJoin", tableNameOrSpec, ...args);
|
|
@@ -331,13 +383,13 @@ export class Puri<TSchema, TTables extends Record<string, any>, TResult> {
|
|
|
331
383
|
if (args.length === 1 && typeof args[0] === "function") {
|
|
332
384
|
// Callback
|
|
333
385
|
const callback = args[0];
|
|
334
|
-
this.knexQuery[joinType](spec.
|
|
386
|
+
this.knexQuery[joinType](spec.rawQuery().as(alias), (joinClause) => {
|
|
335
387
|
callback(new JoinClauseGroup(joinClause));
|
|
336
388
|
});
|
|
337
389
|
} else {
|
|
338
390
|
// Simple
|
|
339
391
|
const [left, right] = args;
|
|
340
|
-
this.knexQuery[joinType](spec.
|
|
392
|
+
this.knexQuery[joinType](spec.rawQuery().as(alias), left, right);
|
|
341
393
|
}
|
|
342
394
|
} else {
|
|
343
395
|
throw new Error("Invalid table specification");
|
|
@@ -351,17 +403,23 @@ export class Puri<TSchema, TTables extends Record<string, any>, TResult> {
|
|
|
351
403
|
|
|
352
404
|
// WHERE: 객체 - 사용: .where({ "u.id": 1, "u.status": "active" })
|
|
353
405
|
where(conditions: WhereCondition<TTables>): this;
|
|
354
|
-
// WHERE: 컬럼 - 사용: .where("u.id", 1)
|
|
406
|
+
// WHERE: 컬럼 - 사용: .where("u.id", 1), .where("u.id", null)
|
|
355
407
|
where<TColumn extends AvailableColumns<TTables>>(
|
|
356
408
|
column: TColumn,
|
|
357
409
|
value: ExtractColumnType<TTables, TColumn & string>,
|
|
358
410
|
): this;
|
|
359
|
-
// WHERE: 컬럼 - 사용: .where("u.id", ">", 10)
|
|
411
|
+
// WHERE: 컬럼 - 사용: .where("u.id", ">", 10), .where("u.id", "!=", null)
|
|
360
412
|
where<TColumn extends AvailableColumns<TTables>>(
|
|
361
413
|
column: TColumn,
|
|
362
414
|
operator: ComparisonOperator | "like" | "not like",
|
|
363
415
|
value: ExtractColumnType<TTables, TColumn & string>,
|
|
364
416
|
): this;
|
|
417
|
+
// WHERE: SQL 표현식 - 사용: .where(puri.raw("CONCAT(u.name, u.email)"), "like", "%test%")
|
|
418
|
+
where<TColumn extends Knex.Raw>(
|
|
419
|
+
column: TColumn,
|
|
420
|
+
operator: ComparisonOperator | "like" | "not like",
|
|
421
|
+
value: any,
|
|
422
|
+
): this;
|
|
365
423
|
// WHERE: 컬럼 - 사용: .where("u.id", "like", "%test%")
|
|
366
424
|
where(...args: [columnOrConditions: any, operatorOrValue?: any, value?: any]): this {
|
|
367
425
|
const [columnOrConditions, operatorOrValue, value] = args;
|
|
@@ -442,11 +500,17 @@ export class Puri<TSchema, TTables extends Record<string, any>, TResult> {
|
|
|
442
500
|
|
|
443
501
|
// 기본 쿼리 메서드들
|
|
444
502
|
limit(count: number): this {
|
|
503
|
+
if (count < 0) {
|
|
504
|
+
throw new Error("Invalid limit: must be >= 0");
|
|
505
|
+
}
|
|
445
506
|
this.knexQuery.limit(count);
|
|
446
507
|
return this;
|
|
447
508
|
}
|
|
448
509
|
|
|
449
510
|
offset(count: number): this {
|
|
511
|
+
if (count < 0) {
|
|
512
|
+
throw new Error("Invalid offset: must be >= 0");
|
|
513
|
+
}
|
|
450
514
|
this.knexQuery.offset(count);
|
|
451
515
|
return this;
|
|
452
516
|
}
|
|
@@ -534,7 +598,7 @@ export class Puri<TSchema, TTables extends Record<string, any>, TResult> {
|
|
|
534
598
|
}
|
|
535
599
|
|
|
536
600
|
// Increment
|
|
537
|
-
increment<TColumn extends
|
|
601
|
+
increment<TColumn extends NumericColumns<TTables>>(
|
|
538
602
|
column: TColumn,
|
|
539
603
|
value: number,
|
|
540
604
|
): ResolvedPuri<number, SingleTableValue<TTables>> {
|
|
@@ -545,7 +609,7 @@ export class Puri<TSchema, TTables extends Record<string, any>, TResult> {
|
|
|
545
609
|
return new ResolvedPuri(this.knexQuery, this.knex);
|
|
546
610
|
}
|
|
547
611
|
// Decrement
|
|
548
|
-
decrement<TColumn extends
|
|
612
|
+
decrement<TColumn extends NumericColumns<TTables>>(
|
|
549
613
|
column: TColumn,
|
|
550
614
|
value: number,
|
|
551
615
|
): ResolvedPuri<number, SingleTableValue<TTables>> {
|
|
@@ -688,8 +752,12 @@ export class Puri<TSchema, TTables extends Record<string, any>, TResult> {
|
|
|
688
752
|
return indentedLines.join("\n").trim();
|
|
689
753
|
}
|
|
690
754
|
|
|
755
|
+
raw(sql: string): Knex.Raw {
|
|
756
|
+
return this.knex.raw(sql);
|
|
757
|
+
}
|
|
758
|
+
|
|
691
759
|
// Knex 쿼리 빌더 직접 접근
|
|
692
|
-
|
|
760
|
+
rawQuery(): Knex.QueryBuilder {
|
|
693
761
|
return this.knexQuery;
|
|
694
762
|
}
|
|
695
763
|
}
|
|
@@ -705,7 +773,7 @@ export class WhereGroup<TTables extends Record<string, any>> {
|
|
|
705
773
|
): this;
|
|
706
774
|
where<TColumn extends AvailableColumns<TTables>>(
|
|
707
775
|
column: TColumn,
|
|
708
|
-
operator:
|
|
776
|
+
operator: WhereOperator,
|
|
709
777
|
value: ExtractColumnType<TTables, TColumn & string>,
|
|
710
778
|
): this;
|
|
711
779
|
where(...args: any[]): WhereGroup<TTables> {
|
|
@@ -721,7 +789,7 @@ export class WhereGroup<TTables extends Record<string, any>> {
|
|
|
721
789
|
): this;
|
|
722
790
|
orWhere<TColumn extends AvailableColumns<TTables>>(
|
|
723
791
|
column: TColumn,
|
|
724
|
-
operator:
|
|
792
|
+
operator: WhereOperator,
|
|
725
793
|
value: ExtractColumnType<TTables, TColumn & string>,
|
|
726
794
|
): this;
|
|
727
795
|
orWhere(...args: any[]): WhereGroup<TTables> {
|
|
@@ -748,6 +816,7 @@ export class WhereGroup<TTables extends Record<string, any>> {
|
|
|
748
816
|
}
|
|
749
817
|
}
|
|
750
818
|
|
|
819
|
+
// JOIN 절 그룹에는 Left와 Right에 대한 순서가 필요하지 않으므로, 모든 경우의 수를 계산해야함.
|
|
751
820
|
export class JoinClauseGroup<
|
|
752
821
|
TLeft extends Record<string, any>,
|
|
753
822
|
TRight extends Record<string, any>,
|
|
@@ -756,14 +825,41 @@ export class JoinClauseGroup<
|
|
|
756
825
|
|
|
757
826
|
// ON(AND): 컬럼 = 컬럼
|
|
758
827
|
on(left: AvailableColumns<TLeft>, right: AvailableColumns<TRight>): this;
|
|
828
|
+
on(left: AvailableColumns<TRight>, right: AvailableColumns<TLeft>): this;
|
|
829
|
+
// ON(AND): 컬럼 = 값
|
|
830
|
+
on(
|
|
831
|
+
left: AvailableColumns<TLeft>,
|
|
832
|
+
right: ExtractColumnType<TLeft, AvailableColumns<TLeft> & string>,
|
|
833
|
+
): this;
|
|
834
|
+
on(
|
|
835
|
+
left: AvailableColumns<TRight>,
|
|
836
|
+
right: ExtractColumnType<TRight, AvailableColumns<TRight> & string>,
|
|
837
|
+
): this;
|
|
759
838
|
// ON(AND): 컬럼 (연산자) 컬럼
|
|
760
839
|
on(
|
|
761
840
|
left: AvailableColumns<TLeft>,
|
|
762
841
|
operator: ComparisonOperator,
|
|
763
842
|
right: AvailableColumns<TRight>,
|
|
764
843
|
): this;
|
|
844
|
+
on(
|
|
845
|
+
left: AvailableColumns<TRight>,
|
|
846
|
+
operator: ComparisonOperator,
|
|
847
|
+
right: AvailableColumns<TLeft>,
|
|
848
|
+
): this;
|
|
849
|
+
// ON(AND): 컬럼 (연산자) 값
|
|
850
|
+
on(
|
|
851
|
+
left: AvailableColumns<TLeft>,
|
|
852
|
+
operator: ComparisonOperator,
|
|
853
|
+
right: ExtractColumnType<TLeft, AvailableColumns<TLeft> & string>,
|
|
854
|
+
): this;
|
|
855
|
+
on(
|
|
856
|
+
left: AvailableColumns<TRight>,
|
|
857
|
+
operator: ComparisonOperator,
|
|
858
|
+
right: ExtractColumnType<TRight, AvailableColumns<TRight> & string>,
|
|
859
|
+
): this;
|
|
765
860
|
// ON(AND): 콜백
|
|
766
861
|
on(callback: (nested: JoinClauseGroup<TLeft, TRight>) => void): this;
|
|
862
|
+
on(callback: (nested: JoinClauseGroup<TRight, TLeft>) => void): this;
|
|
767
863
|
// ON(AND) 구현
|
|
768
864
|
on(...args: any[]): this {
|
|
769
865
|
this.callback.on(...(args as [string, string]));
|
|
@@ -772,14 +868,41 @@ export class JoinClauseGroup<
|
|
|
772
868
|
|
|
773
869
|
// ON(OR): 컬럼 = 컬럼
|
|
774
870
|
orOn(left: AvailableColumns<TLeft>, right: AvailableColumns<TRight>): this;
|
|
871
|
+
orOn(left: AvailableColumns<TRight>, right: AvailableColumns<TLeft>): this;
|
|
872
|
+
// ON(OR): 컬럼 = 값
|
|
873
|
+
orOn(
|
|
874
|
+
left: AvailableColumns<TLeft>,
|
|
875
|
+
right: ExtractColumnType<TLeft, AvailableColumns<TLeft> & string>,
|
|
876
|
+
): this;
|
|
877
|
+
orOn(
|
|
878
|
+
left: AvailableColumns<TRight>,
|
|
879
|
+
right: ExtractColumnType<TRight, AvailableColumns<TRight> & string>,
|
|
880
|
+
): this;
|
|
775
881
|
// ON(OR): 컬럼 (연산자) 컬럼
|
|
776
882
|
orOn(
|
|
777
883
|
left: AvailableColumns<TLeft>,
|
|
778
884
|
operator: ComparisonOperator,
|
|
779
885
|
right: AvailableColumns<TRight>,
|
|
780
886
|
): this;
|
|
887
|
+
orOn(
|
|
888
|
+
left: AvailableColumns<TRight>,
|
|
889
|
+
operator: ComparisonOperator,
|
|
890
|
+
right: AvailableColumns<TLeft>,
|
|
891
|
+
): this;
|
|
892
|
+
// ON(OR): 컬럼 (연산자) 값
|
|
893
|
+
orOn(
|
|
894
|
+
left: AvailableColumns<TLeft>,
|
|
895
|
+
operator: ComparisonOperator,
|
|
896
|
+
right: ExtractColumnType<TLeft, AvailableColumns<TLeft> & string>,
|
|
897
|
+
): this;
|
|
898
|
+
orOn(
|
|
899
|
+
left: AvailableColumns<TRight>,
|
|
900
|
+
operator: ComparisonOperator,
|
|
901
|
+
right: ExtractColumnType<TRight, AvailableColumns<TRight> & string>,
|
|
902
|
+
): this;
|
|
781
903
|
// ON(OR): 콜백
|
|
782
904
|
orOn(callback: (nested: JoinClauseGroup<TLeft, TRight>) => void): this;
|
|
905
|
+
orOn(callback: (nested: JoinClauseGroup<TRight, TLeft>) => void): this;
|
|
783
906
|
// ON(OR) 구현
|
|
784
907
|
orOn(...args: any[]): this {
|
|
785
908
|
this.callback.orOn(...(args as [string, string]));
|