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.
- package/dist/mysql.js +61270 -4259
- package/dist/postgres/metadata.js +176 -82
- package/dist/postgres.js +5903 -3316
- package/package.json +14 -1
- package/src/internal/aggregation-validation.ts +3 -3
- package/src/internal/case-analysis.d.ts +18 -0
- package/src/internal/case-analysis.ts +4 -4
- package/src/internal/coercion/analysis.d.ts +7 -0
- package/src/internal/{coercion-analysis.ts → coercion/analysis.ts} +3 -3
- package/src/internal/coercion/errors.d.ts +17 -0
- package/src/internal/{coercion-errors.ts → coercion/errors.ts} +1 -1
- package/src/internal/coercion/kind.d.ts +4 -0
- package/src/internal/{coercion-kind.ts → coercion/kind.ts} +2 -2
- package/src/internal/{coercion-normalize.ts → coercion/normalize.ts} +1 -1
- package/src/internal/coercion/rules.d.ts +6 -0
- package/src/internal/{coercion-rules.ts → coercion/rules.ts} +2 -2
- package/src/internal/column-state.d.ts +190 -0
- package/src/internal/column-state.ts +36 -47
- package/src/internal/column.ts +21 -305
- package/src/internal/datatypes/define.d.ts +17 -0
- package/src/internal/datatypes/define.ts +18 -4
- package/src/internal/datatypes/lookup.d.ts +44 -0
- package/src/internal/datatypes/lookup.ts +61 -152
- package/src/internal/datatypes/shape.d.ts +16 -0
- package/src/internal/datatypes/shape.ts +1 -1
- package/src/internal/derived-table.d.ts +4 -0
- package/src/internal/derived-table.ts +21 -16
- package/src/internal/dsl-mutation-runtime.ts +378 -0
- package/src/internal/dsl-plan-runtime.ts +387 -0
- package/src/internal/dsl-query-runtime.ts +160 -0
- package/src/internal/dsl-transaction-ddl-runtime.ts +263 -0
- package/src/internal/executor.ts +132 -31
- package/src/internal/expression-ast.ts +15 -5
- package/src/internal/grouping-key.d.ts +3 -0
- package/src/internal/grouping-key.ts +1 -1
- package/src/internal/implication-runtime.d.ts +15 -0
- package/src/internal/implication-runtime.ts +4 -4
- package/src/internal/json/ast.d.ts +30 -0
- package/src/internal/json/ast.ts +1 -1
- package/src/internal/json/errors.d.ts +8 -0
- package/src/internal/json/path.d.ts +75 -0
- package/src/internal/json/path.ts +1 -1
- package/src/internal/json/types.d.ts +62 -0
- package/src/internal/predicate/analysis.d.ts +20 -0
- package/src/internal/{predicate-analysis.ts → predicate/analysis.ts} +3 -3
- package/src/internal/predicate/atom.d.ts +28 -0
- package/src/internal/{predicate-branches.ts → predicate/branches.ts} +2 -2
- package/src/internal/predicate/context.d.ts +67 -0
- package/src/internal/{predicate-context.ts → predicate/context.ts} +8 -5
- package/src/internal/predicate/formula.d.ts +35 -0
- package/src/internal/{predicate-formula.ts → predicate/formula.ts} +1 -1
- package/src/internal/predicate/key.d.ts +11 -0
- package/src/internal/{predicate-key.ts → predicate/key.ts} +2 -2
- package/src/internal/{predicate-nnf.ts → predicate/nnf.ts} +2 -2
- package/src/internal/predicate/normalize.d.ts +53 -0
- package/src/internal/{predicate-normalize.ts → predicate/normalize.ts} +19 -19
- package/src/internal/predicate/runtime.d.ts +31 -0
- package/src/internal/{predicate-runtime.ts → predicate/runtime.ts} +9 -6
- package/src/internal/projection-alias.d.ts +13 -0
- package/src/internal/projections.d.ts +31 -0
- package/src/internal/projections.ts +1 -1
- package/src/internal/query-ast.d.ts +217 -0
- package/src/internal/query-ast.ts +1 -1
- package/src/internal/query-requirements.d.ts +20 -0
- package/src/internal/query.d.ts +775 -0
- package/src/internal/query.ts +389 -313
- package/src/internal/renderer.ts +7 -21
- package/src/internal/row-set.d.ts +53 -0
- package/src/internal/{plan.ts → row-set.ts} +11 -9
- package/src/internal/{runtime-normalize.ts → runtime/normalize.ts} +9 -31
- package/src/internal/{runtime-schema.ts → runtime/schema.ts} +13 -38
- package/src/internal/runtime/value.d.ts +22 -0
- package/src/internal/{runtime-value.ts → runtime/value.ts} +2 -2
- package/src/internal/scalar.d.ts +107 -0
- package/src/internal/scalar.ts +191 -0
- package/src/internal/schema-derivation.d.ts +105 -0
- package/src/internal/schema-expression.d.ts +18 -0
- package/src/internal/schema-expression.ts +38 -7
- package/src/internal/table-options.d.ts +94 -0
- package/src/internal/table-options.ts +8 -2
- package/src/internal/table.d.ts +173 -0
- package/src/internal/table.ts +32 -14
- package/src/mysql/column.ts +94 -18
- package/src/mysql/datatypes/index.ts +47 -7
- package/src/mysql/errors/generated.ts +57336 -0
- package/src/mysql/errors/index.ts +1 -0
- package/src/mysql/errors/normalize.ts +55 -53
- package/src/mysql/errors/types.ts +74 -0
- package/src/mysql/executor.ts +69 -7
- package/src/mysql/function/aggregate.ts +1 -5
- package/src/mysql/function/core.ts +1 -4
- package/src/mysql/function/index.ts +0 -1
- package/src/mysql/function/string.ts +1 -5
- package/src/mysql/function/temporal.ts +12 -15
- package/src/mysql/function/window.ts +1 -6
- package/src/{internal/mysql-dialect.ts → mysql/internal/dialect.ts} +1 -1
- package/src/{internal/mysql-query.ts → mysql/internal/dsl.ts} +1024 -2082
- package/src/{internal/mysql-renderer.ts → mysql/internal/renderer.ts} +6 -6
- package/src/mysql/internal/sql-expression-renderer.ts +1455 -0
- package/src/mysql/json.ts +2 -0
- package/src/mysql/query.ts +111 -91
- package/src/mysql/renderer.ts +1 -1
- package/src/mysql/table.ts +1 -1
- package/src/mysql.ts +6 -4
- package/src/postgres/cast.ts +11 -12
- package/src/postgres/column.ts +178 -46
- package/src/postgres/datatypes/index.d.ts +515 -0
- package/src/postgres/datatypes/index.ts +22 -13
- package/src/postgres/datatypes/spec.d.ts +412 -0
- package/src/postgres/errors/generated.ts +2636 -0
- package/src/postgres/errors/index.ts +1 -0
- package/src/postgres/errors/normalize.ts +47 -62
- package/src/postgres/errors/types.ts +92 -34
- package/src/postgres/executor.ts +37 -5
- package/src/postgres/function/aggregate.ts +1 -5
- package/src/postgres/function/core.ts +12 -6
- package/src/postgres/function/index.ts +0 -1
- package/src/postgres/function/string.ts +1 -5
- package/src/postgres/function/temporal.ts +12 -15
- package/src/postgres/function/window.ts +1 -6
- package/src/{internal/postgres-dialect.ts → postgres/internal/dialect.ts} +1 -1
- package/src/{internal/postgres-query.ts → postgres/internal/dsl.ts} +1085 -2089
- package/src/{internal/postgres-renderer.ts → postgres/internal/renderer.ts} +6 -6
- package/src/postgres/internal/schema-ddl.ts +108 -0
- package/src/{internal/postgres-schema-model.ts → postgres/internal/schema-model.ts} +12 -6
- package/src/{internal → postgres/internal}/sql-expression-renderer.ts +19 -17
- package/src/postgres/{function/json.ts → json.ts} +77 -85
- package/src/postgres/metadata.ts +2 -2
- package/src/postgres/query.ts +113 -89
- package/src/postgres/renderer.ts +3 -13
- package/src/postgres/schema-expression.ts +2 -1
- package/src/postgres/schema-management.ts +1 -1
- package/src/postgres/table.ts +12 -4
- package/src/postgres/type.ts +29 -2
- package/src/postgres.ts +6 -4
- package/src/internal/expression.ts +0 -327
- package/src/internal/schema-ddl.ts +0 -55
- package/src/mysql/function/json.ts +0 -4
- package/src/mysql/private/query.ts +0 -1
- package/src/postgres/private/query.ts +0 -1
- /package/src/internal/{predicate-atom.ts → predicate/atom.ts} +0 -0
|
@@ -1,32 +1,6 @@
|
|
|
1
|
-
import type * as Expression from "
|
|
2
|
-
import type { mysqlDatatypeFamilies, mysqlDatatypeKinds } from "../../mysql/datatypes/spec.js"
|
|
3
|
-
import type { postgresDatatypeFamilies, postgresDatatypeKinds } from "../../postgres/datatypes/spec.js"
|
|
1
|
+
import type * as Expression from "../scalar.js"
|
|
4
2
|
import type { RuntimeOfTag, RuntimeTag } from "./shape.js"
|
|
5
3
|
|
|
6
|
-
type KnownDialect = "postgres" | "mysql"
|
|
7
|
-
|
|
8
|
-
type DialectKinds<Dialect extends KnownDialect> =
|
|
9
|
-
Dialect extends "postgres" ? typeof postgresDatatypeKinds :
|
|
10
|
-
typeof mysqlDatatypeKinds
|
|
11
|
-
|
|
12
|
-
type DialectFamilies<Dialect extends KnownDialect> =
|
|
13
|
-
Dialect extends "postgres" ? typeof postgresDatatypeFamilies :
|
|
14
|
-
typeof mysqlDatatypeFamilies
|
|
15
|
-
|
|
16
|
-
type StripParameterizedKind<Kind extends string> =
|
|
17
|
-
Kind extends `${infer Base}(${string}`
|
|
18
|
-
? StripParameterizedKind<Base>
|
|
19
|
-
: Kind
|
|
20
|
-
|
|
21
|
-
type StripArrayKind<Kind extends string> =
|
|
22
|
-
Kind extends `${infer Base}[]`
|
|
23
|
-
? StripArrayKind<Base>
|
|
24
|
-
: Kind
|
|
25
|
-
|
|
26
|
-
type BaseKind<Kind extends string> = StripArrayKind<StripParameterizedKind<Kind>>
|
|
27
|
-
|
|
28
|
-
type IsArrayKind<Kind extends string> = Kind extends `${string}[]` ? true : false
|
|
29
|
-
|
|
30
4
|
type ExactKindFamily =
|
|
31
5
|
| "array"
|
|
32
6
|
| "range"
|
|
@@ -35,101 +9,55 @@ type ExactKindFamily =
|
|
|
35
9
|
| "enum"
|
|
36
10
|
| "set"
|
|
37
11
|
|
|
38
|
-
type
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
: `other:${Dialect}:${Kind}`
|
|
12
|
+
type BaseFamilyOf<Db extends Expression.DbType.Base<any, any>> =
|
|
13
|
+
Db extends { readonly family?: infer Family extends string }
|
|
14
|
+
? Family
|
|
15
|
+
: Db["kind"] extends "null"
|
|
16
|
+
? "null"
|
|
17
|
+
: `other:${Db["dialect"]}:${Db["kind"]}`
|
|
18
|
+
|
|
19
|
+
type BaseRuntimeTagOf<Db extends Expression.DbType.Base<any, any>> =
|
|
20
|
+
Db extends { readonly runtime?: infer Runtime extends RuntimeTag }
|
|
21
|
+
? Runtime
|
|
22
|
+
: "unknown"
|
|
50
23
|
|
|
51
|
-
type
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
? "array"
|
|
56
|
-
: BaseKind<Kind> extends "null"
|
|
57
|
-
? "null"
|
|
58
|
-
: BaseKind<Kind> extends keyof DialectKinds<Dialect>
|
|
59
|
-
? DialectKinds<Dialect>[BaseKind<Kind>] extends { readonly runtime: infer Runtime extends RuntimeTag }
|
|
60
|
-
? Runtime
|
|
61
|
-
: "unknown"
|
|
62
|
-
: "unknown"
|
|
24
|
+
type BaseCompareGroupOf<Db extends Expression.DbType.Base<any, any>> =
|
|
25
|
+
Db extends { readonly compareGroup?: infer CompareGroup extends string }
|
|
26
|
+
? CompareGroup
|
|
27
|
+
: BaseFamilyOf<Db>
|
|
63
28
|
|
|
64
|
-
type
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
> = Family extends keyof DialectFamilies<Dialect>
|
|
68
|
-
? DialectFamilies<Dialect>[Family] extends { readonly castTargets: readonly (infer CastTarget extends string)[] }
|
|
69
|
-
? CastTarget
|
|
29
|
+
type BaseCastTargetsOf<Db extends Expression.DbType.Base<any, any>> =
|
|
30
|
+
Db extends { readonly castTargets?: readonly (infer Target extends string)[] }
|
|
31
|
+
? Target
|
|
70
32
|
: never
|
|
71
|
-
: never
|
|
72
33
|
|
|
73
|
-
type
|
|
74
|
-
|
|
75
|
-
Family extends string
|
|
76
|
-
> = Family extends keyof DialectFamilies<Dialect>
|
|
77
|
-
? DialectFamilies<Dialect>[Family] extends { readonly traits: infer Traits }
|
|
34
|
+
type BaseHasTextualTrait<Db extends Expression.DbType.Base<any, any>> =
|
|
35
|
+
Db extends { readonly traits?: infer Traits }
|
|
78
36
|
? Traits extends { readonly textual: true }
|
|
79
37
|
? true
|
|
80
38
|
: false
|
|
81
39
|
: false
|
|
82
|
-
: false
|
|
83
|
-
|
|
84
|
-
type BaseFamilyOf<
|
|
85
|
-
Dialect extends KnownDialect,
|
|
86
|
-
Kind extends string
|
|
87
|
-
> = Kind extends keyof DialectKinds<Dialect>
|
|
88
|
-
? DialectKinds<Dialect>[Kind] extends { readonly family: infer Family extends string }
|
|
89
|
-
? Family
|
|
90
|
-
: never
|
|
91
|
-
: `other:${Dialect}:${Kind}`
|
|
92
|
-
|
|
93
|
-
type BaseRuntimeTagOf<
|
|
94
|
-
Dialect extends KnownDialect,
|
|
95
|
-
Kind extends string
|
|
96
|
-
> = Kind extends keyof DialectKinds<Dialect>
|
|
97
|
-
? DialectKinds<Dialect>[Kind] extends { readonly runtime: infer Runtime extends RuntimeTag }
|
|
98
|
-
? Runtime
|
|
99
|
-
: "unknown"
|
|
100
|
-
: "unknown"
|
|
101
|
-
|
|
102
|
-
type BaseCompareGroupOf<
|
|
103
|
-
Dialect extends KnownDialect,
|
|
104
|
-
Kind extends string
|
|
105
|
-
> = BaseFamilyOf<Dialect, Kind> extends ExactKindFamily
|
|
106
|
-
? Kind
|
|
107
|
-
: BaseFamilyOf<Dialect, Kind> extends keyof DialectFamilies<Dialect>
|
|
108
|
-
? DialectFamilies<Dialect>[BaseFamilyOf<Dialect, Kind>] extends { readonly compareGroup: infer CompareGroup extends string }
|
|
109
|
-
? CompareGroup
|
|
110
|
-
: never
|
|
111
|
-
: BaseFamilyOf<Dialect, Kind>
|
|
112
40
|
|
|
113
41
|
export type FamilyOfDbType<Db extends Expression.DbType.Any> =
|
|
114
42
|
Db extends Expression.DbType.Domain<any, infer Base extends Expression.DbType.Any, any>
|
|
115
43
|
? FamilyOfDbType<Base>
|
|
116
44
|
: Db extends Expression.DbType.Array<any, any, any>
|
|
117
45
|
? "array"
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
46
|
+
: Db extends Expression.DbType.Range<any, any, any>
|
|
47
|
+
? "range"
|
|
48
|
+
: Db extends Expression.DbType.Multirange<any, any, any>
|
|
49
|
+
? "multirange"
|
|
50
|
+
: Db extends Expression.DbType.Composite<any, any, any>
|
|
51
|
+
? "record"
|
|
52
|
+
: Db extends Expression.DbType.Enum<any, any>
|
|
53
|
+
? "enum"
|
|
54
|
+
: Db extends Expression.DbType.Set<any, any>
|
|
55
|
+
? "set"
|
|
56
|
+
: Db extends Expression.DbType.Json<any, any>
|
|
57
|
+
? "json"
|
|
58
|
+
: Db extends Expression.DbType.Base<any, any>
|
|
59
|
+
? BaseFamilyOf<Db>
|
|
60
|
+
: "other:unknown:unknown"
|
|
133
61
|
|
|
134
62
|
export type CompareGroupOfDbType<Db extends Expression.DbType.Any> =
|
|
135
63
|
Db extends Expression.DbType.Domain<any, infer Base extends Expression.DbType.Any, any>
|
|
@@ -140,17 +68,17 @@ export type CompareGroupOfDbType<Db extends Expression.DbType.Any> =
|
|
|
140
68
|
? Kind
|
|
141
69
|
: Db extends Expression.DbType.Multirange<any, any, infer Kind extends string>
|
|
142
70
|
? Kind
|
|
143
|
-
|
|
71
|
+
: Db extends Expression.DbType.Composite<any, any, infer Kind extends string>
|
|
144
72
|
? Kind
|
|
145
73
|
: Db extends Expression.DbType.Enum<any, infer Kind extends string>
|
|
146
74
|
? Kind
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
75
|
+
: Db extends Expression.DbType.Set<any, infer Kind extends string>
|
|
76
|
+
? Kind
|
|
77
|
+
: Db extends Expression.DbType.Json<any, any>
|
|
78
|
+
? never
|
|
79
|
+
: Db extends Expression.DbType.Base<any, any>
|
|
80
|
+
? BaseCompareGroupOf<Db>
|
|
81
|
+
: "other:unknown:unknown"
|
|
154
82
|
|
|
155
83
|
export type RuntimeOfDbType<Db extends Expression.DbType.Any> =
|
|
156
84
|
Db extends Expression.DbType.Domain<any, infer Base extends Expression.DbType.Any, any>
|
|
@@ -159,17 +87,17 @@ export type RuntimeOfDbType<Db extends Expression.DbType.Any> =
|
|
|
159
87
|
? ReadonlyArray<RuntimeOfDbType<Element>>
|
|
160
88
|
: Db extends Expression.DbType.Composite<any, infer Fields extends Record<string, Expression.DbType.Any>, any>
|
|
161
89
|
? { readonly [K in keyof Fields]: RuntimeOfDbType<Fields[K]> }
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
90
|
+
: Db extends Expression.DbType.Range<any, any, any> | Expression.DbType.Multirange<any, any, any>
|
|
91
|
+
? unknown
|
|
92
|
+
: Db extends Expression.DbType.Json<any, any>
|
|
93
|
+
? import("../runtime/value.js").JsonValue
|
|
166
94
|
: Db extends Expression.DbType.Enum<any, any> | Expression.DbType.Set<any, any>
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
95
|
+
? string
|
|
96
|
+
: Db extends Expression.DbType.Base<any, any>
|
|
97
|
+
? BaseRuntimeTagOf<Db> extends infer Runtime extends RuntimeTag
|
|
98
|
+
? RuntimeOfTag<Runtime>
|
|
99
|
+
: unknown
|
|
171
100
|
: unknown
|
|
172
|
-
: unknown
|
|
173
101
|
|
|
174
102
|
export type CanCompareDbTypes<
|
|
175
103
|
Left extends Expression.DbType.Any,
|
|
@@ -221,12 +149,8 @@ export type CanTextuallyCoerceDbType<
|
|
|
221
149
|
? true
|
|
222
150
|
: Db extends Expression.DbType.Json<any, any>
|
|
223
151
|
? false
|
|
224
|
-
: Db extends Expression.DbType.Base<
|
|
225
|
-
?
|
|
226
|
-
? FamilyHasTextualTrait<D, BaseFamilyOf<D, Kind>> extends true
|
|
227
|
-
? true
|
|
228
|
-
: false
|
|
229
|
-
: false
|
|
152
|
+
: Db extends Expression.DbType.Base<any, any>
|
|
153
|
+
? BaseHasTextualTrait<Db>
|
|
230
154
|
: false
|
|
231
155
|
: false
|
|
232
156
|
|
|
@@ -252,29 +176,14 @@ export type CanCastDbType<
|
|
|
252
176
|
| Expression.DbType.Enum<any, any>
|
|
253
177
|
| Expression.DbType.Set<any, any>
|
|
254
178
|
? true
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
?
|
|
261
|
-
? BaseFamilyOf<SourceDialect, TargetKind> extends "text"
|
|
262
|
-
? FamilyCastTargets<SourceDialect, Extract<BaseFamilyOf<SourceDialect, SourceKind>, string>> extends infer Targets extends string
|
|
263
|
-
? "text" extends Targets
|
|
264
|
-
? true
|
|
265
|
-
: false
|
|
266
|
-
: false
|
|
267
|
-
: false
|
|
268
|
-
: BaseFamilyOf<SourceDialect, TargetKind> extends FamilyCastTargets<
|
|
269
|
-
SourceDialect,
|
|
270
|
-
Extract<BaseFamilyOf<SourceDialect, SourceKind>, string>
|
|
271
|
-
>
|
|
272
|
-
? true
|
|
273
|
-
: false
|
|
179
|
+
: Source extends Expression.DbType.Base<any, any>
|
|
180
|
+
? Target extends Expression.DbType.Base<any, any>
|
|
181
|
+
? BaseFamilyOf<Target> extends ExactKindFamily
|
|
182
|
+
? false
|
|
183
|
+
: BaseFamilyOf<Target> extends BaseCastTargetsOf<Source>
|
|
184
|
+
? true
|
|
274
185
|
: false
|
|
275
|
-
: false
|
|
276
186
|
: false
|
|
277
187
|
: false
|
|
278
|
-
: false
|
|
279
188
|
: false
|
|
280
189
|
: false
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { BigIntString, DecimalString, InstantString, JsonValue, LocalDateString, LocalDateTimeString, LocalTimeString, OffsetTimeString, YearString } from "../runtime/value.js";
|
|
2
|
+
export type RuntimeTag = "string" | "number" | "bigintString" | "boolean" | "json" | "localDate" | "localTime" | "offsetTime" | "localDateTime" | "instant" | "year" | "decimalString" | "bytes" | "array" | "record" | "unknown" | "null";
|
|
3
|
+
export type RuntimeOfTag<Tag extends RuntimeTag> = Tag extends "string" ? string : Tag extends "number" ? number : Tag extends "bigintString" ? BigIntString : Tag extends "boolean" ? boolean : Tag extends "json" ? JsonValue : Tag extends "localDate" ? LocalDateString : Tag extends "localTime" ? LocalTimeString : Tag extends "offsetTime" ? OffsetTimeString : Tag extends "localDateTime" ? LocalDateTimeString : Tag extends "instant" ? InstantString : Tag extends "year" ? YearString : Tag extends "decimalString" ? DecimalString : Tag extends "bytes" ? Uint8Array : Tag extends "array" ? ReadonlyArray<unknown> : Tag extends "record" ? Record<string, unknown> : Tag extends "null" ? null : unknown;
|
|
4
|
+
export interface DatatypeTraits {
|
|
5
|
+
readonly textual?: true;
|
|
6
|
+
readonly ordered?: true;
|
|
7
|
+
}
|
|
8
|
+
export interface DatatypeFamilySpec<CompareGroup extends string = string, CastTargets extends readonly string[] = readonly string[], Traits extends DatatypeTraits = DatatypeTraits> {
|
|
9
|
+
readonly compareGroup: CompareGroup;
|
|
10
|
+
readonly castTargets: CastTargets;
|
|
11
|
+
readonly traits: Traits;
|
|
12
|
+
}
|
|
13
|
+
export interface DatatypeKindSpec<Family extends string = string, Runtime extends RuntimeTag = RuntimeTag> {
|
|
14
|
+
readonly family: Family;
|
|
15
|
+
readonly runtime: Runtime;
|
|
16
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type CompletePlan, type CteSource, type DerivedSource, type LateralSource, type QueryPlan } from "./query.js";
|
|
2
|
+
export declare const makeDerivedSource: <PlanValue extends QueryPlan<any, any, any, any, any, any, any, any, any, any>, Alias extends string>(plan: CompletePlan<PlanValue>, alias: Alias) => DerivedSource<PlanValue, Alias>;
|
|
3
|
+
export declare const makeCteSource: <PlanValue extends QueryPlan<any, any, any, any, any, any, any, any, any, any>, Alias extends string>(plan: CompletePlan<PlanValue>, alias: Alias, recursive?: boolean) => CteSource<PlanValue, Alias>;
|
|
4
|
+
export declare const makeLateralSource: <PlanValue extends QueryPlan<any, any, any, any, any, any, any, any, any, any>, Alias extends string>(plan: PlanValue, alias: Alias) => LateralSource<PlanValue, Alias>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { pipeArguments } from "effect/Pipeable"
|
|
2
2
|
|
|
3
|
-
import * as Expression from "./
|
|
4
|
-
import * as Plan from "./
|
|
3
|
+
import * as Expression from "./scalar.js"
|
|
4
|
+
import * as Plan from "./row-set.js"
|
|
5
5
|
import {
|
|
6
6
|
type CompletePlan,
|
|
7
7
|
type CteSource,
|
|
@@ -22,6 +22,17 @@ const DerivedProto = {
|
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
+
const attachPipe = <Value extends object>(value: Value): Value => {
|
|
26
|
+
Object.defineProperty(value, "pipe", {
|
|
27
|
+
configurable: true,
|
|
28
|
+
writable: true,
|
|
29
|
+
value: function(this: unknown) {
|
|
30
|
+
return pipeArguments(value, arguments)
|
|
31
|
+
}
|
|
32
|
+
})
|
|
33
|
+
return value
|
|
34
|
+
}
|
|
35
|
+
|
|
25
36
|
const setPath = (
|
|
26
37
|
target: Record<string, unknown>,
|
|
27
38
|
path: readonly string[],
|
|
@@ -45,7 +56,7 @@ const setPath = (
|
|
|
45
56
|
const pathAlias = (path: readonly string[]): string => path.join("__")
|
|
46
57
|
|
|
47
58
|
const reboundedColumns = <
|
|
48
|
-
PlanValue extends QueryPlan<any, any, any, any, any, any, any, any, any>,
|
|
59
|
+
PlanValue extends QueryPlan<any, any, any, any, any, any, any, any, any, any>,
|
|
49
60
|
Alias extends string
|
|
50
61
|
>(
|
|
51
62
|
plan: PlanValue,
|
|
@@ -67,13 +78,7 @@ const reboundedColumns = <
|
|
|
67
78
|
runtimeSchema: expression[Expression.TypeId].runtimeSchema,
|
|
68
79
|
nullability: expression[Expression.TypeId].nullability,
|
|
69
80
|
dialect: expression[Expression.TypeId].dialect,
|
|
70
|
-
|
|
71
|
-
source: {
|
|
72
|
-
tableName: alias,
|
|
73
|
-
columnName: projection.alias,
|
|
74
|
-
baseTableName: alias
|
|
75
|
-
},
|
|
76
|
-
sourceNullability: "propagate" as const,
|
|
81
|
+
kind: "scalar",
|
|
77
82
|
dependencies: {
|
|
78
83
|
[alias]: true
|
|
79
84
|
} as Record<Alias, true>
|
|
@@ -87,14 +92,14 @@ const reboundedColumns = <
|
|
|
87
92
|
}
|
|
88
93
|
|
|
89
94
|
export const makeDerivedSource = <
|
|
90
|
-
PlanValue extends QueryPlan<any, any, any, any, any, any, any, any, any>,
|
|
95
|
+
PlanValue extends QueryPlan<any, any, any, any, any, any, any, any, any, any>,
|
|
91
96
|
Alias extends string
|
|
92
97
|
>(
|
|
93
98
|
plan: CompletePlan<PlanValue>,
|
|
94
99
|
alias: Alias
|
|
95
100
|
): DerivedSource<PlanValue, Alias> => {
|
|
96
101
|
const columns = reboundedColumns(plan, alias)
|
|
97
|
-
const derived = Object.create(DerivedProto) as Record<string, unknown>
|
|
102
|
+
const derived = attachPipe(Object.create(DerivedProto)) as Record<string, unknown>
|
|
98
103
|
Object.assign(derived, columns)
|
|
99
104
|
derived.kind = "derived"
|
|
100
105
|
derived.name = alias
|
|
@@ -107,7 +112,7 @@ export const makeDerivedSource = <
|
|
|
107
112
|
}
|
|
108
113
|
|
|
109
114
|
export const makeCteSource = <
|
|
110
|
-
PlanValue extends QueryPlan<any, any, any, any, any, any, any, any, any>,
|
|
115
|
+
PlanValue extends QueryPlan<any, any, any, any, any, any, any, any, any, any>,
|
|
111
116
|
Alias extends string
|
|
112
117
|
>(
|
|
113
118
|
plan: CompletePlan<PlanValue>,
|
|
@@ -115,7 +120,7 @@ export const makeCteSource = <
|
|
|
115
120
|
recursive = false
|
|
116
121
|
): CteSource<PlanValue, Alias> => {
|
|
117
122
|
const columns = reboundedColumns(plan, alias)
|
|
118
|
-
const cte = Object.create(DerivedProto) as Record<string, unknown>
|
|
123
|
+
const cte = attachPipe(Object.create(DerivedProto)) as Record<string, unknown>
|
|
119
124
|
Object.assign(cte, columns)
|
|
120
125
|
cte.kind = "cte"
|
|
121
126
|
cte.name = alias
|
|
@@ -129,14 +134,14 @@ export const makeCteSource = <
|
|
|
129
134
|
}
|
|
130
135
|
|
|
131
136
|
export const makeLateralSource = <
|
|
132
|
-
PlanValue extends QueryPlan<any, any, any, any, any, any, any, any, any>,
|
|
137
|
+
PlanValue extends QueryPlan<any, any, any, any, any, any, any, any, any, any>,
|
|
133
138
|
Alias extends string
|
|
134
139
|
>(
|
|
135
140
|
plan: PlanValue,
|
|
136
141
|
alias: Alias
|
|
137
142
|
): LateralSource<PlanValue, Alias> => {
|
|
138
143
|
const columns = reboundedColumns(plan, alias)
|
|
139
|
-
const lateral = Object.create(DerivedProto) as Record<string, unknown>
|
|
144
|
+
const lateral = attachPipe(Object.create(DerivedProto)) as Record<string, unknown>
|
|
140
145
|
Object.assign(lateral, columns)
|
|
141
146
|
lateral.kind = "lateral"
|
|
142
147
|
lateral.name = alias
|