effect-qb 4.0.0-beta.66 → 4.0.0-beta.98
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/README.md +5 -2
- package/dist/index.js +9376 -0
- package/dist/mysql.js +3921 -2573
- package/dist/postgres/metadata.js +2491 -1373
- package/dist/postgres.js +5453 -5155
- package/dist/sqlite.js +6895 -5529
- package/dist/standard.js +9330 -0
- package/package.json +9 -2
- package/src/casing.ts +71 -0
- package/src/index.ts +2 -0
- package/src/internal/casing.ts +89 -0
- package/src/internal/coercion/rules.ts +13 -1
- package/src/internal/column-state.ts +21 -15
- package/src/internal/column.ts +44 -7
- package/src/internal/datatypes/define.ts +7 -1
- package/src/internal/datatypes/enrich.ts +23 -0
- package/src/internal/datatypes/lookup.ts +81 -25
- package/src/internal/datatypes/matrix.ts +903 -0
- package/src/internal/datatypes/shape.ts +2 -0
- package/src/internal/derived-table.ts +4 -36
- package/src/{mysql/internal/sql-expression-renderer.ts → internal/dialect-renderers/mysql.ts} +552 -361
- package/src/{postgres/internal/sql-expression-renderer.ts → internal/dialect-renderers/postgres.ts} +657 -400
- package/src/{sqlite/internal/sql-expression-renderer.ts → internal/dialect-renderers/sqlite.ts} +505 -347
- package/src/internal/dialect.ts +35 -0
- package/src/internal/dsl-mutation-runtime.ts +12 -162
- package/src/internal/dsl-plan-runtime.ts +10 -138
- package/src/internal/dsl-query-runtime.ts +5 -79
- package/src/internal/dsl-transaction-ddl-runtime.ts +41 -65
- package/src/internal/executor.ts +14 -16
- package/src/internal/grouping-key.ts +87 -20
- package/src/internal/implication-runtime.ts +1 -1
- package/src/internal/json/path-access.ts +351 -0
- package/src/internal/predicate/runtime.ts +3 -0
- package/src/internal/query.d.ts +38 -11
- package/src/internal/query.ts +64 -25
- package/src/internal/renderer.ts +26 -14
- package/src/internal/runtime/normalize.ts +12 -5
- package/src/internal/scalar.ts +7 -1
- package/src/internal/schema-derivation.d.ts +7 -7
- package/src/internal/schema-derivation.ts +9 -9
- package/src/internal/schema-expression.ts +2 -2
- package/src/internal/sql-expression-renderer.ts +19 -0
- package/src/internal/standard-dsl.ts +6978 -0
- package/src/internal/table-options.ts +126 -66
- package/src/internal/table.ts +652 -219
- package/src/mysql/column-extension.ts +3 -0
- package/src/mysql/column.ts +8 -9
- package/src/mysql/datatypes/index.ts +4 -2
- package/src/mysql/datatypes/spec.ts +6 -176
- package/src/mysql/errors/normalize.ts +0 -1
- package/src/mysql/executor.ts +7 -7
- package/src/mysql/internal/dialect.ts +9 -4
- package/src/mysql/internal/dsl.ts +312 -154
- package/src/mysql/internal/renderer.ts +6 -2
- package/src/mysql/json.ts +7 -2
- package/src/mysql/query-extension.ts +16 -0
- package/src/mysql/renderer.ts +37 -3
- package/src/mysql/type.ts +60 -0
- package/src/mysql.ts +7 -13
- package/src/postgres/check.ts +1 -0
- package/src/postgres/column-extension.ts +28 -0
- package/src/postgres/column.ts +2 -8
- package/src/postgres/datatypes/index.d.ts +2 -1
- package/src/postgres/datatypes/index.ts +4 -2
- package/src/postgres/datatypes/spec.ts +6 -260
- package/src/postgres/errors/normalize.ts +0 -1
- package/src/postgres/executor.ts +7 -7
- package/src/postgres/foreign-key.ts +24 -0
- package/src/postgres/function/core.ts +1 -3
- package/src/postgres/function/index.ts +1 -17
- package/src/postgres/index.ts +1 -0
- package/src/postgres/internal/dialect.ts +9 -4
- package/src/postgres/internal/dsl.ts +306 -163
- package/src/postgres/internal/renderer.ts +6 -2
- package/src/postgres/internal/schema-ddl.ts +22 -10
- package/src/postgres/internal/schema-model.ts +238 -7
- package/src/postgres/json-extension.ts +7 -0
- package/src/postgres/json.ts +762 -173
- package/src/postgres/jsonb.ts +37 -0
- package/src/postgres/primary-key.ts +24 -0
- package/src/postgres/query-extension.ts +2 -0
- package/src/postgres/renderer.ts +37 -3
- package/src/postgres/schema-management.ts +12 -11
- package/src/postgres/schema.ts +106 -15
- package/src/postgres/table.ts +205 -530
- package/src/postgres/type.ts +93 -10
- package/src/postgres/unique.ts +32 -0
- package/src/postgres.ts +20 -16
- package/src/sqlite/column-extension.ts +3 -0
- package/src/sqlite/column.ts +8 -9
- package/src/sqlite/datatypes/index.ts +4 -2
- package/src/sqlite/datatypes/spec.ts +6 -94
- package/src/sqlite/errors/normalize.ts +0 -1
- package/src/sqlite/executor.ts +7 -7
- package/src/sqlite/internal/dialect.ts +9 -4
- package/src/sqlite/internal/dsl.ts +301 -154
- package/src/sqlite/internal/renderer.ts +6 -2
- package/src/sqlite/json.ts +8 -2
- package/src/sqlite/query-extension.ts +2 -0
- package/src/sqlite/renderer.ts +37 -3
- package/src/sqlite/type.ts +40 -0
- package/src/sqlite.ts +7 -13
- package/src/standard/cast.ts +113 -0
- package/src/standard/check.ts +17 -0
- package/src/standard/column.ts +163 -0
- package/src/standard/datatypes/index.ts +83 -0
- package/src/standard/datatypes/spec.ts +12 -0
- package/src/standard/dialect.ts +40 -0
- package/src/standard/foreign-key.ts +37 -0
- package/src/standard/function/aggregate.ts +2 -0
- package/src/standard/function/core.ts +2 -0
- package/src/standard/function/index.ts +18 -0
- package/src/standard/function/string.ts +2 -0
- package/src/standard/function/temporal.ts +78 -0
- package/src/standard/function/window.ts +2 -0
- package/src/standard/index.ts +17 -0
- package/src/standard/internal/renderer.ts +45 -0
- package/src/standard/json.ts +883 -0
- package/src/standard/primary-key.ts +17 -0
- package/src/standard/query.ts +152 -0
- package/src/standard/renderer.ts +49 -0
- package/src/standard/table.ts +151 -0
- package/src/standard/unique.ts +17 -0
- package/src/standard.ts +32 -0
- package/src/internal/aggregation-validation.ts +0 -57
- package/src/internal/table.d.ts +0 -180
- package/src/mysql/table.ts +0 -186
- package/src/postgres/cast.ts +0 -45
- package/src/sqlite/table.ts +0 -175
|
@@ -27,10 +27,31 @@ type BaseCompareGroupOf<Db extends Expression.DbType.Base<any, any>> =
|
|
|
27
27
|
: BaseFamilyOf<Db>
|
|
28
28
|
|
|
29
29
|
type BaseCastTargetsOf<Db extends Expression.DbType.Base<any, any>> =
|
|
30
|
-
Db extends { readonly castTargets
|
|
31
|
-
?
|
|
30
|
+
Db extends { readonly castTargets: infer Targets extends readonly string[] }
|
|
31
|
+
? Targets[number]
|
|
32
32
|
: never
|
|
33
33
|
|
|
34
|
+
type BaseImplicitTargetsOf<Db extends Expression.DbType.Base<any, any>> =
|
|
35
|
+
Db extends { readonly implicitTargets: infer Targets extends readonly string[] }
|
|
36
|
+
? Targets[number]
|
|
37
|
+
: never
|
|
38
|
+
|
|
39
|
+
type IsCustomBaseDbType<Db extends Expression.DbType.Any> =
|
|
40
|
+
Db extends Expression.DbType.Json<any, any>
|
|
41
|
+
? false
|
|
42
|
+
: Db extends Expression.DbType.Base<any, any>
|
|
43
|
+
? Db extends { readonly family: string }
|
|
44
|
+
? false
|
|
45
|
+
: true
|
|
46
|
+
: false
|
|
47
|
+
|
|
48
|
+
type DbTypeCompatibleWithDialect<
|
|
49
|
+
Db extends Expression.DbType.Any,
|
|
50
|
+
Dialect extends string
|
|
51
|
+
> = Dialect extends "standard"
|
|
52
|
+
? Db extends { readonly dialect: string } ? true : false
|
|
53
|
+
: Db extends { readonly dialect: Dialect | "standard" } ? true : false
|
|
54
|
+
|
|
34
55
|
type BaseHasTextualTrait<Db extends Expression.DbType.Base<any, any>> =
|
|
35
56
|
Db extends { readonly traits?: infer Traits }
|
|
36
57
|
? Traits extends { readonly textual: true }
|
|
@@ -99,25 +120,56 @@ export type RuntimeOfDbType<Db extends Expression.DbType.Any> =
|
|
|
99
120
|
: unknown
|
|
100
121
|
: unknown
|
|
101
122
|
|
|
102
|
-
|
|
123
|
+
type HaveSameComparableGroup<
|
|
103
124
|
Left extends Expression.DbType.Any,
|
|
104
|
-
Right extends Expression.DbType.Any
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
?
|
|
125
|
+
Right extends Expression.DbType.Any
|
|
126
|
+
> = CompareGroupOfDbType<Left> extends never
|
|
127
|
+
? false
|
|
128
|
+
: CompareGroupOfDbType<Right> extends never
|
|
129
|
+
? false
|
|
130
|
+
: CompareGroupOfDbType<Left> extends "null"
|
|
109
131
|
? false
|
|
110
|
-
: CompareGroupOfDbType<Right> extends
|
|
132
|
+
: CompareGroupOfDbType<Right> extends "null"
|
|
111
133
|
? false
|
|
112
|
-
: CompareGroupOfDbType<Left> extends
|
|
113
|
-
?
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
134
|
+
: [CompareGroupOfDbType<Left>] extends [CompareGroupOfDbType<Right>]
|
|
135
|
+
? [CompareGroupOfDbType<Right>] extends [CompareGroupOfDbType<Left>]
|
|
136
|
+
? true
|
|
137
|
+
: false
|
|
138
|
+
: false
|
|
139
|
+
|
|
140
|
+
export type CanImplicitlyConvertDbType<
|
|
141
|
+
Source extends Expression.DbType.Any,
|
|
142
|
+
Target extends Expression.DbType.Any,
|
|
143
|
+
Dialect extends string
|
|
144
|
+
> = DbTypeCompatibleWithDialect<Source, Dialect> extends true
|
|
145
|
+
? DbTypeCompatibleWithDialect<Target, Dialect> extends true
|
|
146
|
+
? Source extends Expression.DbType.Domain<any, infer Base extends Expression.DbType.Any, any>
|
|
147
|
+
? CanImplicitlyConvertDbType<Base, Target, Dialect>
|
|
148
|
+
: Target extends Expression.DbType.Domain<any, infer TargetBase extends Expression.DbType.Any, any>
|
|
149
|
+
? CanImplicitlyConvertDbType<Source, TargetBase, Dialect>
|
|
150
|
+
: HaveSameComparableGroup<Source, Target> extends true
|
|
151
|
+
? true
|
|
152
|
+
: Source extends Expression.DbType.Base<any, any>
|
|
153
|
+
? FamilyOfDbType<Target> extends BaseImplicitTargetsOf<Source>
|
|
154
|
+
? true
|
|
120
155
|
: false
|
|
156
|
+
: false
|
|
157
|
+
: false
|
|
158
|
+
: false
|
|
159
|
+
|
|
160
|
+
export type CanCompareDbTypes<
|
|
161
|
+
Left extends Expression.DbType.Any,
|
|
162
|
+
Right extends Expression.DbType.Any,
|
|
163
|
+
Dialect extends string
|
|
164
|
+
> = DbTypeCompatibleWithDialect<Left, Dialect> extends true
|
|
165
|
+
? DbTypeCompatibleWithDialect<Right, Dialect> extends true
|
|
166
|
+
? HaveSameComparableGroup<Left, Right> extends true
|
|
167
|
+
? true
|
|
168
|
+
: CanImplicitlyConvertDbType<Left, Right, Dialect> extends true
|
|
169
|
+
? true
|
|
170
|
+
: CanImplicitlyConvertDbType<Right, Left, Dialect> extends true
|
|
171
|
+
? true
|
|
172
|
+
: false
|
|
121
173
|
: false
|
|
122
174
|
: false
|
|
123
175
|
|
|
@@ -125,8 +177,8 @@ export type CanContainDbTypes<
|
|
|
125
177
|
Left extends Expression.DbType.Any,
|
|
126
178
|
Right extends Expression.DbType.Any,
|
|
127
179
|
Dialect extends string
|
|
128
|
-
> = Left extends
|
|
129
|
-
? Right extends
|
|
180
|
+
> = DbTypeCompatibleWithDialect<Left, Dialect> extends true
|
|
181
|
+
? DbTypeCompatibleWithDialect<Right, Dialect> extends true
|
|
130
182
|
? FamilyOfDbType<Left> extends "array" | "range" | "multirange"
|
|
131
183
|
? FamilyOfDbType<Right> extends "array" | "range" | "multirange"
|
|
132
184
|
? [CompareGroupOfDbType<Left>] extends [CompareGroupOfDbType<Right>]
|
|
@@ -142,7 +194,7 @@ export type CanContainDbTypes<
|
|
|
142
194
|
export type CanTextuallyCoerceDbType<
|
|
143
195
|
Db extends Expression.DbType.Any,
|
|
144
196
|
Dialect extends string
|
|
145
|
-
> = Db extends
|
|
197
|
+
> = DbTypeCompatibleWithDialect<Db, Dialect> extends true
|
|
146
198
|
? Db extends Expression.DbType.Domain<any, infer Base extends Expression.DbType.Any, any>
|
|
147
199
|
? CanTextuallyCoerceDbType<Base, Dialect>
|
|
148
200
|
: Db extends Expression.DbType.Enum<any, any> | Expression.DbType.Set<any, any>
|
|
@@ -158,13 +210,17 @@ export type CanCastDbType<
|
|
|
158
210
|
Source extends Expression.DbType.Any,
|
|
159
211
|
Target extends Expression.DbType.Any,
|
|
160
212
|
Dialect extends string
|
|
161
|
-
> = Source extends
|
|
162
|
-
? Target extends
|
|
213
|
+
> = DbTypeCompatibleWithDialect<Source, Dialect> extends true
|
|
214
|
+
? DbTypeCompatibleWithDialect<Target, Dialect> extends true
|
|
163
215
|
? Source extends Expression.DbType.Domain<any, infer Base extends Expression.DbType.Any, any>
|
|
164
216
|
? CanCastDbType<Base, Target, Dialect>
|
|
165
217
|
: Target extends Expression.DbType.Domain<any, infer TargetBase extends Expression.DbType.Any, any>
|
|
166
218
|
? CanCastDbType<Source, TargetBase, Dialect>
|
|
167
|
-
:
|
|
219
|
+
: IsCustomBaseDbType<Source> extends true
|
|
220
|
+
? true
|
|
221
|
+
: IsCustomBaseDbType<Target> extends true
|
|
222
|
+
? true
|
|
223
|
+
: [CompareGroupOfDbType<Source>] extends [CompareGroupOfDbType<Target>]
|
|
168
224
|
? [CompareGroupOfDbType<Target>] extends [CompareGroupOfDbType<Source>]
|
|
169
225
|
? true
|
|
170
226
|
: false
|
|
@@ -178,9 +234,9 @@ export type CanCastDbType<
|
|
|
178
234
|
? true
|
|
179
235
|
: Source extends Expression.DbType.Base<any, any>
|
|
180
236
|
? Target extends Expression.DbType.Base<any, any>
|
|
181
|
-
?
|
|
237
|
+
? FamilyOfDbType<Target> extends ExactKindFamily
|
|
182
238
|
? false
|
|
183
|
-
:
|
|
239
|
+
: FamilyOfDbType<Target> extends BaseCastTargetsOf<Source>
|
|
184
240
|
? true
|
|
185
241
|
: false
|
|
186
242
|
: false
|