effect-qb 0.19.0 → 0.21.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/README.md +7 -1
- package/dist/index.js +1990 -679
- package/dist/mysql.js +1490 -617
- package/dist/postgres/metadata.js +1334 -263
- package/dist/postgres.js +3376 -2307
- package/dist/sqlite.js +1573 -628
- package/dist/standard.js +1984 -673
- package/package.json +3 -6
- package/src/internal/coercion/rules.ts +13 -1
- package/src/internal/column-state.d.ts +3 -3
- package/src/internal/column-state.ts +13 -12
- package/src/internal/column.ts +8 -8
- package/src/internal/datatypes/define.ts +5 -0
- package/src/internal/datatypes/lookup.ts +67 -18
- package/src/internal/datatypes/matrix.ts +903 -0
- package/src/internal/datatypes/shape.ts +2 -0
- package/src/internal/dialect-renderers/mysql.ts +6 -4
- package/src/internal/dialect-renderers/postgres.ts +6 -4
- package/src/internal/dialect-renderers/sqlite.ts +6 -4
- package/src/internal/dialect.ts +1 -1
- package/src/internal/executor.ts +56 -43
- package/src/internal/json/path-access.ts +351 -0
- package/src/internal/query.d.ts +1 -1
- package/src/internal/query.ts +1 -1
- package/src/internal/runtime/driver-value-mapping.ts +3 -3
- package/src/internal/runtime/schema.ts +28 -38
- package/src/internal/runtime/value.ts +20 -23
- package/src/internal/scalar.d.ts +1 -1
- package/src/internal/scalar.ts +2 -1
- package/src/internal/schema-derivation.d.ts +7 -7
- package/src/internal/schema-derivation.ts +11 -11
- package/src/internal/standard-dsl.ts +121 -28
- package/src/internal/table.ts +451 -120
- package/src/mysql/column.ts +6 -6
- package/src/mysql/datatypes/index.ts +1 -0
- package/src/mysql/datatypes/spec.ts +6 -176
- package/src/mysql/errors/normalize.ts +0 -1
- package/src/mysql/executor.ts +4 -6
- package/src/mysql/function/temporal.ts +1 -1
- package/src/mysql/internal/dsl.ts +116 -16
- package/src/mysql/json.ts +1 -33
- package/src/mysql/renderer.ts +13 -6
- package/src/mysql/type.ts +60 -0
- package/src/mysql.ts +3 -1
- package/src/postgres/check.ts +1 -0
- package/src/postgres/column.ts +11 -11
- package/src/postgres/datatypes/index.ts +1 -0
- package/src/postgres/datatypes/spec.ts +6 -260
- package/src/postgres/errors/normalize.ts +0 -1
- package/src/postgres/executor.ts +4 -6
- package/src/postgres/foreign-key.ts +24 -0
- package/src/postgres/function/temporal.ts +1 -1
- package/src/postgres/index.ts +1 -0
- package/src/postgres/internal/dsl.ts +122 -21
- package/src/postgres/json-extension.ts +7 -0
- package/src/postgres/json.ts +726 -173
- package/src/postgres/jsonb.ts +0 -1
- package/src/postgres/primary-key.ts +24 -0
- package/src/postgres/renderer.ts +13 -6
- package/src/postgres/schema-management.ts +1 -6
- package/src/postgres/schema.ts +16 -8
- package/src/postgres/table.ts +111 -113
- package/src/postgres/type.ts +86 -4
- package/src/postgres/unique.ts +32 -0
- package/src/postgres.ts +12 -6
- package/src/sqlite/column.ts +6 -6
- package/src/sqlite/datatypes/index.ts +1 -0
- package/src/sqlite/datatypes/spec.ts +6 -94
- package/src/sqlite/errors/normalize.ts +0 -1
- package/src/sqlite/executor.ts +4 -6
- package/src/sqlite/function/temporal.ts +1 -1
- package/src/sqlite/internal/dsl.ts +100 -5
- package/src/sqlite/json.ts +1 -32
- package/src/sqlite/renderer.ts +13 -6
- package/src/sqlite/type.ts +40 -0
- package/src/sqlite.ts +3 -1
- package/src/standard/cast.ts +113 -0
- package/src/standard/check.ts +17 -0
- package/src/standard/column.ts +10 -10
- package/src/standard/datatypes/index.ts +2 -2
- package/src/standard/datatypes/spec.ts +10 -96
- package/src/standard/foreign-key.ts +37 -0
- package/src/standard/function/temporal.ts +1 -1
- package/src/standard/index.ts +17 -0
- package/src/standard/json.ts +883 -0
- package/src/standard/primary-key.ts +17 -0
- package/src/standard/renderer.ts +31 -3
- package/src/standard/table.ts +25 -21
- package/src/standard/unique.ts +17 -0
- package/src/standard.ts +14 -0
- package/src/internal/table.d.ts +0 -174
- package/src/postgres/cast.ts +0 -45
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "effect-qb",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.21.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -12,8 +12,7 @@
|
|
|
12
12
|
},
|
|
13
13
|
"homepage": "https://github.com/relsunkaev/effect-qb#readme",
|
|
14
14
|
"engines": {
|
|
15
|
-
"node": ">=22"
|
|
16
|
-
"bun": ">=1.3.5"
|
|
15
|
+
"node": ">=22"
|
|
17
16
|
},
|
|
18
17
|
"files": [
|
|
19
18
|
"dist",
|
|
@@ -65,8 +64,6 @@
|
|
|
65
64
|
"pgsql-ast-parser": "^12.0.2"
|
|
66
65
|
},
|
|
67
66
|
"peerDependencies": {
|
|
68
|
-
"
|
|
69
|
-
"@effect/sql": "^0.48.0",
|
|
70
|
-
"effect": "^3.19.3"
|
|
67
|
+
"effect": "4.0.0-beta.98"
|
|
71
68
|
}
|
|
72
69
|
}
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import type * as Expression from "../scalar.js"
|
|
2
|
-
import type {
|
|
2
|
+
import type {
|
|
3
|
+
CanCastDbType as LookupCanCastDbType,
|
|
4
|
+
CanCompareDbTypes as LookupCanCompareDbTypes,
|
|
5
|
+
CanContainDbTypes as LookupCanContainDbTypes,
|
|
6
|
+
CanImplicitlyConvertDbType as LookupCanImplicitlyConvertDbType,
|
|
7
|
+
CanTextuallyCoerceDbType as LookupCanTextuallyCoerceDbType
|
|
8
|
+
} from "../datatypes/lookup.js"
|
|
3
9
|
|
|
4
10
|
export type CanCompareDbTypes<
|
|
5
11
|
Left extends Expression.DbType.Any,
|
|
@@ -18,6 +24,12 @@ export type CanTextuallyCoerceDbType<
|
|
|
18
24
|
Dialect extends string
|
|
19
25
|
> = LookupCanTextuallyCoerceDbType<Db, Dialect>
|
|
20
26
|
|
|
27
|
+
export type CanImplicitlyConvertDbType<
|
|
28
|
+
Source extends Expression.DbType.Any,
|
|
29
|
+
Target extends Expression.DbType.Any,
|
|
30
|
+
Dialect extends string
|
|
31
|
+
> = LookupCanImplicitlyConvertDbType<Source, Target, Dialect>
|
|
32
|
+
|
|
21
33
|
export type CanCastDbType<
|
|
22
34
|
Source extends Expression.DbType.Any,
|
|
23
35
|
Target extends Expression.DbType.Any,
|
|
@@ -70,7 +70,7 @@ export interface ColumnState<Select, Insert, Update, Db extends Expression.DbTyp
|
|
|
70
70
|
export interface ColumnDefinition<Select, Insert, Update, Db extends Expression.DbType.Any, Nullable extends boolean, HasDefault extends boolean, Generated extends boolean, PrimaryKey extends boolean, Unique extends boolean, Ref, Dependencies extends Expression.BindingId = never> extends Pipeable, Expression.Scalar<Select, Db, Nullable extends true ? "maybe" : "never", Db["dialect"], "scalar", Dependencies> {
|
|
71
71
|
readonly pipe: Pipeable["pipe"];
|
|
72
72
|
readonly [ColumnTypeId]: ColumnState<Select, Insert, Update, Db, Nullable, HasDefault, Generated, PrimaryKey, Unique, Ref, Dependencies>;
|
|
73
|
-
readonly schema: Schema.Schema<NonNullable<Select
|
|
73
|
+
readonly schema: Schema.Schema<NonNullable<Select>>;
|
|
74
74
|
readonly metadata: {
|
|
75
75
|
readonly dbType: Db;
|
|
76
76
|
readonly nullable: Nullable;
|
|
@@ -111,7 +111,7 @@ export type AnyColumnDefinition = ColumnDefinition<any, any, any, Expression.DbT
|
|
|
111
111
|
/** Convenience alias for any bound column. */
|
|
112
112
|
export type AnyBoundColumn = BoundColumn<any, any, any, Expression.DbType.Any, boolean, boolean, boolean, boolean, boolean, any, string, string, string>;
|
|
113
113
|
/** Constructs a runtime column-definition object from schema and metadata. */
|
|
114
|
-
export declare const makeColumnDefinition: <Select, Insert, Update, Db extends Expression.DbType.Any, Nullable extends boolean, HasDefault extends boolean, Generated extends boolean, PrimaryKey extends boolean, Unique extends boolean, Ref, Dependencies extends string = never>(schema: Schema.Schema<NonNullable<Select
|
|
114
|
+
export declare const makeColumnDefinition: <Select, Insert, Update, Db extends Expression.DbType.Any, Nullable extends boolean, HasDefault extends boolean, Generated extends boolean, PrimaryKey extends boolean, Unique extends boolean, Ref, Dependencies extends string = never>(schema: Schema.Schema<NonNullable<Select>>, metadata: {
|
|
115
115
|
readonly dbType: Db;
|
|
116
116
|
readonly nullable: Nullable;
|
|
117
117
|
readonly hasDefault: HasDefault;
|
|
@@ -135,7 +135,7 @@ export declare const makeColumnDefinition: <Select, Insert, Update, Db extends E
|
|
|
135
135
|
} | undefined;
|
|
136
136
|
}) => ColumnDefinition<Select, Insert, Update, Db, Nullable, HasDefault, Generated, PrimaryKey, Unique, Ref, Dependencies>;
|
|
137
137
|
export declare const remapColumnDefinition: <Select, Insert, Update, Db extends Expression.DbType.Any, Nullable extends boolean, HasDefault extends boolean, Generated extends boolean, PrimaryKey extends boolean, Unique extends boolean, Ref, Dependencies extends string = never>(column: ColumnDefinition<Select, Insert, Update, Db, Nullable, HasDefault, Generated, PrimaryKey, Unique, Ref, Dependencies>, options?: {
|
|
138
|
-
readonly schema?: Schema.
|
|
138
|
+
readonly schema?: Schema.Top | undefined;
|
|
139
139
|
readonly metadata?: {
|
|
140
140
|
readonly dbType: Db;
|
|
141
141
|
readonly nullable: Nullable;
|
|
@@ -4,6 +4,7 @@ import * as Schema from "effect/Schema"
|
|
|
4
4
|
|
|
5
5
|
import * as Expression from "./scalar.js"
|
|
6
6
|
import * as ExpressionAst from "./expression-ast.js"
|
|
7
|
+
import { withJsonPathAccess, type WithJsonPathAccess } from "./json/path-access.js"
|
|
7
8
|
import type * as Casing from "./casing.js"
|
|
8
9
|
import type * as SchemaExpression from "./schema-expression.js"
|
|
9
10
|
|
|
@@ -124,7 +125,7 @@ export interface ColumnDefinition<
|
|
|
124
125
|
Ref,
|
|
125
126
|
Dependencies
|
|
126
127
|
>
|
|
127
|
-
readonly schema: Schema.Schema<NonNullable<Select
|
|
128
|
+
readonly schema: Schema.Schema<NonNullable<Select>>
|
|
128
129
|
readonly metadata: {
|
|
129
130
|
readonly dbType: Db
|
|
130
131
|
readonly nullable: Nullable
|
|
@@ -259,7 +260,7 @@ export const makeColumnDefinition = <
|
|
|
259
260
|
Ref,
|
|
260
261
|
Dependencies extends Expression.BindingId = never
|
|
261
262
|
>(
|
|
262
|
-
schema: Schema.Schema<NonNullable<Select
|
|
263
|
+
schema: Schema.Schema<NonNullable<Select>>,
|
|
263
264
|
metadata: ColumnDefinition<
|
|
264
265
|
Select,
|
|
265
266
|
Insert,
|
|
@@ -273,7 +274,7 @@ export const makeColumnDefinition = <
|
|
|
273
274
|
Ref,
|
|
274
275
|
Dependencies
|
|
275
276
|
>["metadata"]
|
|
276
|
-
): ColumnDefinition<
|
|
277
|
+
): WithJsonPathAccess<ColumnDefinition<
|
|
277
278
|
Select,
|
|
278
279
|
Insert,
|
|
279
280
|
Update,
|
|
@@ -285,7 +286,7 @@ export const makeColumnDefinition = <
|
|
|
285
286
|
Unique,
|
|
286
287
|
Ref,
|
|
287
288
|
Dependencies
|
|
288
|
-
|
|
289
|
+
>> => {
|
|
289
290
|
const column = attachPipe(Object.create(ColumnProto))
|
|
290
291
|
column.schema = schema
|
|
291
292
|
column.metadata = metadata
|
|
@@ -317,7 +318,7 @@ export const makeColumnDefinition = <
|
|
|
317
318
|
identity: metadata.identity,
|
|
318
319
|
enum: metadata.enum
|
|
319
320
|
}
|
|
320
|
-
return column
|
|
321
|
+
return withJsonPathAccess(column)
|
|
321
322
|
}
|
|
322
323
|
|
|
323
324
|
export const remapColumnDefinition = <
|
|
@@ -347,7 +348,7 @@ export const remapColumnDefinition = <
|
|
|
347
348
|
Dependencies
|
|
348
349
|
>,
|
|
349
350
|
options: {
|
|
350
|
-
readonly schema?: Schema.
|
|
351
|
+
readonly schema?: Schema.Top
|
|
351
352
|
readonly metadata?: ColumnDefinition<
|
|
352
353
|
Select,
|
|
353
354
|
Insert,
|
|
@@ -362,7 +363,7 @@ export const remapColumnDefinition = <
|
|
|
362
363
|
Dependencies
|
|
363
364
|
>["metadata"]
|
|
364
365
|
} = {}
|
|
365
|
-
): ColumnDefinition<
|
|
366
|
+
): WithJsonPathAccess<ColumnDefinition<
|
|
366
367
|
Select,
|
|
367
368
|
Insert,
|
|
368
369
|
Update,
|
|
@@ -374,7 +375,7 @@ export const remapColumnDefinition = <
|
|
|
374
375
|
Unique,
|
|
375
376
|
Ref,
|
|
376
377
|
Dependencies
|
|
377
|
-
|
|
378
|
+
>> => {
|
|
378
379
|
const schema = options.schema ?? column.schema
|
|
379
380
|
const metadata = options.metadata ?? column.metadata
|
|
380
381
|
const next = attachPipe(Object.create(ColumnProto))
|
|
@@ -424,7 +425,7 @@ export const remapColumnDefinition = <
|
|
|
424
425
|
}
|
|
425
426
|
})[BoundColumnTypeId]
|
|
426
427
|
}
|
|
427
|
-
return next
|
|
428
|
+
return withJsonPathAccess(next)
|
|
428
429
|
}
|
|
429
430
|
|
|
430
431
|
/** Attaches table/column provenance to an existing column definition. */
|
|
@@ -474,7 +475,7 @@ export const bindColumn = <
|
|
|
474
475
|
schemaName,
|
|
475
476
|
casing
|
|
476
477
|
}
|
|
477
|
-
return bound
|
|
478
|
+
return withJsonPathAccess(bound) as BoundColumnFrom<Column, TableName, ColumnName, BaseTableName>
|
|
478
479
|
}
|
|
479
480
|
|
|
480
481
|
/** Extracts the internal state record for a column. */
|
|
@@ -513,7 +514,7 @@ export type BoundColumnFrom<
|
|
|
513
514
|
TableName extends string,
|
|
514
515
|
ColumnName extends string,
|
|
515
516
|
BaseTableName extends string = TableName
|
|
516
|
-
> = BoundColumn<
|
|
517
|
+
> = WithJsonPathAccess<BoundColumn<
|
|
517
518
|
Column["metadata"]["brand"] extends true
|
|
518
519
|
? BrandedValue<SelectType<Column>, `${TableName}.${ColumnName}`>
|
|
519
520
|
: SelectType<Column>,
|
|
@@ -533,4 +534,4 @@ export type BoundColumnFrom<
|
|
|
533
534
|
TableName,
|
|
534
535
|
ColumnName,
|
|
535
536
|
BaseTableName
|
|
536
|
-
|
|
537
|
+
>>
|
package/src/internal/column.ts
CHANGED
|
@@ -256,21 +256,21 @@ type NonEmptyIndexMetadataInput<Options> =
|
|
|
256
256
|
|
|
257
257
|
type SchemaCompatibleColumn<
|
|
258
258
|
Column extends AnyColumnDefinition,
|
|
259
|
-
SchemaType extends Schema.
|
|
260
|
-
> = [BaseSelectType<Column>] extends [Schema.
|
|
259
|
+
SchemaType extends Schema.Top
|
|
260
|
+
> = [BaseSelectType<Column>] extends [Schema.Codec.Encoded<SchemaType>]
|
|
261
261
|
? Column
|
|
262
262
|
: never
|
|
263
263
|
|
|
264
264
|
type ColumnSchemaOutput<
|
|
265
265
|
Column extends AnyColumnDefinition,
|
|
266
|
-
SchemaType extends Schema.
|
|
266
|
+
SchemaType extends Schema.Top
|
|
267
267
|
> = IsNullable<Column> extends true
|
|
268
268
|
? Schema.Schema.Type<SchemaType> | null
|
|
269
269
|
: Schema.Schema.Type<SchemaType>
|
|
270
270
|
|
|
271
271
|
type ColumnWithSchema<
|
|
272
272
|
Column extends AnyColumnDefinition,
|
|
273
|
-
SchemaType extends Schema.
|
|
273
|
+
SchemaType extends Schema.Top
|
|
274
274
|
> = ColumnDefinition<
|
|
275
275
|
ColumnSchemaOutput<Column, SchemaType>,
|
|
276
276
|
ColumnSchemaOutput<Column, SchemaType>,
|
|
@@ -407,7 +407,7 @@ const isColumnDefinitionValue = (value: unknown): value is AnyColumnDefinition =
|
|
|
407
407
|
typeof value === "object" && value !== null && ColumnTypeId in value
|
|
408
408
|
|
|
409
409
|
const primitive = <Type, Db extends Expression.DbType.Any>(
|
|
410
|
-
schema: Schema.Schema<Type
|
|
410
|
+
schema: Schema.Schema<Type>,
|
|
411
411
|
dbType: Db
|
|
412
412
|
): ColumnDefinition<Type, Type, Type, Db, false, false, false, false, false, undefined> =>
|
|
413
413
|
makeColumnDefinition(schema as Schema.Schema<NonNullable<Type>>, {
|
|
@@ -432,7 +432,7 @@ type ColumnModule<
|
|
|
432
432
|
JsonKind extends string
|
|
433
433
|
> = {
|
|
434
434
|
readonly custom: <
|
|
435
|
-
SchemaType extends Schema.
|
|
435
|
+
SchemaType extends Schema.Top,
|
|
436
436
|
Db extends Expression.DbType.Any
|
|
437
437
|
>(
|
|
438
438
|
schema: SchemaType,
|
|
@@ -456,7 +456,7 @@ type ColumnModule<
|
|
|
456
456
|
readonly boolean: () => ColumnDefinition<boolean, boolean, boolean, Expression.DbType.Base<Dialect, BooleanKind>, false, false, false, false, false, undefined>
|
|
457
457
|
readonly date: () => ColumnDefinition<LocalDateString, LocalDateString, LocalDateString, Expression.DbType.Base<Dialect, DateKind>, false, false, false, false, false, undefined>
|
|
458
458
|
readonly timestamp: () => ColumnDefinition<LocalDateTimeString, LocalDateTimeString, LocalDateTimeString, Expression.DbType.Base<Dialect, TimestampKind>, false, false, false, false, false, undefined>
|
|
459
|
-
readonly json: <SchemaType extends Schema.
|
|
459
|
+
readonly json: <SchemaType extends Schema.Top>(
|
|
460
460
|
schema: SchemaType
|
|
461
461
|
) => ColumnDefinition<
|
|
462
462
|
Schema.Schema.Type<SchemaType>,
|
|
@@ -473,7 +473,7 @@ type ColumnModule<
|
|
|
473
473
|
}
|
|
474
474
|
|
|
475
475
|
/** Replaces a column's runtime schema while preserving its SQL type metadata. */
|
|
476
|
-
export const schema = <SchemaType extends Schema.
|
|
476
|
+
export const schema = <SchemaType extends Schema.Top>(nextSchema: SchemaType) =>
|
|
477
477
|
<Column extends AnyColumnDefinition>(
|
|
478
478
|
column: SchemaCompatibleColumn<Column, SchemaType>
|
|
479
479
|
): ColumnWithSchema<Column, SchemaType> =>
|
|
@@ -2,6 +2,10 @@ import type * as Expression from "../scalar.js"
|
|
|
2
2
|
import type { NonEmptyStringInput } from "../table-options.js"
|
|
3
3
|
import type { DatatypeFamilySpec, DatatypeKindSpec } from "./shape.js"
|
|
4
4
|
|
|
5
|
+
type ImplicitTargetsOf<Family> = Family extends { readonly implicitTargets: infer Targets extends readonly string[] }
|
|
6
|
+
? Targets
|
|
7
|
+
: readonly []
|
|
8
|
+
|
|
5
9
|
type DatatypeWitness<
|
|
6
10
|
Dialect extends string,
|
|
7
11
|
Kinds extends Record<string, DatatypeKindSpec>,
|
|
@@ -12,6 +16,7 @@ type DatatypeWitness<
|
|
|
12
16
|
readonly runtime: Kinds[Kind]["runtime"]
|
|
13
17
|
readonly compareGroup: Families[Kinds[Kind]["family"]]["compareGroup"]
|
|
14
18
|
readonly castTargets: Families[Kinds[Kind]["family"]]["castTargets"]
|
|
19
|
+
readonly implicitTargets: ImplicitTargetsOf<Families[Kinds[Kind]["family"]]>
|
|
15
20
|
readonly traits: Families[Kinds[Kind]["family"]]["traits"]
|
|
16
21
|
}
|
|
17
22
|
|
|
@@ -27,10 +27,24 @@ 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
|
+
|
|
34
48
|
type DbTypeCompatibleWithDialect<
|
|
35
49
|
Db extends Expression.DbType.Any,
|
|
36
50
|
Dialect extends string
|
|
@@ -106,25 +120,56 @@ export type RuntimeOfDbType<Db extends Expression.DbType.Any> =
|
|
|
106
120
|
: unknown
|
|
107
121
|
: unknown
|
|
108
122
|
|
|
123
|
+
type HaveSameComparableGroup<
|
|
124
|
+
Left extends Expression.DbType.Any,
|
|
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"
|
|
131
|
+
? false
|
|
132
|
+
: CompareGroupOfDbType<Right> extends "null"
|
|
133
|
+
? false
|
|
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
|
|
155
|
+
: false
|
|
156
|
+
: false
|
|
157
|
+
: false
|
|
158
|
+
: false
|
|
159
|
+
|
|
109
160
|
export type CanCompareDbTypes<
|
|
110
161
|
Left extends Expression.DbType.Any,
|
|
111
162
|
Right extends Expression.DbType.Any,
|
|
112
163
|
Dialect extends string
|
|
113
164
|
> = DbTypeCompatibleWithDialect<Left, Dialect> extends true
|
|
114
165
|
? DbTypeCompatibleWithDialect<Right, Dialect> extends true
|
|
115
|
-
?
|
|
116
|
-
?
|
|
117
|
-
:
|
|
118
|
-
?
|
|
119
|
-
:
|
|
120
|
-
?
|
|
121
|
-
:
|
|
122
|
-
? false
|
|
123
|
-
: [CompareGroupOfDbType<Left>] extends [CompareGroupOfDbType<Right>]
|
|
124
|
-
? [CompareGroupOfDbType<Right>] extends [CompareGroupOfDbType<Left>]
|
|
125
|
-
? true
|
|
126
|
-
: false
|
|
127
|
-
: false
|
|
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
|
|
128
173
|
: false
|
|
129
174
|
: false
|
|
130
175
|
|
|
@@ -171,7 +216,11 @@ export type CanCastDbType<
|
|
|
171
216
|
? CanCastDbType<Base, Target, Dialect>
|
|
172
217
|
: Target extends Expression.DbType.Domain<any, infer TargetBase extends Expression.DbType.Any, any>
|
|
173
218
|
? CanCastDbType<Source, TargetBase, Dialect>
|
|
174
|
-
:
|
|
219
|
+
: IsCustomBaseDbType<Source> extends true
|
|
220
|
+
? true
|
|
221
|
+
: IsCustomBaseDbType<Target> extends true
|
|
222
|
+
? true
|
|
223
|
+
: [CompareGroupOfDbType<Source>] extends [CompareGroupOfDbType<Target>]
|
|
175
224
|
? [CompareGroupOfDbType<Target>] extends [CompareGroupOfDbType<Source>]
|
|
176
225
|
? true
|
|
177
226
|
: false
|
|
@@ -185,9 +234,9 @@ export type CanCastDbType<
|
|
|
185
234
|
? true
|
|
186
235
|
: Source extends Expression.DbType.Base<any, any>
|
|
187
236
|
? Target extends Expression.DbType.Base<any, any>
|
|
188
|
-
?
|
|
237
|
+
? FamilyOfDbType<Target> extends ExactKindFamily
|
|
189
238
|
? false
|
|
190
|
-
:
|
|
239
|
+
: FamilyOfDbType<Target> extends BaseCastTargetsOf<Source>
|
|
191
240
|
? true
|
|
192
241
|
: false
|
|
193
242
|
: false
|