linkgress-orm 0.2.11 → 0.2.12
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/entity/db-context.d.ts +117 -0
- package/dist/entity/db-context.d.ts.map +1 -1
- package/dist/entity/db-context.js +48 -0
- package/dist/entity/db-context.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +16 -3
- package/dist/index.js.map +1 -1
- package/dist/query/future-query.d.ts +183 -0
- package/dist/query/future-query.d.ts.map +1 -0
- package/dist/query/future-query.js +251 -0
- package/dist/query/future-query.js.map +1 -0
- package/dist/query/query-builder.d.ts +96 -1
- package/dist/query/query-builder.d.ts.map +1 -1
- package/dist/query/query-builder.js +404 -0
- package/dist/query/query-builder.js.map +1 -1
- package/dist/query/union-builder.d.ts +169 -0
- package/dist/query/union-builder.d.ts.map +1 -0
- package/dist/query/union-builder.js +244 -0
- package/dist/query/union-builder.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { SqlBuildContext } from './conditions';
|
|
2
|
+
import type { QueryExecutor, OrderDirection } from '../entity/db-context';
|
|
3
|
+
import type { DatabaseClient } from '../database/database-client.interface';
|
|
4
|
+
/**
|
|
5
|
+
* Union type: UNION removes duplicates, UNION ALL keeps all rows
|
|
6
|
+
*/
|
|
7
|
+
export type UnionType = 'UNION' | 'UNION ALL';
|
|
8
|
+
/**
|
|
9
|
+
* Builder for UNION and UNION ALL queries.
|
|
10
|
+
* Combines multiple SELECT queries into a single result set.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* // Basic UNION (removes duplicates)
|
|
15
|
+
* const result = await db.users
|
|
16
|
+
* .select(u => ({ id: u.id, name: u.name }))
|
|
17
|
+
* .union(
|
|
18
|
+
* db.customers.select(c => ({ id: c.id, name: c.name }))
|
|
19
|
+
* )
|
|
20
|
+
* .toList();
|
|
21
|
+
*
|
|
22
|
+
* // UNION ALL (keeps duplicates)
|
|
23
|
+
* const allRows = await db.activeUsers
|
|
24
|
+
* .select(u => ({ id: u.id }))
|
|
25
|
+
* .unionAll(
|
|
26
|
+
* db.inactiveUsers.select(u => ({ id: u.id }))
|
|
27
|
+
* )
|
|
28
|
+
* .toList();
|
|
29
|
+
*
|
|
30
|
+
* // Multiple unions with ordering
|
|
31
|
+
* const sorted = await db.users
|
|
32
|
+
* .select(u => ({ id: u.id, name: u.name }))
|
|
33
|
+
* .union(db.customers.select(c => ({ id: c.id, name: c.name })))
|
|
34
|
+
* .unionAll(db.vendors.select(v => ({ id: v.id, name: v.name })))
|
|
35
|
+
* .orderBy(r => r.name)
|
|
36
|
+
* .limit(100)
|
|
37
|
+
* .toList();
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export declare class UnionQueryBuilder<TSelection> {
|
|
41
|
+
private components;
|
|
42
|
+
private orderByFields;
|
|
43
|
+
private limitValue?;
|
|
44
|
+
private offsetValue?;
|
|
45
|
+
private client;
|
|
46
|
+
private executor?;
|
|
47
|
+
/**
|
|
48
|
+
* Internal constructor - use SelectQueryBuilder.union() or unionAll() to create instances
|
|
49
|
+
*/
|
|
50
|
+
constructor(firstQuery: {
|
|
51
|
+
buildUnionSql: (context: SqlBuildContext) => string;
|
|
52
|
+
}, client: DatabaseClient, executor?: QueryExecutor);
|
|
53
|
+
/**
|
|
54
|
+
* Add a query with UNION (removes duplicate rows)
|
|
55
|
+
*
|
|
56
|
+
* @param query The query to union with the current result
|
|
57
|
+
* @returns A new UnionQueryBuilder with the added query
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```typescript
|
|
61
|
+
* const users = await db.activeUsers
|
|
62
|
+
* .select(u => ({ id: u.id, email: u.email }))
|
|
63
|
+
* .union(db.pendingUsers.select(u => ({ id: u.id, email: u.email })))
|
|
64
|
+
* .toList();
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
union(query: {
|
|
68
|
+
buildUnionSql: (context: SqlBuildContext) => string;
|
|
69
|
+
}): UnionQueryBuilder<TSelection>;
|
|
70
|
+
/**
|
|
71
|
+
* Add a query with UNION ALL (keeps all rows including duplicates)
|
|
72
|
+
*
|
|
73
|
+
* @param query The query to union with the current result
|
|
74
|
+
* @returns A new UnionQueryBuilder with the added query
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```typescript
|
|
78
|
+
* // UNION ALL is faster than UNION as it doesn't need to remove duplicates
|
|
79
|
+
* const allLogs = await db.errorLogs
|
|
80
|
+
* .select(l => ({ timestamp: l.createdAt, message: l.message }))
|
|
81
|
+
* .unionAll(db.infoLogs.select(l => ({ timestamp: l.createdAt, message: l.message })))
|
|
82
|
+
* .orderBy(r => r.timestamp)
|
|
83
|
+
* .toList();
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
|
+
unionAll(query: {
|
|
87
|
+
buildUnionSql: (context: SqlBuildContext) => string;
|
|
88
|
+
}): UnionQueryBuilder<TSelection>;
|
|
89
|
+
/**
|
|
90
|
+
* Order the combined result set
|
|
91
|
+
*
|
|
92
|
+
* @param selector Function that selects the field(s) to order by
|
|
93
|
+
* @returns This builder for chaining
|
|
94
|
+
*
|
|
95
|
+
* @example
|
|
96
|
+
* ```typescript
|
|
97
|
+
* // Single field
|
|
98
|
+
* .orderBy(r => r.name)
|
|
99
|
+
*
|
|
100
|
+
* // Multiple fields
|
|
101
|
+
* .orderBy(r => [r.lastName, r.firstName])
|
|
102
|
+
*
|
|
103
|
+
* // With direction
|
|
104
|
+
* .orderBy(r => [[r.createdAt, 'DESC'], [r.name, 'ASC']])
|
|
105
|
+
* ```
|
|
106
|
+
*/
|
|
107
|
+
orderBy<T>(selector: (row: TSelection) => T): this;
|
|
108
|
+
orderBy<T>(selector: (row: TSelection) => T[]): this;
|
|
109
|
+
orderBy<T>(selector: (row: TSelection) => Array<[T, OrderDirection]>): this;
|
|
110
|
+
/**
|
|
111
|
+
* Limit the number of results
|
|
112
|
+
*
|
|
113
|
+
* @param count Maximum number of rows to return
|
|
114
|
+
* @returns This builder for chaining
|
|
115
|
+
*/
|
|
116
|
+
limit(count: number): this;
|
|
117
|
+
/**
|
|
118
|
+
* Skip a number of results
|
|
119
|
+
*
|
|
120
|
+
* @param count Number of rows to skip
|
|
121
|
+
* @returns This builder for chaining
|
|
122
|
+
*/
|
|
123
|
+
offset(count: number): this;
|
|
124
|
+
/**
|
|
125
|
+
* Execute the union query and return results
|
|
126
|
+
*
|
|
127
|
+
* @returns Promise resolving to array of results
|
|
128
|
+
*/
|
|
129
|
+
toList(): Promise<TSelection[]>;
|
|
130
|
+
/**
|
|
131
|
+
* Get the first result or null if no results
|
|
132
|
+
*
|
|
133
|
+
* @returns Promise resolving to first result or null
|
|
134
|
+
*/
|
|
135
|
+
firstOrDefault(): Promise<TSelection | null>;
|
|
136
|
+
/**
|
|
137
|
+
* Count the total number of results
|
|
138
|
+
*
|
|
139
|
+
* @returns Promise resolving to the count
|
|
140
|
+
*/
|
|
141
|
+
count(): Promise<number>;
|
|
142
|
+
/**
|
|
143
|
+
* Build the SQL for this union query
|
|
144
|
+
* @internal
|
|
145
|
+
*/
|
|
146
|
+
buildSql(): {
|
|
147
|
+
sql: string;
|
|
148
|
+
params: any[];
|
|
149
|
+
};
|
|
150
|
+
/**
|
|
151
|
+
* Get the SQL string for debugging
|
|
152
|
+
*
|
|
153
|
+
* @returns The SQL that would be executed
|
|
154
|
+
*/
|
|
155
|
+
toSql(): string;
|
|
156
|
+
/**
|
|
157
|
+
* Create a mock row for orderBy selector
|
|
158
|
+
*/
|
|
159
|
+
private createMockRow;
|
|
160
|
+
/**
|
|
161
|
+
* Clone this builder
|
|
162
|
+
*/
|
|
163
|
+
private clone;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Check if a value is a UnionQueryBuilder
|
|
167
|
+
*/
|
|
168
|
+
export declare function isUnionQueryBuilder(value: any): value is UnionQueryBuilder<any>;
|
|
169
|
+
//# sourceMappingURL=union-builder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"union-builder.d.ts","sourceRoot":"","sources":["../../src/query/union-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,eAAe,EAA6B,MAAM,cAAc,CAAC;AAC5F,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAE1E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AAG5E;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,OAAO,GAAG,WAAW,CAAC;AAY9C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,qBAAa,iBAAiB,CAAC,UAAU;IACvC,OAAO,CAAC,UAAU,CAAwB;IAC1C,OAAO,CAAC,aAAa,CAA2D;IAChF,OAAO,CAAC,UAAU,CAAC,CAAS;IAC5B,OAAO,CAAC,WAAW,CAAC,CAAS;IAC7B,OAAO,CAAC,MAAM,CAAiB;IAC/B,OAAO,CAAC,QAAQ,CAAC,CAAgB;IAEjC;;OAEG;gBAED,UAAU,EAAE;QAAE,aAAa,EAAE,CAAC,OAAO,EAAE,eAAe,KAAK,MAAM,CAAA;KAAE,EACnE,MAAM,EAAE,cAAc,EACtB,QAAQ,CAAC,EAAE,aAAa;IAS1B;;;;;;;;;;;;;OAaG;IACH,KAAK,CAAC,KAAK,EAAE;QAAE,aAAa,EAAE,CAAC,OAAO,EAAE,eAAe,KAAK,MAAM,CAAA;KAAE,GAAG,iBAAiB,CAAC,UAAU,CAAC;IASpG;;;;;;;;;;;;;;;OAeG;IACH,QAAQ,CAAC,KAAK,EAAE;QAAE,aAAa,EAAE,CAAC,OAAO,EAAE,eAAe,KAAK,MAAM,CAAA;KAAE,GAAG,iBAAiB,CAAC,UAAU,CAAC;IASvG;;;;;;;;;;;;;;;;;OAiBG;IACH,OAAO,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,GAAG,EAAE,UAAU,KAAK,CAAC,GAAG,IAAI;IAClD,OAAO,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,GAAG,EAAE,UAAU,KAAK,CAAC,EAAE,GAAG,IAAI;IACpD,OAAO,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,GAAG,EAAE,UAAU,KAAK,KAAK,CAAC,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC,GAAG,IAAI;IAa3E;;;;;OAKG;IACH,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAK1B;;;;;OAKG;IACH,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAK3B;;;;OAIG;IACG,MAAM,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;IAUrC;;;;OAIG;IACG,cAAc,IAAI,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC;IAUlD;;;;OAIG;IACG,KAAK,IAAI,OAAO,CAAC,MAAM,CAAC;IAY9B;;;OAGG;IACH,QAAQ,IAAI;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,GAAG,EAAE,CAAA;KAAE;IAyC1C;;;;OAIG;IACH,KAAK,IAAI,MAAM;IAIf;;OAEG;IACH,OAAO,CAAC,aAAa;IAcrB;;OAEG;IACH,OAAO,CAAC,KAAK;CAUd;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI,iBAAiB,CAAC,GAAG,CAAC,CAE/E"}
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UnionQueryBuilder = void 0;
|
|
4
|
+
exports.isUnionQueryBuilder = isUnionQueryBuilder;
|
|
5
|
+
const query_utils_1 = require("./query-utils");
|
|
6
|
+
/**
|
|
7
|
+
* Builder for UNION and UNION ALL queries.
|
|
8
|
+
* Combines multiple SELECT queries into a single result set.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* // Basic UNION (removes duplicates)
|
|
13
|
+
* const result = await db.users
|
|
14
|
+
* .select(u => ({ id: u.id, name: u.name }))
|
|
15
|
+
* .union(
|
|
16
|
+
* db.customers.select(c => ({ id: c.id, name: c.name }))
|
|
17
|
+
* )
|
|
18
|
+
* .toList();
|
|
19
|
+
*
|
|
20
|
+
* // UNION ALL (keeps duplicates)
|
|
21
|
+
* const allRows = await db.activeUsers
|
|
22
|
+
* .select(u => ({ id: u.id }))
|
|
23
|
+
* .unionAll(
|
|
24
|
+
* db.inactiveUsers.select(u => ({ id: u.id }))
|
|
25
|
+
* )
|
|
26
|
+
* .toList();
|
|
27
|
+
*
|
|
28
|
+
* // Multiple unions with ordering
|
|
29
|
+
* const sorted = await db.users
|
|
30
|
+
* .select(u => ({ id: u.id, name: u.name }))
|
|
31
|
+
* .union(db.customers.select(c => ({ id: c.id, name: c.name })))
|
|
32
|
+
* .unionAll(db.vendors.select(v => ({ id: v.id, name: v.name })))
|
|
33
|
+
* .orderBy(r => r.name)
|
|
34
|
+
* .limit(100)
|
|
35
|
+
* .toList();
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
class UnionQueryBuilder {
|
|
39
|
+
/**
|
|
40
|
+
* Internal constructor - use SelectQueryBuilder.union() or unionAll() to create instances
|
|
41
|
+
*/
|
|
42
|
+
constructor(firstQuery, client, executor) {
|
|
43
|
+
this.components = [];
|
|
44
|
+
this.orderByFields = [];
|
|
45
|
+
this.client = client;
|
|
46
|
+
this.executor = executor;
|
|
47
|
+
this.components.push({
|
|
48
|
+
buildSql: (ctx) => firstQuery.buildUnionSql(ctx),
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Add a query with UNION (removes duplicate rows)
|
|
53
|
+
*
|
|
54
|
+
* @param query The query to union with the current result
|
|
55
|
+
* @returns A new UnionQueryBuilder with the added query
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```typescript
|
|
59
|
+
* const users = await db.activeUsers
|
|
60
|
+
* .select(u => ({ id: u.id, email: u.email }))
|
|
61
|
+
* .union(db.pendingUsers.select(u => ({ id: u.id, email: u.email })))
|
|
62
|
+
* .toList();
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
union(query) {
|
|
66
|
+
const newBuilder = this.clone();
|
|
67
|
+
newBuilder.components.push({
|
|
68
|
+
buildSql: (ctx) => query.buildUnionSql(ctx),
|
|
69
|
+
unionType: 'UNION',
|
|
70
|
+
});
|
|
71
|
+
return newBuilder;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Add a query with UNION ALL (keeps all rows including duplicates)
|
|
75
|
+
*
|
|
76
|
+
* @param query The query to union with the current result
|
|
77
|
+
* @returns A new UnionQueryBuilder with the added query
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* ```typescript
|
|
81
|
+
* // UNION ALL is faster than UNION as it doesn't need to remove duplicates
|
|
82
|
+
* const allLogs = await db.errorLogs
|
|
83
|
+
* .select(l => ({ timestamp: l.createdAt, message: l.message }))
|
|
84
|
+
* .unionAll(db.infoLogs.select(l => ({ timestamp: l.createdAt, message: l.message })))
|
|
85
|
+
* .orderBy(r => r.timestamp)
|
|
86
|
+
* .toList();
|
|
87
|
+
* ```
|
|
88
|
+
*/
|
|
89
|
+
unionAll(query) {
|
|
90
|
+
const newBuilder = this.clone();
|
|
91
|
+
newBuilder.components.push({
|
|
92
|
+
buildSql: (ctx) => query.buildUnionSql(ctx),
|
|
93
|
+
unionType: 'UNION ALL',
|
|
94
|
+
});
|
|
95
|
+
return newBuilder;
|
|
96
|
+
}
|
|
97
|
+
orderBy(selector) {
|
|
98
|
+
// Create a mock row with field refs for the selection
|
|
99
|
+
const mockRow = this.createMockRow();
|
|
100
|
+
const result = selector(mockRow);
|
|
101
|
+
// Clear previous orderBy
|
|
102
|
+
this.orderByFields = [];
|
|
103
|
+
(0, query_utils_1.parseOrderBy)(result, this.orderByFields);
|
|
104
|
+
return this;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Limit the number of results
|
|
108
|
+
*
|
|
109
|
+
* @param count Maximum number of rows to return
|
|
110
|
+
* @returns This builder for chaining
|
|
111
|
+
*/
|
|
112
|
+
limit(count) {
|
|
113
|
+
this.limitValue = count;
|
|
114
|
+
return this;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Skip a number of results
|
|
118
|
+
*
|
|
119
|
+
* @param count Number of rows to skip
|
|
120
|
+
* @returns This builder for chaining
|
|
121
|
+
*/
|
|
122
|
+
offset(count) {
|
|
123
|
+
this.offsetValue = count;
|
|
124
|
+
return this;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Execute the union query and return results
|
|
128
|
+
*
|
|
129
|
+
* @returns Promise resolving to array of results
|
|
130
|
+
*/
|
|
131
|
+
async toList() {
|
|
132
|
+
const { sql, params } = this.buildSql();
|
|
133
|
+
const result = this.executor
|
|
134
|
+
? await this.executor.query(sql, params)
|
|
135
|
+
: await this.client.query(sql, params);
|
|
136
|
+
return result.rows;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Get the first result or null if no results
|
|
140
|
+
*
|
|
141
|
+
* @returns Promise resolving to first result or null
|
|
142
|
+
*/
|
|
143
|
+
async firstOrDefault() {
|
|
144
|
+
const originalLimit = this.limitValue;
|
|
145
|
+
this.limitValue = 1;
|
|
146
|
+
const results = await this.toList();
|
|
147
|
+
this.limitValue = originalLimit;
|
|
148
|
+
return results.length > 0 ? results[0] : null;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Count the total number of results
|
|
152
|
+
*
|
|
153
|
+
* @returns Promise resolving to the count
|
|
154
|
+
*/
|
|
155
|
+
async count() {
|
|
156
|
+
const { sql: innerSql, params } = this.buildSql();
|
|
157
|
+
const sql = `SELECT COUNT(*) as count FROM (${innerSql}) as union_count`;
|
|
158
|
+
const result = this.executor
|
|
159
|
+
? await this.executor.query(sql, params)
|
|
160
|
+
: await this.client.query(sql, params);
|
|
161
|
+
return parseInt(result.rows[0]?.count || '0', 10);
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Build the SQL for this union query
|
|
165
|
+
* @internal
|
|
166
|
+
*/
|
|
167
|
+
buildSql() {
|
|
168
|
+
const context = {
|
|
169
|
+
paramCounter: 1,
|
|
170
|
+
params: [],
|
|
171
|
+
};
|
|
172
|
+
const sqlParts = [];
|
|
173
|
+
for (let i = 0; i < this.components.length; i++) {
|
|
174
|
+
const component = this.components[i];
|
|
175
|
+
if (i > 0 && component.unionType) {
|
|
176
|
+
sqlParts.push(component.unionType);
|
|
177
|
+
}
|
|
178
|
+
// Each component query should be wrapped in parentheses
|
|
179
|
+
const componentSql = component.buildSql(context);
|
|
180
|
+
sqlParts.push(`(${componentSql})`);
|
|
181
|
+
}
|
|
182
|
+
let sql = sqlParts.join('\n');
|
|
183
|
+
// Add ORDER BY (applies to the entire union result)
|
|
184
|
+
if (this.orderByFields.length > 0) {
|
|
185
|
+
const orderParts = this.orderByFields.map(({ field, direction }) => `"${field}" ${direction}`);
|
|
186
|
+
sql += `\nORDER BY ${orderParts.join(', ')}`;
|
|
187
|
+
}
|
|
188
|
+
// Add LIMIT
|
|
189
|
+
if (this.limitValue !== undefined) {
|
|
190
|
+
sql += `\nLIMIT ${this.limitValue}`;
|
|
191
|
+
}
|
|
192
|
+
// Add OFFSET
|
|
193
|
+
if (this.offsetValue !== undefined) {
|
|
194
|
+
sql += `\nOFFSET ${this.offsetValue}`;
|
|
195
|
+
}
|
|
196
|
+
return { sql, params: context.params };
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Get the SQL string for debugging
|
|
200
|
+
*
|
|
201
|
+
* @returns The SQL that would be executed
|
|
202
|
+
*/
|
|
203
|
+
toSql() {
|
|
204
|
+
return this.buildSql().sql;
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Create a mock row for orderBy selector
|
|
208
|
+
*/
|
|
209
|
+
createMockRow() {
|
|
210
|
+
// Create a proxy that returns FieldRef objects for any property access
|
|
211
|
+
return new Proxy({}, {
|
|
212
|
+
get: (_target, prop) => {
|
|
213
|
+
if (typeof prop === 'symbol')
|
|
214
|
+
return undefined;
|
|
215
|
+
return {
|
|
216
|
+
__fieldName: prop,
|
|
217
|
+
__dbColumnName: prop,
|
|
218
|
+
};
|
|
219
|
+
},
|
|
220
|
+
has: () => true,
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Clone this builder
|
|
225
|
+
*/
|
|
226
|
+
clone() {
|
|
227
|
+
const cloned = Object.create(UnionQueryBuilder.prototype);
|
|
228
|
+
cloned.components = [...this.components];
|
|
229
|
+
cloned.orderByFields = [...this.orderByFields];
|
|
230
|
+
cloned.limitValue = this.limitValue;
|
|
231
|
+
cloned.offsetValue = this.offsetValue;
|
|
232
|
+
cloned.client = this.client;
|
|
233
|
+
cloned.executor = this.executor;
|
|
234
|
+
return cloned;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
exports.UnionQueryBuilder = UnionQueryBuilder;
|
|
238
|
+
/**
|
|
239
|
+
* Check if a value is a UnionQueryBuilder
|
|
240
|
+
*/
|
|
241
|
+
function isUnionQueryBuilder(value) {
|
|
242
|
+
return value instanceof UnionQueryBuilder;
|
|
243
|
+
}
|
|
244
|
+
//# sourceMappingURL=union-builder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"union-builder.js","sourceRoot":"","sources":["../../src/query/union-builder.ts"],"names":[],"mappings":";;;AA2TA,kDAEC;AA3TD,+CAA6C;AAmB7C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAa,iBAAiB;IAQ5B;;OAEG;IACH,YACE,UAAmE,EACnE,MAAsB,EACtB,QAAwB;QAblB,eAAU,GAAqB,EAAE,CAAC;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