effect-qb 0.17.0 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -1
- package/dist/index.js +9376 -0
- package/dist/mysql.js +4092 -2671
- package/dist/postgres/metadata.js +2589 -1402
- package/dist/postgres.js +3953 -3583
- package/dist/sqlite.js +5527 -4088
- package/dist/standard.js +9330 -0
- package/package.json +9 -4
- package/src/casing.ts +71 -0
- package/src/index.ts +2 -0
- package/src/internal/casing.ts +89 -0
- package/src/internal/coercion/rules.ts +13 -1
- package/src/internal/column-state.d.ts +3 -3
- package/src/internal/column-state.ts +24 -18
- package/src/internal/column.ts +52 -15
- package/src/internal/datatypes/define.ts +7 -1
- package/src/internal/datatypes/enrich.ts +23 -0
- package/src/internal/datatypes/lookup.ts +81 -25
- package/src/internal/datatypes/matrix.ts +903 -0
- package/src/internal/datatypes/shape.ts +2 -0
- package/src/internal/derived-table.ts +4 -36
- package/src/{mysql/internal/sql-expression-renderer.ts → internal/dialect-renderers/mysql.ts} +552 -361
- package/src/{postgres/internal/sql-expression-renderer.ts → internal/dialect-renderers/postgres.ts} +657 -400
- package/src/{sqlite/internal/sql-expression-renderer.ts → internal/dialect-renderers/sqlite.ts} +505 -347
- package/src/internal/dialect.ts +36 -1
- package/src/internal/dsl-mutation-runtime.ts +12 -162
- package/src/internal/dsl-plan-runtime.ts +10 -138
- package/src/internal/dsl-query-runtime.ts +5 -79
- package/src/internal/dsl-transaction-ddl-runtime.ts +41 -65
- package/src/internal/executor.ts +66 -49
- package/src/internal/grouping-key.ts +87 -20
- package/src/internal/implication-runtime.ts +1 -1
- package/src/internal/json/path-access.ts +351 -0
- package/src/internal/predicate/runtime.ts +3 -0
- package/src/internal/query.d.ts +39 -12
- package/src/internal/query.ts +65 -26
- package/src/internal/renderer.ts +26 -14
- package/src/internal/runtime/driver-value-mapping.ts +3 -3
- package/src/internal/runtime/normalize.ts +12 -5
- package/src/internal/runtime/schema.ts +28 -38
- package/src/internal/runtime/value.ts +20 -23
- package/src/internal/scalar.d.ts +1 -1
- package/src/internal/scalar.ts +8 -2
- package/src/internal/schema-derivation.d.ts +12 -61
- package/src/internal/schema-derivation.ts +95 -43
- package/src/internal/schema-expression.ts +2 -2
- package/src/internal/sql-expression-renderer.ts +19 -0
- package/src/internal/standard-dsl.ts +6978 -0
- package/src/internal/table-options.ts +126 -66
- package/src/internal/table.ts +819 -237
- package/src/mysql/column-extension.ts +3 -0
- package/src/mysql/column.ts +14 -15
- package/src/mysql/datatypes/index.ts +4 -2
- package/src/mysql/datatypes/spec.ts +6 -176
- package/src/mysql/errors/normalize.ts +0 -1
- package/src/mysql/executor.ts +11 -11
- package/src/mysql/function/temporal.ts +1 -1
- package/src/mysql/internal/dialect.ts +9 -4
- package/src/mysql/internal/dsl.ts +334 -170
- package/src/mysql/internal/renderer.ts +6 -2
- package/src/mysql/json.ts +7 -2
- package/src/mysql/query-extension.ts +16 -0
- package/src/mysql/renderer.ts +37 -3
- package/src/mysql/type.ts +60 -0
- package/src/mysql.ts +7 -13
- package/src/postgres/check.ts +1 -0
- package/src/postgres/column-extension.ts +28 -0
- package/src/postgres/column.ts +13 -19
- package/src/postgres/datatypes/index.d.ts +2 -1
- package/src/postgres/datatypes/index.ts +4 -2
- package/src/postgres/datatypes/spec.ts +6 -260
- package/src/postgres/errors/normalize.ts +0 -1
- package/src/postgres/executor.ts +11 -11
- package/src/postgres/foreign-key.ts +24 -0
- package/src/postgres/function/core.ts +1 -3
- package/src/postgres/function/index.ts +1 -17
- package/src/postgres/function/temporal.ts +1 -1
- package/src/postgres/index.ts +1 -0
- package/src/postgres/internal/dialect.ts +9 -4
- package/src/postgres/internal/dsl.ts +328 -179
- package/src/postgres/internal/renderer.ts +6 -2
- package/src/postgres/internal/schema-ddl.ts +22 -10
- package/src/postgres/internal/schema-model.ts +238 -7
- package/src/postgres/json-extension.ts +7 -0
- package/src/postgres/json.ts +762 -173
- package/src/postgres/jsonb.ts +37 -0
- package/src/postgres/primary-key.ts +24 -0
- package/src/postgres/query-extension.ts +2 -0
- package/src/postgres/renderer.ts +37 -3
- package/src/postgres/schema-management.ts +13 -13
- package/src/postgres/schema.ts +106 -15
- package/src/postgres/table.ts +205 -538
- package/src/postgres/type.ts +93 -10
- package/src/postgres/unique.ts +32 -0
- package/src/postgres.ts +20 -16
- package/src/sqlite/column-extension.ts +3 -0
- package/src/sqlite/column.ts +14 -15
- package/src/sqlite/datatypes/index.ts +4 -2
- package/src/sqlite/datatypes/spec.ts +6 -94
- package/src/sqlite/errors/normalize.ts +0 -1
- package/src/sqlite/executor.ts +11 -11
- package/src/sqlite/function/temporal.ts +1 -1
- package/src/sqlite/internal/dialect.ts +9 -4
- package/src/sqlite/internal/dsl.ts +307 -159
- package/src/sqlite/internal/renderer.ts +6 -2
- package/src/sqlite/json.ts +8 -2
- package/src/sqlite/query-extension.ts +2 -0
- package/src/sqlite/renderer.ts +37 -3
- package/src/sqlite/type.ts +40 -0
- package/src/sqlite.ts +7 -13
- package/src/standard/cast.ts +113 -0
- package/src/standard/check.ts +17 -0
- package/src/standard/column.ts +163 -0
- package/src/standard/datatypes/index.ts +83 -0
- package/src/standard/datatypes/spec.ts +12 -0
- package/src/standard/dialect.ts +40 -0
- package/src/standard/foreign-key.ts +37 -0
- package/src/standard/function/aggregate.ts +2 -0
- package/src/standard/function/core.ts +2 -0
- package/src/standard/function/index.ts +18 -0
- package/src/standard/function/string.ts +2 -0
- package/src/standard/function/temporal.ts +78 -0
- package/src/standard/function/window.ts +2 -0
- package/src/standard/index.ts +17 -0
- package/src/standard/internal/renderer.ts +45 -0
- package/src/standard/json.ts +883 -0
- package/src/standard/primary-key.ts +17 -0
- package/src/standard/query.ts +152 -0
- package/src/standard/renderer.ts +49 -0
- package/src/standard/table.ts +151 -0
- package/src/standard/unique.ts +17 -0
- package/src/standard.ts +32 -0
- package/src/internal/aggregation-validation.ts +0 -57
- package/src/internal/table.d.ts +0 -173
- package/src/mysql/table.ts +0 -183
- package/src/postgres/cast.ts +0 -45
- package/src/sqlite/table.ts +0 -183
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { pipeArguments } from "effect/Pipeable"
|
|
1
|
+
import { pipeArguments, type Pipeable } from "effect/Pipeable"
|
|
2
2
|
import * as Schema from "effect/Schema"
|
|
3
3
|
|
|
4
4
|
import { mysqlDatatypes } from "../datatypes/index.js"
|
|
@@ -6,6 +6,12 @@ import { mysqlDatatypes } from "../datatypes/index.js"
|
|
|
6
6
|
import * as Expression from "../../internal/scalar.js"
|
|
7
7
|
import * as Plan from "../../internal/row-set.js"
|
|
8
8
|
import * as Table from "../../internal/table.js"
|
|
9
|
+
import type {
|
|
10
|
+
LiteralStringInput,
|
|
11
|
+
NonEmptyStringInput,
|
|
12
|
+
SafeSqlIdentifierInput,
|
|
13
|
+
SafeSqlIdentifierPathInput
|
|
14
|
+
} from "../../internal/table-options.js"
|
|
9
15
|
import type { CastTargetError, OperandCompatibilityError } from "../../internal/coercion/errors.js"
|
|
10
16
|
import type { RuntimeOfDbType } from "../../internal/coercion/analysis.js"
|
|
11
17
|
import type { CanCastDbType, CanCompareDbTypes, CanContainDbTypes, CanTextuallyCoerceDbType } from "../../internal/coercion/rules.js"
|
|
@@ -71,6 +77,7 @@ import {
|
|
|
71
77
|
type ScopedNamesOfPlan,
|
|
72
78
|
type SelectionOfPlan,
|
|
73
79
|
type SelectionShape,
|
|
80
|
+
type SelectionProjectionAliasCollisionConstraint,
|
|
74
81
|
type SetCompatiblePlan,
|
|
75
82
|
type SetCompatibleRightPlan,
|
|
76
83
|
type SchemaTableLike,
|
|
@@ -80,10 +87,8 @@ import {
|
|
|
80
87
|
type TableDialectOf,
|
|
81
88
|
type StatementOfPlan,
|
|
82
89
|
type MutationInputOf,
|
|
83
|
-
type MutationTargetLike,
|
|
84
90
|
type MutationTargetOfPlan,
|
|
85
91
|
type MergeCapabilities,
|
|
86
|
-
type MutationTargetInput,
|
|
87
92
|
type MutationValuesInput,
|
|
88
93
|
type SourceDialectOf,
|
|
89
94
|
type SourceLike,
|
|
@@ -100,7 +105,6 @@ import {
|
|
|
100
105
|
type TableLike,
|
|
101
106
|
type UpdateInputOfTarget,
|
|
102
107
|
type MutationTargetNamesOf,
|
|
103
|
-
type MutationTargetTuple,
|
|
104
108
|
type TupleDependencies,
|
|
105
109
|
type TupleDialect,
|
|
106
110
|
type ResultRow
|
|
@@ -138,6 +142,10 @@ import * as ProjectionAlias from "../../internal/projection-alias.js"
|
|
|
138
142
|
import * as QueryAst from "../../internal/query-ast.js"
|
|
139
143
|
import { normalizeColumnList } from "../../internal/table-options.js"
|
|
140
144
|
|
|
145
|
+
type MutationTargetLike = Table.AnyTable<Dialect | "standard">
|
|
146
|
+
type MutationTargetTuple = readonly [MutationTargetLike, MutationTargetLike, ...MutationTargetLike[]]
|
|
147
|
+
type MutationTargetInput = MutationTargetLike | MutationTargetTuple
|
|
148
|
+
|
|
141
149
|
/**
|
|
142
150
|
* Dialect-specific DB type profile used to specialize the shared query
|
|
143
151
|
* operator surface.
|
|
@@ -710,7 +718,7 @@ type NumericExpressionDialectInput<
|
|
|
710
718
|
BoolDb extends Expression.DbType.Any,
|
|
711
719
|
TimestampDb extends Expression.DbType.Any,
|
|
712
720
|
NullDb extends Expression.DbType.Any
|
|
713
|
-
> = Exclude<DialectOfDialectNumericInput<Value, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>, Dialect> extends never
|
|
721
|
+
> = Exclude<DialectOfDialectNumericInput<Value, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>, Dialect | "standard"> extends never
|
|
714
722
|
? unknown
|
|
715
723
|
: {
|
|
716
724
|
readonly __effect_qb_error__: "effect-qb: numeric expressions cannot mix dialects"
|
|
@@ -803,6 +811,35 @@ type DialectExpressionArray<
|
|
|
803
811
|
? Tuple
|
|
804
812
|
: never
|
|
805
813
|
|
|
814
|
+
type ExtractFunctionFieldInput<
|
|
815
|
+
Value extends ExpressionInput
|
|
816
|
+
> = Value extends string
|
|
817
|
+
? SafeSqlIdentifierInput<Value>
|
|
818
|
+
: Value extends { readonly [ExpressionAst.TypeId]: ExpressionAst.LiteralNode<infer Field extends string> }
|
|
819
|
+
? SafeSqlIdentifierInput<Field> extends never ? never : Value
|
|
820
|
+
: never
|
|
821
|
+
|
|
822
|
+
type GenericFunctionNameInput<Name extends string> =
|
|
823
|
+
Name extends "current_date" | "extract" ? never : SafeSqlIdentifierPathInput<Name>
|
|
824
|
+
|
|
825
|
+
type FunctionCallApi = {
|
|
826
|
+
(name: "current_date"): Expression.Any
|
|
827
|
+
<Field extends string, Source extends ExpressionInput>(
|
|
828
|
+
name: "extract",
|
|
829
|
+
field: SafeSqlIdentifierInput<Field>,
|
|
830
|
+
source: Source
|
|
831
|
+
): Expression.Any
|
|
832
|
+
<Field extends Expression.Any, Source extends ExpressionInput>(
|
|
833
|
+
name: "extract",
|
|
834
|
+
field: Field & ExtractFunctionFieldInput<Field>,
|
|
835
|
+
source: Source
|
|
836
|
+
): Expression.Any
|
|
837
|
+
<Name extends string, Args extends readonly ExpressionInput[]>(
|
|
838
|
+
name: GenericFunctionNameInput<Name>,
|
|
839
|
+
...args: Args
|
|
840
|
+
): Expression.Any
|
|
841
|
+
}
|
|
842
|
+
|
|
806
843
|
/** Normalized expression tuple for generic string operator inputs. */
|
|
807
844
|
type DialectStringExpressionTuple<
|
|
808
845
|
Values extends readonly ExpressionInput[],
|
|
@@ -1069,6 +1106,9 @@ type JsonPathInput = JsonPath.Path<any> | JsonPath.CanonicalSegment
|
|
|
1069
1106
|
|
|
1070
1107
|
type JsonQueryInput = JsonPath.Path<any> | StringExpressionInput
|
|
1071
1108
|
|
|
1109
|
+
type JsonQueryValue<Query extends JsonQueryInput> =
|
|
1110
|
+
Query extends string ? LiteralStringInput<Query> : Query
|
|
1111
|
+
|
|
1072
1112
|
type JsonPathOutputOf<
|
|
1073
1113
|
Root,
|
|
1074
1114
|
Target extends JsonPathInput,
|
|
@@ -1526,18 +1566,21 @@ const profile: QueryDialectProfile<Dialect, TextDb, NumericDb, BoolDb, Timestamp
|
|
|
1526
1566
|
type: mysqlDatatypes
|
|
1527
1567
|
}
|
|
1528
1568
|
const ValuesInputProto = {
|
|
1529
|
-
pipe(this:
|
|
1569
|
+
pipe(this: Pipeable) {
|
|
1530
1570
|
return pipeArguments(this, arguments)
|
|
1531
1571
|
}
|
|
1532
1572
|
}
|
|
1533
1573
|
|
|
1534
1574
|
const literalSchemaOf = <Value extends LiteralValue>(
|
|
1535
1575
|
value: Value
|
|
1536
|
-
): Schema.
|
|
1576
|
+
): Schema.Top | undefined => {
|
|
1537
1577
|
if (value === null || value instanceof Date) {
|
|
1538
1578
|
return undefined
|
|
1539
1579
|
}
|
|
1540
|
-
|
|
1580
|
+
if (typeof value === "number" && !Number.isFinite(value)) {
|
|
1581
|
+
return undefined
|
|
1582
|
+
}
|
|
1583
|
+
return Schema.Literal(value) as unknown as Schema.Top
|
|
1541
1584
|
}
|
|
1542
1585
|
|
|
1543
1586
|
const literal = <const Value extends LiteralValue>(
|
|
@@ -1624,7 +1667,7 @@ const profile: QueryDialectProfile<Dialect, TextDb, NumericDb, BoolDb, Timestamp
|
|
|
1624
1667
|
value: Expression.Any,
|
|
1625
1668
|
target: Expression.Any
|
|
1626
1669
|
): Expression.Any => {
|
|
1627
|
-
const ast = (value as
|
|
1670
|
+
const ast = (value as Expression.Any & { readonly [ExpressionAst.TypeId]: ExpressionAst.Any })[ExpressionAst.TypeId]
|
|
1628
1671
|
if (ast.kind !== "literal") {
|
|
1629
1672
|
return value
|
|
1630
1673
|
}
|
|
@@ -1645,8 +1688,8 @@ const profile: QueryDialectProfile<Dialect, TextDb, NumericDb, BoolDb, Timestamp
|
|
|
1645
1688
|
left: Expression.Any,
|
|
1646
1689
|
right: Expression.Any
|
|
1647
1690
|
): readonly [Expression.Any, Expression.Any] => {
|
|
1648
|
-
const leftAst = (left as
|
|
1649
|
-
const rightAst = (right as
|
|
1691
|
+
const leftAst = (left as Expression.Any & { readonly [ExpressionAst.TypeId]: ExpressionAst.Any })[ExpressionAst.TypeId]
|
|
1692
|
+
const rightAst = (right as Expression.Any & { readonly [ExpressionAst.TypeId]: ExpressionAst.Any })[ExpressionAst.TypeId]
|
|
1650
1693
|
if (leftAst.kind === "literal" && rightAst.kind !== "literal") {
|
|
1651
1694
|
return [retargetLiteralExpression(left, right), right]
|
|
1652
1695
|
}
|
|
@@ -1679,7 +1722,7 @@ const profile: QueryDialectProfile<Dialect, TextDb, NumericDb, BoolDb, Timestamp
|
|
|
1679
1722
|
): readonly Expression.Any[] => {
|
|
1680
1723
|
const flattened: Array<Expression.Any> = []
|
|
1681
1724
|
for (const value of values) {
|
|
1682
|
-
const ast = (value as
|
|
1725
|
+
const ast = (value as Expression.Any & { readonly [ExpressionAst.TypeId]: ExpressionAst.Any })[ExpressionAst.TypeId]
|
|
1683
1726
|
if (ast.kind === kind) {
|
|
1684
1727
|
flattened.push(...ast.values)
|
|
1685
1728
|
} else {
|
|
@@ -1725,7 +1768,33 @@ const profile: QueryDialectProfile<Dialect, TextDb, NumericDb, BoolDb, Timestamp
|
|
|
1725
1768
|
if (operations.every((operation) => typeof operation === "function")) {
|
|
1726
1769
|
return pipeArguments(this, arguments)
|
|
1727
1770
|
}
|
|
1728
|
-
|
|
1771
|
+
const valuesForMixedPipe = (value: unknown): readonly Expression.Any[] => {
|
|
1772
|
+
if (typeof value !== "object" || value === null || !(Expression.TypeId in value)) {
|
|
1773
|
+
return []
|
|
1774
|
+
}
|
|
1775
|
+
const expression = value as Expression.Any & {
|
|
1776
|
+
readonly [ExpressionAst.TypeId]: ExpressionAst.Any
|
|
1777
|
+
}
|
|
1778
|
+
const ast = expression[ExpressionAst.TypeId]
|
|
1779
|
+
if (ast.kind === kind) {
|
|
1780
|
+
return (ast as {
|
|
1781
|
+
readonly values: readonly Expression.Any[]
|
|
1782
|
+
}).values
|
|
1783
|
+
}
|
|
1784
|
+
return [expression]
|
|
1785
|
+
}
|
|
1786
|
+
let current: unknown = this
|
|
1787
|
+
for (const operation of operations) {
|
|
1788
|
+
if (typeof operation === "function") {
|
|
1789
|
+
current = (operation as (value: unknown) => unknown)(current)
|
|
1790
|
+
continue
|
|
1791
|
+
}
|
|
1792
|
+
current = makeVariadicBooleanExpression(
|
|
1793
|
+
kind,
|
|
1794
|
+
[...valuesForMixedPipe(current), toDialectExpression(operation as ExpressionInput)] as const
|
|
1795
|
+
)
|
|
1796
|
+
}
|
|
1797
|
+
return current
|
|
1729
1798
|
}
|
|
1730
1799
|
})
|
|
1731
1800
|
|
|
@@ -1746,9 +1815,6 @@ const profile: QueryDialectProfile<Dialect, TextDb, NumericDb, BoolDb, Timestamp
|
|
|
1746
1815
|
const partitionBy = [...(spec?.partitionBy ?? [])] as unknown as PartitionBy
|
|
1747
1816
|
const orderBy = (spec?.orderBy ?? []).map((term) => {
|
|
1748
1817
|
const direction = term.direction ?? "asc"
|
|
1749
|
-
if (direction !== "asc" && direction !== "desc") {
|
|
1750
|
-
throw new Error("window order direction must be asc or desc")
|
|
1751
|
-
}
|
|
1752
1818
|
return {
|
|
1753
1819
|
value: term.value,
|
|
1754
1820
|
direction
|
|
@@ -1889,7 +1955,8 @@ type BinaryPredicateExpression<
|
|
|
1889
1955
|
>(
|
|
1890
1956
|
...args: ComparableArgs<Left, Right, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb, "eq">
|
|
1891
1957
|
): BinaryPredicateExpression<Left, Right, "eq"> => {
|
|
1892
|
-
const
|
|
1958
|
+
const left = args[0] as Left
|
|
1959
|
+
const right = args[1] as Right
|
|
1893
1960
|
return buildBinaryPredicate(left as ExpressionInput, right as ExpressionInput, "eq")
|
|
1894
1961
|
}
|
|
1895
1962
|
|
|
@@ -1899,7 +1966,8 @@ type BinaryPredicateExpression<
|
|
|
1899
1966
|
>(
|
|
1900
1967
|
...args: ComparableArgs<Left, Right, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb, "neq">
|
|
1901
1968
|
): BinaryPredicateExpression<Left, Right, "neq"> => {
|
|
1902
|
-
const
|
|
1969
|
+
const left = args[0] as Left
|
|
1970
|
+
const right = args[1] as Right
|
|
1903
1971
|
return buildBinaryPredicate(left as ExpressionInput, right as ExpressionInput, "neq")
|
|
1904
1972
|
}
|
|
1905
1973
|
|
|
@@ -1909,7 +1977,8 @@ type BinaryPredicateExpression<
|
|
|
1909
1977
|
>(
|
|
1910
1978
|
...args: ComparableArgs<Left, Right, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb, "lt">
|
|
1911
1979
|
): BinaryPredicateExpression<Left, Right, "lt"> => {
|
|
1912
|
-
const
|
|
1980
|
+
const left = args[0] as Left
|
|
1981
|
+
const right = args[1] as Right
|
|
1913
1982
|
return buildBinaryPredicate(left as ExpressionInput, right as ExpressionInput, "lt")
|
|
1914
1983
|
}
|
|
1915
1984
|
|
|
@@ -1919,7 +1988,8 @@ type BinaryPredicateExpression<
|
|
|
1919
1988
|
>(
|
|
1920
1989
|
...args: ComparableArgs<Left, Right, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb, "lte">
|
|
1921
1990
|
): BinaryPredicateExpression<Left, Right, "lte"> => {
|
|
1922
|
-
const
|
|
1991
|
+
const left = args[0] as Left
|
|
1992
|
+
const right = args[1] as Right
|
|
1923
1993
|
return buildBinaryPredicate(left as ExpressionInput, right as ExpressionInput, "lte")
|
|
1924
1994
|
}
|
|
1925
1995
|
|
|
@@ -1929,7 +1999,8 @@ type BinaryPredicateExpression<
|
|
|
1929
1999
|
>(
|
|
1930
2000
|
...args: ComparableArgs<Left, Right, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb, "gt">
|
|
1931
2001
|
): BinaryPredicateExpression<Left, Right, "gt"> => {
|
|
1932
|
-
const
|
|
2002
|
+
const left = args[0] as Left
|
|
2003
|
+
const right = args[1] as Right
|
|
1933
2004
|
return buildBinaryPredicate(left as ExpressionInput, right as ExpressionInput, "gt")
|
|
1934
2005
|
}
|
|
1935
2006
|
|
|
@@ -1939,7 +2010,8 @@ type BinaryPredicateExpression<
|
|
|
1939
2010
|
>(
|
|
1940
2011
|
...args: ComparableArgs<Left, Right, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb, "gte">
|
|
1941
2012
|
): BinaryPredicateExpression<Left, Right, "gte"> => {
|
|
1942
|
-
const
|
|
2013
|
+
const left = args[0] as Left
|
|
2014
|
+
const right = args[1] as Right
|
|
1943
2015
|
return buildBinaryPredicate(left as ExpressionInput, right as ExpressionInput, "gte")
|
|
1944
2016
|
}
|
|
1945
2017
|
|
|
@@ -1949,7 +2021,8 @@ type BinaryPredicateExpression<
|
|
|
1949
2021
|
>(
|
|
1950
2022
|
...args: TextArgs<Left, Right, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb, "like">
|
|
1951
2023
|
): BinaryPredicateExpression<Left, Right, "like"> => {
|
|
1952
|
-
const
|
|
2024
|
+
const left = args[0] as Left
|
|
2025
|
+
const right = args[1] as Right
|
|
1953
2026
|
return buildBinaryPredicate(left as ExpressionInput, right as ExpressionInput, "like")
|
|
1954
2027
|
}
|
|
1955
2028
|
|
|
@@ -1959,7 +2032,8 @@ type BinaryPredicateExpression<
|
|
|
1959
2032
|
>(
|
|
1960
2033
|
...args: TextArgs<Left, Right, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb, "ilike">
|
|
1961
2034
|
): BinaryPredicateExpression<Left, Right, "ilike"> => {
|
|
1962
|
-
const
|
|
2035
|
+
const left = args[0] as Left
|
|
2036
|
+
const right = args[1] as Right
|
|
1963
2037
|
return buildBinaryPredicate(left as ExpressionInput, right as ExpressionInput, "ilike")
|
|
1964
2038
|
}
|
|
1965
2039
|
|
|
@@ -1969,7 +2043,8 @@ type BinaryPredicateExpression<
|
|
|
1969
2043
|
>(
|
|
1970
2044
|
...args: TextArgs<Left, Right, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb, "regexMatch">
|
|
1971
2045
|
): BinaryPredicateExpression<Left, Right, "regexMatch"> => {
|
|
1972
|
-
const
|
|
2046
|
+
const left = args[0] as Left
|
|
2047
|
+
const right = args[1] as Right
|
|
1973
2048
|
return buildBinaryPredicate(left as ExpressionInput, right as ExpressionInput, "regexMatch")
|
|
1974
2049
|
}
|
|
1975
2050
|
|
|
@@ -1979,7 +2054,8 @@ type BinaryPredicateExpression<
|
|
|
1979
2054
|
>(
|
|
1980
2055
|
...args: TextArgs<Left, Right, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb, "regexIMatch">
|
|
1981
2056
|
): BinaryPredicateExpression<Left, Right, "regexIMatch"> => {
|
|
1982
|
-
const
|
|
2057
|
+
const left = args[0] as Left
|
|
2058
|
+
const right = args[1] as Right
|
|
1983
2059
|
return buildBinaryPredicate(left as ExpressionInput, right as ExpressionInput, "regexIMatch")
|
|
1984
2060
|
}
|
|
1985
2061
|
|
|
@@ -1989,7 +2065,8 @@ type BinaryPredicateExpression<
|
|
|
1989
2065
|
>(
|
|
1990
2066
|
...args: TextArgs<Left, Right, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb, "regexNotMatch">
|
|
1991
2067
|
): BinaryPredicateExpression<Left, Right, "regexNotMatch"> => {
|
|
1992
|
-
const
|
|
2068
|
+
const left = args[0] as Left
|
|
2069
|
+
const right = args[1] as Right
|
|
1993
2070
|
return buildBinaryPredicate(left as ExpressionInput, right as ExpressionInput, "regexNotMatch")
|
|
1994
2071
|
}
|
|
1995
2072
|
|
|
@@ -1999,7 +2076,8 @@ type BinaryPredicateExpression<
|
|
|
1999
2076
|
>(
|
|
2000
2077
|
...args: TextArgs<Left, Right, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb, "regexNotIMatch">
|
|
2001
2078
|
): BinaryPredicateExpression<Left, Right, "regexNotIMatch"> => {
|
|
2002
|
-
const
|
|
2079
|
+
const left = args[0] as Left
|
|
2080
|
+
const right = args[1] as Right
|
|
2003
2081
|
return buildBinaryPredicate(left as ExpressionInput, right as ExpressionInput, "regexNotIMatch")
|
|
2004
2082
|
}
|
|
2005
2083
|
|
|
@@ -2009,7 +2087,8 @@ type BinaryPredicateExpression<
|
|
|
2009
2087
|
>(
|
|
2010
2088
|
...args: ComparableArgs<Left, Right, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb, "isDistinctFrom">
|
|
2011
2089
|
): BinaryPredicateExpression<Left, Right, "isDistinctFrom", "never"> => {
|
|
2012
|
-
const
|
|
2090
|
+
const left = args[0] as Left
|
|
2091
|
+
const right = args[1] as Right
|
|
2013
2092
|
return buildBinaryPredicate(left as ExpressionInput, right as ExpressionInput, "isDistinctFrom", "never")
|
|
2014
2093
|
}
|
|
2015
2094
|
|
|
@@ -2019,7 +2098,8 @@ type BinaryPredicateExpression<
|
|
|
2019
2098
|
>(
|
|
2020
2099
|
...args: ComparableArgs<Left, Right, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb, "isNotDistinctFrom">
|
|
2021
2100
|
): BinaryPredicateExpression<Left, Right, "isNotDistinctFrom", "never"> => {
|
|
2022
|
-
const
|
|
2101
|
+
const left = args[0] as Left
|
|
2102
|
+
const right = args[1] as Right
|
|
2023
2103
|
return buildBinaryPredicate(left as ExpressionInput, right as ExpressionInput, "isNotDistinctFrom", "never")
|
|
2024
2104
|
}
|
|
2025
2105
|
|
|
@@ -2170,62 +2250,62 @@ type BinaryPredicateExpression<
|
|
|
2170
2250
|
})
|
|
2171
2251
|
|
|
2172
2252
|
const range = <Kind extends string, Subtype extends Expression.DbType.Any>(
|
|
2173
|
-
kind: Kind
|
|
2253
|
+
kind: NonEmptyStringInput<Kind>,
|
|
2174
2254
|
subtype: Subtype
|
|
2175
2255
|
): Expression.DbType.Range<Dialect, Subtype, Kind> => ({
|
|
2176
2256
|
dialect: profile.dialect,
|
|
2177
|
-
kind,
|
|
2257
|
+
kind: kind as Kind,
|
|
2178
2258
|
subtype
|
|
2179
2259
|
})
|
|
2180
2260
|
|
|
2181
2261
|
const multirange = <Kind extends string, Subtype extends Expression.DbType.Any>(
|
|
2182
|
-
kind: Kind
|
|
2262
|
+
kind: NonEmptyStringInput<Kind>,
|
|
2183
2263
|
subtype: Subtype
|
|
2184
2264
|
): Expression.DbType.Multirange<Dialect, Subtype, Kind> => ({
|
|
2185
2265
|
dialect: profile.dialect,
|
|
2186
|
-
kind,
|
|
2266
|
+
kind: kind as Kind,
|
|
2187
2267
|
subtype
|
|
2188
2268
|
})
|
|
2189
2269
|
|
|
2190
2270
|
const record = <Kind extends string, Fields extends Record<string, Expression.DbType.Any>>(
|
|
2191
|
-
kind: Kind
|
|
2271
|
+
kind: NonEmptyStringInput<Kind>,
|
|
2192
2272
|
fields: Fields
|
|
2193
2273
|
): Expression.DbType.Composite<Dialect, Fields, Kind> => ({
|
|
2194
2274
|
dialect: profile.dialect,
|
|
2195
|
-
kind,
|
|
2275
|
+
kind: kind as Kind,
|
|
2196
2276
|
fields
|
|
2197
2277
|
})
|
|
2198
2278
|
|
|
2199
2279
|
const domain = <Kind extends string, Base extends Expression.DbType.Any>(
|
|
2200
|
-
kind: Kind
|
|
2280
|
+
kind: NonEmptyStringInput<Kind>,
|
|
2201
2281
|
base: Base
|
|
2202
2282
|
): Expression.DbType.Domain<Dialect, Base, Kind> => ({
|
|
2203
2283
|
dialect: profile.dialect,
|
|
2204
|
-
kind,
|
|
2284
|
+
kind: kind as Kind,
|
|
2205
2285
|
base
|
|
2206
2286
|
})
|
|
2207
2287
|
|
|
2208
2288
|
const enum_ = <Kind extends string>(
|
|
2209
|
-
kind: Kind
|
|
2289
|
+
kind: NonEmptyStringInput<Kind>
|
|
2210
2290
|
): Expression.DbType.Enum<Dialect, Kind> => ({
|
|
2211
2291
|
dialect: profile.dialect,
|
|
2212
|
-
kind,
|
|
2292
|
+
kind: kind as Kind,
|
|
2213
2293
|
variant: "enum"
|
|
2214
2294
|
})
|
|
2215
2295
|
|
|
2216
2296
|
const set = <Kind extends string>(
|
|
2217
|
-
kind: Kind
|
|
2297
|
+
kind: NonEmptyStringInput<Kind>
|
|
2218
2298
|
): Expression.DbType.Set<Dialect, Kind> => ({
|
|
2219
2299
|
dialect: profile.dialect,
|
|
2220
|
-
kind,
|
|
2300
|
+
kind: kind as Kind,
|
|
2221
2301
|
variant: "set"
|
|
2222
2302
|
})
|
|
2223
2303
|
|
|
2224
2304
|
const custom = <Kind extends string>(
|
|
2225
|
-
kind: Kind
|
|
2305
|
+
kind: NonEmptyStringInput<Kind>
|
|
2226
2306
|
): Expression.DbType.Base<Dialect, Kind> => ({
|
|
2227
2307
|
dialect: profile.dialect,
|
|
2228
|
-
kind
|
|
2308
|
+
kind: kind as Kind
|
|
2229
2309
|
})
|
|
2230
2310
|
|
|
2231
2311
|
const driverValueMapping = <Db extends Expression.DbType.Any>(
|
|
@@ -3033,9 +3113,12 @@ type BinaryPredicateExpression<
|
|
|
3033
3113
|
}
|
|
3034
3114
|
)
|
|
3035
3115
|
|
|
3036
|
-
const jsonPathExists = <
|
|
3116
|
+
const jsonPathExists = <
|
|
3117
|
+
Base extends JsonExpressionLike<any>,
|
|
3118
|
+
Query extends JsonQueryInput
|
|
3119
|
+
>(
|
|
3037
3120
|
base: Base,
|
|
3038
|
-
query:
|
|
3121
|
+
query: JsonQueryValue<Query>
|
|
3039
3122
|
) => {
|
|
3040
3123
|
if (isJsonPathValue(query)) {
|
|
3041
3124
|
return buildJsonNodeExpression(
|
|
@@ -3083,9 +3166,12 @@ type BinaryPredicateExpression<
|
|
|
3083
3166
|
}
|
|
3084
3167
|
)
|
|
3085
3168
|
|
|
3086
|
-
const jsonPathMatch = <
|
|
3169
|
+
const jsonPathMatch = <
|
|
3170
|
+
Base extends JsonExpressionLike<any>,
|
|
3171
|
+
Query extends JsonQueryInput
|
|
3172
|
+
>(
|
|
3087
3173
|
base: Base,
|
|
3088
|
-
query:
|
|
3174
|
+
query: JsonQueryValue<Query>
|
|
3089
3175
|
) => {
|
|
3090
3176
|
if (isJsonPathValue(query)) {
|
|
3091
3177
|
return buildJsonNodeExpression(
|
|
@@ -3312,7 +3398,8 @@ type BinaryPredicateExpression<
|
|
|
3312
3398
|
>(
|
|
3313
3399
|
...args: ContainmentArgs<Left, Right, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb, "contains">
|
|
3314
3400
|
): BinaryPredicateExpression<Left, Right, "contains"> => {
|
|
3315
|
-
const
|
|
3401
|
+
const left = args[0] as Left
|
|
3402
|
+
const right = args[1] as Right
|
|
3316
3403
|
return buildBinaryPredicate(left as ExpressionInput, right as ExpressionInput, "contains")
|
|
3317
3404
|
}
|
|
3318
3405
|
|
|
@@ -3322,7 +3409,8 @@ type BinaryPredicateExpression<
|
|
|
3322
3409
|
>(
|
|
3323
3410
|
...args: ContainmentArgs<Left, Right, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb, "containedBy">
|
|
3324
3411
|
): BinaryPredicateExpression<Left, Right, "containedBy"> => {
|
|
3325
|
-
const
|
|
3412
|
+
const left = args[0] as Left
|
|
3413
|
+
const right = args[1] as Right
|
|
3326
3414
|
return buildBinaryPredicate(left as ExpressionInput, right as ExpressionInput, "containedBy")
|
|
3327
3415
|
}
|
|
3328
3416
|
|
|
@@ -3332,7 +3420,8 @@ type BinaryPredicateExpression<
|
|
|
3332
3420
|
>(
|
|
3333
3421
|
...args: ContainmentArgs<Left, Right, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb, "overlaps">
|
|
3334
3422
|
): BinaryPredicateExpression<Left, Right, "overlaps"> => {
|
|
3335
|
-
const
|
|
3423
|
+
const left = args[0] as Left
|
|
3424
|
+
const right = args[1] as Right
|
|
3336
3425
|
return buildBinaryPredicate(left as ExpressionInput, right as ExpressionInput, "overlaps")
|
|
3337
3426
|
}
|
|
3338
3427
|
|
|
@@ -3759,12 +3848,9 @@ type BinaryPredicateExpression<
|
|
|
3759
3848
|
>
|
|
3760
3849
|
}
|
|
3761
3850
|
|
|
3762
|
-
const call =
|
|
3763
|
-
|
|
3764
|
-
|
|
3765
|
-
>(
|
|
3766
|
-
name: Name,
|
|
3767
|
-
...args: Args
|
|
3851
|
+
const call: FunctionCallApi = (
|
|
3852
|
+
name: string,
|
|
3853
|
+
...args: readonly ExpressionInput[]
|
|
3768
3854
|
): Expression.Any => {
|
|
3769
3855
|
const expressions = args.map((value) => toDialectExpression(value)) as readonly Expression.Any[]
|
|
3770
3856
|
return makeExpression({
|
|
@@ -4000,9 +4086,6 @@ type BinaryPredicateExpression<
|
|
|
4000
4086
|
ExpressionAst.ExcludedNode<AstOf<Value> extends ExpressionAst.ColumnNode<any, infer ColumnName extends string> ? ColumnName : string>
|
|
4001
4087
|
> => {
|
|
4002
4088
|
const ast = ((value as unknown) as Expression.Any & { readonly [ExpressionAst.TypeId]: ExpressionAst.Any })[ExpressionAst.TypeId]
|
|
4003
|
-
if (ast.kind !== "column") {
|
|
4004
|
-
throw new Error("excluded(...) only accepts bound table columns")
|
|
4005
|
-
}
|
|
4006
4089
|
return makeExpression({
|
|
4007
4090
|
runtime: undefined as Expression.RuntimeOf<Value>,
|
|
4008
4091
|
dbType: value[Expression.TypeId].dbType as Expression.DbTypeOf<Value>,
|
|
@@ -4015,7 +4098,7 @@ type BinaryPredicateExpression<
|
|
|
4015
4098
|
dependencies: {}
|
|
4016
4099
|
}, {
|
|
4017
4100
|
kind: "excluded",
|
|
4018
|
-
columnName: ast.columnName
|
|
4101
|
+
columnName: (ast as ExpressionAst.ColumnNode<any, string>).columnName
|
|
4019
4102
|
}) as unknown as AstBackedExpression<
|
|
4020
4103
|
Expression.RuntimeOf<Value>,
|
|
4021
4104
|
Expression.DbTypeOf<Value>,
|
|
@@ -4048,7 +4131,7 @@ type BinaryPredicateExpression<
|
|
|
4048
4131
|
}
|
|
4049
4132
|
if (value !== null && typeof value === "object" && Expression.TypeId in value) {
|
|
4050
4133
|
const expression = value as unknown as Expression.Any
|
|
4051
|
-
const ast = (expression as
|
|
4134
|
+
const ast = (expression as Expression.Any & { readonly [ExpressionAst.TypeId]: ExpressionAst.Any })[ExpressionAst.TypeId]
|
|
4052
4135
|
if (ast.kind === "literal") {
|
|
4053
4136
|
const normalizedValue = normalizeMutationValue(ast.value)
|
|
4054
4137
|
return makeExpression({
|
|
@@ -4117,8 +4200,8 @@ type BinaryPredicateExpression<
|
|
|
4117
4200
|
: ">="
|
|
4118
4201
|
|
|
4119
4202
|
const targetSourceDetails = (table: MutationTargetLike | SchemaTableLike) => {
|
|
4120
|
-
const sourceName = (table as
|
|
4121
|
-
const sourceBaseName = (table as
|
|
4203
|
+
const sourceName = (table as TableLike)[Table.TypeId].name
|
|
4204
|
+
const sourceBaseName = (table as TableLike)[Table.TypeId].baseName
|
|
4122
4205
|
return {
|
|
4123
4206
|
sourceName,
|
|
4124
4207
|
sourceBaseName
|
|
@@ -4208,12 +4291,7 @@ type BinaryPredicateExpression<
|
|
|
4208
4291
|
|
|
4209
4292
|
const normalizeUnnestColumns = (columns: UnnestColumnsInput): Record<string, readonly Expression.Any[]> =>
|
|
4210
4293
|
Object.fromEntries(
|
|
4211
|
-
Object.entries(columns).map(([key, values]) =>
|
|
4212
|
-
if (!Array.isArray(values)) {
|
|
4213
|
-
throw new Error("unnest(...) expects every value to be an array")
|
|
4214
|
-
}
|
|
4215
|
-
return [key, values.map((value) => toDialectExpression(value))]
|
|
4216
|
-
})
|
|
4294
|
+
Object.entries(columns).map(([key, values]) => [key, values.map((value) => toDialectExpression(value))])
|
|
4217
4295
|
) as Record<string, readonly Expression.Any[]>
|
|
4218
4296
|
|
|
4219
4297
|
const normalizeMutationTargets = (
|
|
@@ -4259,13 +4337,7 @@ type BinaryPredicateExpression<
|
|
|
4259
4337
|
const getMutationColumn = (
|
|
4260
4338
|
columns: Record<string, unknown>,
|
|
4261
4339
|
columnName: string
|
|
4262
|
-
): Expression.Any =>
|
|
4263
|
-
const column = columns[columnName]
|
|
4264
|
-
if (column === undefined || column === null || typeof column !== "object" || !(Expression.TypeId in column)) {
|
|
4265
|
-
throw new Error("effect-qb: unknown mutation column")
|
|
4266
|
-
}
|
|
4267
|
-
return column as Expression.Any
|
|
4268
|
-
}
|
|
4340
|
+
): Expression.Any => columns[columnName] as Expression.Any
|
|
4269
4341
|
|
|
4270
4342
|
const buildMutationAssignments = <Target extends MutationTargetInput, Values>(
|
|
4271
4343
|
target: Target,
|
|
@@ -4281,7 +4353,7 @@ type BinaryPredicateExpression<
|
|
|
4281
4353
|
}
|
|
4282
4354
|
const valueMap = values as Record<string, Record<string, unknown> | undefined>
|
|
4283
4355
|
return targets.flatMap((table) => {
|
|
4284
|
-
const targetName = (table as
|
|
4356
|
+
const targetName = (table as TableLike)[Table.TypeId].name
|
|
4285
4357
|
const scopedValues = valueMap[targetName] ?? {}
|
|
4286
4358
|
const columns = table as unknown as Record<string, Expression.Any>
|
|
4287
4359
|
return Object.entries(scopedValues).map(([columnName, value]) => ({
|
|
@@ -4302,20 +4374,17 @@ type BinaryPredicateExpression<
|
|
|
4302
4374
|
} => {
|
|
4303
4375
|
const firstRow = rows[0]
|
|
4304
4376
|
const firstColumns = Object.keys(firstRow)
|
|
4305
|
-
if (firstColumns.length === 0) {
|
|
4306
|
-
throw new Error("values(...) rows must specify at least one column; use insert(target) for default-only inserts instead")
|
|
4307
|
-
}
|
|
4308
4377
|
const columns = firstColumns as [string, ...string[]]
|
|
4309
|
-
const
|
|
4310
|
-
const rowKeys = Object.keys(row)
|
|
4311
|
-
if (rowKeys.length !== columns.length || columns.some((column) => !(column in row))) {
|
|
4312
|
-
throw new Error("All values(...) rows must project the same columns in the same shape")
|
|
4313
|
-
}
|
|
4378
|
+
const normalizeRow = (row: InsertRowInput<Target>) => {
|
|
4314
4379
|
const assignments = buildMutationAssignments(target, row) as readonly QueryAst.AssignmentClause[]
|
|
4315
4380
|
return {
|
|
4316
4381
|
values: columns.map((columnName) => assignments.find((assignment) => assignment.columnName === columnName)!)
|
|
4317
4382
|
} satisfies QueryAst.InsertValuesRowClause
|
|
4318
|
-
}
|
|
4383
|
+
}
|
|
4384
|
+
const normalizedRows: readonly [QueryAst.InsertValuesRowClause, ...QueryAst.InsertValuesRowClause[]] = [
|
|
4385
|
+
normalizeRow(rows[0]),
|
|
4386
|
+
...rows.slice(1).map(normalizeRow)
|
|
4387
|
+
]
|
|
4319
4388
|
const required = normalizedRows.flatMap((row) =>
|
|
4320
4389
|
row.values.flatMap((entry) => Object.keys(entry.value[Expression.TypeId].dependencies))
|
|
4321
4390
|
)
|
|
@@ -4330,9 +4399,6 @@ type BinaryPredicateExpression<
|
|
|
4330
4399
|
selection: Record<string, Expression.Any>
|
|
4331
4400
|
): readonly [string, ...string[]] => {
|
|
4332
4401
|
const columns = Object.keys(selection)
|
|
4333
|
-
if (columns.length === 0) {
|
|
4334
|
-
throw new Error("insert(...).pipe(from(subquery)) requires at least one projected column")
|
|
4335
|
-
}
|
|
4336
4402
|
return columns as [string, ...string[]]
|
|
4337
4403
|
}
|
|
4338
4404
|
|
|
@@ -4347,27 +4413,11 @@ type BinaryPredicateExpression<
|
|
|
4347
4413
|
}[]
|
|
4348
4414
|
} => {
|
|
4349
4415
|
const entries = Object.entries(values)
|
|
4350
|
-
if (entries.length === 0) {
|
|
4351
|
-
throw new Error("unnest(...) requires at least one column array")
|
|
4352
|
-
}
|
|
4353
4416
|
const columns = entries.map(([columnName]) => columnName) as [string, ...string[]]
|
|
4354
|
-
const normalized = entries.map(([columnName, items]) => {
|
|
4355
|
-
|
|
4356
|
-
|
|
4357
|
-
|
|
4358
|
-
return {
|
|
4359
|
-
columnName,
|
|
4360
|
-
values: items
|
|
4361
|
-
}
|
|
4362
|
-
})
|
|
4363
|
-
const expectedLength = normalized[0]!.values.length
|
|
4364
|
-
if (normalized.some((entry) => entry.values.length !== expectedLength)) {
|
|
4365
|
-
throw new Error("unnest(...) expects every column array to have the same length")
|
|
4366
|
-
}
|
|
4367
|
-
const knownColumns = new Set(Object.keys(target[Table.TypeId].fields))
|
|
4368
|
-
if (columns.some((columnName) => !knownColumns.has(columnName))) {
|
|
4369
|
-
throw new Error("unnest(...) received a column that does not exist on the target table")
|
|
4370
|
-
}
|
|
4417
|
+
const normalized = entries.map(([columnName, items]) => ({
|
|
4418
|
+
columnName,
|
|
4419
|
+
values: items
|
|
4420
|
+
}))
|
|
4371
4421
|
return {
|
|
4372
4422
|
columns,
|
|
4373
4423
|
values: normalized
|
|
@@ -4379,10 +4429,6 @@ type BinaryPredicateExpression<
|
|
|
4379
4429
|
columnsInput: string | readonly string[]
|
|
4380
4430
|
): readonly [string, ...string[]] => {
|
|
4381
4431
|
const columns = normalizeColumnList(columnsInput) as readonly [string, ...string[]]
|
|
4382
|
-
const knownColumns = new Set(Object.keys(target[Table.TypeId].fields))
|
|
4383
|
-
if (columns.some((columnName) => !knownColumns.has(columnName))) {
|
|
4384
|
-
throw new Error("effect-qb: unknown conflict target column")
|
|
4385
|
-
}
|
|
4386
4432
|
return columns
|
|
4387
4433
|
}
|
|
4388
4434
|
|
|
@@ -4396,7 +4442,21 @@ type BinaryPredicateExpression<
|
|
|
4396
4442
|
columns: normalizeConflictColumns(target, input)
|
|
4397
4443
|
}
|
|
4398
4444
|
}
|
|
4399
|
-
|
|
4445
|
+
if (!Array.isArray(input) && "constraint" in input) {
|
|
4446
|
+
return {
|
|
4447
|
+
kind: "constraint",
|
|
4448
|
+
name: input.constraint
|
|
4449
|
+
}
|
|
4450
|
+
}
|
|
4451
|
+
const columnTarget = input as {
|
|
4452
|
+
readonly columns: string | readonly string[]
|
|
4453
|
+
readonly where?: PredicateInput
|
|
4454
|
+
}
|
|
4455
|
+
return {
|
|
4456
|
+
kind: "columns",
|
|
4457
|
+
columns: normalizeConflictColumns(target, columnTarget.columns),
|
|
4458
|
+
where: columnTarget.where === undefined ? undefined : toDialectExpression(columnTarget.where)
|
|
4459
|
+
}
|
|
4400
4460
|
}
|
|
4401
4461
|
|
|
4402
4462
|
const defaultIndexName = (
|
|
@@ -4447,14 +4507,91 @@ type ValidateTargetColumnInput<
|
|
|
4447
4507
|
Columns extends DdlColumnInput
|
|
4448
4508
|
> = ValidateTargetColumns<Target, NormalizeDdlColumns<Columns>> extends never ? never : Columns
|
|
4449
4509
|
|
|
4450
|
-
type
|
|
4451
|
-
readonly
|
|
4510
|
+
type SameColumnSet<
|
|
4511
|
+
Left extends readonly string[],
|
|
4512
|
+
Right extends readonly string[]
|
|
4513
|
+
> = string extends Left[number] | Right[number]
|
|
4514
|
+
? false
|
|
4515
|
+
: Exclude<Left[number], Right[number]> extends never
|
|
4516
|
+
? Exclude<Right[number], Left[number]> extends never
|
|
4517
|
+
? true
|
|
4518
|
+
: false
|
|
4519
|
+
: false
|
|
4520
|
+
|
|
4521
|
+
type ConflictArbitersOf<Target extends MutationTargetLike> =
|
|
4522
|
+
Target[typeof Table.TypeId]["conflictArbiters"][number]
|
|
4523
|
+
|
|
4524
|
+
type MatchingConflictArbiter<
|
|
4525
|
+
Target extends MutationTargetLike,
|
|
4526
|
+
Columns extends readonly string[],
|
|
4527
|
+
AllowPartial extends boolean
|
|
4528
|
+
> = ConflictArbitersOf<Target> extends infer Arbiter extends Table.ConflictArbiter
|
|
4529
|
+
? Arbiter extends Table.ConflictArbiter
|
|
4530
|
+
? SameColumnSet<Arbiter["columns"], Columns> extends true
|
|
4531
|
+
? Arbiter["scope"] extends "unconditional"
|
|
4532
|
+
? true
|
|
4533
|
+
: AllowPartial extends true ? true : never
|
|
4534
|
+
: never
|
|
4535
|
+
: never
|
|
4536
|
+
: never
|
|
4537
|
+
|
|
4538
|
+
type HasInlineConflictArbiter<
|
|
4539
|
+
Target extends MutationTargetLike,
|
|
4540
|
+
Columns extends readonly string[]
|
|
4541
|
+
> = Columns extends readonly [infer Column extends Extract<keyof Target[typeof Table.TypeId]["fields"], string>]
|
|
4542
|
+
? Target[typeof Table.TypeId]["fields"][Column] extends { readonly metadata: { readonly primaryKey: true } | { readonly unique: true } }
|
|
4543
|
+
? true
|
|
4544
|
+
: false
|
|
4545
|
+
: false
|
|
4546
|
+
|
|
4547
|
+
type HasConflictArbiter<
|
|
4548
|
+
Target extends MutationTargetLike,
|
|
4549
|
+
Columns extends readonly string[],
|
|
4550
|
+
AllowPartial extends boolean
|
|
4551
|
+
> = string extends Extract<keyof Target[typeof Table.TypeId]["fields"], string>
|
|
4552
|
+
? true
|
|
4553
|
+
: HasInlineConflictArbiter<Target, Columns> extends true
|
|
4554
|
+
? true
|
|
4555
|
+
: true extends MatchingConflictArbiter<Target, Columns, AllowPartial> ? true : false
|
|
4556
|
+
|
|
4557
|
+
type ConflictTargetArbiterError<
|
|
4558
|
+
Columns,
|
|
4559
|
+
AllowPartial extends boolean
|
|
4560
|
+
> = {
|
|
4561
|
+
readonly __effect_qb_error__: "effect-qb: conflict target columns must match a primary key, unique constraint, or unique index"
|
|
4562
|
+
readonly __effect_qb_conflict_columns__: Columns
|
|
4563
|
+
readonly __effect_qb_partial_target__: AllowPartial
|
|
4564
|
+
readonly __effect_qb_hint__: "Declare the target columns as primaryKey/unique, add a table-level Unique.make(...), or use a simple Pg.Index.uniqueIndex(...)"
|
|
4565
|
+
}
|
|
4566
|
+
|
|
4567
|
+
type ValidateConflictColumnInput<
|
|
4568
|
+
Target extends MutationTargetLike,
|
|
4569
|
+
Columns extends DdlColumnInput,
|
|
4570
|
+
AllowPartial extends boolean
|
|
4571
|
+
> = ValidateTargetColumnInput<Target, Columns> extends never
|
|
4572
|
+
? never
|
|
4573
|
+
: HasConflictArbiter<Target, NormalizeDdlColumns<Columns>, AllowPartial> extends true
|
|
4574
|
+
? Columns
|
|
4575
|
+
: ConflictTargetArbiterError<NormalizeDdlColumns<Columns>, AllowPartial>
|
|
4576
|
+
|
|
4577
|
+
type ConflictColumnPlanConstraint<
|
|
4578
|
+
Target extends MutationTargetLike,
|
|
4579
|
+
Columns extends DdlColumnInput,
|
|
4580
|
+
AllowPartial extends boolean
|
|
4581
|
+
> = ValidateTargetColumnInput<Target, Columns> extends never
|
|
4582
|
+
? never
|
|
4583
|
+
: HasConflictArbiter<Target, NormalizeDdlColumns<Columns>, AllowPartial> extends true
|
|
4584
|
+
? unknown
|
|
4585
|
+
: ConflictTargetArbiterError<NormalizeDdlColumns<Columns>, AllowPartial>
|
|
4586
|
+
|
|
4587
|
+
type CreateIndexOptions<Name extends string = string> = {
|
|
4588
|
+
readonly name?: NonEmptyStringInput<Name>
|
|
4452
4589
|
readonly unique?: boolean
|
|
4453
4590
|
readonly ifNotExists?: never
|
|
4454
4591
|
}
|
|
4455
4592
|
|
|
4456
|
-
type DropIndexOptions = {
|
|
4457
|
-
readonly name?:
|
|
4593
|
+
type DropIndexOptions<Name extends string = string> = {
|
|
4594
|
+
readonly name?: NonEmptyStringInput<Name>
|
|
4458
4595
|
readonly ifExists?: never
|
|
4459
4596
|
}
|
|
4460
4597
|
|
|
@@ -4558,7 +4695,7 @@ type ValuesRowsDialectInput<
|
|
|
4558
4695
|
BoolDb extends Expression.DbType.Any,
|
|
4559
4696
|
TimestampDb extends Expression.DbType.Any,
|
|
4560
4697
|
NullDb extends Expression.DbType.Any
|
|
4561
|
-
> = Exclude<ValuesRowsDialect<Rows, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>, Dialect> extends never
|
|
4698
|
+
> = Exclude<ValuesRowsDialect<Rows, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>, Dialect | "standard"> extends never
|
|
4562
4699
|
? unknown
|
|
4563
4700
|
: {
|
|
4564
4701
|
readonly __effect_qb_error__: "effect-qb: values rows cannot mix dialects"
|
|
@@ -4613,7 +4750,7 @@ type UnnestColumnsDialectInput<
|
|
|
4613
4750
|
BoolDb extends Expression.DbType.Any,
|
|
4614
4751
|
TimestampDb extends Expression.DbType.Any,
|
|
4615
4752
|
NullDb extends Expression.DbType.Any
|
|
4616
|
-
> = Exclude<UnnestColumnsDialect<Columns, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>, Dialect> extends never
|
|
4753
|
+
> = Exclude<UnnestColumnsDialect<Columns, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>, Dialect | "standard"> extends never
|
|
4617
4754
|
? unknown
|
|
4618
4755
|
: {
|
|
4619
4756
|
readonly __effect_qb_error__: "effect-qb: unnest columns cannot mix dialects"
|
|
@@ -4885,6 +5022,26 @@ type ConflictTargetInput<
|
|
|
4885
5022
|
readonly constraint?: string
|
|
4886
5023
|
}>)
|
|
4887
5024
|
|
|
5025
|
+
type ConflictConstraintNameConstraint<Target> =
|
|
5026
|
+
Target extends { readonly constraint: infer Constraint extends string }
|
|
5027
|
+
? { readonly constraint: NonEmptyStringInput<Constraint> }
|
|
5028
|
+
: unknown
|
|
5029
|
+
|
|
5030
|
+
type ConflictTargetHasPredicate<Target> =
|
|
5031
|
+
Target extends { readonly where: PredicateInput } ? true : false
|
|
5032
|
+
|
|
5033
|
+
type ConflictTargetPlanConstraint<
|
|
5034
|
+
Target extends MutationTargetLike,
|
|
5035
|
+
ConflictTarget
|
|
5036
|
+
> =
|
|
5037
|
+
ConflictTarget extends { readonly constraint: string }
|
|
5038
|
+
? unknown
|
|
5039
|
+
: ConflictTarget extends { readonly columns: infer Columns extends DdlColumnInput }
|
|
5040
|
+
? ConflictColumnPlanConstraint<Target, Columns, ConflictTargetHasPredicate<ConflictTarget>>
|
|
5041
|
+
: ConflictTarget extends DdlColumnInput
|
|
5042
|
+
? ConflictColumnPlanConstraint<Target, ConflictTarget, false>
|
|
5043
|
+
: unknown
|
|
5044
|
+
|
|
4888
5045
|
type ConflictActionInput<
|
|
4889
5046
|
Target extends MutationTargetLike,
|
|
4890
5047
|
Dialect extends string,
|
|
@@ -5031,7 +5188,12 @@ type MutationOrderLimitSupported<PlanValue extends QueryPlan<any, any, any, any,
|
|
|
5031
5188
|
type MutationTargetTupleDialectConstraint<
|
|
5032
5189
|
Targets extends MutationTargetTuple,
|
|
5033
5190
|
Dialect extends string
|
|
5034
|
-
> = Exclude<TableDialectOf<Targets[number]>, Dialect> extends never ? unknown : never
|
|
5191
|
+
> = Exclude<TableDialectOf<Targets[number]>, Dialect | "standard"> extends never ? unknown : never
|
|
5192
|
+
|
|
5193
|
+
type TableDialectConstraint<
|
|
5194
|
+
Target extends TableLike,
|
|
5195
|
+
Dialect extends string
|
|
5196
|
+
> = Exclude<TableDialectOf<Target>, Dialect> extends never ? unknown : never
|
|
5035
5197
|
|
|
5036
5198
|
type DuplicateMutationTargetSourceName<
|
|
5037
5199
|
Targets extends readonly MutationTargetLike[],
|
|
@@ -5112,7 +5274,7 @@ type KnownIncompatibleMutationDialectFromValues<
|
|
|
5112
5274
|
BoolDb extends Expression.DbType.Any,
|
|
5113
5275
|
TimestampDb extends Expression.DbType.Any,
|
|
5114
5276
|
NullDb extends Expression.DbType.Any
|
|
5115
|
-
> = Exclude<KnownMutationDialectFromValues<Values, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>, Dialect>
|
|
5277
|
+
> = Exclude<KnownMutationDialectFromValues<Values, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>, Dialect | "standard">
|
|
5116
5278
|
|
|
5117
5279
|
type MutationValuesDialectConstraint<
|
|
5118
5280
|
Values,
|
|
@@ -5164,9 +5326,11 @@ type SourceDialectConstraint<
|
|
|
5164
5326
|
Dialect extends string
|
|
5165
5327
|
> = [SourceDialectOf<CurrentSource>] extends [never]
|
|
5166
5328
|
? unknown
|
|
5167
|
-
:
|
|
5168
|
-
?
|
|
5169
|
-
:
|
|
5329
|
+
: Exclude<SourceDialectOf<CurrentSource>, Dialect | "standard"> extends never
|
|
5330
|
+
? unknown
|
|
5331
|
+
: Dialect extends "standard"
|
|
5332
|
+
? unknown
|
|
5333
|
+
: never
|
|
5170
5334
|
|
|
5171
5335
|
type SourceRequirementConstraint<
|
|
5172
5336
|
PlanValue extends QueryPlan<any, any, any, any, any, any, any, any, any, any>,
|
|
@@ -5430,7 +5594,7 @@ type AsCurriedResult<
|
|
|
5430
5594
|
function as<
|
|
5431
5595
|
Alias extends string
|
|
5432
5596
|
>(
|
|
5433
|
-
alias: Alias
|
|
5597
|
+
alias: LiteralStringInput<Alias>
|
|
5434
5598
|
): <Value extends AsCurriedInput<Dialect>>(
|
|
5435
5599
|
value: Value
|
|
5436
5600
|
) => AsCurriedResult<Value, Alias, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>
|
|
@@ -5439,7 +5603,7 @@ type AsCurriedResult<
|
|
|
5439
5603
|
Alias extends string
|
|
5440
5604
|
>(
|
|
5441
5605
|
value: Value,
|
|
5442
|
-
alias: Alias
|
|
5606
|
+
alias: LiteralStringInput<Alias>
|
|
5443
5607
|
): ProjectionAliasedExpression<DialectAsExpression<Value, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>, Alias>
|
|
5444
5608
|
function as<
|
|
5445
5609
|
Rows extends ValuesRowsInput,
|
|
@@ -5450,7 +5614,7 @@ type AsCurriedResult<
|
|
|
5450
5614
|
ValuesOutputShape<Rows, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>,
|
|
5451
5615
|
Dialect
|
|
5452
5616
|
>,
|
|
5453
|
-
alias: Alias
|
|
5617
|
+
alias: LiteralStringInput<Alias>
|
|
5454
5618
|
): ValuesSource<
|
|
5455
5619
|
Rows,
|
|
5456
5620
|
ValuesOutputShape<Rows, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>,
|
|
@@ -5462,11 +5626,11 @@ type AsCurriedResult<
|
|
|
5462
5626
|
Alias extends string
|
|
5463
5627
|
>(
|
|
5464
5628
|
value: DerivedTableCompatiblePlan<PlanValue>,
|
|
5465
|
-
alias: Alias
|
|
5629
|
+
alias: LiteralStringInput<Alias>
|
|
5466
5630
|
): DerivedSource<PlanValue, Alias>
|
|
5467
5631
|
function as(valueOrAlias: unknown, alias?: string): unknown {
|
|
5468
5632
|
if (alias === undefined) {
|
|
5469
|
-
return (value: unknown) => as(value as any, valueOrAlias as
|
|
5633
|
+
return (value: unknown) => as(value as any, valueOrAlias as never)
|
|
5470
5634
|
}
|
|
5471
5635
|
const resolvedAlias = alias
|
|
5472
5636
|
const value = valueOrAlias
|
|
@@ -5506,7 +5670,7 @@ type AsCurriedResult<
|
|
|
5506
5670
|
function with_<
|
|
5507
5671
|
Alias extends string
|
|
5508
5672
|
>(
|
|
5509
|
-
alias: Alias
|
|
5673
|
+
alias: LiteralStringInput<Alias>
|
|
5510
5674
|
): <PlanValue extends QueryPlan<any, any, any, any, any, any, any, any, any, any>>(
|
|
5511
5675
|
value: MysqlCteCompatiblePlan<PlanValue>
|
|
5512
5676
|
) => import("../../internal/query.js").CteSource<PlanValue, Alias>
|
|
@@ -5515,11 +5679,11 @@ type AsCurriedResult<
|
|
|
5515
5679
|
Alias extends string
|
|
5516
5680
|
>(
|
|
5517
5681
|
value: MysqlCteCompatiblePlan<PlanValue>,
|
|
5518
|
-
alias: Alias
|
|
5682
|
+
alias: LiteralStringInput<Alias>
|
|
5519
5683
|
): import("../../internal/query.js").CteSource<PlanValue, Alias>
|
|
5520
5684
|
function with_(valueOrAlias: unknown, alias?: string): unknown {
|
|
5521
5685
|
if (alias === undefined) {
|
|
5522
|
-
return (value: unknown) => with_(value as any, valueOrAlias as
|
|
5686
|
+
return (value: unknown) => with_(value as any, valueOrAlias as never)
|
|
5523
5687
|
}
|
|
5524
5688
|
return makeCteSource(
|
|
5525
5689
|
valueOrAlias as CompletePlan<QueryPlan<any, any, any, any, any, any, any, any, any, any>>,
|
|
@@ -5530,7 +5694,7 @@ type AsCurriedResult<
|
|
|
5530
5694
|
function withRecursive_<
|
|
5531
5695
|
Alias extends string
|
|
5532
5696
|
>(
|
|
5533
|
-
alias: Alias
|
|
5697
|
+
alias: LiteralStringInput<Alias>
|
|
5534
5698
|
): <PlanValue extends QueryPlan<any, any, any, any, any, any, any, any, any, any>>(
|
|
5535
5699
|
value: MysqlCteCompatiblePlan<PlanValue>
|
|
5536
5700
|
) => import("../../internal/query.js").CteSource<PlanValue, Alias>
|
|
@@ -5539,11 +5703,11 @@ type AsCurriedResult<
|
|
|
5539
5703
|
Alias extends string
|
|
5540
5704
|
>(
|
|
5541
5705
|
value: MysqlCteCompatiblePlan<PlanValue>,
|
|
5542
|
-
alias: Alias
|
|
5706
|
+
alias: LiteralStringInput<Alias>
|
|
5543
5707
|
): import("../../internal/query.js").CteSource<PlanValue, Alias>
|
|
5544
5708
|
function withRecursive_(valueOrAlias: unknown, alias?: string): unknown {
|
|
5545
5709
|
if (alias === undefined) {
|
|
5546
|
-
return (value: unknown) => withRecursive_(value as any, valueOrAlias as
|
|
5710
|
+
return (value: unknown) => withRecursive_(value as any, valueOrAlias as never)
|
|
5547
5711
|
}
|
|
5548
5712
|
return makeCteSource(
|
|
5549
5713
|
valueOrAlias as CompletePlan<QueryPlan<any, any, any, any, any, any, any, any, any, any>>,
|
|
@@ -5555,7 +5719,7 @@ type AsCurriedResult<
|
|
|
5555
5719
|
function lateral<
|
|
5556
5720
|
Alias extends string
|
|
5557
5721
|
>(
|
|
5558
|
-
alias: Alias
|
|
5722
|
+
alias: LiteralStringInput<Alias>
|
|
5559
5723
|
): <PlanValue extends QueryPlan<any, any, any, any, any, any, any, any, any, any>>(
|
|
5560
5724
|
value: LateralSourceCompatiblePlan<PlanValue>
|
|
5561
5725
|
) => import("../../internal/query.js").LateralSource<PlanValue, Alias>
|
|
@@ -5564,11 +5728,11 @@ type AsCurriedResult<
|
|
|
5564
5728
|
Alias extends string
|
|
5565
5729
|
>(
|
|
5566
5730
|
value: LateralSourceCompatiblePlan<PlanValue>,
|
|
5567
|
-
alias: Alias
|
|
5731
|
+
alias: LiteralStringInput<Alias>
|
|
5568
5732
|
): import("../../internal/query.js").LateralSource<PlanValue, Alias>
|
|
5569
5733
|
function lateral(valueOrAlias: unknown, alias?: string): unknown {
|
|
5570
5734
|
if (alias === undefined) {
|
|
5571
|
-
return (value: unknown) => lateral(value as any, valueOrAlias as
|
|
5735
|
+
return (value: unknown) => lateral(value as any, valueOrAlias as never)
|
|
5572
5736
|
}
|
|
5573
5737
|
return makeLateralSource(
|
|
5574
5738
|
valueOrAlias as QueryPlan<any, any, any, any, any, any, any, any, any, any>,
|
|
@@ -5595,7 +5759,7 @@ type AsCurriedResult<
|
|
|
5595
5759
|
columns: Columns
|
|
5596
5760
|
& UnnestColumnsShapeInput<Columns>
|
|
5597
5761
|
& UnnestColumnsDialectInput<Columns, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>,
|
|
5598
|
-
alias: Alias
|
|
5762
|
+
alias: LiteralStringInput<Alias>
|
|
5599
5763
|
) => UnnestSource<
|
|
5600
5764
|
UnnestOutputShape<Columns, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>,
|
|
5601
5765
|
Alias,
|
|
@@ -5611,7 +5775,7 @@ type AsCurriedResult<
|
|
|
5611
5775
|
start: Start & NumericExpressionDialectInput<Start, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>,
|
|
5612
5776
|
stop: Stop & NumericExpressionDialectInput<Stop, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>,
|
|
5613
5777
|
step?: Step & (Step extends NumericExpressionInput ? NumericExpressionDialectInput<Step, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb> : unknown),
|
|
5614
|
-
alias?: Alias
|
|
5778
|
+
alias?: LiteralStringInput<Alias>
|
|
5615
5779
|
) => Dialect extends "postgres"
|
|
5616
5780
|
? TableFunctionSource<
|
|
5617
5781
|
GenerateSeriesOutputShape<Start, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>,
|
|
@@ -5658,8 +5822,8 @@ type AsCurriedResult<
|
|
|
5658
5822
|
? SelectSelectionNonEmptyError<Selection>
|
|
5659
5823
|
: unknown
|
|
5660
5824
|
|
|
5661
|
-
export type SelectApi = <Selection extends SelectionShape>(
|
|
5662
|
-
selection: Selection & SelectionRootObjectConstraint<Selection> & SelectionNestedNonEmptyConstraint<Selection> & SelectSelectionNonEmptyConstraint<Selection>
|
|
5825
|
+
export type SelectApi = <const Selection extends SelectionShape>(
|
|
5826
|
+
selection: Selection & SelectionRootObjectConstraint<Selection> & SelectionNestedNonEmptyConstraint<Selection> & SelectSelectionNonEmptyConstraint<Selection> & SelectionProjectionAliasCollisionConstraint<Selection>
|
|
5663
5827
|
) => QueryPlan<
|
|
5664
5828
|
Selection,
|
|
5665
5829
|
ExtractRequired<Selection>,
|
|
@@ -6124,8 +6288,8 @@ type AsCurriedResult<
|
|
|
6124
6288
|
: unknown
|
|
6125
6289
|
|
|
6126
6290
|
type ReturningApi = Dialect extends "postgres"
|
|
6127
|
-
? <Selection extends SelectionShape>(
|
|
6128
|
-
selection: Selection & SelectionRootObjectConstraint<Selection> & SelectionNestedNonEmptyConstraint<Selection> & ReturningSelectionNonEmptyConstraint<Selection>
|
|
6291
|
+
? <const Selection extends SelectionShape>(
|
|
6292
|
+
selection: Selection & SelectionRootObjectConstraint<Selection> & SelectionNestedNonEmptyConstraint<Selection> & ReturningSelectionNonEmptyConstraint<Selection> & SelectionProjectionAliasCollisionConstraint<Selection>
|
|
6129
6293
|
) =>
|
|
6130
6294
|
<PlanValue extends QueryPlan<any, any, any, any, any, any, any, any, any, any>>(
|
|
6131
6295
|
plan: PlanValue & RequireMutationStatement<PlanValue>
|
|
@@ -6148,7 +6312,7 @@ type AsCurriedResult<
|
|
|
6148
6312
|
|
|
6149
6313
|
export interface InsertApi {
|
|
6150
6314
|
<Target extends MutationTargetLike>(
|
|
6151
|
-
target: Target
|
|
6315
|
+
target: Target & TableDialectConstraint<Target, Dialect>
|
|
6152
6316
|
): QueryPlan<
|
|
6153
6317
|
{},
|
|
6154
6318
|
never,
|
|
@@ -6165,7 +6329,7 @@ type AsCurriedResult<
|
|
|
6165
6329
|
EmptyFacts
|
|
6166
6330
|
>
|
|
6167
6331
|
<Target extends MutationTargetLike, Values extends Record<string, unknown>>(
|
|
6168
|
-
target: Target,
|
|
6332
|
+
target: Target & TableDialectConstraint<Target, Dialect>,
|
|
6169
6333
|
values: MutationValuesInput<"insert", Target, Values> & MutationValuesDialectConstraint<Values, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>
|
|
6170
6334
|
): QueryPlan<
|
|
6171
6335
|
{},
|
|
@@ -6194,13 +6358,13 @@ type AsCurriedResult<
|
|
|
6194
6358
|
const Columns extends DdlColumnInput,
|
|
6195
6359
|
UpdateValues extends MutationInputOf<Table.UpdateOf<Target>> | undefined = MutationInputOf<Table.UpdateOf<Target>> | undefined,
|
|
6196
6360
|
Options extends ConflictActionInput<Target, Dialect, UpdateValues> = ConflictActionInput<Target, Dialect, UpdateValues>,
|
|
6197
|
-
ConflictTarget extends ConflictTargetInput<Target, Dialect, Columns> = ConflictTargetInput<Target, Dialect, Columns>
|
|
6361
|
+
const ConflictTarget extends ConflictTargetInput<Target, Dialect, Columns> = ConflictTargetInput<Target, Dialect, Columns>
|
|
6198
6362
|
>(
|
|
6199
|
-
target: ConflictTarget
|
|
6363
|
+
target: ConflictTarget & ConflictConstraintNameConstraint<ConflictTarget>,
|
|
6200
6364
|
options?: Options & ConflictActionUpdateNonEmptyConstraint<Options>
|
|
6201
|
-
|
|
6365
|
+
) =>
|
|
6202
6366
|
<PlanValue extends QueryPlan<any, any, any, any, any, any, any, any, any, any>>(
|
|
6203
|
-
plan: PlanValue & RequireInsertStatement<PlanValue>
|
|
6367
|
+
plan: PlanValue & RequireInsertStatement<PlanValue> & ConflictTargetPlanConstraint<MutationTargetOfPlan<PlanValue>, ConflictTarget>
|
|
6204
6368
|
) => QueryPlan<
|
|
6205
6369
|
SelectionOfPlan<PlanValue>,
|
|
6206
6370
|
Exclude<RequiredOfPlan<PlanValue> | ConflictRequired<UpdateValues, Options, ConflictTarget>, AvailableNames<AvailableOfPlan<PlanValue>>>,
|
|
@@ -6237,7 +6401,7 @@ type AsCurriedResult<
|
|
|
6237
6401
|
EmptyFacts
|
|
6238
6402
|
>
|
|
6239
6403
|
<Target extends MutationTargetLike, Values extends Record<string, unknown>>(
|
|
6240
|
-
target: Target,
|
|
6404
|
+
target: Target & TableDialectConstraint<Target, Dialect>,
|
|
6241
6405
|
values: MutationValuesInput<"update", Target, Values> & UpdateValuesNonEmptyConstraint<Values> & MutationValuesDialectConstraint<Values, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>
|
|
6242
6406
|
): QueryPlan<
|
|
6243
6407
|
{},
|
|
@@ -6262,9 +6426,9 @@ type AsCurriedResult<
|
|
|
6262
6426
|
const Columns extends DdlColumnInput,
|
|
6263
6427
|
UpdateValues extends MutationInputOf<Table.UpdateOf<Target>> | undefined = undefined
|
|
6264
6428
|
>(
|
|
6265
|
-
target: Target,
|
|
6429
|
+
target: Target & TableDialectConstraint<Target, Dialect>,
|
|
6266
6430
|
values: Values & MutationValuesDialectConstraint<Values, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>,
|
|
6267
|
-
conflictColumns:
|
|
6431
|
+
conflictColumns: ValidateConflictColumnInput<Target, Columns, false>,
|
|
6268
6432
|
updateValues?: UpdateValues & UpdateValuesNonEmptyConstraint<Exclude<UpdateValues, undefined>> & MutationValuesDialectConstraint<Exclude<UpdateValues, undefined>, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>
|
|
6269
6433
|
) => QueryPlan<
|
|
6270
6434
|
{},
|
|
@@ -6286,7 +6450,7 @@ type AsCurriedResult<
|
|
|
6286
6450
|
|
|
6287
6451
|
interface DeleteApi {
|
|
6288
6452
|
<Target extends MutationTargetLike>(
|
|
6289
|
-
target: Target
|
|
6453
|
+
target: Target & TableDialectConstraint<Target, Dialect>
|
|
6290
6454
|
): QueryPlan<
|
|
6291
6455
|
{},
|
|
6292
6456
|
never,
|
|
@@ -6322,7 +6486,7 @@ type AsCurriedResult<
|
|
|
6322
6486
|
}
|
|
6323
6487
|
|
|
6324
6488
|
type TruncateApi = <Target extends MutationTargetLike>(
|
|
6325
|
-
target: Target,
|
|
6489
|
+
target: Target & TableDialectConstraint<Target, Dialect>,
|
|
6326
6490
|
options?: TruncateOptions
|
|
6327
6491
|
) => QueryPlan<
|
|
6328
6492
|
{},
|
|
@@ -6355,10 +6519,10 @@ type AsCurriedResult<
|
|
|
6355
6519
|
MatchedPredicate extends PredicateInput | undefined = undefined,
|
|
6356
6520
|
NotMatchedPredicate extends PredicateInput | undefined = undefined
|
|
6357
6521
|
>(
|
|
6358
|
-
target: Target,
|
|
6522
|
+
target: Target & TableDialectConstraint<Target, Dialect>,
|
|
6359
6523
|
source: Source & (
|
|
6360
6524
|
SourceRequiredOf<Source> extends never ? unknown : SourceRequirementError<Source>
|
|
6361
|
-
),
|
|
6525
|
+
) & SourceDialectConstraint<Source, Dialect>,
|
|
6362
6526
|
on: On,
|
|
6363
6527
|
options: MergeOptions<Target, MatchedValues, InsertValues, MatchedPredicate, NotMatchedPredicate>
|
|
6364
6528
|
) => QueryPlan<
|
|
@@ -6572,7 +6736,7 @@ type AsCurriedResult<
|
|
|
6572
6736
|
"rollback"
|
|
6573
6737
|
>
|
|
6574
6738
|
|
|
6575
|
-
type SavepointApi = <Name extends string>(name: Name) => QueryPlan<
|
|
6739
|
+
type SavepointApi = <Name extends string>(name: NonEmptyStringInput<Name>) => QueryPlan<
|
|
6576
6740
|
{},
|
|
6577
6741
|
never,
|
|
6578
6742
|
{},
|
|
@@ -6585,7 +6749,7 @@ type AsCurriedResult<
|
|
|
6585
6749
|
"savepoint"
|
|
6586
6750
|
>
|
|
6587
6751
|
|
|
6588
|
-
type RollbackToApi = <Name extends string>(name: Name) => QueryPlan<
|
|
6752
|
+
type RollbackToApi = <Name extends string>(name: NonEmptyStringInput<Name>) => QueryPlan<
|
|
6589
6753
|
{},
|
|
6590
6754
|
never,
|
|
6591
6755
|
{},
|
|
@@ -6598,7 +6762,7 @@ type AsCurriedResult<
|
|
|
6598
6762
|
"rollbackTo"
|
|
6599
6763
|
>
|
|
6600
6764
|
|
|
6601
|
-
type ReleaseSavepointApi = <Name extends string>(name: Name) => QueryPlan<
|
|
6765
|
+
type ReleaseSavepointApi = <Name extends string>(name: NonEmptyStringInput<Name>) => QueryPlan<
|
|
6602
6766
|
{},
|
|
6603
6767
|
never,
|
|
6604
6768
|
{},
|
|
@@ -6612,7 +6776,7 @@ type AsCurriedResult<
|
|
|
6612
6776
|
>
|
|
6613
6777
|
|
|
6614
6778
|
type CreateTableApi = <Target extends SchemaTableLike>(
|
|
6615
|
-
target: Target,
|
|
6779
|
+
target: Target & TableDialectConstraint<Target, Dialect>,
|
|
6616
6780
|
options?: CreateTableOptions
|
|
6617
6781
|
) => QueryPlan<
|
|
6618
6782
|
{},
|
|
@@ -6628,7 +6792,7 @@ type AsCurriedResult<
|
|
|
6628
6792
|
>
|
|
6629
6793
|
|
|
6630
6794
|
type DropTableApi = <Target extends SchemaTableLike>(
|
|
6631
|
-
target: Target,
|
|
6795
|
+
target: Target & TableDialectConstraint<Target, Dialect>,
|
|
6632
6796
|
options?: DropTableOptions
|
|
6633
6797
|
) => QueryPlan<
|
|
6634
6798
|
{},
|
|
@@ -6643,10 +6807,10 @@ type AsCurriedResult<
|
|
|
6643
6807
|
"dropTable"
|
|
6644
6808
|
>
|
|
6645
6809
|
|
|
6646
|
-
type CreateIndexApi = <Target extends SchemaTableLike, const Columns extends DdlColumnInput>(
|
|
6647
|
-
target: Target,
|
|
6810
|
+
type CreateIndexApi = <Target extends SchemaTableLike, const Columns extends DdlColumnInput, Name extends string = string>(
|
|
6811
|
+
target: Target & TableDialectConstraint<Target, Dialect>,
|
|
6648
6812
|
columns: Columns & ValidateDdlColumnInput<Target, Columns>,
|
|
6649
|
-
options?: CreateIndexOptions
|
|
6813
|
+
options?: CreateIndexOptions<Name>
|
|
6650
6814
|
) => QueryPlan<
|
|
6651
6815
|
{},
|
|
6652
6816
|
never,
|
|
@@ -6660,10 +6824,10 @@ type AsCurriedResult<
|
|
|
6660
6824
|
"createIndex"
|
|
6661
6825
|
>
|
|
6662
6826
|
|
|
6663
|
-
type DropIndexApi = <Target extends SchemaTableLike, const Columns extends DdlColumnInput>(
|
|
6664
|
-
target: Target,
|
|
6827
|
+
type DropIndexApi = <Target extends SchemaTableLike, const Columns extends DdlColumnInput, Name extends string = string>(
|
|
6828
|
+
target: Target & TableDialectConstraint<Target, Dialect>,
|
|
6665
6829
|
columns: Columns & ValidateDdlColumnInput<Target, Columns>,
|
|
6666
|
-
options?: DropIndexOptions
|
|
6830
|
+
options?: DropIndexOptions<Name>
|
|
6667
6831
|
) => QueryPlan<
|
|
6668
6832
|
{},
|
|
6669
6833
|
never,
|