effect-qb 0.14.0 → 0.15.0

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 (141) hide show
  1. package/dist/mysql.js +61270 -4259
  2. package/dist/postgres/metadata.js +176 -82
  3. package/dist/postgres.js +5903 -3316
  4. package/package.json +14 -1
  5. package/src/internal/aggregation-validation.ts +3 -3
  6. package/src/internal/case-analysis.d.ts +18 -0
  7. package/src/internal/case-analysis.ts +4 -4
  8. package/src/internal/coercion/analysis.d.ts +7 -0
  9. package/src/internal/{coercion-analysis.ts → coercion/analysis.ts} +3 -3
  10. package/src/internal/coercion/errors.d.ts +17 -0
  11. package/src/internal/{coercion-errors.ts → coercion/errors.ts} +1 -1
  12. package/src/internal/coercion/kind.d.ts +4 -0
  13. package/src/internal/{coercion-kind.ts → coercion/kind.ts} +2 -2
  14. package/src/internal/{coercion-normalize.ts → coercion/normalize.ts} +1 -1
  15. package/src/internal/coercion/rules.d.ts +6 -0
  16. package/src/internal/{coercion-rules.ts → coercion/rules.ts} +2 -2
  17. package/src/internal/column-state.d.ts +190 -0
  18. package/src/internal/column-state.ts +36 -47
  19. package/src/internal/column.ts +21 -305
  20. package/src/internal/datatypes/define.d.ts +17 -0
  21. package/src/internal/datatypes/define.ts +18 -4
  22. package/src/internal/datatypes/lookup.d.ts +44 -0
  23. package/src/internal/datatypes/lookup.ts +61 -152
  24. package/src/internal/datatypes/shape.d.ts +16 -0
  25. package/src/internal/datatypes/shape.ts +1 -1
  26. package/src/internal/derived-table.d.ts +4 -0
  27. package/src/internal/derived-table.ts +21 -16
  28. package/src/internal/dsl-mutation-runtime.ts +378 -0
  29. package/src/internal/dsl-plan-runtime.ts +387 -0
  30. package/src/internal/dsl-query-runtime.ts +160 -0
  31. package/src/internal/dsl-transaction-ddl-runtime.ts +263 -0
  32. package/src/internal/executor.ts +132 -31
  33. package/src/internal/expression-ast.ts +15 -5
  34. package/src/internal/grouping-key.d.ts +3 -0
  35. package/src/internal/grouping-key.ts +1 -1
  36. package/src/internal/implication-runtime.d.ts +15 -0
  37. package/src/internal/implication-runtime.ts +4 -4
  38. package/src/internal/json/ast.d.ts +30 -0
  39. package/src/internal/json/ast.ts +1 -1
  40. package/src/internal/json/errors.d.ts +8 -0
  41. package/src/internal/json/path.d.ts +75 -0
  42. package/src/internal/json/path.ts +1 -1
  43. package/src/internal/json/types.d.ts +62 -0
  44. package/src/internal/predicate/analysis.d.ts +20 -0
  45. package/src/internal/{predicate-analysis.ts → predicate/analysis.ts} +3 -3
  46. package/src/internal/predicate/atom.d.ts +28 -0
  47. package/src/internal/{predicate-branches.ts → predicate/branches.ts} +2 -2
  48. package/src/internal/predicate/context.d.ts +67 -0
  49. package/src/internal/{predicate-context.ts → predicate/context.ts} +8 -5
  50. package/src/internal/predicate/formula.d.ts +35 -0
  51. package/src/internal/{predicate-formula.ts → predicate/formula.ts} +1 -1
  52. package/src/internal/predicate/key.d.ts +11 -0
  53. package/src/internal/{predicate-key.ts → predicate/key.ts} +2 -2
  54. package/src/internal/{predicate-nnf.ts → predicate/nnf.ts} +2 -2
  55. package/src/internal/predicate/normalize.d.ts +53 -0
  56. package/src/internal/{predicate-normalize.ts → predicate/normalize.ts} +19 -19
  57. package/src/internal/predicate/runtime.d.ts +31 -0
  58. package/src/internal/{predicate-runtime.ts → predicate/runtime.ts} +9 -6
  59. package/src/internal/projection-alias.d.ts +13 -0
  60. package/src/internal/projections.d.ts +31 -0
  61. package/src/internal/projections.ts +1 -1
  62. package/src/internal/query-ast.d.ts +217 -0
  63. package/src/internal/query-ast.ts +1 -1
  64. package/src/internal/query-requirements.d.ts +20 -0
  65. package/src/internal/query.d.ts +775 -0
  66. package/src/internal/query.ts +389 -313
  67. package/src/internal/renderer.ts +7 -21
  68. package/src/internal/row-set.d.ts +53 -0
  69. package/src/internal/{plan.ts → row-set.ts} +11 -9
  70. package/src/internal/{runtime-normalize.ts → runtime/normalize.ts} +9 -31
  71. package/src/internal/{runtime-schema.ts → runtime/schema.ts} +13 -38
  72. package/src/internal/runtime/value.d.ts +22 -0
  73. package/src/internal/{runtime-value.ts → runtime/value.ts} +2 -2
  74. package/src/internal/scalar.d.ts +107 -0
  75. package/src/internal/scalar.ts +191 -0
  76. package/src/internal/schema-derivation.d.ts +105 -0
  77. package/src/internal/schema-expression.d.ts +18 -0
  78. package/src/internal/schema-expression.ts +38 -7
  79. package/src/internal/table-options.d.ts +94 -0
  80. package/src/internal/table-options.ts +8 -2
  81. package/src/internal/table.d.ts +173 -0
  82. package/src/internal/table.ts +32 -14
  83. package/src/mysql/column.ts +94 -18
  84. package/src/mysql/datatypes/index.ts +47 -7
  85. package/src/mysql/errors/generated.ts +57336 -0
  86. package/src/mysql/errors/index.ts +1 -0
  87. package/src/mysql/errors/normalize.ts +55 -53
  88. package/src/mysql/errors/types.ts +74 -0
  89. package/src/mysql/executor.ts +69 -7
  90. package/src/mysql/function/aggregate.ts +1 -5
  91. package/src/mysql/function/core.ts +1 -4
  92. package/src/mysql/function/index.ts +0 -1
  93. package/src/mysql/function/string.ts +1 -5
  94. package/src/mysql/function/temporal.ts +12 -15
  95. package/src/mysql/function/window.ts +1 -6
  96. package/src/{internal/mysql-dialect.ts → mysql/internal/dialect.ts} +1 -1
  97. package/src/{internal/mysql-query.ts → mysql/internal/dsl.ts} +1024 -2082
  98. package/src/{internal/mysql-renderer.ts → mysql/internal/renderer.ts} +6 -6
  99. package/src/mysql/internal/sql-expression-renderer.ts +1455 -0
  100. package/src/mysql/json.ts +2 -0
  101. package/src/mysql/query.ts +111 -91
  102. package/src/mysql/renderer.ts +1 -1
  103. package/src/mysql/table.ts +1 -1
  104. package/src/mysql.ts +6 -4
  105. package/src/postgres/cast.ts +11 -12
  106. package/src/postgres/column.ts +178 -46
  107. package/src/postgres/datatypes/index.d.ts +515 -0
  108. package/src/postgres/datatypes/index.ts +22 -13
  109. package/src/postgres/datatypes/spec.d.ts +412 -0
  110. package/src/postgres/errors/generated.ts +2636 -0
  111. package/src/postgres/errors/index.ts +1 -0
  112. package/src/postgres/errors/normalize.ts +47 -62
  113. package/src/postgres/errors/types.ts +92 -34
  114. package/src/postgres/executor.ts +37 -5
  115. package/src/postgres/function/aggregate.ts +1 -5
  116. package/src/postgres/function/core.ts +12 -6
  117. package/src/postgres/function/index.ts +0 -1
  118. package/src/postgres/function/string.ts +1 -5
  119. package/src/postgres/function/temporal.ts +12 -15
  120. package/src/postgres/function/window.ts +1 -6
  121. package/src/{internal/postgres-dialect.ts → postgres/internal/dialect.ts} +1 -1
  122. package/src/{internal/postgres-query.ts → postgres/internal/dsl.ts} +1085 -2089
  123. package/src/{internal/postgres-renderer.ts → postgres/internal/renderer.ts} +6 -6
  124. package/src/postgres/internal/schema-ddl.ts +108 -0
  125. package/src/{internal/postgres-schema-model.ts → postgres/internal/schema-model.ts} +12 -6
  126. package/src/{internal → postgres/internal}/sql-expression-renderer.ts +19 -17
  127. package/src/postgres/{function/json.ts → json.ts} +77 -85
  128. package/src/postgres/metadata.ts +2 -2
  129. package/src/postgres/query.ts +113 -89
  130. package/src/postgres/renderer.ts +3 -13
  131. package/src/postgres/schema-expression.ts +2 -1
  132. package/src/postgres/schema-management.ts +1 -1
  133. package/src/postgres/table.ts +12 -4
  134. package/src/postgres/type.ts +29 -2
  135. package/src/postgres.ts +6 -4
  136. package/src/internal/expression.ts +0 -327
  137. package/src/internal/schema-ddl.ts +0 -55
  138. package/src/mysql/function/json.ts +0 -4
  139. package/src/mysql/private/query.ts +0 -1
  140. package/src/postgres/private/query.ts +0 -1
  141. /package/src/internal/{predicate-atom.ts → predicate/atom.ts} +0 -0
@@ -0,0 +1,515 @@
1
+ import type * as Expression from "../../internal/scalar.js";
2
+ import { postgresDatatypeFamilies, postgresDatatypeKinds } from "./spec.js";
3
+ export declare const postgresDatatypes: {
4
+ custom: <Kind extends string>(kind: Kind) => Expression.DbType.Base<"postgres", Kind>;
5
+ text: () => Expression.DbType.Base<"postgres", "text"> & {
6
+ readonly family: "text";
7
+ readonly runtime: "string";
8
+ readonly compareGroup: "text";
9
+ readonly castTargets: readonly ["text", "numeric", "boolean", "date", "time", "timestamp", "interval", "binary", "uuid", "json", "xml", "bit", "oid", "identifier", "network", "spatial", "textsearch", "range", "multirange", "array", "money", "null"];
10
+ readonly traits: {
11
+ readonly textual: true;
12
+ readonly ordered: true;
13
+ };
14
+ };
15
+ varchar: () => Expression.DbType.Base<"postgres", "varchar"> & {
16
+ readonly family: "text";
17
+ readonly runtime: "string";
18
+ readonly compareGroup: "text";
19
+ readonly castTargets: readonly ["text", "numeric", "boolean", "date", "time", "timestamp", "interval", "binary", "uuid", "json", "xml", "bit", "oid", "identifier", "network", "spatial", "textsearch", "range", "multirange", "array", "money", "null"];
20
+ readonly traits: {
21
+ readonly textual: true;
22
+ readonly ordered: true;
23
+ };
24
+ };
25
+ char: () => Expression.DbType.Base<"postgres", "char"> & {
26
+ readonly family: "text";
27
+ readonly runtime: "string";
28
+ readonly compareGroup: "text";
29
+ readonly castTargets: readonly ["text", "numeric", "boolean", "date", "time", "timestamp", "interval", "binary", "uuid", "json", "xml", "bit", "oid", "identifier", "network", "spatial", "textsearch", "range", "multirange", "array", "money", "null"];
30
+ readonly traits: {
31
+ readonly textual: true;
32
+ readonly ordered: true;
33
+ };
34
+ };
35
+ citext: () => Expression.DbType.Base<"postgres", "citext"> & {
36
+ readonly family: "text";
37
+ readonly runtime: "string";
38
+ readonly compareGroup: "text";
39
+ readonly castTargets: readonly ["text", "numeric", "boolean", "date", "time", "timestamp", "interval", "binary", "uuid", "json", "xml", "bit", "oid", "identifier", "network", "spatial", "textsearch", "range", "multirange", "array", "money", "null"];
40
+ readonly traits: {
41
+ readonly textual: true;
42
+ readonly ordered: true;
43
+ };
44
+ };
45
+ name: () => Expression.DbType.Base<"postgres", "name"> & {
46
+ readonly family: "text";
47
+ readonly runtime: "string";
48
+ readonly compareGroup: "text";
49
+ readonly castTargets: readonly ["text", "numeric", "boolean", "date", "time", "timestamp", "interval", "binary", "uuid", "json", "xml", "bit", "oid", "identifier", "network", "spatial", "textsearch", "range", "multirange", "array", "money", "null"];
50
+ readonly traits: {
51
+ readonly textual: true;
52
+ readonly ordered: true;
53
+ };
54
+ };
55
+ uuid: () => Expression.DbType.Base<"postgres", "uuid"> & {
56
+ readonly family: "uuid";
57
+ readonly runtime: "string";
58
+ readonly compareGroup: "uuid";
59
+ readonly castTargets: readonly ["uuid", "text"];
60
+ readonly traits: {
61
+ readonly ordered: true;
62
+ };
63
+ };
64
+ int2: () => Expression.DbType.Base<"postgres", "int2"> & {
65
+ readonly family: "numeric";
66
+ readonly runtime: "number";
67
+ readonly compareGroup: "numeric";
68
+ readonly castTargets: readonly ["numeric", "text", "boolean", "date", "time", "timestamp", "interval", "uuid", "bit", "oid", "money"];
69
+ readonly traits: {
70
+ readonly ordered: true;
71
+ };
72
+ };
73
+ int4: () => Expression.DbType.Base<"postgres", "int4"> & {
74
+ readonly family: "numeric";
75
+ readonly runtime: "number";
76
+ readonly compareGroup: "numeric";
77
+ readonly castTargets: readonly ["numeric", "text", "boolean", "date", "time", "timestamp", "interval", "uuid", "bit", "oid", "money"];
78
+ readonly traits: {
79
+ readonly ordered: true;
80
+ };
81
+ };
82
+ int8: () => Expression.DbType.Base<"postgres", "int8"> & {
83
+ readonly family: "numeric";
84
+ readonly runtime: "bigintString";
85
+ readonly compareGroup: "numeric";
86
+ readonly castTargets: readonly ["numeric", "text", "boolean", "date", "time", "timestamp", "interval", "uuid", "bit", "oid", "money"];
87
+ readonly traits: {
88
+ readonly ordered: true;
89
+ };
90
+ };
91
+ numeric: () => Expression.DbType.Base<"postgres", "numeric"> & {
92
+ readonly family: "numeric";
93
+ readonly runtime: "decimalString";
94
+ readonly compareGroup: "numeric";
95
+ readonly castTargets: readonly ["numeric", "text", "boolean", "date", "time", "timestamp", "interval", "uuid", "bit", "oid", "money"];
96
+ readonly traits: {
97
+ readonly ordered: true;
98
+ };
99
+ };
100
+ float4: () => Expression.DbType.Base<"postgres", "float4"> & {
101
+ readonly family: "numeric";
102
+ readonly runtime: "number";
103
+ readonly compareGroup: "numeric";
104
+ readonly castTargets: readonly ["numeric", "text", "boolean", "date", "time", "timestamp", "interval", "uuid", "bit", "oid", "money"];
105
+ readonly traits: {
106
+ readonly ordered: true;
107
+ };
108
+ };
109
+ float8: () => Expression.DbType.Base<"postgres", "float8"> & {
110
+ readonly family: "numeric";
111
+ readonly runtime: "number";
112
+ readonly compareGroup: "numeric";
113
+ readonly castTargets: readonly ["numeric", "text", "boolean", "date", "time", "timestamp", "interval", "uuid", "bit", "oid", "money"];
114
+ readonly traits: {
115
+ readonly ordered: true;
116
+ };
117
+ };
118
+ money: () => Expression.DbType.Base<"postgres", "money"> & {
119
+ readonly family: "money";
120
+ readonly runtime: "number";
121
+ readonly compareGroup: "money";
122
+ readonly castTargets: readonly ["money", "text", "numeric"];
123
+ readonly traits: {
124
+ readonly ordered: true;
125
+ };
126
+ };
127
+ bool: () => Expression.DbType.Base<"postgres", "bool"> & {
128
+ readonly family: "boolean";
129
+ readonly runtime: "boolean";
130
+ readonly compareGroup: "boolean";
131
+ readonly castTargets: readonly ["boolean", "text", "numeric"];
132
+ readonly traits: {};
133
+ };
134
+ date: () => Expression.DbType.Base<"postgres", "date"> & {
135
+ readonly family: "date";
136
+ readonly runtime: "localDate";
137
+ readonly compareGroup: "date";
138
+ readonly castTargets: readonly ["date", "timestamp", "text"];
139
+ readonly traits: {
140
+ readonly ordered: true;
141
+ };
142
+ };
143
+ time: () => Expression.DbType.Base<"postgres", "time"> & {
144
+ readonly family: "time";
145
+ readonly runtime: "localTime";
146
+ readonly compareGroup: "time";
147
+ readonly castTargets: readonly ["time", "timestamp", "text"];
148
+ readonly traits: {
149
+ readonly ordered: true;
150
+ };
151
+ };
152
+ timetz: () => Expression.DbType.Base<"postgres", "timetz"> & {
153
+ readonly family: "time";
154
+ readonly runtime: "offsetTime";
155
+ readonly compareGroup: "time";
156
+ readonly castTargets: readonly ["time", "timestamp", "text"];
157
+ readonly traits: {
158
+ readonly ordered: true;
159
+ };
160
+ };
161
+ timestamp: () => Expression.DbType.Base<"postgres", "timestamp"> & {
162
+ readonly family: "timestamp";
163
+ readonly runtime: "localDateTime";
164
+ readonly compareGroup: "timestamp";
165
+ readonly castTargets: readonly ["timestamp", "date", "text"];
166
+ readonly traits: {
167
+ readonly ordered: true;
168
+ };
169
+ };
170
+ timestamptz: () => Expression.DbType.Base<"postgres", "timestamptz"> & {
171
+ readonly family: "timestamp";
172
+ readonly runtime: "instant";
173
+ readonly compareGroup: "timestamp";
174
+ readonly castTargets: readonly ["timestamp", "date", "text"];
175
+ readonly traits: {
176
+ readonly ordered: true;
177
+ };
178
+ };
179
+ interval: () => Expression.DbType.Base<"postgres", "interval"> & {
180
+ readonly family: "interval";
181
+ readonly runtime: "string";
182
+ readonly compareGroup: "interval";
183
+ readonly castTargets: readonly ["interval", "text"];
184
+ readonly traits: {
185
+ readonly ordered: true;
186
+ };
187
+ };
188
+ bytea: () => Expression.DbType.Base<"postgres", "bytea"> & {
189
+ readonly family: "binary";
190
+ readonly runtime: "bytes";
191
+ readonly compareGroup: "binary";
192
+ readonly castTargets: readonly ["binary", "text"];
193
+ readonly traits: {};
194
+ };
195
+ xml: () => Expression.DbType.Base<"postgres", "xml"> & {
196
+ readonly family: "xml";
197
+ readonly runtime: "string";
198
+ readonly compareGroup: "xml";
199
+ readonly castTargets: readonly ["xml", "text"];
200
+ readonly traits: {};
201
+ };
202
+ bit: () => Expression.DbType.Base<"postgres", "bit"> & {
203
+ readonly family: "bit";
204
+ readonly runtime: "string";
205
+ readonly compareGroup: "bit";
206
+ readonly castTargets: readonly ["bit", "text", "numeric"];
207
+ readonly traits: {};
208
+ };
209
+ varbit: () => Expression.DbType.Base<"postgres", "varbit"> & {
210
+ readonly family: "bit";
211
+ readonly runtime: "string";
212
+ readonly compareGroup: "bit";
213
+ readonly castTargets: readonly ["bit", "text", "numeric"];
214
+ readonly traits: {};
215
+ };
216
+ oid: () => Expression.DbType.Base<"postgres", "oid"> & {
217
+ readonly family: "oid";
218
+ readonly runtime: "number";
219
+ readonly compareGroup: "oid";
220
+ readonly castTargets: readonly ["oid", "text", "numeric"];
221
+ readonly traits: {
222
+ readonly ordered: true;
223
+ };
224
+ };
225
+ xid: () => Expression.DbType.Base<"postgres", "xid"> & {
226
+ readonly family: "oid";
227
+ readonly runtime: "number";
228
+ readonly compareGroup: "oid";
229
+ readonly castTargets: readonly ["oid", "text", "numeric"];
230
+ readonly traits: {
231
+ readonly ordered: true;
232
+ };
233
+ };
234
+ xid8: () => Expression.DbType.Base<"postgres", "xid8"> & {
235
+ readonly family: "oid";
236
+ readonly runtime: "bigintString";
237
+ readonly compareGroup: "oid";
238
+ readonly castTargets: readonly ["oid", "text", "numeric"];
239
+ readonly traits: {
240
+ readonly ordered: true;
241
+ };
242
+ };
243
+ cid: () => Expression.DbType.Base<"postgres", "cid"> & {
244
+ readonly family: "oid";
245
+ readonly runtime: "number";
246
+ readonly compareGroup: "oid";
247
+ readonly castTargets: readonly ["oid", "text", "numeric"];
248
+ readonly traits: {
249
+ readonly ordered: true;
250
+ };
251
+ };
252
+ tid: () => Expression.DbType.Base<"postgres", "tid"> & {
253
+ readonly family: "identifier";
254
+ readonly runtime: "string";
255
+ readonly compareGroup: "identifier";
256
+ readonly castTargets: readonly ["identifier", "text"];
257
+ readonly traits: {};
258
+ };
259
+ regclass: () => Expression.DbType.Base<"postgres", "regclass"> & {
260
+ readonly family: "identifier";
261
+ readonly runtime: "string";
262
+ readonly compareGroup: "identifier";
263
+ readonly castTargets: readonly ["identifier", "text"];
264
+ readonly traits: {};
265
+ };
266
+ regtype: () => Expression.DbType.Base<"postgres", "regtype"> & {
267
+ readonly family: "identifier";
268
+ readonly runtime: "string";
269
+ readonly compareGroup: "identifier";
270
+ readonly castTargets: readonly ["identifier", "text"];
271
+ readonly traits: {};
272
+ };
273
+ regproc: () => Expression.DbType.Base<"postgres", "regproc"> & {
274
+ readonly family: "identifier";
275
+ readonly runtime: "string";
276
+ readonly compareGroup: "identifier";
277
+ readonly castTargets: readonly ["identifier", "text"];
278
+ readonly traits: {};
279
+ };
280
+ regprocedure: () => Expression.DbType.Base<"postgres", "regprocedure"> & {
281
+ readonly family: "identifier";
282
+ readonly runtime: "string";
283
+ readonly compareGroup: "identifier";
284
+ readonly castTargets: readonly ["identifier", "text"];
285
+ readonly traits: {};
286
+ };
287
+ regoper: () => Expression.DbType.Base<"postgres", "regoper"> & {
288
+ readonly family: "identifier";
289
+ readonly runtime: "string";
290
+ readonly compareGroup: "identifier";
291
+ readonly castTargets: readonly ["identifier", "text"];
292
+ readonly traits: {};
293
+ };
294
+ regoperator: () => Expression.DbType.Base<"postgres", "regoperator"> & {
295
+ readonly family: "identifier";
296
+ readonly runtime: "string";
297
+ readonly compareGroup: "identifier";
298
+ readonly castTargets: readonly ["identifier", "text"];
299
+ readonly traits: {};
300
+ };
301
+ regconfig: () => Expression.DbType.Base<"postgres", "regconfig"> & {
302
+ readonly family: "identifier";
303
+ readonly runtime: "string";
304
+ readonly compareGroup: "identifier";
305
+ readonly castTargets: readonly ["identifier", "text"];
306
+ readonly traits: {};
307
+ };
308
+ regdictionary: () => Expression.DbType.Base<"postgres", "regdictionary"> & {
309
+ readonly family: "identifier";
310
+ readonly runtime: "string";
311
+ readonly compareGroup: "identifier";
312
+ readonly castTargets: readonly ["identifier", "text"];
313
+ readonly traits: {};
314
+ };
315
+ pg_lsn: () => Expression.DbType.Base<"postgres", "pg_lsn"> & {
316
+ readonly family: "identifier";
317
+ readonly runtime: "string";
318
+ readonly compareGroup: "identifier";
319
+ readonly castTargets: readonly ["identifier", "text"];
320
+ readonly traits: {};
321
+ };
322
+ txid_snapshot: () => Expression.DbType.Base<"postgres", "txid_snapshot"> & {
323
+ readonly family: "identifier";
324
+ readonly runtime: "string";
325
+ readonly compareGroup: "identifier";
326
+ readonly castTargets: readonly ["identifier", "text"];
327
+ readonly traits: {};
328
+ };
329
+ inet: () => Expression.DbType.Base<"postgres", "inet"> & {
330
+ readonly family: "network";
331
+ readonly runtime: "string";
332
+ readonly compareGroup: "network";
333
+ readonly castTargets: readonly ["network", "text"];
334
+ readonly traits: {};
335
+ };
336
+ cidr: () => Expression.DbType.Base<"postgres", "cidr"> & {
337
+ readonly family: "network";
338
+ readonly runtime: "string";
339
+ readonly compareGroup: "network";
340
+ readonly castTargets: readonly ["network", "text"];
341
+ readonly traits: {};
342
+ };
343
+ macaddr: () => Expression.DbType.Base<"postgres", "macaddr"> & {
344
+ readonly family: "network";
345
+ readonly runtime: "string";
346
+ readonly compareGroup: "network";
347
+ readonly castTargets: readonly ["network", "text"];
348
+ readonly traits: {};
349
+ };
350
+ macaddr8: () => Expression.DbType.Base<"postgres", "macaddr8"> & {
351
+ readonly family: "network";
352
+ readonly runtime: "string";
353
+ readonly compareGroup: "network";
354
+ readonly castTargets: readonly ["network", "text"];
355
+ readonly traits: {};
356
+ };
357
+ point: () => Expression.DbType.Base<"postgres", "point"> & {
358
+ readonly family: "spatial";
359
+ readonly runtime: "unknown";
360
+ readonly compareGroup: "spatial";
361
+ readonly castTargets: readonly ["spatial", "text"];
362
+ readonly traits: {};
363
+ };
364
+ line: () => Expression.DbType.Base<"postgres", "line"> & {
365
+ readonly family: "spatial";
366
+ readonly runtime: "unknown";
367
+ readonly compareGroup: "spatial";
368
+ readonly castTargets: readonly ["spatial", "text"];
369
+ readonly traits: {};
370
+ };
371
+ lseg: () => Expression.DbType.Base<"postgres", "lseg"> & {
372
+ readonly family: "spatial";
373
+ readonly runtime: "unknown";
374
+ readonly compareGroup: "spatial";
375
+ readonly castTargets: readonly ["spatial", "text"];
376
+ readonly traits: {};
377
+ };
378
+ box: () => Expression.DbType.Base<"postgres", "box"> & {
379
+ readonly family: "spatial";
380
+ readonly runtime: "unknown";
381
+ readonly compareGroup: "spatial";
382
+ readonly castTargets: readonly ["spatial", "text"];
383
+ readonly traits: {};
384
+ };
385
+ path: () => Expression.DbType.Base<"postgres", "path"> & {
386
+ readonly family: "spatial";
387
+ readonly runtime: "unknown";
388
+ readonly compareGroup: "spatial";
389
+ readonly castTargets: readonly ["spatial", "text"];
390
+ readonly traits: {};
391
+ };
392
+ polygon: () => Expression.DbType.Base<"postgres", "polygon"> & {
393
+ readonly family: "spatial";
394
+ readonly runtime: "unknown";
395
+ readonly compareGroup: "spatial";
396
+ readonly castTargets: readonly ["spatial", "text"];
397
+ readonly traits: {};
398
+ };
399
+ circle: () => Expression.DbType.Base<"postgres", "circle"> & {
400
+ readonly family: "spatial";
401
+ readonly runtime: "unknown";
402
+ readonly compareGroup: "spatial";
403
+ readonly castTargets: readonly ["spatial", "text"];
404
+ readonly traits: {};
405
+ };
406
+ tsvector: () => Expression.DbType.Base<"postgres", "tsvector"> & {
407
+ readonly family: "textsearch";
408
+ readonly runtime: "string";
409
+ readonly compareGroup: "textsearch";
410
+ readonly castTargets: readonly ["textsearch", "text"];
411
+ readonly traits: {};
412
+ };
413
+ tsquery: () => Expression.DbType.Base<"postgres", "tsquery"> & {
414
+ readonly family: "textsearch";
415
+ readonly runtime: "string";
416
+ readonly compareGroup: "textsearch";
417
+ readonly castTargets: readonly ["textsearch", "text"];
418
+ readonly traits: {};
419
+ };
420
+ int4range: () => Expression.DbType.Base<"postgres", "int4range"> & {
421
+ readonly family: "range";
422
+ readonly runtime: "unknown";
423
+ readonly compareGroup: "range";
424
+ readonly castTargets: readonly ["range", "text"];
425
+ readonly traits: {};
426
+ };
427
+ int8range: () => Expression.DbType.Base<"postgres", "int8range"> & {
428
+ readonly family: "range";
429
+ readonly runtime: "unknown";
430
+ readonly compareGroup: "range";
431
+ readonly castTargets: readonly ["range", "text"];
432
+ readonly traits: {};
433
+ };
434
+ numrange: () => Expression.DbType.Base<"postgres", "numrange"> & {
435
+ readonly family: "range";
436
+ readonly runtime: "unknown";
437
+ readonly compareGroup: "range";
438
+ readonly castTargets: readonly ["range", "text"];
439
+ readonly traits: {};
440
+ };
441
+ tsrange: () => Expression.DbType.Base<"postgres", "tsrange"> & {
442
+ readonly family: "range";
443
+ readonly runtime: "unknown";
444
+ readonly compareGroup: "range";
445
+ readonly castTargets: readonly ["range", "text"];
446
+ readonly traits: {};
447
+ };
448
+ tstzrange: () => Expression.DbType.Base<"postgres", "tstzrange"> & {
449
+ readonly family: "range";
450
+ readonly runtime: "unknown";
451
+ readonly compareGroup: "range";
452
+ readonly castTargets: readonly ["range", "text"];
453
+ readonly traits: {};
454
+ };
455
+ daterange: () => Expression.DbType.Base<"postgres", "daterange"> & {
456
+ readonly family: "range";
457
+ readonly runtime: "unknown";
458
+ readonly compareGroup: "range";
459
+ readonly castTargets: readonly ["range", "text"];
460
+ readonly traits: {};
461
+ };
462
+ int4multirange: () => Expression.DbType.Base<"postgres", "int4multirange"> & {
463
+ readonly family: "multirange";
464
+ readonly runtime: "unknown";
465
+ readonly compareGroup: "multirange";
466
+ readonly castTargets: readonly ["multirange", "text"];
467
+ readonly traits: {};
468
+ };
469
+ int8multirange: () => Expression.DbType.Base<"postgres", "int8multirange"> & {
470
+ readonly family: "multirange";
471
+ readonly runtime: "unknown";
472
+ readonly compareGroup: "multirange";
473
+ readonly castTargets: readonly ["multirange", "text"];
474
+ readonly traits: {};
475
+ };
476
+ nummultirange: () => Expression.DbType.Base<"postgres", "nummultirange"> & {
477
+ readonly family: "multirange";
478
+ readonly runtime: "unknown";
479
+ readonly compareGroup: "multirange";
480
+ readonly castTargets: readonly ["multirange", "text"];
481
+ readonly traits: {};
482
+ };
483
+ tsmultirange: () => Expression.DbType.Base<"postgres", "tsmultirange"> & {
484
+ readonly family: "multirange";
485
+ readonly runtime: "unknown";
486
+ readonly compareGroup: "multirange";
487
+ readonly castTargets: readonly ["multirange", "text"];
488
+ readonly traits: {};
489
+ };
490
+ tstzmultirange: () => Expression.DbType.Base<"postgres", "tstzmultirange"> & {
491
+ readonly family: "multirange";
492
+ readonly runtime: "unknown";
493
+ readonly compareGroup: "multirange";
494
+ readonly castTargets: readonly ["multirange", "text"];
495
+ readonly traits: {};
496
+ };
497
+ datemultirange: () => Expression.DbType.Base<"postgres", "datemultirange"> & {
498
+ readonly family: "multirange";
499
+ readonly runtime: "unknown";
500
+ readonly compareGroup: "multirange";
501
+ readonly castTargets: readonly ["multirange", "text"];
502
+ readonly traits: {};
503
+ };
504
+ boolean: () => Expression.DbType.Base<"postgres", "bool"> & {
505
+ readonly family: "boolean";
506
+ readonly runtime: "boolean";
507
+ readonly compareGroup: "boolean";
508
+ readonly castTargets: readonly ["boolean", "text", "numeric"];
509
+ readonly traits: {};
510
+ };
511
+ json: () => Expression.DbType.Json<"postgres", "json">;
512
+ jsonb: () => Expression.DbType.Json<"postgres", "jsonb">;
513
+ };
514
+ export { postgresDatatypeFamilies, postgresDatatypeKinds };
515
+ export type PostgresDatatypeModule = typeof postgresDatatypes;
@@ -1,39 +1,48 @@
1
1
  import type { DatatypeModule } from "../../internal/datatypes/define.js"
2
- import type * as Expression from "../../internal/expression.js"
2
+ import type * as Expression from "../../internal/scalar.js"
3
3
  import { postgresDatatypeFamilies, postgresDatatypeKinds } from "./spec.js"
4
4
 
5
+ const withMetadata = <Kind extends keyof typeof postgresDatatypeKinds & string>(
6
+ kind: Kind
7
+ ): Expression.DbType.Base<"postgres", Kind> => {
8
+ const kindSpec = postgresDatatypeKinds[kind]
9
+ const familySpec = postgresDatatypeFamilies[kindSpec.family as keyof typeof postgresDatatypeFamilies]
10
+ return {
11
+ dialect: "postgres",
12
+ kind,
13
+ family: kindSpec.family,
14
+ runtime: kindSpec.runtime,
15
+ compareGroup: familySpec?.compareGroup,
16
+ castTargets: familySpec?.castTargets,
17
+ traits: familySpec?.traits
18
+ }
19
+ }
20
+
5
21
  const postgresDatatypeModule = {
6
22
  custom: (kind: string) => ({
7
23
  dialect: "postgres",
8
24
  kind
9
25
  }),
10
- boolean: () => ({
11
- dialect: "postgres",
12
- kind: "bool"
13
- })
26
+ boolean: () => withMetadata("bool")
14
27
  } as Record<string, (...args: readonly any[]) => Expression.DbType.Base<"postgres", string>>
15
28
 
16
29
  for (const kind of Object.keys(postgresDatatypeKinds)) {
17
- postgresDatatypeModule[kind] = () => ({
18
- dialect: "postgres",
19
- kind
20
- })
30
+ postgresDatatypeModule[kind] = () => withMetadata(kind as keyof typeof postgresDatatypeKinds & string)
21
31
  }
22
32
 
23
33
  export const postgresDatatypes = {
24
34
  ...(postgresDatatypeModule as DatatypeModule<
25
35
  "postgres",
26
36
  typeof postgresDatatypeKinds,
37
+ typeof postgresDatatypeFamilies,
27
38
  { readonly boolean: "bool" }
28
39
  >),
29
40
  json: (): Expression.DbType.Json<"postgres", "json"> => ({
30
- dialect: "postgres",
31
- kind: "json",
41
+ ...withMetadata("json"),
32
42
  variant: "json"
33
43
  }),
34
44
  jsonb: (): Expression.DbType.Json<"postgres", "jsonb"> => ({
35
- dialect: "postgres",
36
- kind: "jsonb",
45
+ ...withMetadata("jsonb"),
37
46
  variant: "jsonb"
38
47
  })
39
48
  }