@tinqerjs/better-sqlite3-adapter 0.0.21

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.
Files changed (109) hide show
  1. package/dist/expression-generator.d.ts +18 -0
  2. package/dist/expression-generator.d.ts.map +1 -0
  3. package/dist/expression-generator.js +756 -0
  4. package/dist/expression-generator.js.map +1 -0
  5. package/dist/generators/all.d.ts +11 -0
  6. package/dist/generators/all.d.ts.map +1 -0
  7. package/dist/generators/all.js +15 -0
  8. package/dist/generators/all.js.map +1 -0
  9. package/dist/generators/any.d.ts +11 -0
  10. package/dist/generators/any.d.ts.map +1 -0
  11. package/dist/generators/any.js +20 -0
  12. package/dist/generators/any.js.map +1 -0
  13. package/dist/generators/average.d.ts +10 -0
  14. package/dist/generators/average.d.ts.map +1 -0
  15. package/dist/generators/average.js +15 -0
  16. package/dist/generators/average.js.map +1 -0
  17. package/dist/generators/count.d.ts +10 -0
  18. package/dist/generators/count.d.ts.map +1 -0
  19. package/dist/generators/count.js +11 -0
  20. package/dist/generators/count.js.map +1 -0
  21. package/dist/generators/delete.d.ts +10 -0
  22. package/dist/generators/delete.d.ts.map +1 -0
  23. package/dist/generators/delete.js +24 -0
  24. package/dist/generators/delete.js.map +1 -0
  25. package/dist/generators/distinct.d.ts +11 -0
  26. package/dist/generators/distinct.d.ts.map +1 -0
  27. package/dist/generators/distinct.js +12 -0
  28. package/dist/generators/distinct.js.map +1 -0
  29. package/dist/generators/first.d.ts +12 -0
  30. package/dist/generators/first.d.ts.map +1 -0
  31. package/dist/generators/first.js +13 -0
  32. package/dist/generators/first.js.map +1 -0
  33. package/dist/generators/from.d.ts +10 -0
  34. package/dist/generators/from.d.ts.map +1 -0
  35. package/dist/generators/from.js +41 -0
  36. package/dist/generators/from.js.map +1 -0
  37. package/dist/generators/groupby.d.ts +10 -0
  38. package/dist/generators/groupby.d.ts.map +1 -0
  39. package/dist/generators/groupby.js +36 -0
  40. package/dist/generators/groupby.js.map +1 -0
  41. package/dist/generators/insert.d.ts +11 -0
  42. package/dist/generators/insert.d.ts.map +1 -0
  43. package/dist/generators/insert.js +61 -0
  44. package/dist/generators/insert.js.map +1 -0
  45. package/dist/generators/join.d.ts +10 -0
  46. package/dist/generators/join.d.ts.map +1 -0
  47. package/dist/generators/join.js +246 -0
  48. package/dist/generators/join.js.map +1 -0
  49. package/dist/generators/last.d.ts +13 -0
  50. package/dist/generators/last.d.ts.map +1 -0
  51. package/dist/generators/last.js +16 -0
  52. package/dist/generators/last.js.map +1 -0
  53. package/dist/generators/max.d.ts +10 -0
  54. package/dist/generators/max.d.ts.map +1 -0
  55. package/dist/generators/max.js +15 -0
  56. package/dist/generators/max.js.map +1 -0
  57. package/dist/generators/min.d.ts +10 -0
  58. package/dist/generators/min.d.ts.map +1 -0
  59. package/dist/generators/min.js +15 -0
  60. package/dist/generators/min.js.map +1 -0
  61. package/dist/generators/orderby.d.ts +10 -0
  62. package/dist/generators/orderby.d.ts.map +1 -0
  63. package/dist/generators/orderby.js +66 -0
  64. package/dist/generators/orderby.js.map +1 -0
  65. package/dist/generators/select.d.ts +10 -0
  66. package/dist/generators/select.d.ts.map +1 -0
  67. package/dist/generators/select.js +34 -0
  68. package/dist/generators/select.js.map +1 -0
  69. package/dist/generators/single.d.ts +12 -0
  70. package/dist/generators/single.d.ts.map +1 -0
  71. package/dist/generators/single.js +13 -0
  72. package/dist/generators/single.js.map +1 -0
  73. package/dist/generators/skip.d.ts +10 -0
  74. package/dist/generators/skip.d.ts.map +1 -0
  75. package/dist/generators/skip.js +18 -0
  76. package/dist/generators/skip.js.map +1 -0
  77. package/dist/generators/sum.d.ts +10 -0
  78. package/dist/generators/sum.d.ts.map +1 -0
  79. package/dist/generators/sum.js +15 -0
  80. package/dist/generators/sum.js.map +1 -0
  81. package/dist/generators/take.d.ts +10 -0
  82. package/dist/generators/take.d.ts.map +1 -0
  83. package/dist/generators/take.js +18 -0
  84. package/dist/generators/take.js.map +1 -0
  85. package/dist/generators/thenby.d.ts +11 -0
  86. package/dist/generators/thenby.d.ts.map +1 -0
  87. package/dist/generators/thenby.js +58 -0
  88. package/dist/generators/thenby.js.map +1 -0
  89. package/dist/generators/update.d.ts +11 -0
  90. package/dist/generators/update.d.ts.map +1 -0
  91. package/dist/generators/update.js +69 -0
  92. package/dist/generators/update.js.map +1 -0
  93. package/dist/generators/where.d.ts +10 -0
  94. package/dist/generators/where.d.ts.map +1 -0
  95. package/dist/generators/where.js +12 -0
  96. package/dist/generators/where.js.map +1 -0
  97. package/dist/index.d.ts +172 -0
  98. package/dist/index.d.ts.map +1 -0
  99. package/dist/index.js +234 -0
  100. package/dist/index.js.map +1 -0
  101. package/dist/sql-generator.d.ts +9 -0
  102. package/dist/sql-generator.d.ts.map +1 -0
  103. package/dist/sql-generator.js +325 -0
  104. package/dist/sql-generator.js.map +1 -0
  105. package/dist/types.d.ts +62 -0
  106. package/dist/types.d.ts.map +1 -0
  107. package/dist/types.js +5 -0
  108. package/dist/types.js.map +1 -0
  109. package/package.json +44 -0
@@ -0,0 +1,246 @@
1
+ /**
2
+ * JOIN operation generator
3
+ */
4
+ import { generateSql } from "../sql-generator.js";
5
+ /**
6
+ * Build symbol table from ResultShape (new approach with full fidelity)
7
+ */
8
+ function buildSymbolTableFromShape(resultShape, outerAlias, innerAlias, context) {
9
+ if (!resultShape) {
10
+ return;
11
+ }
12
+ // Initialize symbol table if not exists
13
+ if (!context.symbolTable) {
14
+ context.symbolTable = {
15
+ entries: new Map(),
16
+ };
17
+ }
18
+ // Process each property in the result shape
19
+ for (const [propName, shapeNode] of resultShape.properties) {
20
+ processShapeNode(propName, shapeNode, outerAlias, innerAlias, context.symbolTable, "");
21
+ }
22
+ }
23
+ /**
24
+ * Build symbol table for chained JOINs, preserving table references
25
+ */
26
+ function buildSymbolTableFromShapeForChain(resultShape, existingAliases, newInnerAlias, context) {
27
+ if (!resultShape) {
28
+ return;
29
+ }
30
+ // Initialize symbol table if not exists
31
+ if (!context.symbolTable) {
32
+ context.symbolTable = {
33
+ entries: new Map(),
34
+ };
35
+ }
36
+ // For chained JOINs, we need to map sourceTable indices correctly:
37
+ // - sourceTable indices in the shape refer to the tables at the time the shape was created
38
+ // - We need to preserve those original table references
39
+ for (const [propName, shapeNode] of resultShape.properties) {
40
+ processShapeNodeForChain(propName, shapeNode, existingAliases, newInnerAlias, context.symbolTable, "");
41
+ }
42
+ }
43
+ /**
44
+ * Recursively process shape nodes to build symbol table entries
45
+ */
46
+ function processShapeNode(propName, node, outerAlias, innerAlias, symbolTable, parentPath) {
47
+ const fullPath = parentPath ? `${parentPath}.${propName}` : propName;
48
+ switch (node.type) {
49
+ case "column": {
50
+ const colNode = node;
51
+ const tableAlias = colNode.sourceTable === 0 ? outerAlias : innerAlias;
52
+ symbolTable.entries.set(fullPath, {
53
+ tableAlias,
54
+ columnName: colNode.columnName,
55
+ });
56
+ break;
57
+ }
58
+ case "object": {
59
+ // Nested object - recurse
60
+ const objNode = node;
61
+ for (const [nestedProp, nestedNode] of objNode.properties) {
62
+ processShapeNode(nestedProp, nestedNode, outerAlias, innerAlias, symbolTable, fullPath);
63
+ }
64
+ break;
65
+ }
66
+ case "reference": {
67
+ // Reference to entire table - we can't map individual columns yet
68
+ // but we can store that this path references a specific table
69
+ const refNode = node;
70
+ const tableAlias = refNode.sourceTable === 0 ? outerAlias : innerAlias;
71
+ // Store a special marker for reference nodes
72
+ symbolTable.entries.set(fullPath, {
73
+ tableAlias,
74
+ columnName: "*", // Special marker for "all columns from this table"
75
+ });
76
+ break;
77
+ }
78
+ }
79
+ }
80
+ /**
81
+ * Process shape nodes for chained JOINs, preserving original table references
82
+ */
83
+ function processShapeNodeForChain(propName, node, existingAliases, newInnerAlias, symbolTable, parentPath) {
84
+ const fullPath = parentPath ? `${parentPath}.${propName}` : propName;
85
+ switch (node.type) {
86
+ case "column": {
87
+ const colNode = node;
88
+ // For chained JOINs, sourceTable refers to the original table indices
89
+ // If sourceTable < existingAliases.length, use the existing alias
90
+ // Otherwise, it's the new inner table
91
+ const tableAlias = colNode.sourceTable < existingAliases.length
92
+ ? existingAliases[colNode.sourceTable]
93
+ : newInnerAlias;
94
+ symbolTable.entries.set(fullPath, {
95
+ tableAlias,
96
+ columnName: colNode.columnName,
97
+ });
98
+ break;
99
+ }
100
+ case "object": {
101
+ // Nested object - recurse
102
+ const objNode = node;
103
+ for (const [nestedProp, nestedNode] of objNode.properties) {
104
+ processShapeNodeForChain(nestedProp, nestedNode, existingAliases, newInnerAlias, symbolTable, fullPath);
105
+ }
106
+ break;
107
+ }
108
+ case "reference": {
109
+ const refNode = node;
110
+ const tableAlias = refNode.sourceTable < existingAliases.length
111
+ ? existingAliases[refNode.sourceTable]
112
+ : newInnerAlias;
113
+ symbolTable.entries.set(fullPath, {
114
+ tableAlias,
115
+ columnName: "*",
116
+ });
117
+ break;
118
+ }
119
+ }
120
+ }
121
+ /**
122
+ * Build symbol table from JOIN result selector (legacy approach)
123
+ */
124
+ function buildSymbolTable(resultSelector, outerAlias, innerAlias, context) {
125
+ if (!resultSelector || resultSelector.type !== "object") {
126
+ return;
127
+ }
128
+ // Initialize symbol table if not exists
129
+ if (!context.symbolTable) {
130
+ context.symbolTable = {
131
+ entries: new Map(),
132
+ };
133
+ }
134
+ const objExpr = resultSelector;
135
+ // Process each property in the result selector
136
+ for (const [propName, expr] of Object.entries(objExpr.properties)) {
137
+ processExpression(propName, expr, outerAlias, innerAlias, context.symbolTable, "");
138
+ }
139
+ }
140
+ /**
141
+ * Recursively process expressions to build symbol table entries
142
+ */
143
+ function processExpression(propName, expr, outerAlias, innerAlias, symbolTable, parentPath) {
144
+ const fullPath = parentPath ? `${parentPath}.${propName}` : propName;
145
+ if (expr.type === "column") {
146
+ const colExpr = expr;
147
+ // Check if this references a JOIN parameter ($param0, $param1)
148
+ if (colExpr.table && colExpr.table.startsWith("$param")) {
149
+ const paramIndex = parseInt(colExpr.table.substring(6), 10);
150
+ const tableAlias = paramIndex === 0 ? outerAlias : innerAlias;
151
+ symbolTable.entries.set(fullPath, {
152
+ tableAlias,
153
+ columnName: colExpr.name,
154
+ });
155
+ }
156
+ else {
157
+ // Regular column without parameter reference
158
+ symbolTable.entries.set(fullPath, {
159
+ tableAlias: colExpr.table || outerAlias,
160
+ columnName: colExpr.name,
161
+ });
162
+ }
163
+ }
164
+ else if (expr.type === "object") {
165
+ // Nested object - recurse
166
+ const nestedObj = expr;
167
+ for (const [nestedProp, nestedExpr] of Object.entries(nestedObj.properties)) {
168
+ processExpression(nestedProp, nestedExpr, outerAlias, innerAlias, symbolTable, fullPath);
169
+ }
170
+ }
171
+ // TODO: Handle other expression types (arithmetic, concat, etc.)
172
+ }
173
+ /**
174
+ * Generate JOIN clause
175
+ */
176
+ export function generateJoin(operation, context) {
177
+ // Get table aliases - for chained JOINs, we need all existing aliases
178
+ const allAliases = Array.from(context.tableAliases.values());
179
+ const outerAlias = allAliases[0] || "t0";
180
+ const innerAlias = `t${context.aliasCounter++}`;
181
+ // Add the inner table alias to the context so it can be resolved later
182
+ // Store it with a key that indicates it's the second table (index 1)
183
+ context.tableAliases.set(`join_${context.aliasCounter - 1}`, innerAlias);
184
+ // Build symbol table from result shape (preferred) or result selector (fallback)
185
+ if (operation.resultShape) {
186
+ // For chained JOINs, pass all existing aliases so we can map sourceTable indices correctly
187
+ if (allAliases.length > 1) {
188
+ // This is a chained JOIN - use the special handler
189
+ buildSymbolTableFromShapeForChain(operation.resultShape, allAliases, innerAlias, context);
190
+ }
191
+ else {
192
+ // First JOIN - use the regular handler
193
+ buildSymbolTableFromShape(operation.resultShape, outerAlias, innerAlias, context);
194
+ }
195
+ }
196
+ else if (operation.resultSelector) {
197
+ buildSymbolTable(operation.resultSelector, outerAlias, innerAlias, context);
198
+ }
199
+ // Store the result selector for SELECT generation
200
+ if (operation.resultSelector) {
201
+ context.currentShape = operation.resultSelector;
202
+ }
203
+ // Check if inner is just a simple FROM operation
204
+ let joinClause;
205
+ const joinKeyword = (() => {
206
+ switch (operation.joinType) {
207
+ case "left":
208
+ return "LEFT OUTER JOIN";
209
+ case "right":
210
+ return "RIGHT OUTER JOIN";
211
+ case "full":
212
+ return "FULL OUTER JOIN";
213
+ case "cross":
214
+ return "CROSS JOIN";
215
+ default:
216
+ return "INNER JOIN";
217
+ }
218
+ })();
219
+ if (operation.inner.operationType === "from") {
220
+ const fromOp = operation.inner;
221
+ const tableName = fromOp.table;
222
+ joinClause = `${joinKeyword} "${tableName}" AS "${innerAlias}"`;
223
+ }
224
+ else {
225
+ // Complex inner query - need subquery
226
+ const innerSql = generateSql(operation.inner, {});
227
+ joinClause = `${joinKeyword} (${innerSql}) AS "${innerAlias}"`;
228
+ }
229
+ if (joinKeyword === "CROSS JOIN") {
230
+ return joinClause;
231
+ }
232
+ // Build ON clause - resolve keys through symbol table if available
233
+ let resolvedOuterKey = operation.outerKey;
234
+ let resolvedOuterAlias = outerAlias;
235
+ // Check if outerKey needs resolution through symbol table
236
+ if (context.symbolTable) {
237
+ const sourceRef = context.symbolTable.entries.get(operation.outerKey);
238
+ if (sourceRef) {
239
+ resolvedOuterKey = sourceRef.columnName;
240
+ resolvedOuterAlias = sourceRef.tableAlias;
241
+ }
242
+ }
243
+ const onClause = `ON "${resolvedOuterAlias}"."${resolvedOuterKey}" = "${innerAlias}"."${operation.innerKey}"`;
244
+ return `${joinClause} ${onClause}`;
245
+ }
246
+ //# sourceMappingURL=join.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"join.js","sourceRoot":"","sources":["../../src/generators/join.ts"],"names":[],"mappings":"AAAA;;GAEG;AAeH,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAElD;;GAEG;AACH,SAAS,yBAAyB,CAChC,WAAoC,EACpC,UAAkB,EAClB,UAAkB,EAClB,OAAmB;IAEnB,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,OAAO;IACT,CAAC;IAED,wCAAwC;IACxC,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC;QACzB,OAAO,CAAC,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GAAG,CAAC;IACjE,CAAC;IAED,IAAI,WAAW,KAAK,YAAY,EAAE,CAAC;QACjC,OAAO,UAAU,CAAC;IACpB,CAAC;IAED,mEAAmE;IACnE,IAAI,gBAAgB,GAAG,SAAS,CAAC,QAAQ,CAAC;IAC1C,IAAI,kBAAkB,GAAG,UAAU,CAAC;IAEpC,0DAA0D;IAC1D,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;QACxB,MAAM,SAAS,GAAG,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;QACtE,IAAI,SAAS,EAAE,CAAC;YACd,gBAAgB,GAAG,SAAS,CAAC,UAAU,CAAC;YACxC,kBAAkB,GAAG,SAAS,CAAC,UAAU,CAAC;QAC5C,CAAC;IACH,CAAC;IAED,MAAM,QAAQ,GAAG,OAAO,kBAAkB,MAAM,gBAAgB,QAAQ,UAAU,MAAM,SAAS,CAAC,QAAQ,GAAG,CAAC;IAE9G,OAAO,GAAG,UAAU,IAAI,QAAQ,EAAE,CAAC;AACrC,CAAC"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * LAST operation generator
3
+ */
4
+ import type { LastOperation, LastOrDefaultOperation } from "@tinqerjs/tinqer";
5
+ import type { SqlContext } from "../types.js";
6
+ /**
7
+ * Generate SQL for LAST or LASTORDEFAULT operations
8
+ * In PostgreSQL, this requires reversing any existing ORDER BY and adding LIMIT 1
9
+ * Note: If no ORDER BY exists, we should error since LAST is undefined without order
10
+ * Note: Predicates are handled as WHERE operations before this
11
+ */
12
+ export declare function generateLast(_operation: LastOperation | LastOrDefaultOperation, _context: SqlContext): string;
13
+ //# sourceMappingURL=last.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"last.d.ts","sourceRoot":"","sources":["../../src/generators/last.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAC9E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C;;;;;GAKG;AACH,wBAAgB,YAAY,CAC1B,UAAU,EAAE,aAAa,GAAG,sBAAsB,EAClD,QAAQ,EAAE,UAAU,GACnB,MAAM,CAKR"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * LAST operation generator
3
+ */
4
+ /**
5
+ * Generate SQL for LAST or LASTORDEFAULT operations
6
+ * In PostgreSQL, this requires reversing any existing ORDER BY and adding LIMIT 1
7
+ * Note: If no ORDER BY exists, we should error since LAST is undefined without order
8
+ * Note: Predicates are handled as WHERE operations before this
9
+ */
10
+ export function generateLast(_operation, _context) {
11
+ // LAST/LASTORDEFAULT requires an ORDER BY to be meaningful
12
+ // The SQL generator should handle reversing existing ORDER BY or adding a default one
13
+ // For now, just return LIMIT 1 and let the orchestrator handle the ordering
14
+ return "LIMIT 1";
15
+ }
16
+ //# sourceMappingURL=last.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"last.js","sourceRoot":"","sources":["../../src/generators/last.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAC1B,UAAkD,EAClD,QAAoB;IAEpB,2DAA2D;IAC3D,sFAAsF;IACtF,4EAA4E;IAC5E,OAAO,SAAS,CAAC;AACnB,CAAC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * MAX aggregate generator
3
+ */
4
+ import type { MaxOperation } from "@tinqerjs/tinqer";
5
+ import type { SqlContext } from "../types.js";
6
+ /**
7
+ * Generate MAX aggregate
8
+ */
9
+ export declare function generateMax(operation: MaxOperation, context: SqlContext): string;
10
+ //# sourceMappingURL=max.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"max.d.ts","sourceRoot":"","sources":["../../src/generators/max.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAG9C;;GAEG;AACH,wBAAgB,WAAW,CAAC,SAAS,EAAE,YAAY,EAAE,OAAO,EAAE,UAAU,GAAG,MAAM,CAMhF"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * MAX aggregate generator
3
+ */
4
+ import { generateExpression } from "../expression-generator.js";
5
+ /**
6
+ * Generate MAX aggregate
7
+ */
8
+ export function generateMax(operation, context) {
9
+ if (operation.selectorExpression) {
10
+ const expr = generateExpression(operation.selectorExpression, context);
11
+ return `MAX(${expr})`;
12
+ }
13
+ return "MAX(*)";
14
+ }
15
+ //# sourceMappingURL=max.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"max.js","sourceRoot":"","sources":["../../src/generators/max.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAEhE;;GAEG;AACH,MAAM,UAAU,WAAW,CAAC,SAAuB,EAAE,OAAmB;IACtE,IAAI,SAAS,CAAC,kBAAkB,EAAE,CAAC;QACjC,MAAM,IAAI,GAAG,kBAAkB,CAAC,SAAS,CAAC,kBAAkB,EAAE,OAAO,CAAC,CAAC;QACvE,OAAO,OAAO,IAAI,GAAG,CAAC;IACxB,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * MIN aggregate generator
3
+ */
4
+ import type { MinOperation } from "@tinqerjs/tinqer";
5
+ import type { SqlContext } from "../types.js";
6
+ /**
7
+ * Generate MIN aggregate
8
+ */
9
+ export declare function generateMin(operation: MinOperation, context: SqlContext): string;
10
+ //# sourceMappingURL=min.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"min.d.ts","sourceRoot":"","sources":["../../src/generators/min.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAG9C;;GAEG;AACH,wBAAgB,WAAW,CAAC,SAAS,EAAE,YAAY,EAAE,OAAO,EAAE,UAAU,GAAG,MAAM,CAMhF"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * MIN aggregate generator
3
+ */
4
+ import { generateExpression } from "../expression-generator.js";
5
+ /**
6
+ * Generate MIN aggregate
7
+ */
8
+ export function generateMin(operation, context) {
9
+ if (operation.selectorExpression) {
10
+ const expr = generateExpression(operation.selectorExpression, context);
11
+ return `MIN(${expr})`;
12
+ }
13
+ return "MIN(*)";
14
+ }
15
+ //# sourceMappingURL=min.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"min.js","sourceRoot":"","sources":["../../src/generators/min.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAEhE;;GAEG;AACH,MAAM,UAAU,WAAW,CAAC,SAAuB,EAAE,OAAmB;IACtE,IAAI,SAAS,CAAC,kBAAkB,EAAE,CAAC;QACjC,MAAM,IAAI,GAAG,kBAAkB,CAAC,SAAS,CAAC,kBAAkB,EAAE,OAAO,CAAC,CAAC;QACvE,OAAO,OAAO,IAAI,GAAG,CAAC;IACxB,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * ORDER BY clause generator
3
+ */
4
+ import type { OrderByOperation } from "@tinqerjs/tinqer";
5
+ import type { SqlContext } from "../types.js";
6
+ /**
7
+ * Generate ORDER BY clause
8
+ */
9
+ export declare function generateOrderBy(operation: OrderByOperation, context: SqlContext): string;
10
+ //# sourceMappingURL=orderby.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"orderby.d.ts","sourceRoot":"","sources":["../../src/generators/orderby.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAG9C;;GAEG;AACH,wBAAgB,eAAe,CAAC,SAAS,EAAE,gBAAgB,EAAE,OAAO,EAAE,UAAU,GAAG,MAAM,CAmDxF"}
@@ -0,0 +1,66 @@
1
+ /**
2
+ * ORDER BY clause generator
3
+ */
4
+ import { generateValueExpression, generateExpression } from "../expression-generator.js";
5
+ /**
6
+ * Generate ORDER BY clause
7
+ */
8
+ export function generateOrderBy(operation, context) {
9
+ let orderByExpr;
10
+ if (typeof operation.keySelector === "string") {
11
+ // Simple column name - check if it maps to a source column
12
+ // Special handling for "key" when we have GROUP BY
13
+ if (operation.keySelector === "key" && context.groupByKey) {
14
+ // Translate g.key to the actual grouped column
15
+ if (context.groupByKey.type === "column") {
16
+ orderByExpr = `"${context.groupByKey.name}"`;
17
+ }
18
+ else {
19
+ // For complex GROUP BY expressions, generate the expression
20
+ orderByExpr = generateExpression(context.groupByKey, context);
21
+ }
22
+ }
23
+ else if (operation.keySelector.includes(".") && context.symbolTable) {
24
+ // Check if it's a path like "o.amount"
25
+ const parts = operation.keySelector.split(".");
26
+ if (parts.length === 2) {
27
+ const tableRef = context.symbolTable.entries.get(parts[0]);
28
+ if (tableRef && tableRef.columnName === "*") {
29
+ orderByExpr = `"${tableRef.tableAlias}"."${parts[1]}"`;
30
+ }
31
+ else {
32
+ // Try full path
33
+ const pathRef = context.symbolTable.entries.get(operation.keySelector);
34
+ if (pathRef) {
35
+ orderByExpr = `"${pathRef.tableAlias}"."${pathRef.columnName}"`;
36
+ }
37
+ else {
38
+ orderByExpr = `"${operation.keySelector}"`;
39
+ }
40
+ }
41
+ }
42
+ else {
43
+ orderByExpr = `"${operation.keySelector}"`;
44
+ }
45
+ }
46
+ else if (context.symbolTable) {
47
+ const sourceRef = context.symbolTable.entries.get(operation.keySelector);
48
+ if (sourceRef) {
49
+ orderByExpr = `"${sourceRef.tableAlias}"."${sourceRef.columnName}"`;
50
+ }
51
+ else {
52
+ orderByExpr = `"${operation.keySelector}"`;
53
+ }
54
+ }
55
+ else {
56
+ orderByExpr = `"${operation.keySelector}"`;
57
+ }
58
+ }
59
+ else {
60
+ // Complex expression
61
+ orderByExpr = generateValueExpression(operation.keySelector, context);
62
+ }
63
+ const direction = operation.descending ? "DESC" : "ASC";
64
+ return `ORDER BY ${orderByExpr} ${direction}`;
65
+ }
66
+ //# sourceMappingURL=orderby.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"orderby.js","sourceRoot":"","sources":["../../src/generators/orderby.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,EAAE,uBAAuB,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAEzF;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,SAA2B,EAAE,OAAmB;IAC9E,IAAI,WAAmB,CAAC;IAExB,IAAI,OAAO,SAAS,CAAC,WAAW,KAAK,QAAQ,EAAE,CAAC;QAC9C,2DAA2D;QAE3D,mDAAmD;QACnD,IAAI,SAAS,CAAC,WAAW,KAAK,KAAK,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;YAC1D,+CAA+C;YAC/C,IAAI,OAAO,CAAC,UAAU,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;gBACzC,WAAW,GAAG,IAAI,OAAO,CAAC,UAAU,CAAC,IAAI,GAAG,CAAC;YAC/C,CAAC;iBAAM,CAAC;gBACN,4DAA4D;gBAC5D,WAAW,GAAG,kBAAkB,CAAC,OAAO,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;YAChE,CAAC;QACH,CAAC;aAAM,IAAI,SAAS,CAAC,WAAW,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;YACtE,uCAAuC;YACvC,MAAM,KAAK,GAAG,SAAS,CAAC,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YAC/C,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gB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AC,SAAS,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;IACxE,CAAC;IAED,MAAM,SAAS,GAAG,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC;IACxD,OAAO,YAAY,WAAW,IAAI,SAAS,EAAE,CAAC;AAChD,CAAC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * SELECT clause generator
3
+ */
4
+ import type { SelectOperation } from "@tinqerjs/tinqer";
5
+ import type { SqlContext } from "../types.js";
6
+ /**
7
+ * Generate SELECT clause
8
+ */
9
+ export declare function generateSelect(operation: SelectOperation, context: SqlContext): string;
10
+ //# sourceMappingURL=select.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"select.d.ts","sourceRoot":"","sources":["../../src/generators/select.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAmB,MAAM,kBAAkB,CAAC;AACzE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAG9C;;GAEG;AACH,wBAAgB,cAAc,CAAC,SAAS,EAAE,eAAe,EAAE,OAAO,EAAE,UAAU,GAAG,MAAM,CAyBtF"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * SELECT clause generator
3
+ */
4
+ import { generateExpression, generateValueExpression } from "../expression-generator.js";
5
+ /**
6
+ * Generate SELECT clause
7
+ */
8
+ export function generateSelect(operation, context) {
9
+ // Handle null selector (legacy support, should not happen with new code)
10
+ if (!operation.selector) {
11
+ return "SELECT *";
12
+ }
13
+ // Handle AllColumnsExpression (identity function like .select(u => u))
14
+ if (operation.selector.type === "allColumns") {
15
+ return "SELECT *";
16
+ }
17
+ // Handle different selector types
18
+ if (operation.selector.type === "object") {
19
+ // Object projection - generate columns with aliases
20
+ const projection = generateExpression(operation.selector, context);
21
+ return `SELECT ${projection}`;
22
+ }
23
+ else if (operation.selector.type === "column") {
24
+ // Simple column selection
25
+ const column = generateValueExpression(operation.selector, context);
26
+ return `SELECT ${column}`;
27
+ }
28
+ else {
29
+ // Other value expressions
30
+ const value = generateExpression(operation.selector, context);
31
+ return `SELECT ${value}`;
32
+ }
33
+ }
34
+ //# sourceMappingURL=select.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"select.js","sourceRoot":"","sources":["../../src/generators/select.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAEzF;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,SAA0B,EAAE,OAAmB;IAC5E,yEAAyE;IACzE,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC;QACxB,OAAO,UAAU,CAAC;IACpB,CAAC;IAED,uEAAuE;IACvE,IAAI,SAAS,CAAC,QAAQ,CAAC,IAAI,KAAK,YAAY,EAAE,CAAC;QAC7C,OAAO,UAAU,CAAC;IACpB,CAAC;IAED,kCAAkC;IAClC,IAAI,SAAS,CAAC,QAAQ,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;QACzC,oDAAoD;QACpD,MAAM,UAAU,GAAG,kBAAkB,CAAC,SAAS,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QACnE,OAAO,UAAU,UAAU,EAAE,CAAC;IAChC,CAAC;SAAM,IAAI,SAAS,CAAC,QAAQ,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;QAChD,0BAA0B;QAC1B,MAAM,MAAM,GAAG,uBAAuB,CAAC,SAAS,CAAC,QAA2B,EAAE,OAAO,CAAC,CAAC;QACvF,OAAO,UAAU,MAAM,EAAE,CAAC;IAC5B,CAAC;SAAM,CAAC;QACN,0BAA0B;QAC1B,MAAM,KAAK,GAAG,kBAAkB,CAAC,SAAS,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QAC9D,OAAO,UAAU,KAAK,EAAE,CAAC;IAC3B,CAAC;AACH,CAAC"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * SINGLE operation generator
3
+ */
4
+ import type { SingleOperation, SingleOrDefaultOperation } from "@tinqerjs/tinqer";
5
+ import type { SqlContext } from "../types.js";
6
+ /**
7
+ * Generate SQL for SINGLE or SINGLEORDEFAULT operations
8
+ * In PostgreSQL, we use LIMIT 2 and check for exactly 1 result in the client
9
+ * Note: Predicates are handled as WHERE operations before this
10
+ */
11
+ export declare function generateSingle(_operation: SingleOperation | SingleOrDefaultOperation, _context: SqlContext): string;
12
+ //# sourceMappingURL=single.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"single.d.ts","sourceRoot":"","sources":["../../src/generators/single.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AAClF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C;;;;GAIG;AACH,wBAAgB,cAAc,CAC5B,UAAU,EAAE,eAAe,GAAG,wBAAwB,EACtD,QAAQ,EAAE,UAAU,GACnB,MAAM,CAGR"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * SINGLE operation generator
3
+ */
4
+ /**
5
+ * Generate SQL for SINGLE or SINGLEORDEFAULT operations
6
+ * In PostgreSQL, we use LIMIT 2 and check for exactly 1 result in the client
7
+ * Note: Predicates are handled as WHERE operations before this
8
+ */
9
+ export function generateSingle(_operation, _context) {
10
+ // SINGLE/SINGLEORDEFAULT - LIMIT 2 to check for multiple results (client validates exactly 1)
11
+ return "LIMIT 2";
12
+ }
13
+ //# sourceMappingURL=single.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"single.js","sourceRoot":"","sources":["../../src/generators/single.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAC5B,UAAsD,EACtD,QAAoB;IAEpB,8FAA8F;IAC9F,OAAO,SAAS,CAAC;AACnB,CAAC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * SKIP (OFFSET) clause generator
3
+ */
4
+ import type { SkipOperation } from "@tinqerjs/tinqer";
5
+ import type { SqlContext } from "../types.js";
6
+ /**
7
+ * Generate OFFSET clause
8
+ */
9
+ export declare function generateSkip(operation: SkipOperation, context: SqlContext): string;
10
+ //# sourceMappingURL=skip.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"skip.d.ts","sourceRoot":"","sources":["../../src/generators/skip.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAmB,MAAM,kBAAkB,CAAC;AACvE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAG9C;;GAEG;AACH,wBAAgB,YAAY,CAAC,SAAS,EAAE,aAAa,EAAE,OAAO,EAAE,UAAU,GAAG,MAAM,CAQlF"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * SKIP (OFFSET) clause generator
3
+ */
4
+ import { generateValueExpression } from "../expression-generator.js";
5
+ /**
6
+ * Generate OFFSET clause
7
+ */
8
+ export function generateSkip(operation, context) {
9
+ if (typeof operation.count === "number") {
10
+ return `OFFSET ${operation.count}`;
11
+ }
12
+ else {
13
+ // Handle as expression (ParamRef, ArithmeticExpression, etc.)
14
+ const expr = generateValueExpression(operation.count, context);
15
+ return `OFFSET ${expr}`;
16
+ }
17
+ }
18
+ //# sourceMappingURL=skip.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"skip.js","sourceRoot":"","sources":["../../src/generators/skip.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAErE;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,SAAwB,EAAE,OAAmB;IACxE,IAAI,OAAO,SAAS,CAAC,KAAK,KAAK,QAAQ,EAAE,CAAC;QACxC,OAAO,UAAU,SAAS,CAAC,KAAK,EAAE,CAAC;IACrC,CAAC;SAAM,CAAC;QACN,8DAA8D;QAC9D,MAAM,IAAI,GAAG,uBAAuB,CAAC,SAAS,CAAC,KAAwB,EAAE,OAAO,CAAC,CAAC;QAClF,OAAO,UAAU,IAAI,EAAE,CAAC;IAC1B,CAAC;AACH,CAAC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * SUM aggregate generator
3
+ */
4
+ import type { SumOperation } from "@tinqerjs/tinqer";
5
+ import type { SqlContext } from "../types.js";
6
+ /**
7
+ * Generate SUM aggregate
8
+ */
9
+ export declare function generateSum(operation: SumOperation, context: SqlContext): string;
10
+ //# sourceMappingURL=sum.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sum.d.ts","sourceRoot":"","sources":["../../src/generators/sum.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAG9C;;GAEG;AACH,wBAAgB,WAAW,CAAC,SAAS,EAAE,YAAY,EAAE,OAAO,EAAE,UAAU,GAAG,MAAM,CAMhF"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * SUM aggregate generator
3
+ */
4
+ import { generateExpression } from "../expression-generator.js";
5
+ /**
6
+ * Generate SUM aggregate
7
+ */
8
+ export function generateSum(operation, context) {
9
+ if (operation.selectorExpression) {
10
+ const expr = generateExpression(operation.selectorExpression, context);
11
+ return `SUM(${expr})`;
12
+ }
13
+ return "SUM(*)";
14
+ }
15
+ //# sourceMappingURL=sum.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sum.js","sourceRoot":"","sources":["../../src/generators/sum.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAEhE;;GAEG;AACH,MAAM,UAAU,WAAW,CAAC,SAAuB,EAAE,OAAmB;IACtE,IAAI,SAAS,CAAC,kBAAkB,EAAE,CAAC;QACjC,MAAM,IAAI,GAAG,kBAAkB,CAAC,SAAS,CAAC,kBAAkB,EAAE,OAAO,CAAC,CAAC;QACvE,OAAO,OAAO,IAAI,GAAG,CAAC;IACxB,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * TAKE (LIMIT) clause generator
3
+ */
4
+ import type { TakeOperation } from "@tinqerjs/tinqer";
5
+ import type { SqlContext } from "../types.js";
6
+ /**
7
+ * Generate LIMIT clause
8
+ */
9
+ export declare function generateTake(operation: TakeOperation, context: SqlContext): string;
10
+ //# sourceMappingURL=take.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"take.d.ts","sourceRoot":"","sources":["../../src/generators/take.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAmB,MAAM,kBAAkB,CAAC;AACvE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAG9C;;GAEG;AACH,wBAAgB,YAAY,CAAC,SAAS,EAAE,aAAa,EAAE,OAAO,EAAE,UAAU,GAAG,MAAM,CAQlF"}