effect-qb 0.16.0 → 4.0.0-beta.66
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 -0
- package/dist/mysql.js +1858 -715
- package/dist/postgres/metadata.js +2036 -172
- package/dist/postgres.js +8011 -6849
- package/dist/sqlite.js +8433 -0
- package/package.json +7 -4
- package/src/internal/column-state.d.ts +3 -3
- package/src/internal/column-state.ts +3 -3
- package/src/internal/column.ts +8 -8
- package/src/internal/derived-table.ts +29 -3
- package/src/internal/dialect.ts +3 -1
- package/src/internal/dsl-mutation-runtime.ts +173 -4
- package/src/internal/dsl-plan-runtime.ts +165 -20
- package/src/internal/dsl-query-runtime.ts +60 -6
- package/src/internal/dsl-transaction-ddl-runtime.ts +72 -2
- package/src/internal/executor.ts +100 -43
- package/src/internal/expression-ast.ts +3 -2
- package/src/internal/grouping-key.ts +141 -1
- package/src/internal/implication-runtime.ts +2 -1
- package/src/internal/json/types.ts +155 -40
- package/src/internal/predicate/context.ts +14 -1
- package/src/internal/predicate/key.ts +19 -2
- package/src/internal/predicate/runtime.ts +27 -3
- package/src/internal/query.d.ts +1 -1
- package/src/internal/query.ts +253 -31
- package/src/internal/renderer.ts +35 -2
- package/src/internal/runtime/driver-value-mapping.ts +60 -2
- package/src/internal/runtime/normalize.ts +62 -38
- package/src/internal/runtime/schema.ts +32 -40
- package/src/internal/runtime/value.ts +159 -39
- package/src/internal/scalar.d.ts +1 -1
- package/src/internal/scalar.ts +1 -1
- package/src/internal/schema-derivation.d.ts +12 -61
- package/src/internal/schema-derivation.ts +95 -43
- package/src/internal/table-options.ts +108 -1
- package/src/internal/table.d.ts +29 -22
- package/src/internal/table.ts +260 -53
- package/src/mysql/column.ts +24 -8
- package/src/mysql/datatypes/index.ts +21 -0
- package/src/mysql/errors/catalog.ts +5 -5
- package/src/mysql/errors/normalize.ts +2 -2
- package/src/mysql/executor.ts +4 -4
- package/src/mysql/function/temporal.ts +1 -1
- package/src/mysql/internal/dsl.ts +759 -235
- package/src/mysql/internal/renderer.ts +2 -1
- package/src/mysql/internal/sql-expression-renderer.ts +486 -130
- package/src/mysql/query.ts +9 -2
- package/src/mysql/table.ts +64 -35
- package/src/postgres/column.ts +14 -12
- package/src/postgres/errors/normalize.ts +2 -2
- package/src/postgres/executor.ts +52 -9
- package/src/postgres/function/core.ts +19 -1
- package/src/postgres/function/temporal.ts +1 -1
- package/src/postgres/internal/dsl.ts +705 -256
- package/src/postgres/internal/renderer.ts +2 -1
- package/src/postgres/internal/schema-ddl.ts +2 -1
- package/src/postgres/internal/schema-model.ts +6 -3
- package/src/postgres/internal/sql-expression-renderer.ts +420 -91
- package/src/postgres/json.ts +57 -17
- package/src/postgres/query.ts +9 -2
- package/src/postgres/schema-management.ts +92 -6
- package/src/postgres/schema.ts +1 -1
- package/src/postgres/table.ts +203 -75
- package/src/sqlite/column.ts +128 -0
- package/src/sqlite/datatypes/index.ts +79 -0
- package/src/sqlite/datatypes/spec.ts +98 -0
- package/src/sqlite/errors/catalog.ts +103 -0
- package/src/sqlite/errors/fields.ts +19 -0
- package/src/sqlite/errors/index.ts +19 -0
- package/src/sqlite/errors/normalize.ts +229 -0
- package/src/sqlite/errors/requirements.ts +71 -0
- package/src/sqlite/errors/types.ts +29 -0
- package/src/sqlite/executor.ts +227 -0
- package/src/sqlite/function/aggregate.ts +2 -0
- package/src/sqlite/function/core.ts +2 -0
- package/src/sqlite/function/index.ts +19 -0
- package/src/sqlite/function/string.ts +2 -0
- package/src/sqlite/function/temporal.ts +100 -0
- package/src/sqlite/function/window.ts +2 -0
- package/src/sqlite/internal/dialect.ts +37 -0
- package/src/sqlite/internal/dsl.ts +6927 -0
- package/src/sqlite/internal/renderer.ts +47 -0
- package/src/sqlite/internal/sql-expression-renderer.ts +1821 -0
- package/src/sqlite/json.ts +2 -0
- package/src/sqlite/query.ts +196 -0
- package/src/sqlite/renderer.ts +24 -0
- package/src/sqlite/table.ts +175 -0
- package/src/sqlite.ts +22 -0
|
@@ -9,6 +9,7 @@ import * as Table from "../../internal/table.js"
|
|
|
9
9
|
import type { CastTargetError, OperandCompatibilityError } from "../../internal/coercion/errors.js"
|
|
10
10
|
import type { RuntimeOfDbType } from "../../internal/coercion/analysis.js"
|
|
11
11
|
import type { CanCastDbType, CanCompareDbTypes, CanContainDbTypes, CanTextuallyCoerceDbType } from "../../internal/coercion/rules.js"
|
|
12
|
+
import { normalizeDbValue } from "../../internal/runtime/normalize.js"
|
|
12
13
|
import {
|
|
13
14
|
currentRequiredList,
|
|
14
15
|
extractRequiredRuntime,
|
|
@@ -30,11 +31,15 @@ import {
|
|
|
30
31
|
type AssumptionsOfPlan,
|
|
31
32
|
type AvailableOfPlan,
|
|
32
33
|
type CapabilitiesOfPlan,
|
|
34
|
+
type CommonSetFacts,
|
|
33
35
|
type DialectCompatibleNestedPlan,
|
|
34
36
|
type DependenciesOf,
|
|
35
37
|
type DependencyRecord,
|
|
36
38
|
type DialectOf,
|
|
37
39
|
type DerivedSelectionOf,
|
|
40
|
+
type DerivedTableCompatiblePlan,
|
|
41
|
+
type LateralSourceCompatiblePlan,
|
|
42
|
+
type DerivedSourceCompatiblePlan,
|
|
38
43
|
type DerivedSource,
|
|
39
44
|
type CompletePlan,
|
|
40
45
|
type ExpressionInput,
|
|
@@ -75,10 +80,8 @@ import {
|
|
|
75
80
|
type TableDialectOf,
|
|
76
81
|
type StatementOfPlan,
|
|
77
82
|
type MutationInputOf,
|
|
78
|
-
type MutationTargetLike,
|
|
79
83
|
type MutationTargetOfPlan,
|
|
80
84
|
type MergeCapabilities,
|
|
81
|
-
type MutationTargetInput,
|
|
82
85
|
type MutationValuesInput,
|
|
83
86
|
type SourceDialectOf,
|
|
84
87
|
type SourceLike,
|
|
@@ -95,7 +98,6 @@ import {
|
|
|
95
98
|
type TableLike,
|
|
96
99
|
type UpdateInputOfTarget,
|
|
97
100
|
type MutationTargetNamesOf,
|
|
98
|
-
type MutationTargetTuple,
|
|
99
101
|
type TupleDependencies,
|
|
100
102
|
type TupleDialect,
|
|
101
103
|
type ResultRow
|
|
@@ -133,6 +135,10 @@ import * as ProjectionAlias from "../../internal/projection-alias.js"
|
|
|
133
135
|
import * as QueryAst from "../../internal/query-ast.js"
|
|
134
136
|
import { normalizeColumnList } from "../../internal/table-options.js"
|
|
135
137
|
|
|
138
|
+
type MutationTargetLike = Table.AnyTable<Dialect>
|
|
139
|
+
type MutationTargetTuple = readonly [MutationTargetLike, MutationTargetLike, ...MutationTargetLike[]]
|
|
140
|
+
type MutationTargetInput = MutationTargetLike | MutationTargetTuple
|
|
141
|
+
|
|
136
142
|
/**
|
|
137
143
|
* Dialect-specific DB type profile used to specialize the shared query
|
|
138
144
|
* operator surface.
|
|
@@ -217,6 +223,13 @@ type DialectAsExpression<
|
|
|
217
223
|
? Value
|
|
218
224
|
: DialectLiteralExpression<Extract<Value, LiteralValue>, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>
|
|
219
225
|
|
|
226
|
+
type ProjectionAliasedExpression<
|
|
227
|
+
Value extends Expression.Any,
|
|
228
|
+
Alias extends string
|
|
229
|
+
> = Value & {
|
|
230
|
+
readonly [ProjectionAlias.TypeId]: ProjectionAlias.State<Alias>
|
|
231
|
+
}
|
|
232
|
+
|
|
220
233
|
/** Normalizes a generic string-capable input into the expression form used internally. */
|
|
221
234
|
type DialectAsStringExpression<
|
|
222
235
|
Value extends ExpressionInput,
|
|
@@ -690,6 +703,21 @@ type DialectOfDialectNumericInput<
|
|
|
690
703
|
NullDb extends Expression.DbType.Any
|
|
691
704
|
> = DialectOf<DialectAsNumericExpression<Value, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>>
|
|
692
705
|
|
|
706
|
+
type NumericExpressionDialectInput<
|
|
707
|
+
Value extends NumericExpressionInput,
|
|
708
|
+
Dialect extends string,
|
|
709
|
+
TextDb extends Expression.DbType.Any,
|
|
710
|
+
NumericDb extends Expression.DbType.Any,
|
|
711
|
+
BoolDb extends Expression.DbType.Any,
|
|
712
|
+
TimestampDb extends Expression.DbType.Any,
|
|
713
|
+
NullDb extends Expression.DbType.Any
|
|
714
|
+
> = Exclude<DialectOfDialectNumericInput<Value, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>, Dialect> extends never
|
|
715
|
+
? unknown
|
|
716
|
+
: {
|
|
717
|
+
readonly __effect_qb_error__: "effect-qb: numeric expressions cannot mix dialects"
|
|
718
|
+
readonly __effect_qb_dialect__: DialectOfDialectNumericInput<Value, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>
|
|
719
|
+
}
|
|
720
|
+
|
|
693
721
|
/** Dependency map carried by a numeric-clause input after coercion. */
|
|
694
722
|
type DependenciesOfDialectNumericInput<
|
|
695
723
|
Value extends NumericExpressionInput,
|
|
@@ -1073,6 +1101,16 @@ type JsonSetOutputOf<
|
|
|
1073
1101
|
? JsonSetAtPath<Root, JsonPath.Path<[Target]>, Next, Operation>
|
|
1074
1102
|
: never
|
|
1075
1103
|
|
|
1104
|
+
type JsonSetOutputWithCreateMissing<
|
|
1105
|
+
Root,
|
|
1106
|
+
Target extends JsonPathInput,
|
|
1107
|
+
Next,
|
|
1108
|
+
Operation extends string,
|
|
1109
|
+
CreateMissing extends boolean
|
|
1110
|
+
> = false extends CreateMissing
|
|
1111
|
+
? Root | JsonSetOutputOf<Root, Target, Next, Operation>
|
|
1112
|
+
: JsonSetOutputOf<Root, Target, Next, Operation>
|
|
1113
|
+
|
|
1076
1114
|
type JsonInsertOutputOf<
|
|
1077
1115
|
Root,
|
|
1078
1116
|
Target extends JsonPathInput,
|
|
@@ -1085,6 +1123,27 @@ type JsonInsertOutputOf<
|
|
|
1085
1123
|
? JsonInsertAtPath<Root, JsonPath.Path<[Target]>, Next, InsertAfter, Operation>
|
|
1086
1124
|
: never
|
|
1087
1125
|
|
|
1126
|
+
type MySqlJsonLengthResult<Value> =
|
|
1127
|
+
JsonLengthResult<Value> extends null ? number : JsonLengthResult<Value>
|
|
1128
|
+
|
|
1129
|
+
type MySqlJsonTypeName<Value> =
|
|
1130
|
+
JsonTypeName<Value> extends "object" ? "OBJECT" :
|
|
1131
|
+
JsonTypeName<Value> extends "array" ? "ARRAY" :
|
|
1132
|
+
JsonTypeName<Value> extends "string" ? "STRING" :
|
|
1133
|
+
JsonTypeName<Value> extends "number" ? "INTEGER" | "DOUBLE" | "DECIMAL" :
|
|
1134
|
+
JsonTypeName<Value> extends "boolean" ? "BOOLEAN" :
|
|
1135
|
+
JsonTypeName<Value> extends "null" ? "NULL" :
|
|
1136
|
+
JsonTypeName<Value>
|
|
1137
|
+
|
|
1138
|
+
type MySqlUnsupportedJsonFeatureUsageError<Feature extends string> = {
|
|
1139
|
+
readonly __effect_qb_error__: "effect-qb: unsupported mysql json feature"
|
|
1140
|
+
readonly __effect_qb_json_feature__: Feature
|
|
1141
|
+
}
|
|
1142
|
+
|
|
1143
|
+
type MySqlUnsupportedJsonFeature<Feature extends string> = (
|
|
1144
|
+
feature: MySqlUnsupportedJsonFeatureUsageError<Feature>
|
|
1145
|
+
) => never
|
|
1146
|
+
|
|
1088
1147
|
type JsonPathGuard<
|
|
1089
1148
|
Root,
|
|
1090
1149
|
Target extends JsonPathInput,
|
|
@@ -1475,11 +1534,11 @@ const profile: QueryDialectProfile<Dialect, TextDb, NumericDb, BoolDb, Timestamp
|
|
|
1475
1534
|
|
|
1476
1535
|
const literalSchemaOf = <Value extends LiteralValue>(
|
|
1477
1536
|
value: Value
|
|
1478
|
-
): Schema.
|
|
1537
|
+
): Schema.Top | undefined => {
|
|
1479
1538
|
if (value === null || value instanceof Date) {
|
|
1480
1539
|
return undefined
|
|
1481
1540
|
}
|
|
1482
|
-
return Schema.Literal(value) as unknown as Schema.
|
|
1541
|
+
return Schema.Literal(value) as unknown as Schema.Top
|
|
1483
1542
|
}
|
|
1484
1543
|
|
|
1485
1544
|
const literal = <const Value extends LiteralValue>(
|
|
@@ -1686,10 +1745,16 @@ const profile: QueryDialectProfile<Dialect, TextDb, NumericDb, BoolDb, Timestamp
|
|
|
1686
1745
|
spec: WindowSpecInput<PartitionBy, OrderBy> | OrderedWindowSpecInput<PartitionBy, Extract<OrderBy, NonEmptyWindowOrderTerms>> | undefined
|
|
1687
1746
|
) => {
|
|
1688
1747
|
const partitionBy = [...(spec?.partitionBy ?? [])] as unknown as PartitionBy
|
|
1689
|
-
const orderBy = (spec?.orderBy ?? []).map((term) =>
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1748
|
+
const orderBy = (spec?.orderBy ?? []).map((term) => {
|
|
1749
|
+
const direction = term.direction ?? "asc"
|
|
1750
|
+
if (direction !== "asc" && direction !== "desc") {
|
|
1751
|
+
throw new Error("window order direction must be asc or desc")
|
|
1752
|
+
}
|
|
1753
|
+
return {
|
|
1754
|
+
value: term.value,
|
|
1755
|
+
direction
|
|
1756
|
+
}
|
|
1757
|
+
}) as {
|
|
1693
1758
|
readonly [K in keyof OrderBy]: OrderBy[K] extends WindowOrderTermInput<infer Value extends WindowOrderInput>
|
|
1694
1759
|
? { readonly value: Value; readonly direction: OrderDirection }
|
|
1695
1760
|
: never
|
|
@@ -2655,18 +2720,19 @@ type BinaryPredicateExpression<
|
|
|
2655
2720
|
const jsonSet = <
|
|
2656
2721
|
Base extends JsonExpressionLike<any>,
|
|
2657
2722
|
Target extends JsonPathInput,
|
|
2658
|
-
Next extends JsonValueInput
|
|
2723
|
+
Next extends JsonValueInput,
|
|
2724
|
+
CreateMissing extends boolean = true
|
|
2659
2725
|
>(
|
|
2660
2726
|
base: Base,
|
|
2661
|
-
target: Target & JsonSetGuard<Expression.RuntimeOf<Base>, Target, Next
|
|
2727
|
+
target: Target & JsonSetGuard<Expression.RuntimeOf<Base>, Target, NoInfer<Next>, "json.set">,
|
|
2662
2728
|
next: Next,
|
|
2663
2729
|
options: {
|
|
2664
|
-
readonly createMissing?:
|
|
2730
|
+
readonly createMissing?: CreateMissing
|
|
2665
2731
|
} = {}
|
|
2666
2732
|
): JsonExpression<
|
|
2667
|
-
|
|
2733
|
+
JsonSetOutputWithCreateMissing<Expression.RuntimeOf<Base>, Target, Next, "json.set", CreateMissing>,
|
|
2668
2734
|
JsonDbOfExpression<Base>,
|
|
2669
|
-
JsonNullabilityOf<
|
|
2735
|
+
JsonNullabilityOf<JsonSetOutputWithCreateMissing<Expression.RuntimeOf<Base>, Target, Next, "json.set", CreateMissing>>,
|
|
2670
2736
|
DialectOf<Base>,
|
|
2671
2737
|
KindOf<Base>,
|
|
2672
2738
|
DependenciesOf<Base>,
|
|
@@ -2677,9 +2743,9 @@ type BinaryPredicateExpression<
|
|
|
2677
2743
|
return buildJsonNodeExpression(
|
|
2678
2744
|
[base, newValue],
|
|
2679
2745
|
{
|
|
2680
|
-
runtime: undefined as unknown as
|
|
2746
|
+
runtime: undefined as unknown as JsonSetOutputWithCreateMissing<Expression.RuntimeOf<Base>, Target, Next, "json.set", CreateMissing>,
|
|
2681
2747
|
dbType: jsonDbTypeOf(base),
|
|
2682
|
-
nullability: undefined as unknown as JsonNullabilityOf<
|
|
2748
|
+
nullability: undefined as unknown as JsonNullabilityOf<JsonSetOutputWithCreateMissing<Expression.RuntimeOf<Base>, Target, Next, "json.set", CreateMissing>>
|
|
2683
2749
|
},
|
|
2684
2750
|
{
|
|
2685
2751
|
kind: "jsonSet",
|
|
@@ -2689,9 +2755,9 @@ type BinaryPredicateExpression<
|
|
|
2689
2755
|
createMissing: options.createMissing ?? true
|
|
2690
2756
|
}
|
|
2691
2757
|
) as JsonExpression<
|
|
2692
|
-
|
|
2758
|
+
JsonSetOutputWithCreateMissing<Expression.RuntimeOf<Base>, Target, Next, "json.set", CreateMissing>,
|
|
2693
2759
|
JsonDbOfExpression<Base>,
|
|
2694
|
-
JsonNullabilityOf<
|
|
2760
|
+
JsonNullabilityOf<JsonSetOutputWithCreateMissing<Expression.RuntimeOf<Base>, Target, Next, "json.set", CreateMissing>>,
|
|
2695
2761
|
DialectOf<Base>,
|
|
2696
2762
|
KindOf<Base>,
|
|
2697
2763
|
DependenciesOf<Base>,
|
|
@@ -2706,7 +2772,7 @@ type BinaryPredicateExpression<
|
|
|
2706
2772
|
InsertAfter extends boolean = false
|
|
2707
2773
|
>(
|
|
2708
2774
|
base: Base,
|
|
2709
|
-
target: Target & JsonInsertGuard<Expression.RuntimeOf<Base>, Target, Next
|
|
2775
|
+
target: Target & JsonInsertGuard<Expression.RuntimeOf<Base>, Target, NoInfer<Next>, NoInfer<InsertAfter>, "json.insert">,
|
|
2710
2776
|
next: Next,
|
|
2711
2777
|
options: {
|
|
2712
2778
|
readonly insertAfter?: InsertAfter
|
|
@@ -2928,7 +2994,7 @@ type BinaryPredicateExpression<
|
|
|
2928
2994
|
) => buildJsonNodeExpression(
|
|
2929
2995
|
[base],
|
|
2930
2996
|
{
|
|
2931
|
-
runtime: undefined as unknown as
|
|
2997
|
+
runtime: undefined as unknown as MySqlJsonTypeName<Expression.RuntimeOf<Base>>,
|
|
2932
2998
|
dbType: profile.textDb as TextDb,
|
|
2933
2999
|
nullability: base[Expression.TypeId].nullability
|
|
2934
3000
|
},
|
|
@@ -2943,9 +3009,9 @@ type BinaryPredicateExpression<
|
|
|
2943
3009
|
) => buildJsonNodeExpression(
|
|
2944
3010
|
[base],
|
|
2945
3011
|
{
|
|
2946
|
-
runtime: undefined as unknown as
|
|
3012
|
+
runtime: undefined as unknown as MySqlJsonLengthResult<Expression.RuntimeOf<Base>>,
|
|
2947
3013
|
dbType: profile.numericDb as NumericDb,
|
|
2948
|
-
nullability: undefined as unknown as JsonNullabilityOf<
|
|
3014
|
+
nullability: undefined as unknown as JsonNullabilityOf<MySqlJsonLengthResult<Expression.RuntimeOf<Base>>>
|
|
2949
3015
|
},
|
|
2950
3016
|
{
|
|
2951
3017
|
kind: "jsonLength",
|
|
@@ -3085,9 +3151,9 @@ type BinaryPredicateExpression<
|
|
|
3085
3151
|
typeOf: jsonTypeOf,
|
|
3086
3152
|
length: jsonLength,
|
|
3087
3153
|
keys: jsonKeys,
|
|
3088
|
-
stripNulls: jsonStripNulls
|
|
3154
|
+
stripNulls: jsonStripNulls as unknown as MySqlUnsupportedJsonFeature<"json.stripNulls">,
|
|
3089
3155
|
pathExists: jsonPathExists,
|
|
3090
|
-
pathMatch: jsonPathMatch
|
|
3156
|
+
pathMatch: jsonPathMatch as unknown as MySqlUnsupportedJsonFeature<"json.pathMatch">
|
|
3091
3157
|
}
|
|
3092
3158
|
|
|
3093
3159
|
const jsonb = {
|
|
@@ -3920,7 +3986,9 @@ type BinaryPredicateExpression<
|
|
|
3920
3986
|
string,
|
|
3921
3987
|
"scalar",
|
|
3922
3988
|
Expression.BindingId
|
|
3923
|
-
>
|
|
3989
|
+
> & {
|
|
3990
|
+
readonly [ExpressionAst.TypeId]: ExpressionAst.ColumnNode<any, string>
|
|
3991
|
+
}
|
|
3924
3992
|
>(
|
|
3925
3993
|
value: Value
|
|
3926
3994
|
): AstBackedExpression<
|
|
@@ -3964,22 +4032,56 @@ type BinaryPredicateExpression<
|
|
|
3964
4032
|
value: Value,
|
|
3965
4033
|
column: Expression.Any
|
|
3966
4034
|
): Expression.Any => {
|
|
4035
|
+
const columnState = column[Expression.TypeId]
|
|
4036
|
+
const normalizeMutationValue = (candidate: unknown): unknown => {
|
|
4037
|
+
if (candidate === null && columnState.nullability !== "never") {
|
|
4038
|
+
return null
|
|
4039
|
+
}
|
|
4040
|
+
const runtimeSchemaAccepts = columnState.runtimeSchema !== undefined &&
|
|
4041
|
+
(Schema.is(columnState.runtimeSchema) as (input: unknown) => boolean)(candidate)
|
|
4042
|
+
if (runtimeSchemaAccepts) {
|
|
4043
|
+
return candidate
|
|
4044
|
+
}
|
|
4045
|
+
const normalized = normalizeDbValue(columnState.dbType, candidate)
|
|
4046
|
+
return columnState.runtimeSchema === undefined
|
|
4047
|
+
? normalized
|
|
4048
|
+
: (Schema.decodeUnknownSync as any)(columnState.runtimeSchema)(normalized)
|
|
4049
|
+
}
|
|
3967
4050
|
if (value !== null && typeof value === "object" && Expression.TypeId in value) {
|
|
4051
|
+
const expression = value as unknown as Expression.Any
|
|
4052
|
+
const ast = (expression as unknown as { readonly [ExpressionAst.TypeId]: ExpressionAst.Any })[ExpressionAst.TypeId]
|
|
4053
|
+
if (ast.kind === "literal") {
|
|
4054
|
+
const normalizedValue = normalizeMutationValue(ast.value)
|
|
4055
|
+
return makeExpression({
|
|
4056
|
+
runtime: normalizedValue,
|
|
4057
|
+
dbType: columnState.dbType,
|
|
4058
|
+
runtimeSchema: columnState.runtimeSchema,
|
|
4059
|
+
driverValueMapping: columnState.driverValueMapping,
|
|
4060
|
+
nullability: normalizedValue === null ? "always" : "never",
|
|
4061
|
+
dialect: columnState.dialect,
|
|
4062
|
+
kind: "scalar",
|
|
4063
|
+
dependencies: {}
|
|
4064
|
+
}, {
|
|
4065
|
+
kind: "literal",
|
|
4066
|
+
value: normalizedValue
|
|
4067
|
+
})
|
|
4068
|
+
}
|
|
3968
4069
|
return retargetLiteralExpression(value as unknown as Expression.Any, column)
|
|
3969
4070
|
}
|
|
4071
|
+
const normalizedValue = normalizeMutationValue(value)
|
|
3970
4072
|
return makeExpression({
|
|
3971
|
-
runtime:
|
|
3972
|
-
dbType:
|
|
3973
|
-
runtimeSchema:
|
|
3974
|
-
driverValueMapping:
|
|
3975
|
-
nullability:
|
|
3976
|
-
dialect:
|
|
4073
|
+
runtime: normalizedValue as Value,
|
|
4074
|
+
dbType: columnState.dbType,
|
|
4075
|
+
runtimeSchema: columnState.runtimeSchema,
|
|
4076
|
+
driverValueMapping: columnState.driverValueMapping,
|
|
4077
|
+
nullability: normalizedValue === null ? "always" : "never",
|
|
4078
|
+
dialect: columnState.dialect,
|
|
3977
4079
|
kind: "scalar",
|
|
3978
4080
|
|
|
3979
4081
|
dependencies: {}
|
|
3980
4082
|
}, {
|
|
3981
4083
|
kind: "literal",
|
|
3982
|
-
value
|
|
4084
|
+
value: normalizedValue
|
|
3983
4085
|
})
|
|
3984
4086
|
}
|
|
3985
4087
|
|
|
@@ -4067,16 +4169,16 @@ type BinaryPredicateExpression<
|
|
|
4067
4169
|
Alias extends string
|
|
4068
4170
|
>(
|
|
4069
4171
|
rows: readonly [Record<string, Expression.Any>, ...Record<string, Expression.Any>[]],
|
|
4070
|
-
selection: ValuesOutputShape<Rows
|
|
4172
|
+
selection: ValuesOutputShape<Rows, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>,
|
|
4071
4173
|
alias: Alias
|
|
4072
4174
|
): ValuesSource<
|
|
4073
4175
|
Rows,
|
|
4074
|
-
ValuesOutputShape<Rows
|
|
4176
|
+
ValuesOutputShape<Rows, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>,
|
|
4075
4177
|
Alias,
|
|
4076
4178
|
Dialect
|
|
4077
4179
|
> => {
|
|
4078
4180
|
const columns = makeColumnReferenceSelection(alias, selection as Record<string, Expression.Any>) as unknown as ValuesOutputShape<
|
|
4079
|
-
Rows
|
|
4181
|
+
Rows,
|
|
4080
4182
|
Dialect,
|
|
4081
4183
|
TextDb,
|
|
4082
4184
|
NumericDb,
|
|
@@ -4094,7 +4196,7 @@ type BinaryPredicateExpression<
|
|
|
4094
4196
|
}
|
|
4095
4197
|
return Object.assign(source, columns) as unknown as ValuesSource<
|
|
4096
4198
|
Rows,
|
|
4097
|
-
ValuesOutputShape<Rows
|
|
4199
|
+
ValuesOutputShape<Rows, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>,
|
|
4098
4200
|
Alias,
|
|
4099
4201
|
Dialect
|
|
4100
4202
|
>
|
|
@@ -4107,7 +4209,12 @@ type BinaryPredicateExpression<
|
|
|
4107
4209
|
|
|
4108
4210
|
const normalizeUnnestColumns = (columns: UnnestColumnsInput): Record<string, readonly Expression.Any[]> =>
|
|
4109
4211
|
Object.fromEntries(
|
|
4110
|
-
Object.entries(columns).map(([key, values]) =>
|
|
4212
|
+
Object.entries(columns).map(([key, values]) => {
|
|
4213
|
+
if (!Array.isArray(values)) {
|
|
4214
|
+
throw new Error("unnest(...) expects every value to be an array")
|
|
4215
|
+
}
|
|
4216
|
+
return [key, values.map((value) => toDialectExpression(value))]
|
|
4217
|
+
})
|
|
4111
4218
|
) as Record<string, readonly Expression.Any[]>
|
|
4112
4219
|
|
|
4113
4220
|
const normalizeMutationTargets = (
|
|
@@ -4150,6 +4257,17 @@ type BinaryPredicateExpression<
|
|
|
4150
4257
|
})
|
|
4151
4258
|
) as unknown as AddAvailableMany<{}, MutationTargetNamesOf<Target>, Mode>
|
|
4152
4259
|
|
|
4260
|
+
const getMutationColumn = (
|
|
4261
|
+
columns: Record<string, unknown>,
|
|
4262
|
+
columnName: string
|
|
4263
|
+
): Expression.Any => {
|
|
4264
|
+
const column = columns[columnName]
|
|
4265
|
+
if (column === undefined || column === null || typeof column !== "object" || !(Expression.TypeId in column)) {
|
|
4266
|
+
throw new Error("effect-qb: unknown mutation column")
|
|
4267
|
+
}
|
|
4268
|
+
return column as Expression.Any
|
|
4269
|
+
}
|
|
4270
|
+
|
|
4153
4271
|
const buildMutationAssignments = <Target extends MutationTargetInput, Values>(
|
|
4154
4272
|
target: Target,
|
|
4155
4273
|
values: Values
|
|
@@ -4159,7 +4277,7 @@ type BinaryPredicateExpression<
|
|
|
4159
4277
|
const columns = target as unknown as Record<string, Expression.Any>
|
|
4160
4278
|
return Object.entries(values as Record<string, unknown>).map(([columnName, value]) => ({
|
|
4161
4279
|
columnName,
|
|
4162
|
-
value: toMutationValueExpression(value, columns
|
|
4280
|
+
value: toMutationValueExpression(value, getMutationColumn(columns, columnName))
|
|
4163
4281
|
}))
|
|
4164
4282
|
}
|
|
4165
4283
|
const valueMap = values as Record<string, Record<string, unknown> | undefined>
|
|
@@ -4170,7 +4288,7 @@ type BinaryPredicateExpression<
|
|
|
4170
4288
|
return Object.entries(scopedValues).map(([columnName, value]) => ({
|
|
4171
4289
|
tableName: targetName,
|
|
4172
4290
|
columnName,
|
|
4173
|
-
value: toMutationValueExpression(value, columns
|
|
4291
|
+
value: toMutationValueExpression(value, getMutationColumn(columns, columnName))
|
|
4174
4292
|
}))
|
|
4175
4293
|
})
|
|
4176
4294
|
}
|
|
@@ -4257,31 +4375,29 @@ type BinaryPredicateExpression<
|
|
|
4257
4375
|
}
|
|
4258
4376
|
}
|
|
4259
4377
|
|
|
4378
|
+
const normalizeConflictColumns = <Target extends MutationTargetLike>(
|
|
4379
|
+
target: Target,
|
|
4380
|
+
columnsInput: string | readonly string[]
|
|
4381
|
+
): readonly [string, ...string[]] => {
|
|
4382
|
+
const columns = normalizeColumnList(columnsInput) as readonly [string, ...string[]]
|
|
4383
|
+
const knownColumns = new Set(Object.keys(target[Table.TypeId].fields))
|
|
4384
|
+
if (columns.some((columnName) => !knownColumns.has(columnName))) {
|
|
4385
|
+
throw new Error("effect-qb: unknown conflict target column")
|
|
4386
|
+
}
|
|
4387
|
+
return columns
|
|
4388
|
+
}
|
|
4389
|
+
|
|
4260
4390
|
const buildConflictTarget = <Target extends MutationTargetLike>(
|
|
4261
4391
|
target: Target,
|
|
4262
|
-
input: readonly string[] | { readonly columns: readonly string[]; readonly where?: PredicateInput } | { readonly constraint: string }
|
|
4392
|
+
input: string | readonly string[] | { readonly columns: string | readonly string[]; readonly where?: PredicateInput } | { readonly constraint: string }
|
|
4263
4393
|
): QueryAst.ConflictTargetClause => {
|
|
4264
|
-
if (Array.isArray(input)) {
|
|
4394
|
+
if (typeof input === "string" || Array.isArray(input)) {
|
|
4265
4395
|
return {
|
|
4266
4396
|
kind: "columns",
|
|
4267
|
-
columns:
|
|
4397
|
+
columns: normalizeConflictColumns(target, input)
|
|
4268
4398
|
}
|
|
4269
4399
|
}
|
|
4270
|
-
|
|
4271
|
-
return {
|
|
4272
|
-
kind: "constraint",
|
|
4273
|
-
name: input.constraint
|
|
4274
|
-
}
|
|
4275
|
-
}
|
|
4276
|
-
const columnTarget = input as {
|
|
4277
|
-
readonly columns: readonly string[]
|
|
4278
|
-
readonly where?: PredicateInput
|
|
4279
|
-
}
|
|
4280
|
-
return {
|
|
4281
|
-
kind: "columns",
|
|
4282
|
-
columns: normalizeColumnList(columnTarget.columns) as readonly [string, ...string[]],
|
|
4283
|
-
where: columnTarget.where === undefined ? undefined : toDialectExpression(columnTarget.where)
|
|
4284
|
-
}
|
|
4400
|
+
throw new Error("Unsupported mysql conflict target")
|
|
4285
4401
|
}
|
|
4286
4402
|
|
|
4287
4403
|
const defaultIndexName = (
|
|
@@ -4317,20 +4433,30 @@ type ValidateDdlColumns<
|
|
|
4317
4433
|
Columns extends readonly string[]
|
|
4318
4434
|
> = Exclude<Columns[number], SchemaColumnNames<Target>> extends never ? Columns : never
|
|
4319
4435
|
|
|
4436
|
+
type ValidateDdlColumnInput<
|
|
4437
|
+
Target extends SchemaTableLike,
|
|
4438
|
+
Columns extends DdlColumnInput
|
|
4439
|
+
> = ValidateDdlColumns<Target, NormalizeDdlColumns<Columns>> extends never ? never : Columns
|
|
4440
|
+
|
|
4320
4441
|
type ValidateTargetColumns<
|
|
4321
4442
|
Target extends MutationTargetLike,
|
|
4322
4443
|
Columns extends readonly string[]
|
|
4323
4444
|
> = Exclude<Columns[number], Extract<keyof Target[typeof Table.TypeId]["fields"], string>> extends never ? Columns : never
|
|
4324
4445
|
|
|
4446
|
+
type ValidateTargetColumnInput<
|
|
4447
|
+
Target extends MutationTargetLike,
|
|
4448
|
+
Columns extends DdlColumnInput
|
|
4449
|
+
> = ValidateTargetColumns<Target, NormalizeDdlColumns<Columns>> extends never ? never : Columns
|
|
4450
|
+
|
|
4325
4451
|
type CreateIndexOptions = {
|
|
4326
4452
|
readonly name?: string
|
|
4327
4453
|
readonly unique?: boolean
|
|
4328
|
-
readonly ifNotExists?:
|
|
4454
|
+
readonly ifNotExists?: never
|
|
4329
4455
|
}
|
|
4330
4456
|
|
|
4331
4457
|
type DropIndexOptions = {
|
|
4332
4458
|
readonly name?: string
|
|
4333
|
-
readonly ifExists?:
|
|
4459
|
+
readonly ifExists?: never
|
|
4334
4460
|
}
|
|
4335
4461
|
|
|
4336
4462
|
type CreateTableOptions = {
|
|
@@ -4342,8 +4468,8 @@ type DropTableOptions = {
|
|
|
4342
4468
|
}
|
|
4343
4469
|
|
|
4344
4470
|
type TruncateOptions = {
|
|
4345
|
-
readonly restartIdentity?:
|
|
4346
|
-
readonly cascade?:
|
|
4471
|
+
readonly restartIdentity?: never
|
|
4472
|
+
readonly cascade?: never
|
|
4347
4473
|
}
|
|
4348
4474
|
|
|
4349
4475
|
type TransactionOptions = {
|
|
@@ -4351,10 +4477,15 @@ type TransactionOptions = {
|
|
|
4351
4477
|
readonly readOnly?: boolean
|
|
4352
4478
|
}
|
|
4353
4479
|
|
|
4354
|
-
type LockOptions =
|
|
4355
|
-
|
|
4356
|
-
|
|
4357
|
-
|
|
4480
|
+
type LockOptions =
|
|
4481
|
+
| {
|
|
4482
|
+
readonly nowait?: boolean
|
|
4483
|
+
readonly skipLocked?: false
|
|
4484
|
+
}
|
|
4485
|
+
| {
|
|
4486
|
+
readonly nowait?: false
|
|
4487
|
+
readonly skipLocked?: boolean
|
|
4488
|
+
}
|
|
4358
4489
|
|
|
4359
4490
|
type UpsertConflictOptions = {
|
|
4360
4491
|
readonly update?: Record<string, unknown>
|
|
@@ -4369,14 +4500,133 @@ type InsertRowInput<Target extends MutationTargetLike> = MutationInputOf<Table.I
|
|
|
4369
4500
|
type ValuesRowInput = Record<string, ExpressionInput>
|
|
4370
4501
|
type ValuesRowsInput = readonly [ValuesRowInput, ...ValuesRowInput[]]
|
|
4371
4502
|
|
|
4503
|
+
type ValuesColumnInput<Row, Key extends PropertyKey> =
|
|
4504
|
+
Row extends ValuesRowInput
|
|
4505
|
+
? Key extends keyof Row ? Row[Key] : never
|
|
4506
|
+
: never
|
|
4507
|
+
|
|
4508
|
+
type ValuesRowShapeMismatch<
|
|
4509
|
+
First extends ValuesRowInput,
|
|
4510
|
+
Row extends ValuesRowInput
|
|
4511
|
+
> =
|
|
4512
|
+
| Exclude<Extract<keyof Row, string>, Extract<keyof First, string>>
|
|
4513
|
+
| Exclude<Extract<keyof First, string>, Extract<keyof Row, string>>
|
|
4514
|
+
|
|
4515
|
+
type ValuesRowsShapeMismatchesFor<
|
|
4516
|
+
First extends ValuesRowInput,
|
|
4517
|
+
Row
|
|
4518
|
+
> = Row extends ValuesRowInput ? ValuesRowShapeMismatch<First, Row> : never
|
|
4519
|
+
|
|
4520
|
+
type ValuesRowsShapeMismatches<Rows extends ValuesRowsInput> =
|
|
4521
|
+
Rows extends readonly [infer First extends ValuesRowInput, ...infer Rest extends ValuesRowInput[]]
|
|
4522
|
+
? ValuesRowsShapeMismatchesFor<First, Rest[number]>
|
|
4523
|
+
: never
|
|
4524
|
+
|
|
4525
|
+
type ValuesRowsColumnKeys<Rows extends ValuesRowsInput> =
|
|
4526
|
+
Rows extends readonly [infer First extends ValuesRowInput, ...ValuesRowInput[]]
|
|
4527
|
+
? Extract<keyof First, string>
|
|
4528
|
+
: never
|
|
4529
|
+
|
|
4530
|
+
type ValuesRowsShapeInput<Rows extends ValuesRowsInput> =
|
|
4531
|
+
[ValuesRowsColumnKeys<Rows>] extends [never]
|
|
4532
|
+
? {
|
|
4533
|
+
readonly __effect_qb_error__: "effect-qb: values rows must project at least one column"
|
|
4534
|
+
}
|
|
4535
|
+
: [ValuesRowsShapeMismatches<Rows>] extends [never]
|
|
4536
|
+
? unknown
|
|
4537
|
+
: {
|
|
4538
|
+
readonly __effect_qb_error__: "effect-qb: values rows must project the same columns"
|
|
4539
|
+
readonly __effect_qb_mismatched_columns__: ValuesRowsShapeMismatches<Rows>
|
|
4540
|
+
}
|
|
4541
|
+
|
|
4542
|
+
type ValuesRowsDialect<
|
|
4543
|
+
Rows extends ValuesRowsInput,
|
|
4544
|
+
Dialect extends string,
|
|
4545
|
+
TextDb extends Expression.DbType.Any,
|
|
4546
|
+
NumericDb extends Expression.DbType.Any,
|
|
4547
|
+
BoolDb extends Expression.DbType.Any,
|
|
4548
|
+
TimestampDb extends Expression.DbType.Any,
|
|
4549
|
+
NullDb extends Expression.DbType.Any
|
|
4550
|
+
> = Rows[number][keyof Rows[number]] extends infer Value extends ExpressionInput
|
|
4551
|
+
? DialectOfDialectInput<Value, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>
|
|
4552
|
+
: never
|
|
4553
|
+
|
|
4554
|
+
type ValuesRowsDialectInput<
|
|
4555
|
+
Rows extends ValuesRowsInput,
|
|
4556
|
+
Dialect extends string,
|
|
4557
|
+
TextDb extends Expression.DbType.Any,
|
|
4558
|
+
NumericDb extends Expression.DbType.Any,
|
|
4559
|
+
BoolDb extends Expression.DbType.Any,
|
|
4560
|
+
TimestampDb extends Expression.DbType.Any,
|
|
4561
|
+
NullDb extends Expression.DbType.Any
|
|
4562
|
+
> = Exclude<ValuesRowsDialect<Rows, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>, Dialect> extends never
|
|
4563
|
+
? unknown
|
|
4564
|
+
: {
|
|
4565
|
+
readonly __effect_qb_error__: "effect-qb: values rows cannot mix dialects"
|
|
4566
|
+
readonly __effect_qb_dialect__: ValuesRowsDialect<Rows, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>
|
|
4567
|
+
}
|
|
4568
|
+
|
|
4372
4569
|
type UnnestColumnsInput = Record<string, readonly [ExpressionInput, ...ExpressionInput[]]>
|
|
4373
4570
|
|
|
4571
|
+
type IsNever<Value> = [Value] extends [never] ? true : false
|
|
4572
|
+
|
|
4573
|
+
type IsUnion<Value, All = Value> = Value extends any
|
|
4574
|
+
? ([All] extends [Value] ? false : true)
|
|
4575
|
+
: never
|
|
4576
|
+
|
|
4577
|
+
type UnnestColumnKeys<Columns extends UnnestColumnsInput> =
|
|
4578
|
+
Extract<keyof Columns, string>
|
|
4579
|
+
|
|
4580
|
+
type UnnestColumnLengths<Columns extends UnnestColumnsInput> =
|
|
4581
|
+
Columns[UnnestColumnKeys<Columns>]["length"]
|
|
4582
|
+
|
|
4583
|
+
type UnnestColumnsShapeInput<Columns extends UnnestColumnsInput> =
|
|
4584
|
+
IsNever<UnnestColumnKeys<Columns>> extends true
|
|
4585
|
+
? {
|
|
4586
|
+
readonly __effect_qb_error__: "effect-qb: unnest requires at least one column array"
|
|
4587
|
+
}
|
|
4588
|
+
: number extends UnnestColumnLengths<Columns>
|
|
4589
|
+
? unknown
|
|
4590
|
+
: IsUnion<UnnestColumnLengths<Columns>> extends true
|
|
4591
|
+
? {
|
|
4592
|
+
readonly __effect_qb_error__: "effect-qb: unnest column arrays must have the same length"
|
|
4593
|
+
readonly __effect_qb_column_lengths__: UnnestColumnLengths<Columns>
|
|
4594
|
+
}
|
|
4595
|
+
: unknown
|
|
4596
|
+
|
|
4597
|
+
type UnnestColumnsDialect<
|
|
4598
|
+
Columns extends UnnestColumnsInput,
|
|
4599
|
+
Dialect extends string,
|
|
4600
|
+
TextDb extends Expression.DbType.Any,
|
|
4601
|
+
NumericDb extends Expression.DbType.Any,
|
|
4602
|
+
BoolDb extends Expression.DbType.Any,
|
|
4603
|
+
TimestampDb extends Expression.DbType.Any,
|
|
4604
|
+
NullDb extends Expression.DbType.Any
|
|
4605
|
+
> = Columns[UnnestColumnKeys<Columns>][number] extends infer Value extends ExpressionInput
|
|
4606
|
+
? DialectOfDialectInput<Value, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>
|
|
4607
|
+
: never
|
|
4608
|
+
|
|
4609
|
+
type UnnestColumnsDialectInput<
|
|
4610
|
+
Columns extends UnnestColumnsInput,
|
|
4611
|
+
Dialect extends string,
|
|
4612
|
+
TextDb extends Expression.DbType.Any,
|
|
4613
|
+
NumericDb extends Expression.DbType.Any,
|
|
4614
|
+
BoolDb extends Expression.DbType.Any,
|
|
4615
|
+
TimestampDb extends Expression.DbType.Any,
|
|
4616
|
+
NullDb extends Expression.DbType.Any
|
|
4617
|
+
> = Exclude<UnnestColumnsDialect<Columns, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>, Dialect> extends never
|
|
4618
|
+
? unknown
|
|
4619
|
+
: {
|
|
4620
|
+
readonly __effect_qb_error__: "effect-qb: unnest columns cannot mix dialects"
|
|
4621
|
+
readonly __effect_qb_dialect__: UnnestColumnsDialect<Columns, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>
|
|
4622
|
+
}
|
|
4623
|
+
|
|
4374
4624
|
type UnnestRowShape<Shape extends Record<string, readonly unknown[]>> = {
|
|
4375
4625
|
readonly [K in keyof Shape]: Shape[K] extends readonly (infer Item)[] ? Item : never
|
|
4376
4626
|
}
|
|
4377
4627
|
|
|
4378
4628
|
type ValuesOutputShape<
|
|
4379
|
-
|
|
4629
|
+
Rows extends ValuesRowsInput,
|
|
4380
4630
|
Dialect extends string,
|
|
4381
4631
|
TextDb extends Expression.DbType.Any,
|
|
4382
4632
|
NumericDb extends Expression.DbType.Any,
|
|
@@ -4384,7 +4634,7 @@ type ValuesOutputShape<
|
|
|
4384
4634
|
TimestampDb extends Expression.DbType.Any,
|
|
4385
4635
|
NullDb extends Expression.DbType.Any
|
|
4386
4636
|
> = {
|
|
4387
|
-
readonly [K in keyof
|
|
4637
|
+
readonly [K in keyof Rows[0]]: DialectAsExpression<ValuesColumnInput<Rows[number], K>, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>
|
|
4388
4638
|
}
|
|
4389
4639
|
|
|
4390
4640
|
type UnnestOutputShape<
|
|
@@ -4423,19 +4673,44 @@ type DistinctOnUnsupportedError<Dialect extends string> = {
|
|
|
4423
4673
|
readonly __effect_qb_hint__: "Use postgres.Query.distinctOn(...) or regular distinct()/grouping logic"
|
|
4424
4674
|
}
|
|
4425
4675
|
|
|
4676
|
+
type FullJoinUnsupportedError<Dialect extends string> = {
|
|
4677
|
+
readonly __effect_qb_error__: "effect-qb: fullJoin(...) is only supported by the postgres dialect"
|
|
4678
|
+
readonly __effect_qb_dialect__: Dialect
|
|
4679
|
+
readonly __effect_qb_hint__: "Use leftJoin/rightJoin with nullable handling or switch to postgres.Query.fullJoin(...)"
|
|
4680
|
+
}
|
|
4681
|
+
|
|
4682
|
+
type ReturningUnsupportedError<Dialect extends string> = {
|
|
4683
|
+
readonly __effect_qb_error__: "effect-qb: returning(...) is only supported by the postgres dialect"
|
|
4684
|
+
readonly __effect_qb_dialect__: Dialect
|
|
4685
|
+
readonly __effect_qb_hint__: "Use postgres.Query.returning(...) or run a follow-up select after MySQL mutations"
|
|
4686
|
+
}
|
|
4687
|
+
|
|
4688
|
+
type MysqlCteStatementError<PlanValue extends QueryPlan<any, any, any, any, any, any, any, any, any, any>> =
|
|
4689
|
+
PlanValue & {
|
|
4690
|
+
readonly __effect_qb_error__: "effect-qb: mysql cte sources only accept select-like query plans"
|
|
4691
|
+
readonly __effect_qb_statement__: StatementOfPlan<PlanValue>
|
|
4692
|
+
readonly __effect_qb_hint__: "Use select(...) or a set operator before wrapping a MySQL plan in with(...)"
|
|
4693
|
+
}
|
|
4694
|
+
|
|
4695
|
+
type MysqlCteCompatiblePlan<
|
|
4696
|
+
PlanValue extends QueryPlan<any, any, any, any, any, any, any, any, any, any>
|
|
4697
|
+
> = StatementOfPlan<PlanValue> extends "select" | "set"
|
|
4698
|
+
? DerivedSourceCompatiblePlan<PlanValue>
|
|
4699
|
+
: MysqlCteStatementError<PlanValue>
|
|
4700
|
+
|
|
4426
4701
|
type DistinctOnApi<Dialect extends string> = Dialect extends "postgres"
|
|
4427
|
-
? <Values extends readonly ExpressionInput[]>(
|
|
4702
|
+
? <Values extends readonly [ExpressionInput, ...ExpressionInput[]]>(
|
|
4428
4703
|
...values: Values
|
|
4429
4704
|
) => <PlanValue extends QueryPlan<any, any, any, any, any, any, any, any, any, any>>(
|
|
4430
4705
|
plan: PlanValue & RequireSelectStatement<PlanValue>
|
|
4431
4706
|
) => QueryPlan<
|
|
4432
4707
|
SelectionOfPlan<PlanValue>,
|
|
4433
|
-
RequiredOfPlan<PlanValue>,
|
|
4708
|
+
AddExpressionRequired<RequiredOfPlan<PlanValue>, AvailableOfPlan<PlanValue>, Values[number]>,
|
|
4434
4709
|
AvailableOfPlan<PlanValue>,
|
|
4435
|
-
PlanDialectOf<PlanValue>,
|
|
4710
|
+
PlanDialectOf<PlanValue> | DialectOfDialectInput<Values[number], Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>,
|
|
4436
4711
|
GroupedOfPlan<PlanValue>,
|
|
4437
4712
|
ScopedNamesOfPlan<PlanValue>,
|
|
4438
|
-
OutstandingOfPlan<PlanValue>,
|
|
4713
|
+
AddExpressionRequired<OutstandingOfPlan<PlanValue>, AvailableOfPlan<PlanValue>, Values[number]>,
|
|
4439
4714
|
AssumptionsOfPlan<PlanValue>,
|
|
4440
4715
|
CapabilitiesOfPlan<PlanValue>,
|
|
4441
4716
|
StatementOfPlan<PlanValue>
|
|
@@ -4468,6 +4743,27 @@ type MysqlConflictWhereError<Values> = Values & {
|
|
|
4468
4743
|
readonly __effect_qb_hint__: "Move the condition into the update assignment expressions or use the Postgres dialect"
|
|
4469
4744
|
}
|
|
4470
4745
|
|
|
4746
|
+
type UpdateValuesNonEmptyError<Values> = Values & {
|
|
4747
|
+
readonly __effect_qb_error__: "effect-qb: update statements require at least one assignment"
|
|
4748
|
+
}
|
|
4749
|
+
|
|
4750
|
+
type UpdateValuesNonEmptyConstraint<Values> =
|
|
4751
|
+
[Extract<keyof Values, string>] extends [never]
|
|
4752
|
+
? UpdateValuesNonEmptyError<Values>
|
|
4753
|
+
: unknown
|
|
4754
|
+
|
|
4755
|
+
type NestedUpdateValuesNonEmptyConstraint<Values> =
|
|
4756
|
+
[Extract<keyof Values, string>] extends [never]
|
|
4757
|
+
? UpdateValuesNonEmptyError<Values>
|
|
4758
|
+
: true extends {
|
|
4759
|
+
[K in Extract<keyof Values, string>]:
|
|
4760
|
+
Values[K] extends Record<string, unknown>
|
|
4761
|
+
? [Extract<keyof Values[K], string>] extends [never] ? false : true
|
|
4762
|
+
: false
|
|
4763
|
+
}[Extract<keyof Values, string>]
|
|
4764
|
+
? unknown
|
|
4765
|
+
: UpdateValuesNonEmptyError<Values>
|
|
4766
|
+
|
|
4471
4767
|
type InsertShapeExtraKeys<TargetShape, SourceShape> = Exclude<Extract<keyof SourceShape, string>, Extract<keyof TargetShape, string>>
|
|
4472
4768
|
type InsertShapeMissingKeys<TargetShape, SourceShape> = Exclude<RequiredKeys<TargetShape>, Extract<keyof SourceShape, string>>
|
|
4473
4769
|
type InsertShapeMismatchedKeys<TargetShape, SourceShape> = Extract<{
|
|
@@ -4561,10 +4857,15 @@ type InsertSourceRequired<Source> =
|
|
|
4561
4857
|
Source extends QueryPlan<any, any, any, any, any, any, any, any, any, any> ? RequiredOfPlan<Source> :
|
|
4562
4858
|
never
|
|
4563
4859
|
|
|
4860
|
+
type InsertSourceDialect<Source> =
|
|
4861
|
+
Source extends QueryPlan<any, any, any, any, any, any, any, any, any, any> ? PlanDialectOf<Source> :
|
|
4862
|
+
Source extends SourceLike ? SourceDialectOf<Source> :
|
|
4863
|
+
never
|
|
4864
|
+
|
|
4564
4865
|
type ConflictColumnTarget<
|
|
4565
4866
|
Target extends MutationTargetLike,
|
|
4566
4867
|
Columns extends DdlColumnInput
|
|
4567
|
-
> =
|
|
4868
|
+
> = ValidateTargetColumnInput<Target, Columns>
|
|
4568
4869
|
|
|
4569
4870
|
type ConflictTargetInput<
|
|
4570
4871
|
Target extends MutationTargetLike,
|
|
@@ -4594,6 +4895,55 @@ type ConflictActionInput<
|
|
|
4594
4895
|
readonly where?: Dialect extends "postgres" ? PredicateInput : MysqlConflictWhereError<PredicateInput>
|
|
4595
4896
|
}
|
|
4596
4897
|
|
|
4898
|
+
type ConflictActionUpdateNonEmptyConstraint<Options> =
|
|
4899
|
+
Options extends { readonly update: infer Values }
|
|
4900
|
+
? UpdateValuesNonEmptyConstraint<Values>
|
|
4901
|
+
: unknown
|
|
4902
|
+
|
|
4903
|
+
type ConflictTargetPredicate<Target> =
|
|
4904
|
+
Target extends { readonly where?: infer Predicate } ? Extract<Predicate, PredicateInput> : never
|
|
4905
|
+
|
|
4906
|
+
type ConflictActionPredicate<Options> =
|
|
4907
|
+
Options extends { readonly where?: infer Predicate } ? Extract<Predicate, PredicateInput> : never
|
|
4908
|
+
|
|
4909
|
+
type MutationDialectFromValues<
|
|
4910
|
+
Values extends Record<string, unknown>,
|
|
4911
|
+
Dialect extends string,
|
|
4912
|
+
TextDb extends Expression.DbType.Any,
|
|
4913
|
+
NumericDb extends Expression.DbType.Any,
|
|
4914
|
+
BoolDb extends Expression.DbType.Any,
|
|
4915
|
+
TimestampDb extends Expression.DbType.Any,
|
|
4916
|
+
NullDb extends Expression.DbType.Any
|
|
4917
|
+
> = {
|
|
4918
|
+
[K in keyof Values]: Values[K] extends ExpressionInput
|
|
4919
|
+
? DialectOfDialectInput<Values[K], Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>
|
|
4920
|
+
: never
|
|
4921
|
+
}[keyof Values]
|
|
4922
|
+
|
|
4923
|
+
type ConflictRequired<
|
|
4924
|
+
UpdateValues extends MutationInputOf<any> | undefined,
|
|
4925
|
+
Options,
|
|
4926
|
+
ConflictTarget
|
|
4927
|
+
> =
|
|
4928
|
+
| MutationRequiredFromValues<Exclude<UpdateValues, undefined>>
|
|
4929
|
+
| RequiredFromInput<ConflictActionPredicate<Options>>
|
|
4930
|
+
| RequiredFromInput<ConflictTargetPredicate<ConflictTarget>>
|
|
4931
|
+
|
|
4932
|
+
type ConflictDialect<
|
|
4933
|
+
UpdateValues extends MutationInputOf<any> | undefined,
|
|
4934
|
+
Options,
|
|
4935
|
+
ConflictTarget,
|
|
4936
|
+
Dialect extends string,
|
|
4937
|
+
TextDb extends Expression.DbType.Any,
|
|
4938
|
+
NumericDb extends Expression.DbType.Any,
|
|
4939
|
+
BoolDb extends Expression.DbType.Any,
|
|
4940
|
+
TimestampDb extends Expression.DbType.Any,
|
|
4941
|
+
NullDb extends Expression.DbType.Any
|
|
4942
|
+
> =
|
|
4943
|
+
| MutationDialectFromValues<Exclude<UpdateValues, undefined>, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>
|
|
4944
|
+
| DialectOfDialectInput<ConflictActionPredicate<Options>, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>
|
|
4945
|
+
| DialectOfDialectInput<ConflictTargetPredicate<ConflictTarget>, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>
|
|
4946
|
+
|
|
4597
4947
|
type MergeWhenMatchedDelete<
|
|
4598
4948
|
Predicate extends PredicateInput | undefined = undefined
|
|
4599
4949
|
> = {
|
|
@@ -4621,16 +4971,33 @@ type MergeWhenNotMatched<
|
|
|
4621
4971
|
readonly predicate?: Predicate
|
|
4622
4972
|
}
|
|
4623
4973
|
|
|
4974
|
+
type MergeMatchedOption<
|
|
4975
|
+
Target extends MutationTargetLike,
|
|
4976
|
+
MatchedValues extends MutationInputOf<Table.UpdateOf<Target>>,
|
|
4977
|
+
MatchedPredicate extends PredicateInput | undefined = undefined
|
|
4978
|
+
> = MergeWhenMatchedDelete<MatchedPredicate> | MergeWhenMatchedUpdate<Target, MatchedValues, MatchedPredicate>
|
|
4979
|
+
|
|
4980
|
+
type MergeNotMatchedOption<
|
|
4981
|
+
Target extends MutationTargetLike,
|
|
4982
|
+
InsertValues extends MutationInputOf<Table.InsertOf<Target>>,
|
|
4983
|
+
NotMatchedPredicate extends PredicateInput | undefined = undefined
|
|
4984
|
+
> = MergeWhenNotMatched<Target, InsertValues, NotMatchedPredicate>
|
|
4985
|
+
|
|
4624
4986
|
type MergeOptions<
|
|
4625
4987
|
Target extends MutationTargetLike,
|
|
4626
4988
|
MatchedValues extends MutationInputOf<Table.UpdateOf<Target>>,
|
|
4627
4989
|
InsertValues extends MutationInputOf<Table.InsertOf<Target>>,
|
|
4628
4990
|
MatchedPredicate extends PredicateInput | undefined = undefined,
|
|
4629
4991
|
NotMatchedPredicate extends PredicateInput | undefined = undefined
|
|
4630
|
-
> =
|
|
4631
|
-
|
|
4632
|
-
|
|
4633
|
-
|
|
4992
|
+
> =
|
|
4993
|
+
| {
|
|
4994
|
+
readonly whenMatched: MergeMatchedOption<Target, MatchedValues, MatchedPredicate>
|
|
4995
|
+
readonly whenNotMatched?: MergeNotMatchedOption<Target, InsertValues, NotMatchedPredicate>
|
|
4996
|
+
}
|
|
4997
|
+
| {
|
|
4998
|
+
readonly whenMatched?: MergeMatchedOption<Target, MatchedValues, MatchedPredicate>
|
|
4999
|
+
readonly whenNotMatched: MergeNotMatchedOption<Target, InsertValues, NotMatchedPredicate>
|
|
5000
|
+
}
|
|
4634
5001
|
|
|
4635
5002
|
type RequireSelectStatement<PlanValue extends QueryPlan<any, any, any, any, any, any, any, any, any, any>> =
|
|
4636
5003
|
StatementOfPlan<PlanValue> extends "select" ? unknown : never
|
|
@@ -4662,6 +5029,43 @@ type MutationOrderLimitSupported<PlanValue extends QueryPlan<any, any, any, any,
|
|
|
4662
5029
|
? StatementOfPlan<PlanValue> extends "update" | "delete" ? unknown : never
|
|
4663
5030
|
: never
|
|
4664
5031
|
|
|
5032
|
+
type MutationTargetTupleDialectConstraint<
|
|
5033
|
+
Targets extends MutationTargetTuple,
|
|
5034
|
+
Dialect extends string
|
|
5035
|
+
> = Exclude<TableDialectOf<Targets[number]>, Dialect> extends never ? unknown : never
|
|
5036
|
+
|
|
5037
|
+
type TableDialectConstraint<
|
|
5038
|
+
Target extends TableLike,
|
|
5039
|
+
Dialect extends string
|
|
5040
|
+
> = Exclude<TableDialectOf<Target>, Dialect> extends never ? unknown : never
|
|
5041
|
+
|
|
5042
|
+
type DuplicateMutationTargetSourceName<
|
|
5043
|
+
Targets extends readonly MutationTargetLike[],
|
|
5044
|
+
Seen extends string = never
|
|
5045
|
+
> = Targets extends readonly [infer Head extends MutationTargetLike, ...infer Tail extends readonly MutationTargetLike[]]
|
|
5046
|
+
? SourceNameOf<Head> extends infer Name extends string
|
|
5047
|
+
? string extends Name
|
|
5048
|
+
? DuplicateMutationTargetSourceName<Tail, Seen>
|
|
5049
|
+
: Name extends Seen
|
|
5050
|
+
? Name
|
|
5051
|
+
: DuplicateMutationTargetSourceName<Tail, Seen | Name>
|
|
5052
|
+
: never
|
|
5053
|
+
: never
|
|
5054
|
+
|
|
5055
|
+
type MutationTargetTupleDuplicateNameError<Name extends string> = {
|
|
5056
|
+
readonly __effect_qb_error__: "effect-qb: mutation target source names must be unique"
|
|
5057
|
+
readonly __effect_qb_duplicate_source_name__: Name
|
|
5058
|
+
readonly __effect_qb_hint__: "Alias duplicate mutation targets with Table.alias(...)"
|
|
5059
|
+
}
|
|
5060
|
+
|
|
5061
|
+
type MutationTargetTupleUniqueNamesConstraint<
|
|
5062
|
+
Targets extends MutationTargetTuple
|
|
5063
|
+
> = DuplicateMutationTargetSourceName<Targets> extends infer Name extends string
|
|
5064
|
+
? [Name] extends [never]
|
|
5065
|
+
? unknown
|
|
5066
|
+
: MutationTargetTupleDuplicateNameError<Name>
|
|
5067
|
+
: unknown
|
|
5068
|
+
|
|
4665
5069
|
type MutationRequiredFromValues<Values extends Record<string, unknown>> = {
|
|
4666
5070
|
[K in keyof Values]: Values[K] extends Expression.Any ? RequiredFromDependencies<DependenciesOf<Values[K]>> : never
|
|
4667
5071
|
}[keyof Values]
|
|
@@ -4675,6 +5079,59 @@ type NestedMutationRequiredFromValues<Values> =
|
|
|
4675
5079
|
}[keyof Values]
|
|
4676
5080
|
: never
|
|
4677
5081
|
|
|
5082
|
+
type NestedMutationDialectFromValues<
|
|
5083
|
+
Values,
|
|
5084
|
+
Dialect extends string,
|
|
5085
|
+
TextDb extends Expression.DbType.Any,
|
|
5086
|
+
NumericDb extends Expression.DbType.Any,
|
|
5087
|
+
BoolDb extends Expression.DbType.Any,
|
|
5088
|
+
TimestampDb extends Expression.DbType.Any,
|
|
5089
|
+
NullDb extends Expression.DbType.Any
|
|
5090
|
+
> =
|
|
5091
|
+
Values extends ExpressionInput
|
|
5092
|
+
? DialectOfDialectInput<Values, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>
|
|
5093
|
+
: Values extends Record<string, unknown>
|
|
5094
|
+
? {
|
|
5095
|
+
[K in keyof Values]: NestedMutationDialectFromValues<Values[K], Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>
|
|
5096
|
+
}[keyof Values]
|
|
5097
|
+
: never
|
|
5098
|
+
|
|
5099
|
+
type KnownMutationDialectFromValues<
|
|
5100
|
+
Values,
|
|
5101
|
+
Dialect extends string,
|
|
5102
|
+
TextDb extends Expression.DbType.Any,
|
|
5103
|
+
NumericDb extends Expression.DbType.Any,
|
|
5104
|
+
BoolDb extends Expression.DbType.Any,
|
|
5105
|
+
TimestampDb extends Expression.DbType.Any,
|
|
5106
|
+
NullDb extends Expression.DbType.Any
|
|
5107
|
+
> = NestedMutationDialectFromValues<Values, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb> extends infer Current
|
|
5108
|
+
? Current extends string
|
|
5109
|
+
? string extends Current ? never : Current
|
|
5110
|
+
: never
|
|
5111
|
+
: never
|
|
5112
|
+
|
|
5113
|
+
type KnownIncompatibleMutationDialectFromValues<
|
|
5114
|
+
Values,
|
|
5115
|
+
Dialect extends string,
|
|
5116
|
+
TextDb extends Expression.DbType.Any,
|
|
5117
|
+
NumericDb extends Expression.DbType.Any,
|
|
5118
|
+
BoolDb extends Expression.DbType.Any,
|
|
5119
|
+
TimestampDb extends Expression.DbType.Any,
|
|
5120
|
+
NullDb extends Expression.DbType.Any
|
|
5121
|
+
> = Exclude<KnownMutationDialectFromValues<Values, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>, Dialect>
|
|
5122
|
+
|
|
5123
|
+
type MutationValuesDialectConstraint<
|
|
5124
|
+
Values,
|
|
5125
|
+
Dialect extends string,
|
|
5126
|
+
TextDb extends Expression.DbType.Any,
|
|
5127
|
+
NumericDb extends Expression.DbType.Any,
|
|
5128
|
+
BoolDb extends Expression.DbType.Any,
|
|
5129
|
+
TimestampDb extends Expression.DbType.Any,
|
|
5130
|
+
NullDb extends Expression.DbType.Any
|
|
5131
|
+
> = KnownIncompatibleMutationDialectFromValues<Values, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb> extends never
|
|
5132
|
+
? unknown
|
|
5133
|
+
: never
|
|
5134
|
+
|
|
4678
5135
|
type MutationAssignments<Shape extends Record<string, unknown>> = {
|
|
4679
5136
|
readonly [K in keyof Shape]: QueryAst.AssignmentClause
|
|
4680
5137
|
}
|
|
@@ -4708,12 +5165,38 @@ type InsertDirectSource =
|
|
|
4708
5165
|
|
|
4709
5166
|
type FromInput = SourceLike | InsertDirectSource
|
|
4710
5167
|
|
|
5168
|
+
type SourceDialectConstraint<
|
|
5169
|
+
CurrentSource extends SourceLike,
|
|
5170
|
+
Dialect extends string
|
|
5171
|
+
> = [SourceDialectOf<CurrentSource>] extends [never]
|
|
5172
|
+
? unknown
|
|
5173
|
+
: Extract<SourceDialectOf<CurrentSource>, Dialect> extends never
|
|
5174
|
+
? never
|
|
5175
|
+
: unknown
|
|
5176
|
+
|
|
5177
|
+
type SourceRequirementConstraint<
|
|
5178
|
+
PlanValue extends QueryPlan<any, any, any, any, any, any, any, any, any, any>,
|
|
5179
|
+
CurrentSource extends SourceLike
|
|
5180
|
+
> = [SourceRequiredOf<CurrentSource>] extends [never]
|
|
5181
|
+
? unknown
|
|
5182
|
+
: Exclude<SourceRequiredOf<CurrentSource>, ScopedNamesOfPlan<PlanValue>> extends never
|
|
5183
|
+
? unknown
|
|
5184
|
+
: SourceRequirementError<CurrentSource>
|
|
5185
|
+
|
|
4711
5186
|
type SelectFromConstraint<
|
|
4712
5187
|
PlanValue extends QueryPlan<any, any, any, any, any, any, any, any, any, any>,
|
|
4713
5188
|
CurrentSource extends SourceLike
|
|
4714
5189
|
> =
|
|
4715
5190
|
RequireSelectStatement<PlanValue> &
|
|
4716
|
-
(
|
|
5191
|
+
(
|
|
5192
|
+
SourceNameOf<CurrentSource> extends OutstandingOfPlan<PlanValue>
|
|
5193
|
+
? unknown
|
|
5194
|
+
: [OutstandingOfPlan<PlanValue>] extends [never]
|
|
5195
|
+
? [ScopedNamesOfPlan<PlanValue>] extends [never]
|
|
5196
|
+
? unknown
|
|
5197
|
+
: never
|
|
5198
|
+
: never
|
|
5199
|
+
) &
|
|
4717
5200
|
(SourceRequiredOf<CurrentSource> extends never ? unknown : SourceRequirementError<CurrentSource>)
|
|
4718
5201
|
|
|
4719
5202
|
type UpdateFromConstraint<
|
|
@@ -4730,7 +5213,7 @@ type InsertFromConstraint<
|
|
|
4730
5213
|
Dialect extends string
|
|
4731
5214
|
> =
|
|
4732
5215
|
RequirePendingInsertStatement<PlanValue> &
|
|
4733
|
-
(InsertSourceOfPlanInput<PlanValue, CurrentSource, Dialect>
|
|
5216
|
+
(CurrentSource extends InsertSourceOfPlanInput<PlanValue, CurrentSource, Dialect>
|
|
4734
5217
|
? unknown
|
|
4735
5218
|
: InsertSourceOfPlanInput<PlanValue, CurrentSource, Dialect>)
|
|
4736
5219
|
|
|
@@ -4784,12 +5267,12 @@ type InsertFromResult<
|
|
|
4784
5267
|
Dialect extends string
|
|
4785
5268
|
> = QueryPlan<
|
|
4786
5269
|
SelectionOfPlan<PlanValue>,
|
|
4787
|
-
|
|
5270
|
+
InsertSourceRequired<CurrentSource>,
|
|
4788
5271
|
AvailableOfPlan<PlanValue>,
|
|
4789
|
-
PlanDialectOf<PlanValue>,
|
|
5272
|
+
PlanDialectOf<PlanValue> | InsertSourceDialect<CurrentSource>,
|
|
4790
5273
|
GroupedOfPlan<PlanValue>,
|
|
4791
5274
|
ScopedNamesOfPlan<PlanValue>,
|
|
4792
|
-
|
|
5275
|
+
InsertSourceRequired<CurrentSource>,
|
|
4793
5276
|
AssumptionsOfPlan<PlanValue>,
|
|
4794
5277
|
CurrentSource extends QueryPlan<any, any, any, any, any, any, any, any, any, any>
|
|
4795
5278
|
? MergeCapabilities<CapabilitiesOfPlan<PlanValue>, CapabilitiesOfPlan<CurrentSource>>
|
|
@@ -4806,15 +5289,17 @@ type FromPlanConstraint<
|
|
|
4806
5289
|
Dialect extends string
|
|
4807
5290
|
> =
|
|
4808
5291
|
CurrentSource extends SourceLike
|
|
4809
|
-
?
|
|
4810
|
-
|
|
4811
|
-
|
|
4812
|
-
|
|
4813
|
-
|
|
4814
|
-
|
|
4815
|
-
|
|
4816
|
-
|
|
4817
|
-
|
|
5292
|
+
? SourceDialectConstraint<CurrentSource, Dialect> & (
|
|
5293
|
+
StatementOfPlan<PlanValue> extends "select"
|
|
5294
|
+
? SelectFromConstraint<PlanValue, CurrentSource>
|
|
5295
|
+
: StatementOfPlan<PlanValue> extends "update"
|
|
5296
|
+
? UpdateFromConstraint<PlanValue, CurrentSource>
|
|
5297
|
+
: StatementOfPlan<PlanValue> extends "insert"
|
|
5298
|
+
? CurrentSource extends AnyValuesSource | AnyUnnestSource
|
|
5299
|
+
? InsertFromConstraint<PlanValue, CurrentSource, Dialect>
|
|
5300
|
+
: never
|
|
5301
|
+
: never
|
|
5302
|
+
)
|
|
4818
5303
|
: CurrentSource extends InsertDirectSource
|
|
4819
5304
|
? StatementOfPlan<PlanValue> extends "insert"
|
|
4820
5305
|
? InsertFromConstraint<PlanValue, CurrentSource, Dialect>
|
|
@@ -4869,7 +5354,10 @@ export type PublicStructuredFromResult<
|
|
|
4869
5354
|
Exclude<OutstandingOfPlan<PlanValue>, SourceNameOf<CurrentSource>>,
|
|
4870
5355
|
AssumptionsOfPlan<PlanValue>,
|
|
4871
5356
|
MergeCapabilities<CapabilitiesOfPlan<PlanValue>, SourceCapabilitiesOf<CurrentSource>>,
|
|
4872
|
-
StatementOfPlan<PlanValue
|
|
5357
|
+
StatementOfPlan<PlanValue>,
|
|
5358
|
+
MutationTargetOfPlan<PlanValue>,
|
|
5359
|
+
InsertSourceStateOfPlan<PlanValue>,
|
|
5360
|
+
FactsOfPlan<PlanValue>
|
|
4873
5361
|
>
|
|
4874
5362
|
: StatementOfPlan<PlanValue> extends "update"
|
|
4875
5363
|
? QueryPlan<
|
|
@@ -4882,7 +5370,10 @@ export type PublicStructuredFromResult<
|
|
|
4882
5370
|
Exclude<OutstandingOfPlan<PlanValue>, SourceNameOf<CurrentSource>>,
|
|
4883
5371
|
AssumptionsOfPlan<PlanValue>,
|
|
4884
5372
|
MergeCapabilities<CapabilitiesOfPlan<PlanValue>, SourceCapabilitiesOf<CurrentSource>>,
|
|
4885
|
-
StatementOfPlan<PlanValue
|
|
5373
|
+
StatementOfPlan<PlanValue>,
|
|
5374
|
+
MutationTargetOfPlan<PlanValue>,
|
|
5375
|
+
InsertSourceStateOfPlan<PlanValue>,
|
|
5376
|
+
FactsOfPlan<PlanValue>
|
|
4886
5377
|
>
|
|
4887
5378
|
: StatementOfPlan<PlanValue> extends "insert"
|
|
4888
5379
|
? CurrentSource extends AnyValuesSource | AnyUnnestSource
|
|
@@ -4890,7 +5381,7 @@ export type PublicStructuredFromResult<
|
|
|
4890
5381
|
SelectionOfPlan<PlanValue>,
|
|
4891
5382
|
never,
|
|
4892
5383
|
AvailableOfPlan<PlanValue>,
|
|
4893
|
-
PlanDialectOf<PlanValue>,
|
|
5384
|
+
PlanDialectOf<PlanValue> | SourceDialectOf<CurrentSource>,
|
|
4894
5385
|
GroupedOfPlan<PlanValue>,
|
|
4895
5386
|
ScopedNamesOfPlan<PlanValue>,
|
|
4896
5387
|
never,
|
|
@@ -4898,7 +5389,8 @@ export type PublicStructuredFromResult<
|
|
|
4898
5389
|
CapabilitiesOfPlan<PlanValue>,
|
|
4899
5390
|
StatementOfPlan<PlanValue>,
|
|
4900
5391
|
MutationTargetOfPlan<PlanValue>,
|
|
4901
|
-
"ready"
|
|
5392
|
+
"ready",
|
|
5393
|
+
FactsOfPlan<PlanValue>
|
|
4902
5394
|
>
|
|
4903
5395
|
: FromPlanResult<PlanValue, CurrentSource, Dialect>
|
|
4904
5396
|
: FromPlanResult<PlanValue, CurrentSource, Dialect>
|
|
@@ -4954,20 +5446,20 @@ type AsCurriedResult<
|
|
|
4954
5446
|
>(
|
|
4955
5447
|
value: Value,
|
|
4956
5448
|
alias: Alias
|
|
4957
|
-
): DialectAsExpression<Value, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>
|
|
5449
|
+
): ProjectionAliasedExpression<DialectAsExpression<Value, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>, Alias>
|
|
4958
5450
|
function as<
|
|
4959
5451
|
Rows extends ValuesRowsInput,
|
|
4960
5452
|
Alias extends string
|
|
4961
5453
|
>(
|
|
4962
5454
|
value: ValuesInput<
|
|
4963
5455
|
Rows,
|
|
4964
|
-
ValuesOutputShape<Rows
|
|
5456
|
+
ValuesOutputShape<Rows, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>,
|
|
4965
5457
|
Dialect
|
|
4966
5458
|
>,
|
|
4967
5459
|
alias: Alias
|
|
4968
5460
|
): ValuesSource<
|
|
4969
5461
|
Rows,
|
|
4970
|
-
ValuesOutputShape<Rows
|
|
5462
|
+
ValuesOutputShape<Rows, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>,
|
|
4971
5463
|
Alias,
|
|
4972
5464
|
Dialect
|
|
4973
5465
|
>
|
|
@@ -4975,7 +5467,7 @@ type AsCurriedResult<
|
|
|
4975
5467
|
PlanValue extends QueryPlan<any, any, any, any, any, any, any, any, any, any>,
|
|
4976
5468
|
Alias extends string
|
|
4977
5469
|
>(
|
|
4978
|
-
value:
|
|
5470
|
+
value: DerivedTableCompatiblePlan<PlanValue>,
|
|
4979
5471
|
alias: Alias
|
|
4980
5472
|
): DerivedSource<PlanValue, Alias>
|
|
4981
5473
|
function as(valueOrAlias: unknown, alias?: string): unknown {
|
|
@@ -5022,13 +5514,13 @@ type AsCurriedResult<
|
|
|
5022
5514
|
>(
|
|
5023
5515
|
alias: Alias
|
|
5024
5516
|
): <PlanValue extends QueryPlan<any, any, any, any, any, any, any, any, any, any>>(
|
|
5025
|
-
value:
|
|
5517
|
+
value: MysqlCteCompatiblePlan<PlanValue>
|
|
5026
5518
|
) => import("../../internal/query.js").CteSource<PlanValue, Alias>
|
|
5027
5519
|
function with_<
|
|
5028
5520
|
PlanValue extends QueryPlan<any, any, any, any, any, any, any, any, any, any>,
|
|
5029
5521
|
Alias extends string
|
|
5030
5522
|
>(
|
|
5031
|
-
value:
|
|
5523
|
+
value: MysqlCteCompatiblePlan<PlanValue>,
|
|
5032
5524
|
alias: Alias
|
|
5033
5525
|
): import("../../internal/query.js").CteSource<PlanValue, Alias>
|
|
5034
5526
|
function with_(valueOrAlias: unknown, alias?: string): unknown {
|
|
@@ -5046,13 +5538,13 @@ type AsCurriedResult<
|
|
|
5046
5538
|
>(
|
|
5047
5539
|
alias: Alias
|
|
5048
5540
|
): <PlanValue extends QueryPlan<any, any, any, any, any, any, any, any, any, any>>(
|
|
5049
|
-
value:
|
|
5541
|
+
value: MysqlCteCompatiblePlan<PlanValue>
|
|
5050
5542
|
) => import("../../internal/query.js").CteSource<PlanValue, Alias>
|
|
5051
5543
|
function withRecursive_<
|
|
5052
5544
|
PlanValue extends QueryPlan<any, any, any, any, any, any, any, any, any, any>,
|
|
5053
5545
|
Alias extends string
|
|
5054
5546
|
>(
|
|
5055
|
-
value:
|
|
5547
|
+
value: MysqlCteCompatiblePlan<PlanValue>,
|
|
5056
5548
|
alias: Alias
|
|
5057
5549
|
): import("../../internal/query.js").CteSource<PlanValue, Alias>
|
|
5058
5550
|
function withRecursive_(valueOrAlias: unknown, alias?: string): unknown {
|
|
@@ -5071,13 +5563,13 @@ type AsCurriedResult<
|
|
|
5071
5563
|
>(
|
|
5072
5564
|
alias: Alias
|
|
5073
5565
|
): <PlanValue extends QueryPlan<any, any, any, any, any, any, any, any, any, any>>(
|
|
5074
|
-
value: PlanValue
|
|
5566
|
+
value: LateralSourceCompatiblePlan<PlanValue>
|
|
5075
5567
|
) => import("../../internal/query.js").LateralSource<PlanValue, Alias>
|
|
5076
5568
|
function lateral<
|
|
5077
5569
|
PlanValue extends QueryPlan<any, any, any, any, any, any, any, any, any, any>,
|
|
5078
5570
|
Alias extends string
|
|
5079
5571
|
>(
|
|
5080
|
-
value: PlanValue
|
|
5572
|
+
value: LateralSourceCompatiblePlan<PlanValue>,
|
|
5081
5573
|
alias: Alias
|
|
5082
5574
|
): import("../../internal/query.js").LateralSource<PlanValue, Alias>
|
|
5083
5575
|
function lateral(valueOrAlias: unknown, alias?: string): unknown {
|
|
@@ -5094,9 +5586,11 @@ type AsCurriedResult<
|
|
|
5094
5586
|
Rows extends ValuesRowsInput
|
|
5095
5587
|
>(
|
|
5096
5588
|
rows: Rows
|
|
5589
|
+
& ValuesRowsShapeInput<Rows>
|
|
5590
|
+
& ValuesRowsDialectInput<Rows, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>
|
|
5097
5591
|
) => ValuesInput<
|
|
5098
5592
|
Rows,
|
|
5099
|
-
ValuesOutputShape<Rows
|
|
5593
|
+
ValuesOutputShape<Rows, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>,
|
|
5100
5594
|
Dialect
|
|
5101
5595
|
>
|
|
5102
5596
|
|
|
@@ -5104,7 +5598,9 @@ type AsCurriedResult<
|
|
|
5104
5598
|
Columns extends UnnestColumnsInput,
|
|
5105
5599
|
Alias extends string
|
|
5106
5600
|
>(
|
|
5107
|
-
columns: Columns
|
|
5601
|
+
columns: Columns
|
|
5602
|
+
& UnnestColumnsShapeInput<Columns>
|
|
5603
|
+
& UnnestColumnsDialectInput<Columns, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>,
|
|
5108
5604
|
alias: Alias
|
|
5109
5605
|
) => UnnestSource<
|
|
5110
5606
|
UnnestOutputShape<Columns, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>,
|
|
@@ -5118,9 +5614,9 @@ type AsCurriedResult<
|
|
|
5118
5614
|
Step extends NumericExpressionInput | undefined = undefined,
|
|
5119
5615
|
Alias extends string = "series"
|
|
5120
5616
|
>(
|
|
5121
|
-
start: Start,
|
|
5122
|
-
stop: Stop,
|
|
5123
|
-
step?: Step,
|
|
5617
|
+
start: Start & NumericExpressionDialectInput<Start, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>,
|
|
5618
|
+
stop: Stop & NumericExpressionDialectInput<Stop, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>,
|
|
5619
|
+
step?: Step & (Step extends NumericExpressionInput ? NumericExpressionDialectInput<Step, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb> : unknown),
|
|
5124
5620
|
alias?: Alias
|
|
5125
5621
|
) => Dialect extends "postgres"
|
|
5126
5622
|
? TableFunctionSource<
|
|
@@ -5131,8 +5627,45 @@ type AsCurriedResult<
|
|
|
5131
5627
|
>
|
|
5132
5628
|
: GenerateSeriesUnsupportedError<Dialect>
|
|
5133
5629
|
|
|
5630
|
+
type SelectSelectionNonEmptyError<Selection> = Selection & {
|
|
5631
|
+
readonly __effect_qb_error__: "effect-qb: mysql select statements require at least one selected expression"
|
|
5632
|
+
}
|
|
5633
|
+
|
|
5634
|
+
type SelectionRootObjectError<Selection> = Selection & {
|
|
5635
|
+
readonly __effect_qb_error__: "effect-qb: selections must be projection objects"
|
|
5636
|
+
readonly __effect_qb_hint__: "Use select({ value: expression }) or returning({ value: expression })"
|
|
5637
|
+
}
|
|
5638
|
+
|
|
5639
|
+
type SelectionRootObjectConstraint<Selection> =
|
|
5640
|
+
Selection extends Expression.Any ? SelectionRootObjectError<Selection> : unknown
|
|
5641
|
+
|
|
5642
|
+
type SelectionNestedEmptyError<Selection> = Selection & {
|
|
5643
|
+
readonly __effect_qb_error__: "effect-qb: projection objects cannot contain empty nested selections"
|
|
5644
|
+
}
|
|
5645
|
+
|
|
5646
|
+
type SelectionHasEmptyNestedObject<Selection, IsRoot extends boolean> =
|
|
5647
|
+
Selection extends Expression.Any
|
|
5648
|
+
? false
|
|
5649
|
+
: Selection extends Record<string, any>
|
|
5650
|
+
? [Extract<keyof Selection, string>] extends [never]
|
|
5651
|
+
? IsRoot extends true ? false : true
|
|
5652
|
+
: true extends {
|
|
5653
|
+
[K in Extract<keyof Selection, string>]: SelectionHasEmptyNestedObject<Selection[K], false>
|
|
5654
|
+
}[Extract<keyof Selection, string>]
|
|
5655
|
+
? true
|
|
5656
|
+
: false
|
|
5657
|
+
: false
|
|
5658
|
+
|
|
5659
|
+
type SelectionNestedNonEmptyConstraint<Selection> =
|
|
5660
|
+
SelectionHasEmptyNestedObject<Selection, true> extends true ? SelectionNestedEmptyError<Selection> : unknown
|
|
5661
|
+
|
|
5662
|
+
type SelectSelectionNonEmptyConstraint<Selection> =
|
|
5663
|
+
[Extract<keyof Selection, string>] extends [never]
|
|
5664
|
+
? SelectSelectionNonEmptyError<Selection>
|
|
5665
|
+
: unknown
|
|
5666
|
+
|
|
5134
5667
|
export type SelectApi = <Selection extends SelectionShape>(
|
|
5135
|
-
selection: Selection
|
|
5668
|
+
selection: Selection & SelectionRootObjectConstraint<Selection> & SelectionNestedNonEmptyConstraint<Selection> & SelectSelectionNonEmptyConstraint<Selection>
|
|
5136
5669
|
) => QueryPlan<
|
|
5137
5670
|
Selection,
|
|
5138
5671
|
ExtractRequired<Selection>,
|
|
@@ -5169,7 +5702,7 @@ type AsCurriedResult<
|
|
|
5169
5702
|
getQueryState,
|
|
5170
5703
|
currentRequiredList,
|
|
5171
5704
|
dedupeGroupedExpressions
|
|
5172
|
-
}) as {
|
|
5705
|
+
}) as unknown as {
|
|
5173
5706
|
readonly values: ValuesApi
|
|
5174
5707
|
readonly unnest: UnnestApi
|
|
5175
5708
|
readonly generateSeries: GenerateSeriesApi
|
|
@@ -5191,7 +5724,10 @@ type AsCurriedResult<
|
|
|
5191
5724
|
never,
|
|
5192
5725
|
TrueFormula,
|
|
5193
5726
|
CapabilitiesOfPlan<LeftPlanValue> | CapabilitiesOfPlan<RightPlanValue>,
|
|
5194
|
-
"set"
|
|
5727
|
+
"set",
|
|
5728
|
+
any,
|
|
5729
|
+
"ready",
|
|
5730
|
+
CommonSetFacts<LeftPlanValue, RightPlanValue>
|
|
5195
5731
|
>
|
|
5196
5732
|
|
|
5197
5733
|
type SetOperationApi = <
|
|
@@ -5259,10 +5795,10 @@ type AsCurriedResult<
|
|
|
5259
5795
|
keyof AvailableOfPlan<PlanValue> extends never ? never : unknown
|
|
5260
5796
|
) & (
|
|
5261
5797
|
SourceNameOf<CurrentTable> extends ScopedNamesOfPlan<PlanValue> ? never : unknown
|
|
5262
|
-
)
|
|
5798
|
+
) & SourceRequirementConstraint<PlanValue, CurrentTable> & SourceDialectConstraint<CurrentTable, Dialect>
|
|
5263
5799
|
) => QueryPlan<
|
|
5264
5800
|
SelectionOfPlan<PlanValue>,
|
|
5265
|
-
AddJoinRequired<RequiredOfPlan<PlanValue>, AvailableOfPlan<PlanValue>, SourceNameOf<CurrentTable>, never, "cross"
|
|
5801
|
+
AddJoinRequired<RequiredOfPlan<PlanValue>, AvailableOfPlan<PlanValue>, SourceNameOf<CurrentTable>, never, "cross", SourceRequiredOf<CurrentTable>>,
|
|
5266
5802
|
AddAvailable<
|
|
5267
5803
|
AvailableOfPlan<PlanValue>,
|
|
5268
5804
|
SourceNameOf<CurrentTable>,
|
|
@@ -5273,10 +5809,13 @@ type AsCurriedResult<
|
|
|
5273
5809
|
PlanDialectOf<PlanValue> | SourceDialectOf<CurrentTable>,
|
|
5274
5810
|
GroupedOfPlan<PlanValue>,
|
|
5275
5811
|
ScopedNamesOfPlan<PlanValue> | SourceNameOf<CurrentTable>,
|
|
5276
|
-
AddJoinRequired<OutstandingOfPlan<PlanValue>, AvailableOfPlan<PlanValue>, SourceNameOf<CurrentTable>, never, "cross"
|
|
5812
|
+
AddJoinRequired<OutstandingOfPlan<PlanValue>, AvailableOfPlan<PlanValue>, SourceNameOf<CurrentTable>, never, "cross", SourceRequiredOf<CurrentTable>>,
|
|
5277
5813
|
AssumptionsOfPlan<PlanValue>,
|
|
5278
5814
|
MergeCapabilities<CapabilitiesOfPlan<PlanValue>, SourceCapabilitiesOf<CurrentTable>>,
|
|
5279
|
-
StatementOfPlan<PlanValue
|
|
5815
|
+
StatementOfPlan<PlanValue>,
|
|
5816
|
+
MutationTargetOfPlan<PlanValue>,
|
|
5817
|
+
InsertSourceStateOfPlan<PlanValue>,
|
|
5818
|
+
FactsOfPlan<PlanValue>
|
|
5280
5819
|
>
|
|
5281
5820
|
|
|
5282
5821
|
type JoinApi = <
|
|
@@ -5293,10 +5832,10 @@ type AsCurriedResult<
|
|
|
5293
5832
|
keyof AvailableOfPlan<PlanValue> extends never ? never : unknown
|
|
5294
5833
|
) & (
|
|
5295
5834
|
SourceNameOf<CurrentTable> extends ScopedNamesOfPlan<PlanValue> ? never : unknown
|
|
5296
|
-
)
|
|
5835
|
+
) & SourceRequirementConstraint<PlanValue, CurrentTable> & SourceDialectConstraint<CurrentTable, Dialect>
|
|
5297
5836
|
) => QueryPlan<
|
|
5298
5837
|
SelectionOfPlan<PlanValue>,
|
|
5299
|
-
AddJoinRequired<RequiredOfPlan<PlanValue>, AvailableOfPlan<PlanValue>, SourceNameOf<CurrentTable>, Predicate, Kind
|
|
5838
|
+
AddJoinRequired<RequiredOfPlan<PlanValue>, AvailableOfPlan<PlanValue>, SourceNameOf<CurrentTable>, Predicate, Kind, SourceRequiredOf<CurrentTable>>,
|
|
5300
5839
|
AvailableAfterJoin<
|
|
5301
5840
|
AvailableOfPlan<PlanValue>,
|
|
5302
5841
|
SourceNameOf<CurrentTable>,
|
|
@@ -5307,7 +5846,7 @@ type AsCurriedResult<
|
|
|
5307
5846
|
PlanDialectOf<PlanValue> | SourceDialectOf<CurrentTable> | DialectOfDialectInput<Predicate, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>,
|
|
5308
5847
|
GroupedOfPlan<PlanValue>,
|
|
5309
5848
|
ScopedNamesOfPlan<PlanValue> | SourceNameOf<CurrentTable>,
|
|
5310
|
-
AddJoinRequired<OutstandingOfPlan<PlanValue>, AvailableOfPlan<PlanValue>, SourceNameOf<CurrentTable>, Predicate, Kind
|
|
5849
|
+
AddJoinRequired<OutstandingOfPlan<PlanValue>, AvailableOfPlan<PlanValue>, SourceNameOf<CurrentTable>, Predicate, Kind, SourceRequiredOf<CurrentTable>>,
|
|
5311
5850
|
PlanAssumptionsAfterJoin<PlanValue, Predicate, Kind, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>,
|
|
5312
5851
|
MergeCapabilities<CapabilitiesOfPlan<PlanValue>, SourceCapabilitiesOf<CurrentTable>>,
|
|
5313
5852
|
StatementOfPlan<PlanValue>,
|
|
@@ -5328,10 +5867,10 @@ type AsCurriedResult<
|
|
|
5328
5867
|
keyof AvailableOfPlan<PlanValue> extends never ? never : unknown
|
|
5329
5868
|
) & (
|
|
5330
5869
|
SourceNameOf<CurrentTable> extends ScopedNamesOfPlan<PlanValue> ? never : unknown
|
|
5331
|
-
)
|
|
5870
|
+
) & SourceRequirementConstraint<PlanValue, CurrentTable> & SourceDialectConstraint<CurrentTable, Dialect>
|
|
5332
5871
|
) => QueryPlan<
|
|
5333
5872
|
SelectionOfPlan<PlanValue>,
|
|
5334
|
-
AddJoinRequired<RequiredOfPlan<PlanValue>, AvailableOfPlan<PlanValue>, SourceNameOf<CurrentTable>, Predicate, Kind
|
|
5873
|
+
AddJoinRequired<RequiredOfPlan<PlanValue>, AvailableOfPlan<PlanValue>, SourceNameOf<CurrentTable>, Predicate, Kind, SourceRequiredOf<CurrentTable>>,
|
|
5335
5874
|
AvailableAfterJoin<
|
|
5336
5875
|
AvailableOfPlan<PlanValue>,
|
|
5337
5876
|
SourceNameOf<CurrentTable>,
|
|
@@ -5342,7 +5881,7 @@ type AsCurriedResult<
|
|
|
5342
5881
|
PlanDialectOf<PlanValue> | SourceDialectOf<CurrentTable> | DialectOfDialectInput<Predicate, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>,
|
|
5343
5882
|
GroupedOfPlan<PlanValue>,
|
|
5344
5883
|
ScopedNamesOfPlan<PlanValue> | SourceNameOf<CurrentTable>,
|
|
5345
|
-
AddJoinRequired<OutstandingOfPlan<PlanValue>, AvailableOfPlan<PlanValue>, SourceNameOf<CurrentTable>, Predicate, Kind
|
|
5884
|
+
AddJoinRequired<OutstandingOfPlan<PlanValue>, AvailableOfPlan<PlanValue>, SourceNameOf<CurrentTable>, Predicate, Kind, SourceRequiredOf<CurrentTable>>,
|
|
5346
5885
|
PlanAssumptionsAfterJoin<PlanValue, Predicate, Kind, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>,
|
|
5347
5886
|
MergeCapabilities<CapabilitiesOfPlan<PlanValue>, SourceCapabilitiesOf<CurrentTable>>,
|
|
5348
5887
|
StatementOfPlan<PlanValue>,
|
|
@@ -5351,6 +5890,8 @@ type AsCurriedResult<
|
|
|
5351
5890
|
PlanFactsAfterJoin<PlanValue, Predicate, Kind, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>
|
|
5352
5891
|
>
|
|
5353
5892
|
|
|
5893
|
+
type FullJoinApi = Dialect extends "postgres" ? BinaryJoinApi<"full"> : FullJoinUnsupportedError<Dialect>
|
|
5894
|
+
|
|
5354
5895
|
type OrderByApi = <Value extends ExpressionInput>(
|
|
5355
5896
|
value: Value,
|
|
5356
5897
|
direction?: OrderDirection
|
|
@@ -5548,7 +6089,7 @@ type AsCurriedResult<
|
|
|
5548
6089
|
|
|
5549
6090
|
const rightJoin = ((table, on) => (join as any)("right", table, on)) as BinaryJoinApi<"right">
|
|
5550
6091
|
|
|
5551
|
-
const fullJoin = ((table, on) => (join as any)("full", table, on)) as
|
|
6092
|
+
const fullJoin = ((table: any, on: any) => (join as any)("full", table, on)) as unknown as FullJoinApi
|
|
5552
6093
|
|
|
5553
6094
|
const distinctOn = {
|
|
5554
6095
|
__effect_qb_error__: "effect-qb: distinctOn(...) is only supported by the postgres dialect",
|
|
@@ -5577,30 +6118,43 @@ type AsCurriedResult<
|
|
|
5577
6118
|
FactsOfPlan<PlanValue>
|
|
5578
6119
|
>
|
|
5579
6120
|
|
|
5580
|
-
type
|
|
5581
|
-
|
|
5582
|
-
|
|
5583
|
-
|
|
5584
|
-
|
|
5585
|
-
|
|
5586
|
-
|
|
5587
|
-
|
|
5588
|
-
|
|
5589
|
-
|
|
5590
|
-
|
|
5591
|
-
|
|
5592
|
-
|
|
5593
|
-
|
|
5594
|
-
|
|
5595
|
-
|
|
5596
|
-
|
|
5597
|
-
|
|
5598
|
-
|
|
5599
|
-
|
|
6121
|
+
type ReturningSelectionNonEmptyError<Selection> = Selection & {
|
|
6122
|
+
readonly __effect_qb_error__: "effect-qb: returning(...) requires at least one selected expression"
|
|
6123
|
+
}
|
|
6124
|
+
|
|
6125
|
+
type ReturningSelectionNonEmptyConstraint<Selection> =
|
|
6126
|
+
Selection extends Expression.Any
|
|
6127
|
+
? unknown
|
|
6128
|
+
: [Extract<keyof Selection, string>] extends [never]
|
|
6129
|
+
? ReturningSelectionNonEmptyError<Selection>
|
|
6130
|
+
: unknown
|
|
6131
|
+
|
|
6132
|
+
type ReturningApi = Dialect extends "postgres"
|
|
6133
|
+
? <Selection extends SelectionShape>(
|
|
6134
|
+
selection: Selection & SelectionRootObjectConstraint<Selection> & SelectionNestedNonEmptyConstraint<Selection> & ReturningSelectionNonEmptyConstraint<Selection>
|
|
6135
|
+
) =>
|
|
6136
|
+
<PlanValue extends QueryPlan<any, any, any, any, any, any, any, any, any, any>>(
|
|
6137
|
+
plan: PlanValue & RequireMutationStatement<PlanValue>
|
|
6138
|
+
) => QueryPlan<
|
|
6139
|
+
Selection,
|
|
6140
|
+
Exclude<RequiredOfPlan<PlanValue> | ExtractRequired<Selection>, AvailableNames<AvailableOfPlan<PlanValue>>>,
|
|
6141
|
+
AvailableOfPlan<PlanValue>,
|
|
6142
|
+
PlanDialectOf<PlanValue> | ExtractDialect<Selection>,
|
|
6143
|
+
GroupedOfPlan<PlanValue>,
|
|
6144
|
+
ScopedNamesOfPlan<PlanValue>,
|
|
6145
|
+
Exclude<OutstandingOfPlan<PlanValue> | ExtractRequired<Selection>, AvailableNames<AvailableOfPlan<PlanValue>>>,
|
|
6146
|
+
AssumptionsOfPlan<PlanValue>,
|
|
6147
|
+
CapabilitiesOfPlan<PlanValue>,
|
|
6148
|
+
StatementOfPlan<PlanValue>,
|
|
6149
|
+
MutationTargetOfPlan<PlanValue>,
|
|
6150
|
+
InsertSourceStateOfPlan<PlanValue>,
|
|
6151
|
+
FactsOfPlan<PlanValue>
|
|
6152
|
+
>
|
|
6153
|
+
: ReturningUnsupportedError<Dialect>
|
|
5600
6154
|
|
|
5601
6155
|
export interface InsertApi {
|
|
5602
6156
|
<Target extends MutationTargetLike>(
|
|
5603
|
-
target: Target
|
|
6157
|
+
target: Target & TableDialectConstraint<Target, Dialect>
|
|
5604
6158
|
): QueryPlan<
|
|
5605
6159
|
{},
|
|
5606
6160
|
never,
|
|
@@ -5617,13 +6171,13 @@ type AsCurriedResult<
|
|
|
5617
6171
|
EmptyFacts
|
|
5618
6172
|
>
|
|
5619
6173
|
<Target extends MutationTargetLike, Values extends Record<string, unknown>>(
|
|
5620
|
-
target: Target,
|
|
5621
|
-
values: MutationValuesInput<"insert", Target, Values>
|
|
6174
|
+
target: Target & TableDialectConstraint<Target, Dialect>,
|
|
6175
|
+
values: MutationValuesInput<"insert", Target, Values> & MutationValuesDialectConstraint<Values, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>
|
|
5622
6176
|
): QueryPlan<
|
|
5623
6177
|
{},
|
|
5624
6178
|
Exclude<MutationRequiredFromValues<Values>, SourceNameOf<Target>>,
|
|
5625
6179
|
AddAvailable<{}, SourceNameOf<Target>>,
|
|
5626
|
-
TableDialectOf<Target>,
|
|
6180
|
+
TableDialectOf<Target> | KnownMutationDialectFromValues<Values, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>,
|
|
5627
6181
|
never,
|
|
5628
6182
|
SourceNameOf<Target>,
|
|
5629
6183
|
Exclude<MutationRequiredFromValues<Values>, SourceNameOf<Target>>,
|
|
@@ -5645,21 +6199,22 @@ type AsCurriedResult<
|
|
|
5645
6199
|
Target extends MutationTargetLike,
|
|
5646
6200
|
const Columns extends DdlColumnInput,
|
|
5647
6201
|
UpdateValues extends MutationInputOf<Table.UpdateOf<Target>> | undefined = MutationInputOf<Table.UpdateOf<Target>> | undefined,
|
|
5648
|
-
Options extends ConflictActionInput<Target, Dialect, UpdateValues> = ConflictActionInput<Target, Dialect, UpdateValues
|
|
6202
|
+
Options extends ConflictActionInput<Target, Dialect, UpdateValues> = ConflictActionInput<Target, Dialect, UpdateValues>,
|
|
6203
|
+
ConflictTarget extends ConflictTargetInput<Target, Dialect, Columns> = ConflictTargetInput<Target, Dialect, Columns>
|
|
5649
6204
|
>(
|
|
5650
|
-
target:
|
|
5651
|
-
options?: Options
|
|
6205
|
+
target: ConflictTarget,
|
|
6206
|
+
options?: Options & ConflictActionUpdateNonEmptyConstraint<Options>
|
|
5652
6207
|
) =>
|
|
5653
6208
|
<PlanValue extends QueryPlan<any, any, any, any, any, any, any, any, any, any>>(
|
|
5654
6209
|
plan: PlanValue & RequireInsertStatement<PlanValue>
|
|
5655
6210
|
) => QueryPlan<
|
|
5656
6211
|
SelectionOfPlan<PlanValue>,
|
|
5657
|
-
Exclude<RequiredOfPlan<PlanValue> |
|
|
6212
|
+
Exclude<RequiredOfPlan<PlanValue> | ConflictRequired<UpdateValues, Options, ConflictTarget>, AvailableNames<AvailableOfPlan<PlanValue>>>,
|
|
5658
6213
|
AvailableOfPlan<PlanValue>,
|
|
5659
|
-
PlanDialectOf<PlanValue>,
|
|
6214
|
+
PlanDialectOf<PlanValue> | ConflictDialect<UpdateValues, Options, ConflictTarget, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>,
|
|
5660
6215
|
GroupedOfPlan<PlanValue>,
|
|
5661
6216
|
ScopedNamesOfPlan<PlanValue>,
|
|
5662
|
-
Exclude<OutstandingOfPlan<PlanValue> |
|
|
6217
|
+
Exclude<OutstandingOfPlan<PlanValue> | ConflictRequired<UpdateValues, Options, ConflictTarget>, AvailableNames<AvailableOfPlan<PlanValue>>>,
|
|
5663
6218
|
AssumptionsOfPlan<PlanValue>,
|
|
5664
6219
|
CapabilitiesOfPlan<PlanValue>,
|
|
5665
6220
|
StatementOfPlan<PlanValue>,
|
|
@@ -5670,13 +6225,13 @@ type AsCurriedResult<
|
|
|
5670
6225
|
|
|
5671
6226
|
interface UpdateApi {
|
|
5672
6227
|
<Targets extends MutationTargetTuple, Values extends UpdateInputOfTarget<Targets>>(
|
|
5673
|
-
target: Dialect extends "mysql" ? Targets : never,
|
|
5674
|
-
values: Values
|
|
6228
|
+
target: Dialect extends "mysql" ? Targets & MutationTargetTupleDialectConstraint<Targets, Dialect> & MutationTargetTupleUniqueNamesConstraint<Targets> : never,
|
|
6229
|
+
values: Values & NestedUpdateValuesNonEmptyConstraint<Values> & MutationValuesDialectConstraint<Values, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>
|
|
5675
6230
|
): QueryPlan<
|
|
5676
6231
|
{},
|
|
5677
6232
|
Exclude<NestedMutationRequiredFromValues<Values>, MutationTargetNamesOf<Targets>>,
|
|
5678
6233
|
AddAvailableMany<{}, MutationTargetNamesOf<Targets>>,
|
|
5679
|
-
TableDialectOf<Targets[0]>,
|
|
6234
|
+
TableDialectOf<Targets[0]> | KnownMutationDialectFromValues<Values, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>,
|
|
5680
6235
|
never,
|
|
5681
6236
|
MutationTargetNamesOf<Targets>,
|
|
5682
6237
|
Exclude<NestedMutationRequiredFromValues<Values>, MutationTargetNamesOf<Targets>>,
|
|
@@ -5688,13 +6243,13 @@ type AsCurriedResult<
|
|
|
5688
6243
|
EmptyFacts
|
|
5689
6244
|
>
|
|
5690
6245
|
<Target extends MutationTargetLike, Values extends Record<string, unknown>>(
|
|
5691
|
-
target: Target,
|
|
5692
|
-
values: MutationValuesInput<"update", Target, Values>
|
|
6246
|
+
target: Target & TableDialectConstraint<Target, Dialect>,
|
|
6247
|
+
values: MutationValuesInput<"update", Target, Values> & UpdateValuesNonEmptyConstraint<Values> & MutationValuesDialectConstraint<Values, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>
|
|
5693
6248
|
): QueryPlan<
|
|
5694
6249
|
{},
|
|
5695
6250
|
Exclude<MutationRequiredFromValues<Values>, SourceNameOf<Target>>,
|
|
5696
6251
|
AddAvailable<{}, SourceNameOf<Target>>,
|
|
5697
|
-
TableDialectOf<Target>,
|
|
6252
|
+
TableDialectOf<Target> | KnownMutationDialectFromValues<Values, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>,
|
|
5698
6253
|
never,
|
|
5699
6254
|
SourceNameOf<Target>,
|
|
5700
6255
|
Exclude<MutationRequiredFromValues<Values>, SourceNameOf<Target>>,
|
|
@@ -5711,20 +6266,22 @@ type AsCurriedResult<
|
|
|
5711
6266
|
Target extends MutationTargetLike,
|
|
5712
6267
|
Values extends MutationInputOf<Table.InsertOf<Target>>,
|
|
5713
6268
|
const Columns extends DdlColumnInput,
|
|
5714
|
-
UpdateValues extends MutationInputOf<Table.UpdateOf<Target>>
|
|
6269
|
+
UpdateValues extends MutationInputOf<Table.UpdateOf<Target>> | undefined = undefined
|
|
5715
6270
|
>(
|
|
5716
|
-
target: Target,
|
|
5717
|
-
values: Values,
|
|
5718
|
-
conflictColumns:
|
|
5719
|
-
updateValues?: UpdateValues
|
|
6271
|
+
target: Target & TableDialectConstraint<Target, Dialect>,
|
|
6272
|
+
values: Values & MutationValuesDialectConstraint<Values, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>,
|
|
6273
|
+
conflictColumns: ValidateTargetColumnInput<Target, Columns>,
|
|
6274
|
+
updateValues?: UpdateValues & UpdateValuesNonEmptyConstraint<Exclude<UpdateValues, undefined>> & MutationValuesDialectConstraint<Exclude<UpdateValues, undefined>, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>
|
|
5720
6275
|
) => QueryPlan<
|
|
5721
6276
|
{},
|
|
5722
|
-
Exclude<MutationRequiredFromValues<Values> | MutationRequiredFromValues<UpdateValues
|
|
6277
|
+
Exclude<MutationRequiredFromValues<Values> | MutationRequiredFromValues<Exclude<UpdateValues, undefined>>, SourceNameOf<Target>>,
|
|
5723
6278
|
AddAvailable<{}, SourceNameOf<Target>>,
|
|
5724
|
-
TableDialectOf<Target
|
|
6279
|
+
| TableDialectOf<Target>
|
|
6280
|
+
| KnownMutationDialectFromValues<Values, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>
|
|
6281
|
+
| KnownMutationDialectFromValues<Exclude<UpdateValues, undefined>, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>,
|
|
5725
6282
|
never,
|
|
5726
6283
|
SourceNameOf<Target>,
|
|
5727
|
-
Exclude<MutationRequiredFromValues<Values> | MutationRequiredFromValues<UpdateValues
|
|
6284
|
+
Exclude<MutationRequiredFromValues<Values> | MutationRequiredFromValues<Exclude<UpdateValues, undefined>>, SourceNameOf<Target>>,
|
|
5728
6285
|
TrueFormula,
|
|
5729
6286
|
"write",
|
|
5730
6287
|
"insert",
|
|
@@ -5735,7 +6292,7 @@ type AsCurriedResult<
|
|
|
5735
6292
|
|
|
5736
6293
|
interface DeleteApi {
|
|
5737
6294
|
<Target extends MutationTargetLike>(
|
|
5738
|
-
target: Target
|
|
6295
|
+
target: Target & TableDialectConstraint<Target, Dialect>
|
|
5739
6296
|
): QueryPlan<
|
|
5740
6297
|
{},
|
|
5741
6298
|
never,
|
|
@@ -5752,7 +6309,7 @@ type AsCurriedResult<
|
|
|
5752
6309
|
EmptyFacts
|
|
5753
6310
|
>
|
|
5754
6311
|
<Targets extends MutationTargetTuple>(
|
|
5755
|
-
target: Dialect extends "mysql" ? Targets : never
|
|
6312
|
+
target: Dialect extends "mysql" ? Targets & MutationTargetTupleDialectConstraint<Targets, Dialect> & MutationTargetTupleUniqueNamesConstraint<Targets> : never
|
|
5756
6313
|
): QueryPlan<
|
|
5757
6314
|
{},
|
|
5758
6315
|
never,
|
|
@@ -5771,7 +6328,7 @@ type AsCurriedResult<
|
|
|
5771
6328
|
}
|
|
5772
6329
|
|
|
5773
6330
|
type TruncateApi = <Target extends MutationTargetLike>(
|
|
5774
|
-
target: Target,
|
|
6331
|
+
target: Target & TableDialectConstraint<Target, Dialect>,
|
|
5775
6332
|
options?: TruncateOptions
|
|
5776
6333
|
) => QueryPlan<
|
|
5777
6334
|
{},
|
|
@@ -5789,7 +6346,13 @@ type AsCurriedResult<
|
|
|
5789
6346
|
EmptyFacts
|
|
5790
6347
|
>
|
|
5791
6348
|
|
|
5792
|
-
type
|
|
6349
|
+
type MergeUnsupportedError<Dialect extends string> = {
|
|
6350
|
+
readonly __effect_qb_error__: "effect-qb: merge(...) is only supported by the postgres dialect"
|
|
6351
|
+
readonly __effect_qb_dialect__: Dialect
|
|
6352
|
+
readonly __effect_qb_hint__: "Use postgres.Query.merge(...) or dialect-specific insert/update/delete logic"
|
|
6353
|
+
}
|
|
6354
|
+
|
|
6355
|
+
type MergeSupportedApi = <
|
|
5793
6356
|
Target extends MutationTargetLike,
|
|
5794
6357
|
Source extends SourceLike,
|
|
5795
6358
|
On extends PredicateInput,
|
|
@@ -5798,12 +6361,12 @@ type AsCurriedResult<
|
|
|
5798
6361
|
MatchedPredicate extends PredicateInput | undefined = undefined,
|
|
5799
6362
|
NotMatchedPredicate extends PredicateInput | undefined = undefined
|
|
5800
6363
|
>(
|
|
5801
|
-
target: Target,
|
|
6364
|
+
target: Target & TableDialectConstraint<Target, Dialect>,
|
|
5802
6365
|
source: Source & (
|
|
5803
6366
|
SourceRequiredOf<Source> extends never ? unknown : SourceRequirementError<Source>
|
|
5804
|
-
),
|
|
6367
|
+
) & SourceDialectConstraint<Source, Dialect>,
|
|
5805
6368
|
on: On,
|
|
5806
|
-
options
|
|
6369
|
+
options: MergeOptions<Target, MatchedValues, InsertValues, MatchedPredicate, NotMatchedPredicate>
|
|
5807
6370
|
) => QueryPlan<
|
|
5808
6371
|
{},
|
|
5809
6372
|
Exclude<
|
|
@@ -5846,7 +6409,10 @@ type AsCurriedResult<
|
|
|
5846
6409
|
EmptyFacts
|
|
5847
6410
|
>
|
|
5848
6411
|
|
|
6412
|
+
type MergeApi = Dialect extends "postgres" ? MergeSupportedApi : MergeUnsupportedError<Dialect>
|
|
6413
|
+
|
|
5849
6414
|
const mutationRuntime = makeDslMutationRuntime({
|
|
6415
|
+
profile,
|
|
5850
6416
|
makePlan,
|
|
5851
6417
|
getAst,
|
|
5852
6418
|
getQueryState,
|
|
@@ -5859,7 +6425,7 @@ type AsCurriedResult<
|
|
|
5859
6425
|
buildConflictTarget,
|
|
5860
6426
|
mutationTargetClauses,
|
|
5861
6427
|
mutationAvailableSources,
|
|
5862
|
-
|
|
6428
|
+
normalizeConflictColumns,
|
|
5863
6429
|
targetSourceDetails,
|
|
5864
6430
|
sourceDetails
|
|
5865
6431
|
})
|
|
@@ -5875,63 +6441,21 @@ type AsCurriedResult<
|
|
|
5875
6441
|
): QueryPlan<any, any, any, any, any, any, any, any, any, "insert", MutationTargetLike, "ready"> =>
|
|
5876
6442
|
mutationRuntime.attachInsertSource(plan, source)
|
|
5877
6443
|
|
|
5878
|
-
const onConflict:
|
|
5879
|
-
|
|
5880
|
-
|
|
5881
|
-
UpdateValues extends MutationInputOf<Table.UpdateOf<Target>> | undefined = MutationInputOf<Table.UpdateOf<Target>> | undefined,
|
|
5882
|
-
Options extends ConflictActionInput<Target, Dialect, UpdateValues> = ConflictActionInput<Target, Dialect, UpdateValues>
|
|
5883
|
-
>(
|
|
5884
|
-
target: ConflictTargetInput<Target, Dialect, Columns>,
|
|
5885
|
-
options: Options = {} as Options
|
|
5886
|
-
) =>
|
|
5887
|
-
<PlanValue extends QueryPlan<any, any, any, any, any, any, any, any, any, any>>(
|
|
5888
|
-
plan: PlanValue & RequireInsertStatement<PlanValue>
|
|
5889
|
-
): QueryPlan<
|
|
5890
|
-
SelectionOfPlan<PlanValue>,
|
|
5891
|
-
Exclude<RequiredOfPlan<PlanValue> | MutationRequiredFromValues<Exclude<UpdateValues, undefined>> | RequiredFromInput<Extract<Options["where"], PredicateInput>>, AvailableNames<AvailableOfPlan<PlanValue>>>,
|
|
5892
|
-
AvailableOfPlan<PlanValue>,
|
|
5893
|
-
PlanDialectOf<PlanValue>,
|
|
5894
|
-
GroupedOfPlan<PlanValue>,
|
|
5895
|
-
ScopedNamesOfPlan<PlanValue>,
|
|
5896
|
-
Exclude<OutstandingOfPlan<PlanValue> | MutationRequiredFromValues<Exclude<UpdateValues, undefined>> | RequiredFromInput<Extract<Options["where"], PredicateInput>>, AvailableNames<AvailableOfPlan<PlanValue>>>,
|
|
5897
|
-
AssumptionsOfPlan<PlanValue>,
|
|
5898
|
-
CapabilitiesOfPlan<PlanValue>,
|
|
5899
|
-
StatementOfPlan<PlanValue>,
|
|
5900
|
-
MutationTargetOfPlan<PlanValue>,
|
|
5901
|
-
InsertSourceStateOfPlan<PlanValue>,
|
|
5902
|
-
FactsOfPlan<PlanValue>
|
|
5903
|
-
> => mutationRuntime.onConflict(target, options)(plan)
|
|
6444
|
+
const onConflict = ((target: unknown, options: unknown = {}) =>
|
|
6445
|
+
(plan: QueryPlan<any, any, any, any, any, any, any, any, any, any>) =>
|
|
6446
|
+
mutationRuntime.onConflict(target, options)(plan)) as OnConflictApi
|
|
5904
6447
|
|
|
5905
6448
|
const update: UpdateApi = ((
|
|
5906
6449
|
target: MutationTargetInput,
|
|
5907
6450
|
values: Record<string, unknown>
|
|
5908
6451
|
) => mutationRuntime.update(target, values)) as UpdateApi
|
|
5909
6452
|
|
|
5910
|
-
const upsert
|
|
5911
|
-
|
|
5912
|
-
|
|
5913
|
-
|
|
5914
|
-
|
|
5915
|
-
|
|
5916
|
-
target: Target,
|
|
5917
|
-
values: Values,
|
|
5918
|
-
conflictColumns: ValidateTargetColumns<Target, NormalizeDdlColumns<Columns>>,
|
|
5919
|
-
updateValues?: UpdateValues
|
|
5920
|
-
): QueryPlan<
|
|
5921
|
-
{},
|
|
5922
|
-
Exclude<MutationRequiredFromValues<Values> | MutationRequiredFromValues<UpdateValues>, SourceNameOf<Target>>,
|
|
5923
|
-
AddAvailable<{}, SourceNameOf<Target>>,
|
|
5924
|
-
TableDialectOf<Target>,
|
|
5925
|
-
never,
|
|
5926
|
-
SourceNameOf<Target>,
|
|
5927
|
-
Exclude<MutationRequiredFromValues<Values> | MutationRequiredFromValues<UpdateValues>, SourceNameOf<Target>>,
|
|
5928
|
-
TrueFormula,
|
|
5929
|
-
"write",
|
|
5930
|
-
"insert",
|
|
5931
|
-
Target,
|
|
5932
|
-
"ready",
|
|
5933
|
-
EmptyFacts
|
|
5934
|
-
> => mutationRuntime.upsert(target, values, conflictColumns as string | readonly string[], updateValues)
|
|
6453
|
+
const upsert = ((
|
|
6454
|
+
target: MutationTargetLike,
|
|
6455
|
+
values: Record<string, unknown>,
|
|
6456
|
+
conflictColumns: DdlColumnInput,
|
|
6457
|
+
updateValues?: Record<string, unknown>
|
|
6458
|
+
) => mutationRuntime.upsert(target, values, conflictColumns as string | readonly string[], updateValues)) as UpsertApi
|
|
5935
6459
|
|
|
5936
6460
|
const delete_: DeleteApi = ((
|
|
5937
6461
|
target: MutationTargetInput
|
|
@@ -5958,7 +6482,7 @@ type AsCurriedResult<
|
|
|
5958
6482
|
EmptyFacts
|
|
5959
6483
|
> => mutationRuntime.truncate(target, options)
|
|
5960
6484
|
|
|
5961
|
-
const merge
|
|
6485
|
+
const merge = (<
|
|
5962
6486
|
Target extends MutationTargetLike,
|
|
5963
6487
|
Source extends SourceLike,
|
|
5964
6488
|
On extends PredicateInput,
|
|
@@ -5972,7 +6496,7 @@ type AsCurriedResult<
|
|
|
5972
6496
|
SourceRequiredOf<Source> extends never ? unknown : SourceRequirementError<Source>
|
|
5973
6497
|
),
|
|
5974
6498
|
on: On,
|
|
5975
|
-
options: MergeOptions<Target, MatchedValues, InsertValues, MatchedPredicate, NotMatchedPredicate>
|
|
6499
|
+
options: MergeOptions<Target, MatchedValues, InsertValues, MatchedPredicate, NotMatchedPredicate>
|
|
5976
6500
|
): QueryPlan<
|
|
5977
6501
|
{},
|
|
5978
6502
|
Exclude<
|
|
@@ -6013,7 +6537,7 @@ type AsCurriedResult<
|
|
|
6013
6537
|
any,
|
|
6014
6538
|
"ready",
|
|
6015
6539
|
EmptyFacts
|
|
6016
|
-
> => mutationRuntime.merge(target, source, on, options)
|
|
6540
|
+
> => mutationRuntime.merge(target, source, on, options)) as unknown as MergeApi
|
|
6017
6541
|
|
|
6018
6542
|
type TransactionApi = (options?: TransactionOptions) => QueryPlan<
|
|
6019
6543
|
{},
|
|
@@ -6094,7 +6618,7 @@ type AsCurriedResult<
|
|
|
6094
6618
|
>
|
|
6095
6619
|
|
|
6096
6620
|
type CreateTableApi = <Target extends SchemaTableLike>(
|
|
6097
|
-
target: Target,
|
|
6621
|
+
target: Target & TableDialectConstraint<Target, Dialect>,
|
|
6098
6622
|
options?: CreateTableOptions
|
|
6099
6623
|
) => QueryPlan<
|
|
6100
6624
|
{},
|
|
@@ -6110,7 +6634,7 @@ type AsCurriedResult<
|
|
|
6110
6634
|
>
|
|
6111
6635
|
|
|
6112
6636
|
type DropTableApi = <Target extends SchemaTableLike>(
|
|
6113
|
-
target: Target,
|
|
6637
|
+
target: Target & TableDialectConstraint<Target, Dialect>,
|
|
6114
6638
|
options?: DropTableOptions
|
|
6115
6639
|
) => QueryPlan<
|
|
6116
6640
|
{},
|
|
@@ -6126,8 +6650,8 @@ type AsCurriedResult<
|
|
|
6126
6650
|
>
|
|
6127
6651
|
|
|
6128
6652
|
type CreateIndexApi = <Target extends SchemaTableLike, const Columns extends DdlColumnInput>(
|
|
6129
|
-
target: Target,
|
|
6130
|
-
columns: Columns &
|
|
6653
|
+
target: Target & TableDialectConstraint<Target, Dialect>,
|
|
6654
|
+
columns: Columns & ValidateDdlColumnInput<Target, Columns>,
|
|
6131
6655
|
options?: CreateIndexOptions
|
|
6132
6656
|
) => QueryPlan<
|
|
6133
6657
|
{},
|
|
@@ -6143,8 +6667,8 @@ type AsCurriedResult<
|
|
|
6143
6667
|
>
|
|
6144
6668
|
|
|
6145
6669
|
type DropIndexApi = <Target extends SchemaTableLike, const Columns extends DdlColumnInput>(
|
|
6146
|
-
target: Target,
|
|
6147
|
-
columns: Columns &
|
|
6670
|
+
target: Target & TableDialectConstraint<Target, Dialect>,
|
|
6671
|
+
columns: Columns & ValidateDdlColumnInput<Target, Columns>,
|
|
6148
6672
|
options?: DropIndexOptions
|
|
6149
6673
|
) => QueryPlan<
|
|
6150
6674
|
{},
|