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,
|
|
@@ -1485,11 +1513,11 @@ const profile: QueryDialectProfile<Dialect, TextDb, NumericDb, BoolDb, Timestamp
|
|
|
1485
1513
|
|
|
1486
1514
|
const literalSchemaOf = <Value extends LiteralValue>(
|
|
1487
1515
|
value: Value
|
|
1488
|
-
): Schema.
|
|
1516
|
+
): Schema.Top | undefined => {
|
|
1489
1517
|
if (value === null || value instanceof Date) {
|
|
1490
1518
|
return undefined
|
|
1491
1519
|
}
|
|
1492
|
-
return Schema.Literal(value) as unknown as Schema.
|
|
1520
|
+
return Schema.Literal(value) as unknown as Schema.Top
|
|
1493
1521
|
}
|
|
1494
1522
|
|
|
1495
1523
|
const literal = <const Value extends LiteralValue>(
|
|
@@ -1696,10 +1724,16 @@ const profile: QueryDialectProfile<Dialect, TextDb, NumericDb, BoolDb, Timestamp
|
|
|
1696
1724
|
spec: WindowSpecInput<PartitionBy, OrderBy> | OrderedWindowSpecInput<PartitionBy, Extract<OrderBy, NonEmptyWindowOrderTerms>> | undefined
|
|
1697
1725
|
) => {
|
|
1698
1726
|
const partitionBy = [...(spec?.partitionBy ?? [])] as unknown as PartitionBy
|
|
1699
|
-
const orderBy = (spec?.orderBy ?? []).map((term) =>
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1727
|
+
const orderBy = (spec?.orderBy ?? []).map((term) => {
|
|
1728
|
+
const direction = term.direction ?? "asc"
|
|
1729
|
+
if (direction !== "asc" && direction !== "desc") {
|
|
1730
|
+
throw new Error("window order direction must be asc or desc")
|
|
1731
|
+
}
|
|
1732
|
+
return {
|
|
1733
|
+
value: term.value,
|
|
1734
|
+
direction
|
|
1735
|
+
}
|
|
1736
|
+
}) as {
|
|
1703
1737
|
readonly [K in keyof OrderBy]: OrderBy[K] extends WindowOrderTermInput<infer Value extends WindowOrderInput>
|
|
1704
1738
|
? { readonly value: Value; readonly direction: OrderDirection }
|
|
1705
1739
|
: never
|
|
@@ -2073,9 +2107,15 @@ type BinaryPredicateExpression<
|
|
|
2073
2107
|
})
|
|
2074
2108
|
}
|
|
2075
2109
|
|
|
2076
|
-
|
|
2110
|
+
type NormalizedCollation<Collation extends string | readonly [string, ...string[]]> =
|
|
2111
|
+
Collation extends string ? readonly [Collation] : Collation
|
|
2112
|
+
|
|
2113
|
+
const collate = <
|
|
2114
|
+
Value extends ExpressionInput,
|
|
2115
|
+
Collation extends string | readonly [string, ...string[]]
|
|
2116
|
+
>(
|
|
2077
2117
|
value: Value & TextInput<NoInfer<Value>, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb, "collate">,
|
|
2078
|
-
collation:
|
|
2118
|
+
collation: Collation
|
|
2079
2119
|
): AstBackedExpression<
|
|
2080
2120
|
Expression.RuntimeOf<DialectAsStringExpression<Value, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>>,
|
|
2081
2121
|
Expression.DbTypeOf<DialectAsStringExpression<Value, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>>,
|
|
@@ -2083,10 +2123,10 @@ type BinaryPredicateExpression<
|
|
|
2083
2123
|
DialectOfDialectStringInput<Value, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>,
|
|
2084
2124
|
KindOf<DialectAsStringExpression<Value, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>>,
|
|
2085
2125
|
DependenciesOfDialectStringInput<Value, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>,
|
|
2086
|
-
ExpressionAst.CollateNode<DialectAsStringExpression<Value, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>>
|
|
2126
|
+
ExpressionAst.CollateNode<DialectAsStringExpression<Value, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>, NormalizedCollation<Collation>>
|
|
2087
2127
|
> => {
|
|
2088
2128
|
const expression = toDialectStringExpression(value as any)
|
|
2089
|
-
const normalizedCollation
|
|
2129
|
+
const normalizedCollation = (typeof collation === "string" ? [collation] : collation) as NormalizedCollation<Collation>
|
|
2090
2130
|
return makeExpression({
|
|
2091
2131
|
runtime: expression[Expression.TypeId].runtime as Expression.RuntimeOf<DialectAsStringExpression<Value, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>>,
|
|
2092
2132
|
dbType: expression[Expression.TypeId].dbType as Expression.DbTypeOf<DialectAsStringExpression<Value, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>>,
|
|
@@ -2106,7 +2146,7 @@ type BinaryPredicateExpression<
|
|
|
2106
2146
|
DialectOfDialectStringInput<Value, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>,
|
|
2107
2147
|
KindOf<DialectAsStringExpression<Value, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>>,
|
|
2108
2148
|
DependenciesOfDialectStringInput<Value, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>,
|
|
2109
|
-
ExpressionAst.CollateNode<DialectAsStringExpression<Value, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>>
|
|
2149
|
+
ExpressionAst.CollateNode<DialectAsStringExpression<Value, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>, NormalizedCollation<Collation>>
|
|
2110
2150
|
>
|
|
2111
2151
|
}
|
|
2112
2152
|
|
|
@@ -2702,7 +2742,7 @@ type BinaryPredicateExpression<
|
|
|
2702
2742
|
Next extends JsonValueInput
|
|
2703
2743
|
>(
|
|
2704
2744
|
base: Base,
|
|
2705
|
-
target: Target & JsonSetGuard<Expression.RuntimeOf<Base>, Target, Next
|
|
2745
|
+
target: Target & JsonSetGuard<Expression.RuntimeOf<Base>, Target, NoInfer<Next>, "json.set">,
|
|
2706
2746
|
next: Next,
|
|
2707
2747
|
options: {
|
|
2708
2748
|
readonly createMissing?: boolean
|
|
@@ -2750,7 +2790,7 @@ type BinaryPredicateExpression<
|
|
|
2750
2790
|
InsertAfter extends boolean = false
|
|
2751
2791
|
>(
|
|
2752
2792
|
base: Base,
|
|
2753
|
-
target: Target & JsonInsertGuard<Expression.RuntimeOf<Base>, Target, Next
|
|
2793
|
+
target: Target & JsonInsertGuard<Expression.RuntimeOf<Base>, Target, NoInfer<Next>, NoInfer<InsertAfter>, "json.insert">,
|
|
2754
2794
|
next: Next,
|
|
2755
2795
|
options: {
|
|
2756
2796
|
readonly insertAfter?: InsertAfter
|
|
@@ -3964,7 +4004,9 @@ type BinaryPredicateExpression<
|
|
|
3964
4004
|
string,
|
|
3965
4005
|
"scalar",
|
|
3966
4006
|
Expression.BindingId
|
|
3967
|
-
>
|
|
4007
|
+
> & {
|
|
4008
|
+
readonly [ExpressionAst.TypeId]: ExpressionAst.ColumnNode<any, string>
|
|
4009
|
+
}
|
|
3968
4010
|
>(
|
|
3969
4011
|
value: Value
|
|
3970
4012
|
): AstBackedExpression<
|
|
@@ -4008,22 +4050,56 @@ type BinaryPredicateExpression<
|
|
|
4008
4050
|
value: Value,
|
|
4009
4051
|
column: Expression.Any
|
|
4010
4052
|
): Expression.Any => {
|
|
4053
|
+
const columnState = column[Expression.TypeId]
|
|
4054
|
+
const normalizeMutationValue = (candidate: unknown): unknown => {
|
|
4055
|
+
if (candidate === null && columnState.nullability !== "never") {
|
|
4056
|
+
return null
|
|
4057
|
+
}
|
|
4058
|
+
const runtimeSchemaAccepts = columnState.runtimeSchema !== undefined &&
|
|
4059
|
+
(Schema.is(columnState.runtimeSchema) as (input: unknown) => boolean)(candidate)
|
|
4060
|
+
if (runtimeSchemaAccepts) {
|
|
4061
|
+
return candidate
|
|
4062
|
+
}
|
|
4063
|
+
const normalized = normalizeDbValue(columnState.dbType, candidate)
|
|
4064
|
+
return columnState.runtimeSchema === undefined
|
|
4065
|
+
? normalized
|
|
4066
|
+
: (Schema.decodeUnknownSync as any)(columnState.runtimeSchema)(normalized)
|
|
4067
|
+
}
|
|
4011
4068
|
if (value !== null && typeof value === "object" && Expression.TypeId in value) {
|
|
4069
|
+
const expression = value as unknown as Expression.Any
|
|
4070
|
+
const ast = (expression as unknown as { readonly [ExpressionAst.TypeId]: ExpressionAst.Any })[ExpressionAst.TypeId]
|
|
4071
|
+
if (ast.kind === "literal") {
|
|
4072
|
+
const normalizedValue = normalizeMutationValue(ast.value)
|
|
4073
|
+
return makeExpression({
|
|
4074
|
+
runtime: normalizedValue,
|
|
4075
|
+
dbType: columnState.dbType,
|
|
4076
|
+
runtimeSchema: columnState.runtimeSchema,
|
|
4077
|
+
driverValueMapping: columnState.driverValueMapping,
|
|
4078
|
+
nullability: normalizedValue === null ? "always" : "never",
|
|
4079
|
+
dialect: columnState.dialect,
|
|
4080
|
+
kind: "scalar",
|
|
4081
|
+
dependencies: {}
|
|
4082
|
+
}, {
|
|
4083
|
+
kind: "literal",
|
|
4084
|
+
value: normalizedValue
|
|
4085
|
+
})
|
|
4086
|
+
}
|
|
4012
4087
|
return retargetLiteralExpression(value as unknown as Expression.Any, column)
|
|
4013
4088
|
}
|
|
4089
|
+
const normalizedValue = normalizeMutationValue(value)
|
|
4014
4090
|
return makeExpression({
|
|
4015
|
-
runtime:
|
|
4016
|
-
dbType:
|
|
4017
|
-
runtimeSchema:
|
|
4018
|
-
driverValueMapping:
|
|
4019
|
-
nullability:
|
|
4020
|
-
dialect:
|
|
4091
|
+
runtime: normalizedValue as Value,
|
|
4092
|
+
dbType: columnState.dbType,
|
|
4093
|
+
runtimeSchema: columnState.runtimeSchema,
|
|
4094
|
+
driverValueMapping: columnState.driverValueMapping,
|
|
4095
|
+
nullability: normalizedValue === null ? "always" : "never",
|
|
4096
|
+
dialect: columnState.dialect,
|
|
4021
4097
|
kind: "scalar",
|
|
4022
4098
|
|
|
4023
4099
|
dependencies: {}
|
|
4024
4100
|
}, {
|
|
4025
4101
|
kind: "literal",
|
|
4026
|
-
value
|
|
4102
|
+
value: normalizedValue
|
|
4027
4103
|
})
|
|
4028
4104
|
}
|
|
4029
4105
|
|
|
@@ -4111,16 +4187,16 @@ type BinaryPredicateExpression<
|
|
|
4111
4187
|
Alias extends string
|
|
4112
4188
|
>(
|
|
4113
4189
|
rows: readonly [Record<string, Expression.Any>, ...Record<string, Expression.Any>[]],
|
|
4114
|
-
selection: ValuesOutputShape<Rows
|
|
4190
|
+
selection: ValuesOutputShape<Rows, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>,
|
|
4115
4191
|
alias: Alias
|
|
4116
4192
|
): ValuesSource<
|
|
4117
4193
|
Rows,
|
|
4118
|
-
ValuesOutputShape<Rows
|
|
4194
|
+
ValuesOutputShape<Rows, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>,
|
|
4119
4195
|
Alias,
|
|
4120
4196
|
Dialect
|
|
4121
4197
|
> => {
|
|
4122
4198
|
const columns = makeColumnReferenceSelection(alias, selection as Record<string, Expression.Any>) as unknown as ValuesOutputShape<
|
|
4123
|
-
Rows
|
|
4199
|
+
Rows,
|
|
4124
4200
|
Dialect,
|
|
4125
4201
|
TextDb,
|
|
4126
4202
|
NumericDb,
|
|
@@ -4138,7 +4214,7 @@ type BinaryPredicateExpression<
|
|
|
4138
4214
|
}
|
|
4139
4215
|
return Object.assign(source, columns) as unknown as ValuesSource<
|
|
4140
4216
|
Rows,
|
|
4141
|
-
ValuesOutputShape<Rows
|
|
4217
|
+
ValuesOutputShape<Rows, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>,
|
|
4142
4218
|
Alias,
|
|
4143
4219
|
Dialect
|
|
4144
4220
|
>
|
|
@@ -4151,7 +4227,12 @@ type BinaryPredicateExpression<
|
|
|
4151
4227
|
|
|
4152
4228
|
const normalizeUnnestColumns = (columns: UnnestColumnsInput): Record<string, readonly Expression.Any[]> =>
|
|
4153
4229
|
Object.fromEntries(
|
|
4154
|
-
Object.entries(columns).map(([key, values]) =>
|
|
4230
|
+
Object.entries(columns).map(([key, values]) => {
|
|
4231
|
+
if (!Array.isArray(values)) {
|
|
4232
|
+
throw new Error("unnest(...) expects every value to be an array")
|
|
4233
|
+
}
|
|
4234
|
+
return [key, values.map((value) => toDialectExpression(value))]
|
|
4235
|
+
})
|
|
4155
4236
|
) as Record<string, readonly Expression.Any[]>
|
|
4156
4237
|
|
|
4157
4238
|
const normalizeMutationTargets = (
|
|
@@ -4194,6 +4275,17 @@ type BinaryPredicateExpression<
|
|
|
4194
4275
|
})
|
|
4195
4276
|
) as unknown as AddAvailableMany<{}, MutationTargetNamesOf<Target>, Mode>
|
|
4196
4277
|
|
|
4278
|
+
const getMutationColumn = (
|
|
4279
|
+
columns: Record<string, unknown>,
|
|
4280
|
+
columnName: string
|
|
4281
|
+
): Expression.Any => {
|
|
4282
|
+
const column = columns[columnName]
|
|
4283
|
+
if (column === undefined || column === null || typeof column !== "object" || !(Expression.TypeId in column)) {
|
|
4284
|
+
throw new Error("effect-qb: unknown mutation column")
|
|
4285
|
+
}
|
|
4286
|
+
return column as Expression.Any
|
|
4287
|
+
}
|
|
4288
|
+
|
|
4197
4289
|
const buildMutationAssignments = <Target extends MutationTargetInput, Values>(
|
|
4198
4290
|
target: Target,
|
|
4199
4291
|
values: Values
|
|
@@ -4203,7 +4295,7 @@ type BinaryPredicateExpression<
|
|
|
4203
4295
|
const columns = target as unknown as Record<string, Expression.Any>
|
|
4204
4296
|
return Object.entries(values as Record<string, unknown>).map(([columnName, value]) => ({
|
|
4205
4297
|
columnName,
|
|
4206
|
-
value: toMutationValueExpression(value, columns
|
|
4298
|
+
value: toMutationValueExpression(value, getMutationColumn(columns, columnName))
|
|
4207
4299
|
}))
|
|
4208
4300
|
}
|
|
4209
4301
|
const valueMap = values as Record<string, Record<string, unknown> | undefined>
|
|
@@ -4214,7 +4306,7 @@ type BinaryPredicateExpression<
|
|
|
4214
4306
|
return Object.entries(scopedValues).map(([columnName, value]) => ({
|
|
4215
4307
|
tableName: targetName,
|
|
4216
4308
|
columnName,
|
|
4217
|
-
value: toMutationValueExpression(value, columns
|
|
4309
|
+
value: toMutationValueExpression(value, getMutationColumn(columns, columnName))
|
|
4218
4310
|
}))
|
|
4219
4311
|
})
|
|
4220
4312
|
}
|
|
@@ -4301,14 +4393,26 @@ type BinaryPredicateExpression<
|
|
|
4301
4393
|
}
|
|
4302
4394
|
}
|
|
4303
4395
|
|
|
4396
|
+
const normalizeConflictColumns = <Target extends MutationTargetLike>(
|
|
4397
|
+
target: Target,
|
|
4398
|
+
columnsInput: string | readonly string[]
|
|
4399
|
+
): readonly [string, ...string[]] => {
|
|
4400
|
+
const columns = normalizeColumnList(columnsInput) as readonly [string, ...string[]]
|
|
4401
|
+
const knownColumns = new Set(Object.keys(target[Table.TypeId].fields))
|
|
4402
|
+
if (columns.some((columnName) => !knownColumns.has(columnName))) {
|
|
4403
|
+
throw new Error("effect-qb: unknown conflict target column")
|
|
4404
|
+
}
|
|
4405
|
+
return columns
|
|
4406
|
+
}
|
|
4407
|
+
|
|
4304
4408
|
const buildConflictTarget = <Target extends MutationTargetLike>(
|
|
4305
4409
|
target: Target,
|
|
4306
|
-
input: readonly string[] | { readonly columns: readonly string[]; readonly where?: PredicateInput } | { readonly constraint: string }
|
|
4410
|
+
input: string | readonly string[] | { readonly columns: string | readonly string[]; readonly where?: PredicateInput } | { readonly constraint: string }
|
|
4307
4411
|
): QueryAst.ConflictTargetClause => {
|
|
4308
|
-
if (Array.isArray(input)) {
|
|
4412
|
+
if (typeof input === "string" || Array.isArray(input)) {
|
|
4309
4413
|
return {
|
|
4310
4414
|
kind: "columns",
|
|
4311
|
-
columns:
|
|
4415
|
+
columns: normalizeConflictColumns(target, input)
|
|
4312
4416
|
}
|
|
4313
4417
|
}
|
|
4314
4418
|
if (!Array.isArray(input) && "constraint" in input) {
|
|
@@ -4318,12 +4422,12 @@ type BinaryPredicateExpression<
|
|
|
4318
4422
|
}
|
|
4319
4423
|
}
|
|
4320
4424
|
const columnTarget = input as {
|
|
4321
|
-
readonly columns: readonly string[]
|
|
4425
|
+
readonly columns: string | readonly string[]
|
|
4322
4426
|
readonly where?: PredicateInput
|
|
4323
4427
|
}
|
|
4324
4428
|
return {
|
|
4325
4429
|
kind: "columns",
|
|
4326
|
-
columns:
|
|
4430
|
+
columns: normalizeConflictColumns(target, columnTarget.columns),
|
|
4327
4431
|
where: columnTarget.where === undefined ? undefined : toDialectExpression(columnTarget.where)
|
|
4328
4432
|
}
|
|
4329
4433
|
}
|
|
@@ -4361,11 +4465,21 @@ type ValidateDdlColumns<
|
|
|
4361
4465
|
Columns extends readonly string[]
|
|
4362
4466
|
> = Exclude<Columns[number], SchemaColumnNames<Target>> extends never ? Columns : never
|
|
4363
4467
|
|
|
4468
|
+
type ValidateDdlColumnInput<
|
|
4469
|
+
Target extends SchemaTableLike,
|
|
4470
|
+
Columns extends DdlColumnInput
|
|
4471
|
+
> = ValidateDdlColumns<Target, NormalizeDdlColumns<Columns>> extends never ? never : Columns
|
|
4472
|
+
|
|
4364
4473
|
type ValidateTargetColumns<
|
|
4365
4474
|
Target extends MutationTargetLike,
|
|
4366
4475
|
Columns extends readonly string[]
|
|
4367
4476
|
> = Exclude<Columns[number], Extract<keyof Target[typeof Table.TypeId]["fields"], string>> extends never ? Columns : never
|
|
4368
4477
|
|
|
4478
|
+
type ValidateTargetColumnInput<
|
|
4479
|
+
Target extends MutationTargetLike,
|
|
4480
|
+
Columns extends DdlColumnInput
|
|
4481
|
+
> = ValidateTargetColumns<Target, NormalizeDdlColumns<Columns>> extends never ? never : Columns
|
|
4482
|
+
|
|
4369
4483
|
type CreateIndexOptions = {
|
|
4370
4484
|
readonly name?: string
|
|
4371
4485
|
readonly unique?: boolean
|
|
@@ -4395,10 +4509,15 @@ type TransactionOptions = {
|
|
|
4395
4509
|
readonly readOnly?: boolean
|
|
4396
4510
|
}
|
|
4397
4511
|
|
|
4398
|
-
type LockOptions =
|
|
4399
|
-
|
|
4400
|
-
|
|
4401
|
-
|
|
4512
|
+
type LockOptions =
|
|
4513
|
+
| {
|
|
4514
|
+
readonly nowait?: boolean
|
|
4515
|
+
readonly skipLocked?: false
|
|
4516
|
+
}
|
|
4517
|
+
| {
|
|
4518
|
+
readonly nowait?: false
|
|
4519
|
+
readonly skipLocked?: boolean
|
|
4520
|
+
}
|
|
4402
4521
|
|
|
4403
4522
|
type UpsertConflictOptions = {
|
|
4404
4523
|
readonly update?: Record<string, unknown>
|
|
@@ -4413,14 +4532,133 @@ type InsertRowInput<Target extends MutationTargetLike> = MutationInputOf<Table.I
|
|
|
4413
4532
|
type ValuesRowInput = Record<string, ExpressionInput>
|
|
4414
4533
|
type ValuesRowsInput = readonly [ValuesRowInput, ...ValuesRowInput[]]
|
|
4415
4534
|
|
|
4535
|
+
type ValuesColumnInput<Row, Key extends PropertyKey> =
|
|
4536
|
+
Row extends ValuesRowInput
|
|
4537
|
+
? Key extends keyof Row ? Row[Key] : never
|
|
4538
|
+
: never
|
|
4539
|
+
|
|
4540
|
+
type ValuesRowShapeMismatch<
|
|
4541
|
+
First extends ValuesRowInput,
|
|
4542
|
+
Row extends ValuesRowInput
|
|
4543
|
+
> =
|
|
4544
|
+
| Exclude<Extract<keyof Row, string>, Extract<keyof First, string>>
|
|
4545
|
+
| Exclude<Extract<keyof First, string>, Extract<keyof Row, string>>
|
|
4546
|
+
|
|
4547
|
+
type ValuesRowsShapeMismatchesFor<
|
|
4548
|
+
First extends ValuesRowInput,
|
|
4549
|
+
Row
|
|
4550
|
+
> = Row extends ValuesRowInput ? ValuesRowShapeMismatch<First, Row> : never
|
|
4551
|
+
|
|
4552
|
+
type ValuesRowsShapeMismatches<Rows extends ValuesRowsInput> =
|
|
4553
|
+
Rows extends readonly [infer First extends ValuesRowInput, ...infer Rest extends ValuesRowInput[]]
|
|
4554
|
+
? ValuesRowsShapeMismatchesFor<First, Rest[number]>
|
|
4555
|
+
: never
|
|
4556
|
+
|
|
4557
|
+
type ValuesRowsColumnKeys<Rows extends ValuesRowsInput> =
|
|
4558
|
+
Rows extends readonly [infer First extends ValuesRowInput, ...ValuesRowInput[]]
|
|
4559
|
+
? Extract<keyof First, string>
|
|
4560
|
+
: never
|
|
4561
|
+
|
|
4562
|
+
type ValuesRowsShapeInput<Rows extends ValuesRowsInput> =
|
|
4563
|
+
[ValuesRowsColumnKeys<Rows>] extends [never]
|
|
4564
|
+
? {
|
|
4565
|
+
readonly __effect_qb_error__: "effect-qb: values rows must project at least one column"
|
|
4566
|
+
}
|
|
4567
|
+
: [ValuesRowsShapeMismatches<Rows>] extends [never]
|
|
4568
|
+
? unknown
|
|
4569
|
+
: {
|
|
4570
|
+
readonly __effect_qb_error__: "effect-qb: values rows must project the same columns"
|
|
4571
|
+
readonly __effect_qb_mismatched_columns__: ValuesRowsShapeMismatches<Rows>
|
|
4572
|
+
}
|
|
4573
|
+
|
|
4574
|
+
type ValuesRowsDialect<
|
|
4575
|
+
Rows extends ValuesRowsInput,
|
|
4576
|
+
Dialect extends string,
|
|
4577
|
+
TextDb extends Expression.DbType.Any,
|
|
4578
|
+
NumericDb extends Expression.DbType.Any,
|
|
4579
|
+
BoolDb extends Expression.DbType.Any,
|
|
4580
|
+
TimestampDb extends Expression.DbType.Any,
|
|
4581
|
+
NullDb extends Expression.DbType.Any
|
|
4582
|
+
> = Rows[number][keyof Rows[number]] extends infer Value extends ExpressionInput
|
|
4583
|
+
? DialectOfDialectInput<Value, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>
|
|
4584
|
+
: never
|
|
4585
|
+
|
|
4586
|
+
type ValuesRowsDialectInput<
|
|
4587
|
+
Rows extends ValuesRowsInput,
|
|
4588
|
+
Dialect extends string,
|
|
4589
|
+
TextDb extends Expression.DbType.Any,
|
|
4590
|
+
NumericDb extends Expression.DbType.Any,
|
|
4591
|
+
BoolDb extends Expression.DbType.Any,
|
|
4592
|
+
TimestampDb extends Expression.DbType.Any,
|
|
4593
|
+
NullDb extends Expression.DbType.Any
|
|
4594
|
+
> = Exclude<ValuesRowsDialect<Rows, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>, Dialect> extends never
|
|
4595
|
+
? unknown
|
|
4596
|
+
: {
|
|
4597
|
+
readonly __effect_qb_error__: "effect-qb: values rows cannot mix dialects"
|
|
4598
|
+
readonly __effect_qb_dialect__: ValuesRowsDialect<Rows, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>
|
|
4599
|
+
}
|
|
4600
|
+
|
|
4416
4601
|
type UnnestColumnsInput = Record<string, readonly [ExpressionInput, ...ExpressionInput[]]>
|
|
4417
4602
|
|
|
4603
|
+
type IsNever<Value> = [Value] extends [never] ? true : false
|
|
4604
|
+
|
|
4605
|
+
type IsUnion<Value, All = Value> = Value extends any
|
|
4606
|
+
? ([All] extends [Value] ? false : true)
|
|
4607
|
+
: never
|
|
4608
|
+
|
|
4609
|
+
type UnnestColumnKeys<Columns extends UnnestColumnsInput> =
|
|
4610
|
+
Extract<keyof Columns, string>
|
|
4611
|
+
|
|
4612
|
+
type UnnestColumnLengths<Columns extends UnnestColumnsInput> =
|
|
4613
|
+
Columns[UnnestColumnKeys<Columns>]["length"]
|
|
4614
|
+
|
|
4615
|
+
type UnnestColumnsShapeInput<Columns extends UnnestColumnsInput> =
|
|
4616
|
+
IsNever<UnnestColumnKeys<Columns>> extends true
|
|
4617
|
+
? {
|
|
4618
|
+
readonly __effect_qb_error__: "effect-qb: unnest requires at least one column array"
|
|
4619
|
+
}
|
|
4620
|
+
: number extends UnnestColumnLengths<Columns>
|
|
4621
|
+
? unknown
|
|
4622
|
+
: IsUnion<UnnestColumnLengths<Columns>> extends true
|
|
4623
|
+
? {
|
|
4624
|
+
readonly __effect_qb_error__: "effect-qb: unnest column arrays must have the same length"
|
|
4625
|
+
readonly __effect_qb_column_lengths__: UnnestColumnLengths<Columns>
|
|
4626
|
+
}
|
|
4627
|
+
: unknown
|
|
4628
|
+
|
|
4629
|
+
type UnnestColumnsDialect<
|
|
4630
|
+
Columns extends UnnestColumnsInput,
|
|
4631
|
+
Dialect extends string,
|
|
4632
|
+
TextDb extends Expression.DbType.Any,
|
|
4633
|
+
NumericDb extends Expression.DbType.Any,
|
|
4634
|
+
BoolDb extends Expression.DbType.Any,
|
|
4635
|
+
TimestampDb extends Expression.DbType.Any,
|
|
4636
|
+
NullDb extends Expression.DbType.Any
|
|
4637
|
+
> = Columns[UnnestColumnKeys<Columns>][number] extends infer Value extends ExpressionInput
|
|
4638
|
+
? DialectOfDialectInput<Value, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>
|
|
4639
|
+
: never
|
|
4640
|
+
|
|
4641
|
+
type UnnestColumnsDialectInput<
|
|
4642
|
+
Columns extends UnnestColumnsInput,
|
|
4643
|
+
Dialect extends string,
|
|
4644
|
+
TextDb extends Expression.DbType.Any,
|
|
4645
|
+
NumericDb extends Expression.DbType.Any,
|
|
4646
|
+
BoolDb extends Expression.DbType.Any,
|
|
4647
|
+
TimestampDb extends Expression.DbType.Any,
|
|
4648
|
+
NullDb extends Expression.DbType.Any
|
|
4649
|
+
> = Exclude<UnnestColumnsDialect<Columns, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>, Dialect> extends never
|
|
4650
|
+
? unknown
|
|
4651
|
+
: {
|
|
4652
|
+
readonly __effect_qb_error__: "effect-qb: unnest columns cannot mix dialects"
|
|
4653
|
+
readonly __effect_qb_dialect__: UnnestColumnsDialect<Columns, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>
|
|
4654
|
+
}
|
|
4655
|
+
|
|
4418
4656
|
type UnnestRowShape<Shape extends Record<string, readonly unknown[]>> = {
|
|
4419
4657
|
readonly [K in keyof Shape]: Shape[K] extends readonly (infer Item)[] ? Item : never
|
|
4420
4658
|
}
|
|
4421
4659
|
|
|
4422
4660
|
type ValuesOutputShape<
|
|
4423
|
-
|
|
4661
|
+
Rows extends ValuesRowsInput,
|
|
4424
4662
|
Dialect extends string,
|
|
4425
4663
|
TextDb extends Expression.DbType.Any,
|
|
4426
4664
|
NumericDb extends Expression.DbType.Any,
|
|
@@ -4428,7 +4666,7 @@ type ValuesOutputShape<
|
|
|
4428
4666
|
TimestampDb extends Expression.DbType.Any,
|
|
4429
4667
|
NullDb extends Expression.DbType.Any
|
|
4430
4668
|
> = {
|
|
4431
|
-
readonly [K in keyof
|
|
4669
|
+
readonly [K in keyof Rows[0]]: DialectAsExpression<ValuesColumnInput<Rows[number], K>, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>
|
|
4432
4670
|
}
|
|
4433
4671
|
|
|
4434
4672
|
type UnnestOutputShape<
|
|
@@ -4468,18 +4706,18 @@ type DistinctOnUnsupportedError<Dialect extends string> = {
|
|
|
4468
4706
|
}
|
|
4469
4707
|
|
|
4470
4708
|
type DistinctOnApi<Dialect extends string> = Dialect extends "postgres"
|
|
4471
|
-
? <Values extends readonly ExpressionInput[]>(
|
|
4709
|
+
? <Values extends readonly [ExpressionInput, ...ExpressionInput[]]>(
|
|
4472
4710
|
...values: Values
|
|
4473
4711
|
) => <PlanValue extends QueryPlan<any, any, any, any, any, any, any, any, any, any>>(
|
|
4474
4712
|
plan: PlanValue & RequireSelectStatement<PlanValue>
|
|
4475
4713
|
) => QueryPlan<
|
|
4476
4714
|
SelectionOfPlan<PlanValue>,
|
|
4477
|
-
RequiredOfPlan<PlanValue>,
|
|
4715
|
+
AddExpressionRequired<RequiredOfPlan<PlanValue>, AvailableOfPlan<PlanValue>, Values[number]>,
|
|
4478
4716
|
AvailableOfPlan<PlanValue>,
|
|
4479
|
-
PlanDialectOf<PlanValue>,
|
|
4717
|
+
PlanDialectOf<PlanValue> | DialectOfDialectInput<Values[number], Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>,
|
|
4480
4718
|
GroupedOfPlan<PlanValue>,
|
|
4481
4719
|
ScopedNamesOfPlan<PlanValue>,
|
|
4482
|
-
OutstandingOfPlan<PlanValue>,
|
|
4720
|
+
AddExpressionRequired<OutstandingOfPlan<PlanValue>, AvailableOfPlan<PlanValue>, Values[number]>,
|
|
4483
4721
|
AssumptionsOfPlan<PlanValue>,
|
|
4484
4722
|
CapabilitiesOfPlan<PlanValue>,
|
|
4485
4723
|
StatementOfPlan<PlanValue>,
|
|
@@ -4515,6 +4753,44 @@ type MysqlConflictWhereError<Values> = Values & {
|
|
|
4515
4753
|
readonly __effect_qb_hint__: "Move the condition into the update assignment expressions or use the Postgres dialect"
|
|
4516
4754
|
}
|
|
4517
4755
|
|
|
4756
|
+
type ConflictActionWhereWithoutUpdateError<Values> = Values & {
|
|
4757
|
+
readonly __effect_qb_error__: "effect-qb: conflict action where(...) requires update assignments"
|
|
4758
|
+
readonly __effect_qb_hint__: "Add update assignments or move the predicate into the conflict target"
|
|
4759
|
+
}
|
|
4760
|
+
|
|
4761
|
+
type ConflictActionWhereInput<Dialect extends string> =
|
|
4762
|
+
Dialect extends "postgres" ? PredicateInput : MysqlConflictWhereError<PredicateInput>
|
|
4763
|
+
|
|
4764
|
+
type UpdateValuesNonEmptyError<Values> = Values & {
|
|
4765
|
+
readonly __effect_qb_error__: "effect-qb: update statements require at least one assignment"
|
|
4766
|
+
}
|
|
4767
|
+
|
|
4768
|
+
type UpdateValuesNonEmptyConstraint<Values> =
|
|
4769
|
+
[Extract<keyof Values, string>] extends [never]
|
|
4770
|
+
? UpdateValuesNonEmptyError<Values>
|
|
4771
|
+
: unknown
|
|
4772
|
+
|
|
4773
|
+
type NestedUpdateValuesNonEmptyConstraint<Values> =
|
|
4774
|
+
[Extract<keyof Values, string>] extends [never]
|
|
4775
|
+
? UpdateValuesNonEmptyError<Values>
|
|
4776
|
+
: true extends {
|
|
4777
|
+
[K in Extract<keyof Values, string>]:
|
|
4778
|
+
Values[K] extends Record<string, unknown>
|
|
4779
|
+
? [Extract<keyof Values[K], string>] extends [never] ? false : true
|
|
4780
|
+
: false
|
|
4781
|
+
}[Extract<keyof Values, string>]
|
|
4782
|
+
? unknown
|
|
4783
|
+
: UpdateValuesNonEmptyError<Values>
|
|
4784
|
+
|
|
4785
|
+
type MergeInsertValuesNonEmptyError<Values> = Values & {
|
|
4786
|
+
readonly __effect_qb_error__: "effect-qb: merge insert actions require at least one value"
|
|
4787
|
+
}
|
|
4788
|
+
|
|
4789
|
+
type MergeInsertValuesNonEmptyConstraint<Values> =
|
|
4790
|
+
[Extract<keyof Values, string>] extends [never]
|
|
4791
|
+
? MergeInsertValuesNonEmptyError<Values>
|
|
4792
|
+
: unknown
|
|
4793
|
+
|
|
4518
4794
|
type InsertShapeExtraKeys<TargetShape, SourceShape> = Exclude<Extract<keyof SourceShape, string>, Extract<keyof TargetShape, string>>
|
|
4519
4795
|
type InsertShapeMissingKeys<TargetShape, SourceShape> = Exclude<RequiredKeys<TargetShape>, Extract<keyof SourceShape, string>>
|
|
4520
4796
|
type InsertShapeMismatchedKeys<TargetShape, SourceShape> = Extract<{
|
|
@@ -4608,10 +4884,15 @@ type InsertSourceRequired<Source> =
|
|
|
4608
4884
|
Source extends QueryPlan<any, any, any, any, any, any, any, any, any, any> ? RequiredOfPlan<Source> :
|
|
4609
4885
|
never
|
|
4610
4886
|
|
|
4887
|
+
type InsertSourceDialect<Source> =
|
|
4888
|
+
Source extends QueryPlan<any, any, any, any, any, any, any, any, any, any> ? PlanDialectOf<Source> :
|
|
4889
|
+
Source extends SourceLike ? SourceDialectOf<Source> :
|
|
4890
|
+
never
|
|
4891
|
+
|
|
4611
4892
|
type ConflictColumnTarget<
|
|
4612
4893
|
Target extends MutationTargetLike,
|
|
4613
4894
|
Columns extends DdlColumnInput
|
|
4614
|
-
> =
|
|
4895
|
+
> = ValidateTargetColumnInput<Target, Columns>
|
|
4615
4896
|
|
|
4616
4897
|
type ConflictTargetInput<
|
|
4617
4898
|
Target extends MutationTargetLike,
|
|
@@ -4636,10 +4917,64 @@ type ConflictActionInput<
|
|
|
4636
4917
|
Target extends MutationTargetLike,
|
|
4637
4918
|
Dialect extends string,
|
|
4638
4919
|
UpdateValues extends MutationInputOf<Table.UpdateOf<Target>> | undefined = MutationInputOf<Table.UpdateOf<Target>> | undefined
|
|
4920
|
+
> =
|
|
4921
|
+
| {
|
|
4922
|
+
readonly update: Exclude<UpdateValues, undefined>
|
|
4923
|
+
readonly where?: ConflictActionWhereInput<Dialect>
|
|
4924
|
+
}
|
|
4925
|
+
| {
|
|
4926
|
+
readonly update?: undefined
|
|
4927
|
+
readonly where?: ConflictActionWhereWithoutUpdateError<PredicateInput>
|
|
4928
|
+
}
|
|
4929
|
+
|
|
4930
|
+
type ConflictActionUpdateNonEmptyConstraint<Options> =
|
|
4931
|
+
Options extends { readonly update: infer Values }
|
|
4932
|
+
? UpdateValuesNonEmptyConstraint<Values>
|
|
4933
|
+
: unknown
|
|
4934
|
+
|
|
4935
|
+
type ConflictTargetPredicate<Target> =
|
|
4936
|
+
Target extends { readonly where?: infer Predicate } ? Extract<Predicate, PredicateInput> : never
|
|
4937
|
+
|
|
4938
|
+
type ConflictActionPredicate<Options> =
|
|
4939
|
+
Options extends { readonly where?: infer Predicate } ? Extract<Predicate, PredicateInput> : never
|
|
4940
|
+
|
|
4941
|
+
type MutationDialectFromValues<
|
|
4942
|
+
Values extends Record<string, unknown>,
|
|
4943
|
+
Dialect extends string,
|
|
4944
|
+
TextDb extends Expression.DbType.Any,
|
|
4945
|
+
NumericDb extends Expression.DbType.Any,
|
|
4946
|
+
BoolDb extends Expression.DbType.Any,
|
|
4947
|
+
TimestampDb extends Expression.DbType.Any,
|
|
4948
|
+
NullDb extends Expression.DbType.Any
|
|
4639
4949
|
> = {
|
|
4640
|
-
|
|
4641
|
-
|
|
4642
|
-
|
|
4950
|
+
[K in keyof Values]: Values[K] extends ExpressionInput
|
|
4951
|
+
? DialectOfDialectInput<Values[K], Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>
|
|
4952
|
+
: never
|
|
4953
|
+
}[keyof Values]
|
|
4954
|
+
|
|
4955
|
+
type ConflictRequired<
|
|
4956
|
+
UpdateValues extends MutationInputOf<any> | undefined,
|
|
4957
|
+
Options,
|
|
4958
|
+
ConflictTarget
|
|
4959
|
+
> =
|
|
4960
|
+
| MutationRequiredFromValues<Exclude<UpdateValues, undefined>>
|
|
4961
|
+
| RequiredFromInput<ConflictActionPredicate<Options>>
|
|
4962
|
+
| RequiredFromInput<ConflictTargetPredicate<ConflictTarget>>
|
|
4963
|
+
|
|
4964
|
+
type ConflictDialect<
|
|
4965
|
+
UpdateValues extends MutationInputOf<any> | undefined,
|
|
4966
|
+
Options,
|
|
4967
|
+
ConflictTarget,
|
|
4968
|
+
Dialect extends string,
|
|
4969
|
+
TextDb extends Expression.DbType.Any,
|
|
4970
|
+
NumericDb extends Expression.DbType.Any,
|
|
4971
|
+
BoolDb extends Expression.DbType.Any,
|
|
4972
|
+
TimestampDb extends Expression.DbType.Any,
|
|
4973
|
+
NullDb extends Expression.DbType.Any
|
|
4974
|
+
> =
|
|
4975
|
+
| MutationDialectFromValues<Exclude<UpdateValues, undefined>, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>
|
|
4976
|
+
| DialectOfDialectInput<ConflictActionPredicate<Options>, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>
|
|
4977
|
+
| DialectOfDialectInput<ConflictTargetPredicate<ConflictTarget>, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>
|
|
4643
4978
|
|
|
4644
4979
|
type MergeWhenMatchedDelete<
|
|
4645
4980
|
Predicate extends PredicateInput | undefined = undefined
|
|
@@ -4654,7 +4989,7 @@ type MergeWhenMatchedUpdate<
|
|
|
4654
4989
|
Values extends MutationInputOf<Table.UpdateOf<Target>>,
|
|
4655
4990
|
Predicate extends PredicateInput | undefined = undefined
|
|
4656
4991
|
> = {
|
|
4657
|
-
readonly update: Values
|
|
4992
|
+
readonly update: Values & UpdateValuesNonEmptyConstraint<Values>
|
|
4658
4993
|
readonly predicate?: Predicate
|
|
4659
4994
|
readonly delete?: never
|
|
4660
4995
|
}
|
|
@@ -4664,20 +4999,37 @@ type MergeWhenNotMatched<
|
|
|
4664
4999
|
Values extends MutationInputOf<Table.InsertOf<Target>>,
|
|
4665
5000
|
Predicate extends PredicateInput | undefined = undefined
|
|
4666
5001
|
> = {
|
|
4667
|
-
readonly values: Values
|
|
5002
|
+
readonly values: Values & MergeInsertValuesNonEmptyConstraint<Values>
|
|
4668
5003
|
readonly predicate?: Predicate
|
|
4669
5004
|
}
|
|
4670
5005
|
|
|
5006
|
+
type MergeMatchedOption<
|
|
5007
|
+
Target extends MutationTargetLike,
|
|
5008
|
+
MatchedValues extends MutationInputOf<Table.UpdateOf<Target>>,
|
|
5009
|
+
MatchedPredicate extends PredicateInput | undefined = undefined
|
|
5010
|
+
> = MergeWhenMatchedDelete<MatchedPredicate> | MergeWhenMatchedUpdate<Target, MatchedValues, MatchedPredicate>
|
|
5011
|
+
|
|
5012
|
+
type MergeNotMatchedOption<
|
|
5013
|
+
Target extends MutationTargetLike,
|
|
5014
|
+
InsertValues extends MutationInputOf<Table.InsertOf<Target>>,
|
|
5015
|
+
NotMatchedPredicate extends PredicateInput | undefined = undefined
|
|
5016
|
+
> = MergeWhenNotMatched<Target, InsertValues, NotMatchedPredicate>
|
|
5017
|
+
|
|
4671
5018
|
type MergeOptions<
|
|
4672
5019
|
Target extends MutationTargetLike,
|
|
4673
5020
|
MatchedValues extends MutationInputOf<Table.UpdateOf<Target>>,
|
|
4674
5021
|
InsertValues extends MutationInputOf<Table.InsertOf<Target>>,
|
|
4675
5022
|
MatchedPredicate extends PredicateInput | undefined = undefined,
|
|
4676
5023
|
NotMatchedPredicate extends PredicateInput | undefined = undefined
|
|
4677
|
-
> =
|
|
4678
|
-
|
|
4679
|
-
|
|
4680
|
-
|
|
5024
|
+
> =
|
|
5025
|
+
| {
|
|
5026
|
+
readonly whenMatched: MergeMatchedOption<Target, MatchedValues, MatchedPredicate>
|
|
5027
|
+
readonly whenNotMatched?: MergeNotMatchedOption<Target, InsertValues, NotMatchedPredicate>
|
|
5028
|
+
}
|
|
5029
|
+
| {
|
|
5030
|
+
readonly whenMatched?: MergeMatchedOption<Target, MatchedValues, MatchedPredicate>
|
|
5031
|
+
readonly whenNotMatched: MergeNotMatchedOption<Target, InsertValues, NotMatchedPredicate>
|
|
5032
|
+
}
|
|
4681
5033
|
|
|
4682
5034
|
type RequireSelectStatement<PlanValue extends QueryPlan<any, any, any, any, any, any, any, any, any, any>> =
|
|
4683
5035
|
StatementOfPlan<PlanValue> extends "select" ? unknown : never
|
|
@@ -4709,6 +5061,16 @@ type MutationOrderLimitSupported<PlanValue extends QueryPlan<any, any, any, any,
|
|
|
4709
5061
|
? StatementOfPlan<PlanValue> extends "update" | "delete" ? unknown : never
|
|
4710
5062
|
: never
|
|
4711
5063
|
|
|
5064
|
+
type MutationTargetTupleDialectConstraint<
|
|
5065
|
+
Targets extends MutationTargetTuple,
|
|
5066
|
+
Dialect extends string
|
|
5067
|
+
> = Exclude<TableDialectOf<Targets[number]>, Dialect> extends never ? unknown : never
|
|
5068
|
+
|
|
5069
|
+
type TableDialectConstraint<
|
|
5070
|
+
Target extends TableLike,
|
|
5071
|
+
Dialect extends string
|
|
5072
|
+
> = Exclude<TableDialectOf<Target>, Dialect> extends never ? unknown : never
|
|
5073
|
+
|
|
4712
5074
|
type MutationRequiredFromValues<Values extends Record<string, unknown>> = {
|
|
4713
5075
|
[K in keyof Values]: Values[K] extends Expression.Any ? RequiredFromDependencies<DependenciesOf<Values[K]>> : never
|
|
4714
5076
|
}[keyof Values]
|
|
@@ -4722,6 +5084,59 @@ type NestedMutationRequiredFromValues<Values> =
|
|
|
4722
5084
|
}[keyof Values]
|
|
4723
5085
|
: never
|
|
4724
5086
|
|
|
5087
|
+
type NestedMutationDialectFromValues<
|
|
5088
|
+
Values,
|
|
5089
|
+
Dialect extends string,
|
|
5090
|
+
TextDb extends Expression.DbType.Any,
|
|
5091
|
+
NumericDb extends Expression.DbType.Any,
|
|
5092
|
+
BoolDb extends Expression.DbType.Any,
|
|
5093
|
+
TimestampDb extends Expression.DbType.Any,
|
|
5094
|
+
NullDb extends Expression.DbType.Any
|
|
5095
|
+
> =
|
|
5096
|
+
Values extends ExpressionInput
|
|
5097
|
+
? DialectOfDialectInput<Values, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>
|
|
5098
|
+
: Values extends Record<string, unknown>
|
|
5099
|
+
? {
|
|
5100
|
+
[K in keyof Values]: NestedMutationDialectFromValues<Values[K], Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>
|
|
5101
|
+
}[keyof Values]
|
|
5102
|
+
: never
|
|
5103
|
+
|
|
5104
|
+
type KnownMutationDialectFromValues<
|
|
5105
|
+
Values,
|
|
5106
|
+
Dialect extends string,
|
|
5107
|
+
TextDb extends Expression.DbType.Any,
|
|
5108
|
+
NumericDb extends Expression.DbType.Any,
|
|
5109
|
+
BoolDb extends Expression.DbType.Any,
|
|
5110
|
+
TimestampDb extends Expression.DbType.Any,
|
|
5111
|
+
NullDb extends Expression.DbType.Any
|
|
5112
|
+
> = NestedMutationDialectFromValues<Values, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb> extends infer Current
|
|
5113
|
+
? Current extends string
|
|
5114
|
+
? string extends Current ? never : Current
|
|
5115
|
+
: never
|
|
5116
|
+
: never
|
|
5117
|
+
|
|
5118
|
+
type KnownIncompatibleMutationDialectFromValues<
|
|
5119
|
+
Values,
|
|
5120
|
+
Dialect extends string,
|
|
5121
|
+
TextDb extends Expression.DbType.Any,
|
|
5122
|
+
NumericDb extends Expression.DbType.Any,
|
|
5123
|
+
BoolDb extends Expression.DbType.Any,
|
|
5124
|
+
TimestampDb extends Expression.DbType.Any,
|
|
5125
|
+
NullDb extends Expression.DbType.Any
|
|
5126
|
+
> = Exclude<KnownMutationDialectFromValues<Values, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>, Dialect>
|
|
5127
|
+
|
|
5128
|
+
type MutationValuesDialectConstraint<
|
|
5129
|
+
Values,
|
|
5130
|
+
Dialect extends string,
|
|
5131
|
+
TextDb extends Expression.DbType.Any,
|
|
5132
|
+
NumericDb extends Expression.DbType.Any,
|
|
5133
|
+
BoolDb extends Expression.DbType.Any,
|
|
5134
|
+
TimestampDb extends Expression.DbType.Any,
|
|
5135
|
+
NullDb extends Expression.DbType.Any
|
|
5136
|
+
> = KnownIncompatibleMutationDialectFromValues<Values, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb> extends never
|
|
5137
|
+
? unknown
|
|
5138
|
+
: never
|
|
5139
|
+
|
|
4725
5140
|
type MutationAssignments<Shape extends Record<string, unknown>> = {
|
|
4726
5141
|
readonly [K in keyof Shape]: QueryAst.AssignmentClause
|
|
4727
5142
|
}
|
|
@@ -4755,12 +5170,38 @@ type InsertDirectSource =
|
|
|
4755
5170
|
|
|
4756
5171
|
type FromInput = SourceLike | InsertDirectSource
|
|
4757
5172
|
|
|
5173
|
+
type SourceDialectConstraint<
|
|
5174
|
+
CurrentSource extends SourceLike,
|
|
5175
|
+
Dialect extends string
|
|
5176
|
+
> = [SourceDialectOf<CurrentSource>] extends [never]
|
|
5177
|
+
? unknown
|
|
5178
|
+
: Extract<SourceDialectOf<CurrentSource>, Dialect> extends never
|
|
5179
|
+
? never
|
|
5180
|
+
: unknown
|
|
5181
|
+
|
|
5182
|
+
type SourceRequirementConstraint<
|
|
5183
|
+
PlanValue extends QueryPlan<any, any, any, any, any, any, any, any, any, any>,
|
|
5184
|
+
CurrentSource extends SourceLike
|
|
5185
|
+
> = [SourceRequiredOf<CurrentSource>] extends [never]
|
|
5186
|
+
? unknown
|
|
5187
|
+
: Exclude<SourceRequiredOf<CurrentSource>, ScopedNamesOfPlan<PlanValue>> extends never
|
|
5188
|
+
? unknown
|
|
5189
|
+
: SourceRequirementError<CurrentSource>
|
|
5190
|
+
|
|
4758
5191
|
type SelectFromConstraint<
|
|
4759
5192
|
PlanValue extends QueryPlan<any, any, any, any, any, any, any, any, any, any>,
|
|
4760
5193
|
CurrentSource extends SourceLike
|
|
4761
5194
|
> =
|
|
4762
5195
|
RequireSelectStatement<PlanValue> &
|
|
4763
|
-
(
|
|
5196
|
+
(
|
|
5197
|
+
SourceNameOf<CurrentSource> extends OutstandingOfPlan<PlanValue>
|
|
5198
|
+
? unknown
|
|
5199
|
+
: [OutstandingOfPlan<PlanValue>] extends [never]
|
|
5200
|
+
? [ScopedNamesOfPlan<PlanValue>] extends [never]
|
|
5201
|
+
? unknown
|
|
5202
|
+
: never
|
|
5203
|
+
: never
|
|
5204
|
+
) &
|
|
4764
5205
|
(SourceRequiredOf<CurrentSource> extends never ? unknown : SourceRequirementError<CurrentSource>)
|
|
4765
5206
|
|
|
4766
5207
|
type UpdateFromConstraint<
|
|
@@ -4777,7 +5218,7 @@ type InsertFromConstraint<
|
|
|
4777
5218
|
Dialect extends string
|
|
4778
5219
|
> =
|
|
4779
5220
|
RequirePendingInsertStatement<PlanValue> &
|
|
4780
|
-
(InsertSourceOfPlanInput<PlanValue, CurrentSource, Dialect>
|
|
5221
|
+
(CurrentSource extends InsertSourceOfPlanInput<PlanValue, CurrentSource, Dialect>
|
|
4781
5222
|
? unknown
|
|
4782
5223
|
: InsertSourceOfPlanInput<PlanValue, CurrentSource, Dialect>)
|
|
4783
5224
|
|
|
@@ -4831,12 +5272,12 @@ type InsertFromResult<
|
|
|
4831
5272
|
Dialect extends string
|
|
4832
5273
|
> = QueryPlan<
|
|
4833
5274
|
SelectionOfPlan<PlanValue>,
|
|
4834
|
-
|
|
5275
|
+
InsertSourceRequired<CurrentSource>,
|
|
4835
5276
|
AvailableOfPlan<PlanValue>,
|
|
4836
|
-
PlanDialectOf<PlanValue>,
|
|
5277
|
+
PlanDialectOf<PlanValue> | InsertSourceDialect<CurrentSource>,
|
|
4837
5278
|
GroupedOfPlan<PlanValue>,
|
|
4838
5279
|
ScopedNamesOfPlan<PlanValue>,
|
|
4839
|
-
|
|
5280
|
+
InsertSourceRequired<CurrentSource>,
|
|
4840
5281
|
AssumptionsOfPlan<PlanValue>,
|
|
4841
5282
|
CurrentSource extends QueryPlan<any, any, any, any, any, any, any, any, any, any>
|
|
4842
5283
|
? MergeCapabilities<CapabilitiesOfPlan<PlanValue>, CapabilitiesOfPlan<CurrentSource>>
|
|
@@ -4853,15 +5294,17 @@ type FromPlanConstraint<
|
|
|
4853
5294
|
Dialect extends string
|
|
4854
5295
|
> =
|
|
4855
5296
|
CurrentSource extends SourceLike
|
|
4856
|
-
?
|
|
4857
|
-
|
|
4858
|
-
|
|
4859
|
-
|
|
4860
|
-
|
|
4861
|
-
|
|
4862
|
-
|
|
4863
|
-
|
|
4864
|
-
|
|
5297
|
+
? SourceDialectConstraint<CurrentSource, Dialect> & (
|
|
5298
|
+
StatementOfPlan<PlanValue> extends "select"
|
|
5299
|
+
? SelectFromConstraint<PlanValue, CurrentSource>
|
|
5300
|
+
: StatementOfPlan<PlanValue> extends "update"
|
|
5301
|
+
? UpdateFromConstraint<PlanValue, CurrentSource>
|
|
5302
|
+
: StatementOfPlan<PlanValue> extends "insert"
|
|
5303
|
+
? CurrentSource extends AnyValuesSource | AnyUnnestSource
|
|
5304
|
+
? InsertFromConstraint<PlanValue, CurrentSource, Dialect>
|
|
5305
|
+
: never
|
|
5306
|
+
: never
|
|
5307
|
+
)
|
|
4865
5308
|
: CurrentSource extends InsertDirectSource
|
|
4866
5309
|
? StatementOfPlan<PlanValue> extends "insert"
|
|
4867
5310
|
? InsertFromConstraint<PlanValue, CurrentSource, Dialect>
|
|
@@ -4916,7 +5359,10 @@ export type PublicStructuredFromResult<
|
|
|
4916
5359
|
Exclude<OutstandingOfPlan<PlanValue>, SourceNameOf<CurrentSource>>,
|
|
4917
5360
|
AssumptionsOfPlan<PlanValue>,
|
|
4918
5361
|
MergeCapabilities<CapabilitiesOfPlan<PlanValue>, SourceCapabilitiesOf<CurrentSource>>,
|
|
4919
|
-
StatementOfPlan<PlanValue
|
|
5362
|
+
StatementOfPlan<PlanValue>,
|
|
5363
|
+
MutationTargetOfPlan<PlanValue>,
|
|
5364
|
+
InsertSourceStateOfPlan<PlanValue>,
|
|
5365
|
+
FactsOfPlan<PlanValue>
|
|
4920
5366
|
>
|
|
4921
5367
|
: StatementOfPlan<PlanValue> extends "update"
|
|
4922
5368
|
? QueryPlan<
|
|
@@ -4929,7 +5375,10 @@ export type PublicStructuredFromResult<
|
|
|
4929
5375
|
Exclude<OutstandingOfPlan<PlanValue>, SourceNameOf<CurrentSource>>,
|
|
4930
5376
|
AssumptionsOfPlan<PlanValue>,
|
|
4931
5377
|
MergeCapabilities<CapabilitiesOfPlan<PlanValue>, SourceCapabilitiesOf<CurrentSource>>,
|
|
4932
|
-
StatementOfPlan<PlanValue
|
|
5378
|
+
StatementOfPlan<PlanValue>,
|
|
5379
|
+
MutationTargetOfPlan<PlanValue>,
|
|
5380
|
+
InsertSourceStateOfPlan<PlanValue>,
|
|
5381
|
+
FactsOfPlan<PlanValue>
|
|
4933
5382
|
>
|
|
4934
5383
|
: StatementOfPlan<PlanValue> extends "insert"
|
|
4935
5384
|
? CurrentSource extends AnyValuesSource | AnyUnnestSource
|
|
@@ -4937,7 +5386,7 @@ export type PublicStructuredFromResult<
|
|
|
4937
5386
|
SelectionOfPlan<PlanValue>,
|
|
4938
5387
|
never,
|
|
4939
5388
|
AvailableOfPlan<PlanValue>,
|
|
4940
|
-
PlanDialectOf<PlanValue>,
|
|
5389
|
+
PlanDialectOf<PlanValue> | SourceDialectOf<CurrentSource>,
|
|
4941
5390
|
GroupedOfPlan<PlanValue>,
|
|
4942
5391
|
ScopedNamesOfPlan<PlanValue>,
|
|
4943
5392
|
never,
|
|
@@ -4945,7 +5394,8 @@ export type PublicStructuredFromResult<
|
|
|
4945
5394
|
CapabilitiesOfPlan<PlanValue>,
|
|
4946
5395
|
StatementOfPlan<PlanValue>,
|
|
4947
5396
|
MutationTargetOfPlan<PlanValue>,
|
|
4948
|
-
"ready"
|
|
5397
|
+
"ready",
|
|
5398
|
+
FactsOfPlan<PlanValue>
|
|
4949
5399
|
>
|
|
4950
5400
|
: FromPlanResult<PlanValue, CurrentSource, Dialect>
|
|
4951
5401
|
: FromPlanResult<PlanValue, CurrentSource, Dialect>
|
|
@@ -4962,6 +5412,36 @@ type MergeRequiredFromPredicate<
|
|
|
4962
5412
|
Available extends Record<string, Plan.AnySource>
|
|
4963
5413
|
> = Predicate extends PredicateInput ? AddExpressionRequired<never, Available, Predicate> : never
|
|
4964
5414
|
|
|
5415
|
+
type BroadString<Value extends string> = string extends Value ? true : false
|
|
5416
|
+
|
|
5417
|
+
type SameSourceName<
|
|
5418
|
+
Left extends string,
|
|
5419
|
+
Right extends string
|
|
5420
|
+
> = [Left] extends [Right] ? [Right] extends [Left] ? true : false : false
|
|
5421
|
+
|
|
5422
|
+
type MergeSourceNameConflictError<
|
|
5423
|
+
TargetName extends string,
|
|
5424
|
+
SourceName extends string
|
|
5425
|
+
> = {
|
|
5426
|
+
readonly __effect_qb_error__: "effect-qb: merge source name must differ from target source name"
|
|
5427
|
+
readonly __effect_qb_target_source_name__: TargetName
|
|
5428
|
+
readonly __effect_qb_using_source_name__: SourceName
|
|
5429
|
+
readonly __effect_qb_hint__: "Alias the merge source with Table.alias(...), Query.as(...), or Query.with(...)"
|
|
5430
|
+
}
|
|
5431
|
+
|
|
5432
|
+
type MergeSourceNameConstraint<
|
|
5433
|
+
Target extends MutationTargetLike,
|
|
5434
|
+
Source extends SourceLike,
|
|
5435
|
+
TargetName extends string = SourceNameOf<Target>,
|
|
5436
|
+
SourceName extends string = SourceNameOf<Source>
|
|
5437
|
+
> = BroadString<TargetName> extends true
|
|
5438
|
+
? unknown
|
|
5439
|
+
: BroadString<SourceName> extends true
|
|
5440
|
+
? unknown
|
|
5441
|
+
: SameSourceName<TargetName, SourceName> extends true
|
|
5442
|
+
? MergeSourceNameConflictError<TargetName, SourceName>
|
|
5443
|
+
: unknown
|
|
5444
|
+
|
|
4965
5445
|
type AsCurriedInput<Dialect extends string> =
|
|
4966
5446
|
| ExpressionInput
|
|
4967
5447
|
| ValuesInput<any, any, Dialect>
|
|
@@ -5001,20 +5481,20 @@ type AsCurriedResult<
|
|
|
5001
5481
|
>(
|
|
5002
5482
|
value: Value,
|
|
5003
5483
|
alias: Alias
|
|
5004
|
-
): DialectAsExpression<Value, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>
|
|
5484
|
+
): ProjectionAliasedExpression<DialectAsExpression<Value, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>, Alias>
|
|
5005
5485
|
function as<
|
|
5006
5486
|
Rows extends ValuesRowsInput,
|
|
5007
5487
|
Alias extends string
|
|
5008
5488
|
>(
|
|
5009
5489
|
value: ValuesInput<
|
|
5010
5490
|
Rows,
|
|
5011
|
-
ValuesOutputShape<Rows
|
|
5491
|
+
ValuesOutputShape<Rows, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>,
|
|
5012
5492
|
Dialect
|
|
5013
5493
|
>,
|
|
5014
5494
|
alias: Alias
|
|
5015
5495
|
): ValuesSource<
|
|
5016
5496
|
Rows,
|
|
5017
|
-
ValuesOutputShape<Rows
|
|
5497
|
+
ValuesOutputShape<Rows, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>,
|
|
5018
5498
|
Alias,
|
|
5019
5499
|
Dialect
|
|
5020
5500
|
>
|
|
@@ -5022,7 +5502,7 @@ type AsCurriedResult<
|
|
|
5022
5502
|
PlanValue extends QueryPlan<any, any, any, any, any, any, any, any, any, any>,
|
|
5023
5503
|
Alias extends string
|
|
5024
5504
|
>(
|
|
5025
|
-
value:
|
|
5505
|
+
value: DerivedTableCompatiblePlan<PlanValue>,
|
|
5026
5506
|
alias: Alias
|
|
5027
5507
|
): DerivedSource<PlanValue, Alias>
|
|
5028
5508
|
function as(valueOrAlias: unknown, alias?: string): unknown {
|
|
@@ -5069,13 +5549,13 @@ type AsCurriedResult<
|
|
|
5069
5549
|
>(
|
|
5070
5550
|
alias: Alias
|
|
5071
5551
|
): <PlanValue extends QueryPlan<any, any, any, any, any, any, any, any, any, any>>(
|
|
5072
|
-
value:
|
|
5552
|
+
value: DerivedSourceCompatiblePlan<PlanValue>
|
|
5073
5553
|
) => import("../../internal/query.js").CteSource<PlanValue, Alias>
|
|
5074
5554
|
function with_<
|
|
5075
5555
|
PlanValue extends QueryPlan<any, any, any, any, any, any, any, any, any, any>,
|
|
5076
5556
|
Alias extends string
|
|
5077
5557
|
>(
|
|
5078
|
-
value:
|
|
5558
|
+
value: DerivedSourceCompatiblePlan<PlanValue>,
|
|
5079
5559
|
alias: Alias
|
|
5080
5560
|
): import("../../internal/query.js").CteSource<PlanValue, Alias>
|
|
5081
5561
|
function with_(valueOrAlias: unknown, alias?: string): unknown {
|
|
@@ -5093,13 +5573,13 @@ type AsCurriedResult<
|
|
|
5093
5573
|
>(
|
|
5094
5574
|
alias: Alias
|
|
5095
5575
|
): <PlanValue extends QueryPlan<any, any, any, any, any, any, any, any, any, any>>(
|
|
5096
|
-
value:
|
|
5576
|
+
value: DerivedSourceCompatiblePlan<PlanValue>
|
|
5097
5577
|
) => import("../../internal/query.js").CteSource<PlanValue, Alias>
|
|
5098
5578
|
function withRecursive_<
|
|
5099
5579
|
PlanValue extends QueryPlan<any, any, any, any, any, any, any, any, any, any>,
|
|
5100
5580
|
Alias extends string
|
|
5101
5581
|
>(
|
|
5102
|
-
value:
|
|
5582
|
+
value: DerivedSourceCompatiblePlan<PlanValue>,
|
|
5103
5583
|
alias: Alias
|
|
5104
5584
|
): import("../../internal/query.js").CteSource<PlanValue, Alias>
|
|
5105
5585
|
function withRecursive_(valueOrAlias: unknown, alias?: string): unknown {
|
|
@@ -5118,13 +5598,13 @@ type AsCurriedResult<
|
|
|
5118
5598
|
>(
|
|
5119
5599
|
alias: Alias
|
|
5120
5600
|
): <PlanValue extends QueryPlan<any, any, any, any, any, any, any, any, any, any>>(
|
|
5121
|
-
value: PlanValue
|
|
5601
|
+
value: LateralSourceCompatiblePlan<PlanValue>
|
|
5122
5602
|
) => import("../../internal/query.js").LateralSource<PlanValue, Alias>
|
|
5123
5603
|
function lateral<
|
|
5124
5604
|
PlanValue extends QueryPlan<any, any, any, any, any, any, any, any, any, any>,
|
|
5125
5605
|
Alias extends string
|
|
5126
5606
|
>(
|
|
5127
|
-
value: PlanValue
|
|
5607
|
+
value: LateralSourceCompatiblePlan<PlanValue>,
|
|
5128
5608
|
alias: Alias
|
|
5129
5609
|
): import("../../internal/query.js").LateralSource<PlanValue, Alias>
|
|
5130
5610
|
function lateral(valueOrAlias: unknown, alias?: string): unknown {
|
|
@@ -5141,9 +5621,11 @@ type AsCurriedResult<
|
|
|
5141
5621
|
Rows extends ValuesRowsInput
|
|
5142
5622
|
>(
|
|
5143
5623
|
rows: Rows
|
|
5624
|
+
& ValuesRowsShapeInput<Rows>
|
|
5625
|
+
& ValuesRowsDialectInput<Rows, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>
|
|
5144
5626
|
) => ValuesInput<
|
|
5145
5627
|
Rows,
|
|
5146
|
-
ValuesOutputShape<Rows
|
|
5628
|
+
ValuesOutputShape<Rows, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>,
|
|
5147
5629
|
Dialect
|
|
5148
5630
|
>
|
|
5149
5631
|
|
|
@@ -5151,7 +5633,9 @@ type AsCurriedResult<
|
|
|
5151
5633
|
Columns extends UnnestColumnsInput,
|
|
5152
5634
|
Alias extends string
|
|
5153
5635
|
>(
|
|
5154
|
-
columns: Columns
|
|
5636
|
+
columns: Columns
|
|
5637
|
+
& UnnestColumnsShapeInput<Columns>
|
|
5638
|
+
& UnnestColumnsDialectInput<Columns, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>,
|
|
5155
5639
|
alias: Alias
|
|
5156
5640
|
) => UnnestSource<
|
|
5157
5641
|
UnnestOutputShape<Columns, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>,
|
|
@@ -5165,9 +5649,9 @@ type AsCurriedResult<
|
|
|
5165
5649
|
Step extends NumericExpressionInput | undefined = undefined,
|
|
5166
5650
|
Alias extends string = "series"
|
|
5167
5651
|
>(
|
|
5168
|
-
start: Start,
|
|
5169
|
-
stop: Stop,
|
|
5170
|
-
step?: Step,
|
|
5652
|
+
start: Start & NumericExpressionDialectInput<Start, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>,
|
|
5653
|
+
stop: Stop & NumericExpressionDialectInput<Stop, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>,
|
|
5654
|
+
step?: Step & (Step extends NumericExpressionInput ? NumericExpressionDialectInput<Step, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb> : unknown),
|
|
5171
5655
|
alias?: Alias
|
|
5172
5656
|
) => Dialect extends "postgres"
|
|
5173
5657
|
? TableFunctionSource<
|
|
@@ -5179,11 +5663,14 @@ type AsCurriedResult<
|
|
|
5179
5663
|
: GenerateSeriesUnsupportedError<Dialect>
|
|
5180
5664
|
|
|
5181
5665
|
export type PublicGenerateSeriesApi = <
|
|
5666
|
+
Start extends NumericExpressionInput,
|
|
5667
|
+
Stop extends NumericExpressionInput,
|
|
5668
|
+
Step extends NumericExpressionInput | undefined = undefined,
|
|
5182
5669
|
Alias extends string = "series"
|
|
5183
5670
|
>(
|
|
5184
|
-
start:
|
|
5185
|
-
stop:
|
|
5186
|
-
step?: NumericExpressionInput,
|
|
5671
|
+
start: Start & NumericExpressionDialectInput<Start, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>,
|
|
5672
|
+
stop: Stop & NumericExpressionDialectInput<Stop, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>,
|
|
5673
|
+
step?: Step & (Step extends NumericExpressionInput ? NumericExpressionDialectInput<Step, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb> : unknown),
|
|
5187
5674
|
alias?: Alias
|
|
5188
5675
|
) => TableFunctionSource<
|
|
5189
5676
|
{
|
|
@@ -5194,8 +5681,36 @@ type AsCurriedResult<
|
|
|
5194
5681
|
"generate_series"
|
|
5195
5682
|
>
|
|
5196
5683
|
|
|
5197
|
-
|
|
5198
|
-
|
|
5684
|
+
type SelectionRootObjectError<Selection> = Selection & {
|
|
5685
|
+
readonly __effect_qb_error__: "effect-qb: selections must be projection objects"
|
|
5686
|
+
readonly __effect_qb_hint__: "Use select({ value: expression }) or returning({ value: expression })"
|
|
5687
|
+
}
|
|
5688
|
+
|
|
5689
|
+
type SelectionRootObjectConstraint<Selection> =
|
|
5690
|
+
Selection extends Expression.Any ? SelectionRootObjectError<Selection> : unknown
|
|
5691
|
+
|
|
5692
|
+
type SelectionNestedEmptyError<Selection> = Selection & {
|
|
5693
|
+
readonly __effect_qb_error__: "effect-qb: projection objects cannot contain empty nested selections"
|
|
5694
|
+
}
|
|
5695
|
+
|
|
5696
|
+
type SelectionHasEmptyNestedObject<Selection, IsRoot extends boolean> =
|
|
5697
|
+
Selection extends Expression.Any
|
|
5698
|
+
? false
|
|
5699
|
+
: Selection extends Record<string, any>
|
|
5700
|
+
? [Extract<keyof Selection, string>] extends [never]
|
|
5701
|
+
? IsRoot extends true ? false : true
|
|
5702
|
+
: true extends {
|
|
5703
|
+
[K in Extract<keyof Selection, string>]: SelectionHasEmptyNestedObject<Selection[K], false>
|
|
5704
|
+
}[Extract<keyof Selection, string>]
|
|
5705
|
+
? true
|
|
5706
|
+
: false
|
|
5707
|
+
: false
|
|
5708
|
+
|
|
5709
|
+
type SelectionNestedNonEmptyConstraint<Selection> =
|
|
5710
|
+
SelectionHasEmptyNestedObject<Selection, true> extends true ? SelectionNestedEmptyError<Selection> : unknown
|
|
5711
|
+
|
|
5712
|
+
export type SelectApi = <Selection extends SelectionShape = {}>(
|
|
5713
|
+
selection?: Selection & SelectionRootObjectConstraint<Selection> & SelectionNestedNonEmptyConstraint<Selection>
|
|
5199
5714
|
) => QueryPlan<
|
|
5200
5715
|
Selection,
|
|
5201
5716
|
ExtractRequired<Selection>,
|
|
@@ -5254,7 +5769,10 @@ type AsCurriedResult<
|
|
|
5254
5769
|
never,
|
|
5255
5770
|
TrueFormula,
|
|
5256
5771
|
CapabilitiesOfPlan<LeftPlanValue> | CapabilitiesOfPlan<RightPlanValue>,
|
|
5257
|
-
"set"
|
|
5772
|
+
"set",
|
|
5773
|
+
any,
|
|
5774
|
+
"ready",
|
|
5775
|
+
CommonSetFacts<LeftPlanValue, RightPlanValue>
|
|
5258
5776
|
>
|
|
5259
5777
|
|
|
5260
5778
|
type SetOperationApi = <
|
|
@@ -5322,10 +5840,10 @@ type AsCurriedResult<
|
|
|
5322
5840
|
keyof AvailableOfPlan<PlanValue> extends never ? never : unknown
|
|
5323
5841
|
) & (
|
|
5324
5842
|
SourceNameOf<CurrentTable> extends ScopedNamesOfPlan<PlanValue> ? never : unknown
|
|
5325
|
-
)
|
|
5843
|
+
) & SourceRequirementConstraint<PlanValue, CurrentTable> & SourceDialectConstraint<CurrentTable, Dialect>
|
|
5326
5844
|
) => QueryPlan<
|
|
5327
5845
|
SelectionOfPlan<PlanValue>,
|
|
5328
|
-
AddJoinRequired<RequiredOfPlan<PlanValue>, AvailableOfPlan<PlanValue>, SourceNameOf<CurrentTable>, never, "cross"
|
|
5846
|
+
AddJoinRequired<RequiredOfPlan<PlanValue>, AvailableOfPlan<PlanValue>, SourceNameOf<CurrentTable>, never, "cross", SourceRequiredOf<CurrentTable>>,
|
|
5329
5847
|
AddAvailable<
|
|
5330
5848
|
AvailableOfPlan<PlanValue>,
|
|
5331
5849
|
SourceNameOf<CurrentTable>,
|
|
@@ -5336,10 +5854,13 @@ type AsCurriedResult<
|
|
|
5336
5854
|
PlanDialectOf<PlanValue> | SourceDialectOf<CurrentTable>,
|
|
5337
5855
|
GroupedOfPlan<PlanValue>,
|
|
5338
5856
|
ScopedNamesOfPlan<PlanValue> | SourceNameOf<CurrentTable>,
|
|
5339
|
-
AddJoinRequired<OutstandingOfPlan<PlanValue>, AvailableOfPlan<PlanValue>, SourceNameOf<CurrentTable>, never, "cross"
|
|
5857
|
+
AddJoinRequired<OutstandingOfPlan<PlanValue>, AvailableOfPlan<PlanValue>, SourceNameOf<CurrentTable>, never, "cross", SourceRequiredOf<CurrentTable>>,
|
|
5340
5858
|
AssumptionsOfPlan<PlanValue>,
|
|
5341
5859
|
MergeCapabilities<CapabilitiesOfPlan<PlanValue>, SourceCapabilitiesOf<CurrentTable>>,
|
|
5342
|
-
StatementOfPlan<PlanValue
|
|
5860
|
+
StatementOfPlan<PlanValue>,
|
|
5861
|
+
MutationTargetOfPlan<PlanValue>,
|
|
5862
|
+
InsertSourceStateOfPlan<PlanValue>,
|
|
5863
|
+
FactsOfPlan<PlanValue>
|
|
5343
5864
|
>
|
|
5344
5865
|
|
|
5345
5866
|
type JoinApi = <
|
|
@@ -5356,10 +5877,10 @@ type AsCurriedResult<
|
|
|
5356
5877
|
keyof AvailableOfPlan<PlanValue> extends never ? never : unknown
|
|
5357
5878
|
) & (
|
|
5358
5879
|
SourceNameOf<CurrentTable> extends ScopedNamesOfPlan<PlanValue> ? never : unknown
|
|
5359
|
-
)
|
|
5880
|
+
) & SourceRequirementConstraint<PlanValue, CurrentTable> & SourceDialectConstraint<CurrentTable, Dialect>
|
|
5360
5881
|
) => QueryPlan<
|
|
5361
5882
|
SelectionOfPlan<PlanValue>,
|
|
5362
|
-
AddJoinRequired<RequiredOfPlan<PlanValue>, AvailableOfPlan<PlanValue>, SourceNameOf<CurrentTable>, Predicate, Kind
|
|
5883
|
+
AddJoinRequired<RequiredOfPlan<PlanValue>, AvailableOfPlan<PlanValue>, SourceNameOf<CurrentTable>, Predicate, Kind, SourceRequiredOf<CurrentTable>>,
|
|
5363
5884
|
AvailableAfterJoin<
|
|
5364
5885
|
AvailableOfPlan<PlanValue>,
|
|
5365
5886
|
SourceNameOf<CurrentTable>,
|
|
@@ -5370,7 +5891,7 @@ type AsCurriedResult<
|
|
|
5370
5891
|
PlanDialectOf<PlanValue> | SourceDialectOf<CurrentTable> | DialectOfDialectInput<Predicate, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>,
|
|
5371
5892
|
GroupedOfPlan<PlanValue>,
|
|
5372
5893
|
ScopedNamesOfPlan<PlanValue> | SourceNameOf<CurrentTable>,
|
|
5373
|
-
AddJoinRequired<OutstandingOfPlan<PlanValue>, AvailableOfPlan<PlanValue>, SourceNameOf<CurrentTable>, Predicate, Kind
|
|
5894
|
+
AddJoinRequired<OutstandingOfPlan<PlanValue>, AvailableOfPlan<PlanValue>, SourceNameOf<CurrentTable>, Predicate, Kind, SourceRequiredOf<CurrentTable>>,
|
|
5374
5895
|
PlanAssumptionsAfterJoin<PlanValue, Predicate, Kind, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>,
|
|
5375
5896
|
MergeCapabilities<CapabilitiesOfPlan<PlanValue>, SourceCapabilitiesOf<CurrentTable>>,
|
|
5376
5897
|
StatementOfPlan<PlanValue>,
|
|
@@ -5391,10 +5912,10 @@ type AsCurriedResult<
|
|
|
5391
5912
|
keyof AvailableOfPlan<PlanValue> extends never ? never : unknown
|
|
5392
5913
|
) & (
|
|
5393
5914
|
SourceNameOf<CurrentTable> extends ScopedNamesOfPlan<PlanValue> ? never : unknown
|
|
5394
|
-
)
|
|
5915
|
+
) & SourceRequirementConstraint<PlanValue, CurrentTable> & SourceDialectConstraint<CurrentTable, Dialect>
|
|
5395
5916
|
) => QueryPlan<
|
|
5396
5917
|
SelectionOfPlan<PlanValue>,
|
|
5397
|
-
AddJoinRequired<RequiredOfPlan<PlanValue>, AvailableOfPlan<PlanValue>, SourceNameOf<CurrentTable>, Predicate, Kind
|
|
5918
|
+
AddJoinRequired<RequiredOfPlan<PlanValue>, AvailableOfPlan<PlanValue>, SourceNameOf<CurrentTable>, Predicate, Kind, SourceRequiredOf<CurrentTable>>,
|
|
5398
5919
|
AvailableAfterJoin<
|
|
5399
5920
|
AvailableOfPlan<PlanValue>,
|
|
5400
5921
|
SourceNameOf<CurrentTable>,
|
|
@@ -5405,7 +5926,7 @@ type AsCurriedResult<
|
|
|
5405
5926
|
PlanDialectOf<PlanValue> | SourceDialectOf<CurrentTable> | DialectOfDialectInput<Predicate, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>,
|
|
5406
5927
|
GroupedOfPlan<PlanValue>,
|
|
5407
5928
|
ScopedNamesOfPlan<PlanValue> | SourceNameOf<CurrentTable>,
|
|
5408
|
-
AddJoinRequired<OutstandingOfPlan<PlanValue>, AvailableOfPlan<PlanValue>, SourceNameOf<CurrentTable>, Predicate, Kind
|
|
5929
|
+
AddJoinRequired<OutstandingOfPlan<PlanValue>, AvailableOfPlan<PlanValue>, SourceNameOf<CurrentTable>, Predicate, Kind, SourceRequiredOf<CurrentTable>>,
|
|
5409
5930
|
PlanAssumptionsAfterJoin<PlanValue, Predicate, Kind, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>,
|
|
5410
5931
|
MergeCapabilities<CapabilitiesOfPlan<PlanValue>, SourceCapabilitiesOf<CurrentTable>>,
|
|
5411
5932
|
StatementOfPlan<PlanValue>,
|
|
@@ -5613,18 +6134,21 @@ type AsCurriedResult<
|
|
|
5613
6134
|
|
|
5614
6135
|
const fullJoin = ((table, on) => (join as any)("full", table, on)) as BinaryJoinApi<"full">
|
|
5615
6136
|
|
|
5616
|
-
const distinctOn = (
|
|
6137
|
+
const distinctOn = (<Values extends readonly [ExpressionInput, ...ExpressionInput[]]>(...values: Values) => {
|
|
6138
|
+
if (values.length === 0) {
|
|
6139
|
+
throw new Error("distinctOn(...) requires at least one expression")
|
|
6140
|
+
}
|
|
5617
6141
|
const expressions = values.map((value) => toDialectExpression(value)) as Expression.Any[]
|
|
5618
6142
|
return <PlanValue extends QueryPlan<any, any, any, any, any, any, any, any, any, any>>(
|
|
5619
6143
|
plan: PlanValue & RequireSelectStatement<PlanValue>
|
|
5620
6144
|
): QueryPlan<
|
|
5621
6145
|
SelectionOfPlan<PlanValue>,
|
|
5622
|
-
RequiredOfPlan<PlanValue>,
|
|
6146
|
+
AddExpressionRequired<RequiredOfPlan<PlanValue>, AvailableOfPlan<PlanValue>, Values[number]>,
|
|
5623
6147
|
AvailableOfPlan<PlanValue>,
|
|
5624
|
-
PlanDialectOf<PlanValue>,
|
|
6148
|
+
PlanDialectOf<PlanValue> | DialectOfDialectInput<Values[number], Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>,
|
|
5625
6149
|
GroupedOfPlan<PlanValue>,
|
|
5626
6150
|
ScopedNamesOfPlan<PlanValue>,
|
|
5627
|
-
OutstandingOfPlan<PlanValue>,
|
|
6151
|
+
AddExpressionRequired<OutstandingOfPlan<PlanValue>, AvailableOfPlan<PlanValue>, Values[number]>,
|
|
5628
6152
|
AssumptionsOfPlan<PlanValue>,
|
|
5629
6153
|
CapabilitiesOfPlan<PlanValue>,
|
|
5630
6154
|
StatementOfPlan<PlanValue>
|
|
@@ -5632,11 +6156,13 @@ type AsCurriedResult<
|
|
|
5632
6156
|
const current = plan[Plan.TypeId]
|
|
5633
6157
|
const currentAst = getAst(plan)
|
|
5634
6158
|
const currentQuery = getQueryState(plan)
|
|
6159
|
+
const required = values.flatMap((value) => extractRequiredFromDialectInputRuntime(value))
|
|
5635
6160
|
return makePlan({
|
|
5636
6161
|
selection: current.selection,
|
|
5637
|
-
required: current.required
|
|
6162
|
+
required: [...currentRequiredList(current.required), ...required].filter((name, index, list) =>
|
|
6163
|
+
!(name in current.available) && list.indexOf(name) === index) as AddExpressionRequired<RequiredOfPlan<PlanValue>, AvailableOfPlan<PlanValue>, Values[number]>,
|
|
5638
6164
|
available: current.available,
|
|
5639
|
-
dialect: current.dialect as PlanDialectOf<PlanValue>
|
|
6165
|
+
dialect: current.dialect as PlanDialectOf<PlanValue> | DialectOfDialectInput<Values[number], Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>
|
|
5640
6166
|
}, {
|
|
5641
6167
|
...currentAst,
|
|
5642
6168
|
distinct: true,
|
|
@@ -5666,8 +6192,19 @@ type AsCurriedResult<
|
|
|
5666
6192
|
FactsOfPlan<PlanValue>
|
|
5667
6193
|
>
|
|
5668
6194
|
|
|
6195
|
+
type ReturningSelectionNonEmptyError<Selection> = Selection & {
|
|
6196
|
+
readonly __effect_qb_error__: "effect-qb: returning(...) requires at least one selected expression"
|
|
6197
|
+
}
|
|
6198
|
+
|
|
6199
|
+
type ReturningSelectionNonEmptyConstraint<Selection> =
|
|
6200
|
+
Selection extends Expression.Any
|
|
6201
|
+
? unknown
|
|
6202
|
+
: [Extract<keyof Selection, string>] extends [never]
|
|
6203
|
+
? ReturningSelectionNonEmptyError<Selection>
|
|
6204
|
+
: unknown
|
|
6205
|
+
|
|
5669
6206
|
type ReturningApi = <Selection extends SelectionShape>(
|
|
5670
|
-
selection: Selection
|
|
6207
|
+
selection: Selection & SelectionRootObjectConstraint<Selection> & SelectionNestedNonEmptyConstraint<Selection> & ReturningSelectionNonEmptyConstraint<Selection>
|
|
5671
6208
|
) =>
|
|
5672
6209
|
<PlanValue extends QueryPlan<any, any, any, any, any, any, any, any, any, any>>(
|
|
5673
6210
|
plan: PlanValue & RequireMutationStatement<PlanValue>
|
|
@@ -5689,7 +6226,7 @@ type AsCurriedResult<
|
|
|
5689
6226
|
|
|
5690
6227
|
export interface InsertApi {
|
|
5691
6228
|
<Target extends MutationTargetLike>(
|
|
5692
|
-
target: Target
|
|
6229
|
+
target: Target & TableDialectConstraint<Target, Dialect>
|
|
5693
6230
|
): QueryPlan<
|
|
5694
6231
|
{},
|
|
5695
6232
|
never,
|
|
@@ -5706,13 +6243,13 @@ type AsCurriedResult<
|
|
|
5706
6243
|
EmptyFacts
|
|
5707
6244
|
>
|
|
5708
6245
|
<Target extends MutationTargetLike, Values extends Record<string, unknown>>(
|
|
5709
|
-
target: Target,
|
|
5710
|
-
values: MutationValuesInput<"insert", Target, Values>
|
|
6246
|
+
target: Target & TableDialectConstraint<Target, Dialect>,
|
|
6247
|
+
values: MutationValuesInput<"insert", Target, Values> & MutationValuesDialectConstraint<Values, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>
|
|
5711
6248
|
): QueryPlan<
|
|
5712
6249
|
{},
|
|
5713
6250
|
Exclude<MutationRequiredFromValues<Values>, SourceNameOf<Target>>,
|
|
5714
6251
|
AddAvailable<{}, SourceNameOf<Target>>,
|
|
5715
|
-
TableDialectOf<Target>,
|
|
6252
|
+
TableDialectOf<Target> | KnownMutationDialectFromValues<Values, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>,
|
|
5716
6253
|
never,
|
|
5717
6254
|
SourceNameOf<Target>,
|
|
5718
6255
|
Exclude<MutationRequiredFromValues<Values>, SourceNameOf<Target>>,
|
|
@@ -5734,21 +6271,22 @@ type AsCurriedResult<
|
|
|
5734
6271
|
Target extends MutationTargetLike,
|
|
5735
6272
|
const Columns extends DdlColumnInput,
|
|
5736
6273
|
UpdateValues extends MutationInputOf<Table.UpdateOf<Target>> | undefined = MutationInputOf<Table.UpdateOf<Target>> | undefined,
|
|
5737
|
-
Options extends ConflictActionInput<Target, Dialect, UpdateValues> = ConflictActionInput<Target, Dialect, UpdateValues
|
|
6274
|
+
Options extends ConflictActionInput<Target, Dialect, UpdateValues> = ConflictActionInput<Target, Dialect, UpdateValues>,
|
|
6275
|
+
ConflictTarget extends ConflictTargetInput<Target, Dialect, Columns> = ConflictTargetInput<Target, Dialect, Columns>
|
|
5738
6276
|
>(
|
|
5739
|
-
target:
|
|
5740
|
-
options?: Options
|
|
6277
|
+
target: ConflictTarget,
|
|
6278
|
+
options?: Options & ConflictActionUpdateNonEmptyConstraint<Options>
|
|
5741
6279
|
) =>
|
|
5742
6280
|
<PlanValue extends QueryPlan<any, any, any, any, any, any, any, any, any, any>>(
|
|
5743
6281
|
plan: PlanValue & RequireInsertStatement<PlanValue>
|
|
5744
6282
|
) => QueryPlan<
|
|
5745
6283
|
SelectionOfPlan<PlanValue>,
|
|
5746
|
-
Exclude<RequiredOfPlan<PlanValue> |
|
|
6284
|
+
Exclude<RequiredOfPlan<PlanValue> | ConflictRequired<UpdateValues, Options, ConflictTarget>, AvailableNames<AvailableOfPlan<PlanValue>>>,
|
|
5747
6285
|
AvailableOfPlan<PlanValue>,
|
|
5748
|
-
PlanDialectOf<PlanValue>,
|
|
6286
|
+
PlanDialectOf<PlanValue> | ConflictDialect<UpdateValues, Options, ConflictTarget, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>,
|
|
5749
6287
|
GroupedOfPlan<PlanValue>,
|
|
5750
6288
|
ScopedNamesOfPlan<PlanValue>,
|
|
5751
|
-
Exclude<OutstandingOfPlan<PlanValue> |
|
|
6289
|
+
Exclude<OutstandingOfPlan<PlanValue> | ConflictRequired<UpdateValues, Options, ConflictTarget>, AvailableNames<AvailableOfPlan<PlanValue>>>,
|
|
5752
6290
|
AssumptionsOfPlan<PlanValue>,
|
|
5753
6291
|
CapabilitiesOfPlan<PlanValue>,
|
|
5754
6292
|
StatementOfPlan<PlanValue>,
|
|
@@ -5759,13 +6297,13 @@ type AsCurriedResult<
|
|
|
5759
6297
|
|
|
5760
6298
|
interface UpdateApi {
|
|
5761
6299
|
<Targets extends MutationTargetTuple, Values extends UpdateInputOfTarget<Targets>>(
|
|
5762
|
-
target: Dialect extends "mysql" ? Targets : never,
|
|
5763
|
-
values: Values
|
|
6300
|
+
target: Dialect extends "mysql" ? Targets & MutationTargetTupleDialectConstraint<Targets, Dialect> : never,
|
|
6301
|
+
values: Values & NestedUpdateValuesNonEmptyConstraint<Values> & MutationValuesDialectConstraint<Values, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>
|
|
5764
6302
|
): QueryPlan<
|
|
5765
6303
|
{},
|
|
5766
6304
|
Exclude<NestedMutationRequiredFromValues<Values>, MutationTargetNamesOf<Targets>>,
|
|
5767
6305
|
AddAvailableMany<{}, MutationTargetNamesOf<Targets>>,
|
|
5768
|
-
TableDialectOf<Targets[0]>,
|
|
6306
|
+
TableDialectOf<Targets[0]> | KnownMutationDialectFromValues<Values, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>,
|
|
5769
6307
|
never,
|
|
5770
6308
|
MutationTargetNamesOf<Targets>,
|
|
5771
6309
|
Exclude<NestedMutationRequiredFromValues<Values>, MutationTargetNamesOf<Targets>>,
|
|
@@ -5777,13 +6315,13 @@ type AsCurriedResult<
|
|
|
5777
6315
|
EmptyFacts
|
|
5778
6316
|
>
|
|
5779
6317
|
<Target extends MutationTargetLike, Values extends Record<string, unknown>>(
|
|
5780
|
-
target: Target,
|
|
5781
|
-
values: MutationValuesInput<"update", Target, Values>
|
|
6318
|
+
target: Target & TableDialectConstraint<Target, Dialect>,
|
|
6319
|
+
values: MutationValuesInput<"update", Target, Values> & UpdateValuesNonEmptyConstraint<Values> & MutationValuesDialectConstraint<Values, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>
|
|
5782
6320
|
): QueryPlan<
|
|
5783
6321
|
{},
|
|
5784
6322
|
Exclude<MutationRequiredFromValues<Values>, SourceNameOf<Target>>,
|
|
5785
6323
|
AddAvailable<{}, SourceNameOf<Target>>,
|
|
5786
|
-
TableDialectOf<Target>,
|
|
6324
|
+
TableDialectOf<Target> | KnownMutationDialectFromValues<Values, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>,
|
|
5787
6325
|
never,
|
|
5788
6326
|
SourceNameOf<Target>,
|
|
5789
6327
|
Exclude<MutationRequiredFromValues<Values>, SourceNameOf<Target>>,
|
|
@@ -5800,20 +6338,22 @@ type AsCurriedResult<
|
|
|
5800
6338
|
Target extends MutationTargetLike,
|
|
5801
6339
|
Values extends MutationInputOf<Table.InsertOf<Target>>,
|
|
5802
6340
|
const Columns extends DdlColumnInput,
|
|
5803
|
-
UpdateValues extends MutationInputOf<Table.UpdateOf<Target>>
|
|
6341
|
+
UpdateValues extends MutationInputOf<Table.UpdateOf<Target>> | undefined = undefined
|
|
5804
6342
|
>(
|
|
5805
|
-
target: Target,
|
|
5806
|
-
values: Values,
|
|
5807
|
-
conflictColumns:
|
|
5808
|
-
updateValues?: UpdateValues
|
|
6343
|
+
target: Target & TableDialectConstraint<Target, Dialect>,
|
|
6344
|
+
values: Values & MutationValuesDialectConstraint<Values, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>,
|
|
6345
|
+
conflictColumns: ValidateTargetColumnInput<Target, Columns>,
|
|
6346
|
+
updateValues?: UpdateValues & UpdateValuesNonEmptyConstraint<Exclude<UpdateValues, undefined>> & MutationValuesDialectConstraint<Exclude<UpdateValues, undefined>, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>
|
|
5809
6347
|
) => QueryPlan<
|
|
5810
6348
|
{},
|
|
5811
|
-
Exclude<MutationRequiredFromValues<Values> | MutationRequiredFromValues<UpdateValues
|
|
6349
|
+
Exclude<MutationRequiredFromValues<Values> | MutationRequiredFromValues<Exclude<UpdateValues, undefined>>, SourceNameOf<Target>>,
|
|
5812
6350
|
AddAvailable<{}, SourceNameOf<Target>>,
|
|
5813
|
-
TableDialectOf<Target
|
|
6351
|
+
| TableDialectOf<Target>
|
|
6352
|
+
| KnownMutationDialectFromValues<Values, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>
|
|
6353
|
+
| KnownMutationDialectFromValues<Exclude<UpdateValues, undefined>, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>,
|
|
5814
6354
|
never,
|
|
5815
6355
|
SourceNameOf<Target>,
|
|
5816
|
-
Exclude<MutationRequiredFromValues<Values> | MutationRequiredFromValues<UpdateValues
|
|
6356
|
+
Exclude<MutationRequiredFromValues<Values> | MutationRequiredFromValues<Exclude<UpdateValues, undefined>>, SourceNameOf<Target>>,
|
|
5817
6357
|
TrueFormula,
|
|
5818
6358
|
"write",
|
|
5819
6359
|
"insert",
|
|
@@ -5824,7 +6364,7 @@ type AsCurriedResult<
|
|
|
5824
6364
|
|
|
5825
6365
|
interface DeleteApi {
|
|
5826
6366
|
<Target extends MutationTargetLike>(
|
|
5827
|
-
target: Target
|
|
6367
|
+
target: Target & TableDialectConstraint<Target, Dialect>
|
|
5828
6368
|
): QueryPlan<
|
|
5829
6369
|
{},
|
|
5830
6370
|
never,
|
|
@@ -5841,7 +6381,7 @@ type AsCurriedResult<
|
|
|
5841
6381
|
EmptyFacts
|
|
5842
6382
|
>
|
|
5843
6383
|
<Targets extends MutationTargetTuple>(
|
|
5844
|
-
target: Dialect extends "mysql" ? Targets : never
|
|
6384
|
+
target: Dialect extends "mysql" ? Targets & MutationTargetTupleDialectConstraint<Targets, Dialect> : never
|
|
5845
6385
|
): QueryPlan<
|
|
5846
6386
|
{},
|
|
5847
6387
|
never,
|
|
@@ -5860,7 +6400,7 @@ type AsCurriedResult<
|
|
|
5860
6400
|
}
|
|
5861
6401
|
|
|
5862
6402
|
type TruncateApi = <Target extends MutationTargetLike>(
|
|
5863
|
-
target: Target,
|
|
6403
|
+
target: Target & TableDialectConstraint<Target, Dialect>,
|
|
5864
6404
|
options?: TruncateOptions
|
|
5865
6405
|
) => QueryPlan<
|
|
5866
6406
|
{},
|
|
@@ -5887,12 +6427,12 @@ type AsCurriedResult<
|
|
|
5887
6427
|
MatchedPredicate extends PredicateInput | undefined = undefined,
|
|
5888
6428
|
NotMatchedPredicate extends PredicateInput | undefined = undefined
|
|
5889
6429
|
>(
|
|
5890
|
-
target: Target,
|
|
6430
|
+
target: Target & TableDialectConstraint<Target, Dialect>,
|
|
5891
6431
|
source: Source & (
|
|
5892
6432
|
SourceRequiredOf<Source> extends never ? unknown : SourceRequirementError<Source>
|
|
5893
|
-
),
|
|
6433
|
+
) & MergeSourceNameConstraint<Target, Source> & SourceDialectConstraint<Source, Dialect>,
|
|
5894
6434
|
on: On,
|
|
5895
|
-
options
|
|
6435
|
+
options: MergeOptions<Target, MatchedValues, InsertValues, MatchedPredicate, NotMatchedPredicate>
|
|
5896
6436
|
) => QueryPlan<
|
|
5897
6437
|
{},
|
|
5898
6438
|
Exclude<
|
|
@@ -5936,6 +6476,7 @@ type AsCurriedResult<
|
|
|
5936
6476
|
>
|
|
5937
6477
|
|
|
5938
6478
|
const mutationRuntime = makeDslMutationRuntime({
|
|
6479
|
+
profile,
|
|
5939
6480
|
makePlan,
|
|
5940
6481
|
getAst,
|
|
5941
6482
|
getQueryState,
|
|
@@ -5948,7 +6489,7 @@ type AsCurriedResult<
|
|
|
5948
6489
|
buildConflictTarget,
|
|
5949
6490
|
mutationTargetClauses,
|
|
5950
6491
|
mutationAvailableSources,
|
|
5951
|
-
|
|
6492
|
+
normalizeConflictColumns,
|
|
5952
6493
|
targetSourceDetails,
|
|
5953
6494
|
sourceDetails
|
|
5954
6495
|
})
|
|
@@ -5964,63 +6505,21 @@ type AsCurriedResult<
|
|
|
5964
6505
|
): QueryPlan<any, any, any, any, any, any, any, any, any, "insert", MutationTargetLike, "ready"> =>
|
|
5965
6506
|
mutationRuntime.attachInsertSource(plan, source)
|
|
5966
6507
|
|
|
5967
|
-
const onConflict:
|
|
5968
|
-
|
|
5969
|
-
|
|
5970
|
-
UpdateValues extends MutationInputOf<Table.UpdateOf<Target>> | undefined = MutationInputOf<Table.UpdateOf<Target>> | undefined,
|
|
5971
|
-
Options extends ConflictActionInput<Target, Dialect, UpdateValues> = ConflictActionInput<Target, Dialect, UpdateValues>
|
|
5972
|
-
>(
|
|
5973
|
-
target: ConflictTargetInput<Target, Dialect, Columns>,
|
|
5974
|
-
options: Options = {} as Options
|
|
5975
|
-
) =>
|
|
5976
|
-
<PlanValue extends QueryPlan<any, any, any, any, any, any, any, any, any, any>>(
|
|
5977
|
-
plan: PlanValue & RequireInsertStatement<PlanValue>
|
|
5978
|
-
): QueryPlan<
|
|
5979
|
-
SelectionOfPlan<PlanValue>,
|
|
5980
|
-
Exclude<RequiredOfPlan<PlanValue> | MutationRequiredFromValues<Exclude<UpdateValues, undefined>> | RequiredFromInput<Extract<Options["where"], PredicateInput>>, AvailableNames<AvailableOfPlan<PlanValue>>>,
|
|
5981
|
-
AvailableOfPlan<PlanValue>,
|
|
5982
|
-
PlanDialectOf<PlanValue>,
|
|
5983
|
-
GroupedOfPlan<PlanValue>,
|
|
5984
|
-
ScopedNamesOfPlan<PlanValue>,
|
|
5985
|
-
Exclude<OutstandingOfPlan<PlanValue> | MutationRequiredFromValues<Exclude<UpdateValues, undefined>> | RequiredFromInput<Extract<Options["where"], PredicateInput>>, AvailableNames<AvailableOfPlan<PlanValue>>>,
|
|
5986
|
-
AssumptionsOfPlan<PlanValue>,
|
|
5987
|
-
CapabilitiesOfPlan<PlanValue>,
|
|
5988
|
-
StatementOfPlan<PlanValue>,
|
|
5989
|
-
MutationTargetOfPlan<PlanValue>,
|
|
5990
|
-
InsertSourceStateOfPlan<PlanValue>,
|
|
5991
|
-
FactsOfPlan<PlanValue>
|
|
5992
|
-
> => mutationRuntime.onConflict(target, options)(plan)
|
|
6508
|
+
const onConflict = ((target: unknown, options: unknown = {}) =>
|
|
6509
|
+
(plan: QueryPlan<any, any, any, any, any, any, any, any, any, any>) =>
|
|
6510
|
+
mutationRuntime.onConflict(target, options)(plan)) as OnConflictApi
|
|
5993
6511
|
|
|
5994
6512
|
const update: UpdateApi = ((
|
|
5995
6513
|
target: MutationTargetInput,
|
|
5996
6514
|
values: Record<string, unknown>
|
|
5997
6515
|
) => mutationRuntime.update(target, values)) as UpdateApi
|
|
5998
6516
|
|
|
5999
|
-
const upsert
|
|
6000
|
-
|
|
6001
|
-
|
|
6002
|
-
|
|
6003
|
-
|
|
6004
|
-
|
|
6005
|
-
target: Target,
|
|
6006
|
-
values: Values,
|
|
6007
|
-
conflictColumns: ValidateTargetColumns<Target, NormalizeDdlColumns<Columns>>,
|
|
6008
|
-
updateValues?: UpdateValues
|
|
6009
|
-
): QueryPlan<
|
|
6010
|
-
{},
|
|
6011
|
-
Exclude<MutationRequiredFromValues<Values> | MutationRequiredFromValues<UpdateValues>, SourceNameOf<Target>>,
|
|
6012
|
-
AddAvailable<{}, SourceNameOf<Target>>,
|
|
6013
|
-
TableDialectOf<Target>,
|
|
6014
|
-
never,
|
|
6015
|
-
SourceNameOf<Target>,
|
|
6016
|
-
Exclude<MutationRequiredFromValues<Values> | MutationRequiredFromValues<UpdateValues>, SourceNameOf<Target>>,
|
|
6017
|
-
TrueFormula,
|
|
6018
|
-
"write",
|
|
6019
|
-
"insert",
|
|
6020
|
-
Target,
|
|
6021
|
-
"ready",
|
|
6022
|
-
EmptyFacts
|
|
6023
|
-
> => mutationRuntime.upsert(target, values, conflictColumns as string | readonly string[], updateValues)
|
|
6517
|
+
const upsert = ((
|
|
6518
|
+
target: MutationTargetLike,
|
|
6519
|
+
values: Record<string, unknown>,
|
|
6520
|
+
conflictColumns: DdlColumnInput,
|
|
6521
|
+
updateValues?: Record<string, unknown>
|
|
6522
|
+
) => mutationRuntime.upsert(target, values, conflictColumns as string | readonly string[], updateValues)) as UpsertApi
|
|
6024
6523
|
|
|
6025
6524
|
const delete_: DeleteApi = ((
|
|
6026
6525
|
target: MutationTargetInput
|
|
@@ -6047,62 +6546,12 @@ type AsCurriedResult<
|
|
|
6047
6546
|
EmptyFacts
|
|
6048
6547
|
> => mutationRuntime.truncate(target, options)
|
|
6049
6548
|
|
|
6050
|
-
const merge
|
|
6051
|
-
|
|
6052
|
-
|
|
6053
|
-
|
|
6054
|
-
|
|
6055
|
-
|
|
6056
|
-
MatchedPredicate extends PredicateInput | undefined = undefined,
|
|
6057
|
-
NotMatchedPredicate extends PredicateInput | undefined = undefined
|
|
6058
|
-
>(
|
|
6059
|
-
target: Target,
|
|
6060
|
-
source: Source & (
|
|
6061
|
-
SourceRequiredOf<Source> extends never ? unknown : SourceRequirementError<Source>
|
|
6062
|
-
),
|
|
6063
|
-
on: On,
|
|
6064
|
-
options: MergeOptions<Target, MatchedValues, InsertValues, MatchedPredicate, NotMatchedPredicate> = {}
|
|
6065
|
-
): QueryPlan<
|
|
6066
|
-
{},
|
|
6067
|
-
Exclude<
|
|
6068
|
-
AddExpressionRequired<
|
|
6069
|
-
MergeRequiredFromPredicate<
|
|
6070
|
-
MatchedPredicate,
|
|
6071
|
-
AddAvailable<AddAvailable<{}, SourceNameOf<Target>>, SourceNameOf<Source>>
|
|
6072
|
-
> | MergeRequiredFromPredicate<
|
|
6073
|
-
NotMatchedPredicate,
|
|
6074
|
-
AddAvailable<AddAvailable<{}, SourceNameOf<Target>>, SourceNameOf<Source>>
|
|
6075
|
-
> | MutationRequiredFromValues<MatchedValues> | MutationRequiredFromValues<InsertValues>,
|
|
6076
|
-
AddAvailable<AddAvailable<{}, SourceNameOf<Target>>, SourceNameOf<Source>>,
|
|
6077
|
-
On
|
|
6078
|
-
>,
|
|
6079
|
-
SourceNameOf<Target> | SourceNameOf<Source>
|
|
6080
|
-
>,
|
|
6081
|
-
AddAvailable<AddAvailable<{}, SourceNameOf<Target>>, SourceNameOf<Source>>,
|
|
6082
|
-
TableDialectOf<Target> | SourceDialectOf<Source>,
|
|
6083
|
-
never,
|
|
6084
|
-
SourceNameOf<Target> | SourceNameOf<Source>,
|
|
6085
|
-
Exclude<
|
|
6086
|
-
AddExpressionRequired<
|
|
6087
|
-
MergeRequiredFromPredicate<
|
|
6088
|
-
MatchedPredicate,
|
|
6089
|
-
AddAvailable<AddAvailable<{}, SourceNameOf<Target>>, SourceNameOf<Source>>
|
|
6090
|
-
> | MergeRequiredFromPredicate<
|
|
6091
|
-
NotMatchedPredicate,
|
|
6092
|
-
AddAvailable<AddAvailable<{}, SourceNameOf<Target>>, SourceNameOf<Source>>
|
|
6093
|
-
> | MutationRequiredFromValues<MatchedValues> | MutationRequiredFromValues<InsertValues>,
|
|
6094
|
-
AddAvailable<AddAvailable<{}, SourceNameOf<Target>>, SourceNameOf<Source>>,
|
|
6095
|
-
On
|
|
6096
|
-
>,
|
|
6097
|
-
SourceNameOf<Target> | SourceNameOf<Source>
|
|
6098
|
-
>,
|
|
6099
|
-
TrueFormula,
|
|
6100
|
-
MergeCapabilities<"write", SourceCapabilitiesOf<Source>>,
|
|
6101
|
-
"merge",
|
|
6102
|
-
any,
|
|
6103
|
-
"ready",
|
|
6104
|
-
EmptyFacts
|
|
6105
|
-
> => mutationRuntime.merge(target, source, on, options)
|
|
6549
|
+
const merge = ((
|
|
6550
|
+
target: MutationTargetLike,
|
|
6551
|
+
source: SourceLike,
|
|
6552
|
+
on: PredicateInput,
|
|
6553
|
+
options: Record<string, unknown>
|
|
6554
|
+
) => mutationRuntime.merge(target, source, on, options)) as MergeApi
|
|
6106
6555
|
|
|
6107
6556
|
type TransactionApi = (options?: TransactionOptions) => QueryPlan<
|
|
6108
6557
|
{},
|
|
@@ -6183,7 +6632,7 @@ type AsCurriedResult<
|
|
|
6183
6632
|
>
|
|
6184
6633
|
|
|
6185
6634
|
type CreateTableApi = <Target extends SchemaTableLike>(
|
|
6186
|
-
target: Target,
|
|
6635
|
+
target: Target & TableDialectConstraint<Target, Dialect>,
|
|
6187
6636
|
options?: CreateTableOptions
|
|
6188
6637
|
) => QueryPlan<
|
|
6189
6638
|
{},
|
|
@@ -6199,7 +6648,7 @@ type AsCurriedResult<
|
|
|
6199
6648
|
>
|
|
6200
6649
|
|
|
6201
6650
|
type DropTableApi = <Target extends SchemaTableLike>(
|
|
6202
|
-
target: Target,
|
|
6651
|
+
target: Target & TableDialectConstraint<Target, Dialect>,
|
|
6203
6652
|
options?: DropTableOptions
|
|
6204
6653
|
) => QueryPlan<
|
|
6205
6654
|
{},
|
|
@@ -6215,8 +6664,8 @@ type AsCurriedResult<
|
|
|
6215
6664
|
>
|
|
6216
6665
|
|
|
6217
6666
|
type CreateIndexApi = <Target extends SchemaTableLike, const Columns extends DdlColumnInput>(
|
|
6218
|
-
target: Target,
|
|
6219
|
-
columns: Columns &
|
|
6667
|
+
target: Target & TableDialectConstraint<Target, Dialect>,
|
|
6668
|
+
columns: Columns & ValidateDdlColumnInput<Target, Columns>,
|
|
6220
6669
|
options?: CreateIndexOptions
|
|
6221
6670
|
) => QueryPlan<
|
|
6222
6671
|
{},
|
|
@@ -6232,8 +6681,8 @@ type AsCurriedResult<
|
|
|
6232
6681
|
>
|
|
6233
6682
|
|
|
6234
6683
|
type DropIndexApi = <Target extends SchemaTableLike, const Columns extends DdlColumnInput>(
|
|
6235
|
-
target: Target,
|
|
6236
|
-
columns: Columns &
|
|
6684
|
+
target: Target & TableDialectConstraint<Target, Dialect>,
|
|
6685
|
+
columns: Columns & ValidateDdlColumnInput<Target, Columns>,
|
|
6237
6686
|
options?: DropIndexOptions
|
|
6238
6687
|
) => QueryPlan<
|
|
6239
6688
|
{},
|