effect-qb 4.0.0-beta.66 → 4.0.0-beta.98
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -2
- package/dist/index.js +9376 -0
- package/dist/mysql.js +3921 -2573
- package/dist/postgres/metadata.js +2491 -1373
- package/dist/postgres.js +5453 -5155
- package/dist/sqlite.js +6895 -5529
- package/dist/standard.js +9330 -0
- package/package.json +9 -2
- package/src/casing.ts +71 -0
- package/src/index.ts +2 -0
- package/src/internal/casing.ts +89 -0
- package/src/internal/coercion/rules.ts +13 -1
- package/src/internal/column-state.ts +21 -15
- package/src/internal/column.ts +44 -7
- package/src/internal/datatypes/define.ts +7 -1
- package/src/internal/datatypes/enrich.ts +23 -0
- package/src/internal/datatypes/lookup.ts +81 -25
- package/src/internal/datatypes/matrix.ts +903 -0
- package/src/internal/datatypes/shape.ts +2 -0
- package/src/internal/derived-table.ts +4 -36
- package/src/{mysql/internal/sql-expression-renderer.ts → internal/dialect-renderers/mysql.ts} +552 -361
- package/src/{postgres/internal/sql-expression-renderer.ts → internal/dialect-renderers/postgres.ts} +657 -400
- package/src/{sqlite/internal/sql-expression-renderer.ts → internal/dialect-renderers/sqlite.ts} +505 -347
- package/src/internal/dialect.ts +35 -0
- package/src/internal/dsl-mutation-runtime.ts +12 -162
- package/src/internal/dsl-plan-runtime.ts +10 -138
- package/src/internal/dsl-query-runtime.ts +5 -79
- package/src/internal/dsl-transaction-ddl-runtime.ts +41 -65
- package/src/internal/executor.ts +14 -16
- package/src/internal/grouping-key.ts +87 -20
- package/src/internal/implication-runtime.ts +1 -1
- package/src/internal/json/path-access.ts +351 -0
- package/src/internal/predicate/runtime.ts +3 -0
- package/src/internal/query.d.ts +38 -11
- package/src/internal/query.ts +64 -25
- package/src/internal/renderer.ts +26 -14
- package/src/internal/runtime/normalize.ts +12 -5
- package/src/internal/scalar.ts +7 -1
- package/src/internal/schema-derivation.d.ts +7 -7
- package/src/internal/schema-derivation.ts +9 -9
- package/src/internal/schema-expression.ts +2 -2
- package/src/internal/sql-expression-renderer.ts +19 -0
- package/src/internal/standard-dsl.ts +6978 -0
- package/src/internal/table-options.ts +126 -66
- package/src/internal/table.ts +652 -219
- package/src/mysql/column-extension.ts +3 -0
- package/src/mysql/column.ts +8 -9
- package/src/mysql/datatypes/index.ts +4 -2
- package/src/mysql/datatypes/spec.ts +6 -176
- package/src/mysql/errors/normalize.ts +0 -1
- package/src/mysql/executor.ts +7 -7
- package/src/mysql/internal/dialect.ts +9 -4
- package/src/mysql/internal/dsl.ts +312 -154
- package/src/mysql/internal/renderer.ts +6 -2
- package/src/mysql/json.ts +7 -2
- package/src/mysql/query-extension.ts +16 -0
- package/src/mysql/renderer.ts +37 -3
- package/src/mysql/type.ts +60 -0
- package/src/mysql.ts +7 -13
- package/src/postgres/check.ts +1 -0
- package/src/postgres/column-extension.ts +28 -0
- package/src/postgres/column.ts +2 -8
- package/src/postgres/datatypes/index.d.ts +2 -1
- package/src/postgres/datatypes/index.ts +4 -2
- package/src/postgres/datatypes/spec.ts +6 -260
- package/src/postgres/errors/normalize.ts +0 -1
- package/src/postgres/executor.ts +7 -7
- package/src/postgres/foreign-key.ts +24 -0
- package/src/postgres/function/core.ts +1 -3
- package/src/postgres/function/index.ts +1 -17
- package/src/postgres/index.ts +1 -0
- package/src/postgres/internal/dialect.ts +9 -4
- package/src/postgres/internal/dsl.ts +306 -163
- package/src/postgres/internal/renderer.ts +6 -2
- package/src/postgres/internal/schema-ddl.ts +22 -10
- package/src/postgres/internal/schema-model.ts +238 -7
- package/src/postgres/json-extension.ts +7 -0
- package/src/postgres/json.ts +762 -173
- package/src/postgres/jsonb.ts +37 -0
- package/src/postgres/primary-key.ts +24 -0
- package/src/postgres/query-extension.ts +2 -0
- package/src/postgres/renderer.ts +37 -3
- package/src/postgres/schema-management.ts +12 -11
- package/src/postgres/schema.ts +106 -15
- package/src/postgres/table.ts +205 -530
- package/src/postgres/type.ts +93 -10
- package/src/postgres/unique.ts +32 -0
- package/src/postgres.ts +20 -16
- package/src/sqlite/column-extension.ts +3 -0
- package/src/sqlite/column.ts +8 -9
- package/src/sqlite/datatypes/index.ts +4 -2
- package/src/sqlite/datatypes/spec.ts +6 -94
- package/src/sqlite/errors/normalize.ts +0 -1
- package/src/sqlite/executor.ts +7 -7
- package/src/sqlite/internal/dialect.ts +9 -4
- package/src/sqlite/internal/dsl.ts +301 -154
- package/src/sqlite/internal/renderer.ts +6 -2
- package/src/sqlite/json.ts +8 -2
- package/src/sqlite/query-extension.ts +2 -0
- package/src/sqlite/renderer.ts +37 -3
- package/src/sqlite/type.ts +40 -0
- package/src/sqlite.ts +7 -13
- package/src/standard/cast.ts +113 -0
- package/src/standard/check.ts +17 -0
- package/src/standard/column.ts +163 -0
- package/src/standard/datatypes/index.ts +83 -0
- package/src/standard/datatypes/spec.ts +12 -0
- package/src/standard/dialect.ts +40 -0
- package/src/standard/foreign-key.ts +37 -0
- package/src/standard/function/aggregate.ts +2 -0
- package/src/standard/function/core.ts +2 -0
- package/src/standard/function/index.ts +18 -0
- package/src/standard/function/string.ts +2 -0
- package/src/standard/function/temporal.ts +78 -0
- package/src/standard/function/window.ts +2 -0
- package/src/standard/index.ts +17 -0
- package/src/standard/internal/renderer.ts +45 -0
- package/src/standard/json.ts +883 -0
- package/src/standard/primary-key.ts +17 -0
- package/src/standard/query.ts +152 -0
- package/src/standard/renderer.ts +49 -0
- package/src/standard/table.ts +151 -0
- package/src/standard/unique.ts +17 -0
- package/src/standard.ts +32 -0
- package/src/internal/aggregation-validation.ts +0 -57
- package/src/internal/table.d.ts +0 -180
- package/src/mysql/table.ts +0 -186
- package/src/postgres/cast.ts +0 -45
- package/src/sqlite/table.ts +0 -175
|
@@ -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,
|
|
@@ -135,7 +142,7 @@ import * as ProjectionAlias from "../../internal/projection-alias.js"
|
|
|
135
142
|
import * as QueryAst from "../../internal/query-ast.js"
|
|
136
143
|
import { normalizeColumnList } from "../../internal/table-options.js"
|
|
137
144
|
|
|
138
|
-
type MutationTargetLike = Table.AnyTable<Dialect>
|
|
145
|
+
type MutationTargetLike = Table.AnyTable<Dialect | "standard">
|
|
139
146
|
type MutationTargetTuple = readonly [MutationTargetLike, MutationTargetLike, ...MutationTargetLike[]]
|
|
140
147
|
type MutationTargetInput = MutationTargetLike | MutationTargetTuple
|
|
141
148
|
|
|
@@ -711,7 +718,7 @@ type NumericExpressionDialectInput<
|
|
|
711
718
|
BoolDb extends Expression.DbType.Any,
|
|
712
719
|
TimestampDb extends Expression.DbType.Any,
|
|
713
720
|
NullDb extends Expression.DbType.Any
|
|
714
|
-
> = 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
|
|
715
722
|
? unknown
|
|
716
723
|
: {
|
|
717
724
|
readonly __effect_qb_error__: "effect-qb: numeric expressions cannot mix dialects"
|
|
@@ -804,6 +811,35 @@ type DialectExpressionArray<
|
|
|
804
811
|
? Tuple
|
|
805
812
|
: never
|
|
806
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
|
+
|
|
807
843
|
/** Normalized expression tuple for generic string operator inputs. */
|
|
808
844
|
type DialectStringExpressionTuple<
|
|
809
845
|
Values extends readonly ExpressionInput[],
|
|
@@ -1070,6 +1106,9 @@ type JsonPathInput = JsonPath.Path<any> | JsonPath.CanonicalSegment
|
|
|
1070
1106
|
|
|
1071
1107
|
type JsonQueryInput = JsonPath.Path<any> | StringExpressionInput
|
|
1072
1108
|
|
|
1109
|
+
type JsonQueryValue<Query extends JsonQueryInput> =
|
|
1110
|
+
Query extends string ? LiteralStringInput<Query> : Query
|
|
1111
|
+
|
|
1073
1112
|
type JsonPathOutputOf<
|
|
1074
1113
|
Root,
|
|
1075
1114
|
Target extends JsonPathInput,
|
|
@@ -1527,7 +1566,7 @@ const profile: QueryDialectProfile<Dialect, TextDb, NumericDb, BoolDb, Timestamp
|
|
|
1527
1566
|
type: mysqlDatatypes
|
|
1528
1567
|
}
|
|
1529
1568
|
const ValuesInputProto = {
|
|
1530
|
-
pipe(this:
|
|
1569
|
+
pipe(this: Pipeable) {
|
|
1531
1570
|
return pipeArguments(this, arguments)
|
|
1532
1571
|
}
|
|
1533
1572
|
}
|
|
@@ -1538,6 +1577,9 @@ const profile: QueryDialectProfile<Dialect, TextDb, NumericDb, BoolDb, Timestamp
|
|
|
1538
1577
|
if (value === null || value instanceof Date) {
|
|
1539
1578
|
return undefined
|
|
1540
1579
|
}
|
|
1580
|
+
if (typeof value === "number" && !Number.isFinite(value)) {
|
|
1581
|
+
return undefined
|
|
1582
|
+
}
|
|
1541
1583
|
return Schema.Literal(value) as unknown as Schema.Top
|
|
1542
1584
|
}
|
|
1543
1585
|
|
|
@@ -1625,7 +1667,7 @@ const profile: QueryDialectProfile<Dialect, TextDb, NumericDb, BoolDb, Timestamp
|
|
|
1625
1667
|
value: Expression.Any,
|
|
1626
1668
|
target: Expression.Any
|
|
1627
1669
|
): Expression.Any => {
|
|
1628
|
-
const ast = (value as
|
|
1670
|
+
const ast = (value as Expression.Any & { readonly [ExpressionAst.TypeId]: ExpressionAst.Any })[ExpressionAst.TypeId]
|
|
1629
1671
|
if (ast.kind !== "literal") {
|
|
1630
1672
|
return value
|
|
1631
1673
|
}
|
|
@@ -1646,8 +1688,8 @@ const profile: QueryDialectProfile<Dialect, TextDb, NumericDb, BoolDb, Timestamp
|
|
|
1646
1688
|
left: Expression.Any,
|
|
1647
1689
|
right: Expression.Any
|
|
1648
1690
|
): readonly [Expression.Any, Expression.Any] => {
|
|
1649
|
-
const leftAst = (left as
|
|
1650
|
-
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]
|
|
1651
1693
|
if (leftAst.kind === "literal" && rightAst.kind !== "literal") {
|
|
1652
1694
|
return [retargetLiteralExpression(left, right), right]
|
|
1653
1695
|
}
|
|
@@ -1680,7 +1722,7 @@ const profile: QueryDialectProfile<Dialect, TextDb, NumericDb, BoolDb, Timestamp
|
|
|
1680
1722
|
): readonly Expression.Any[] => {
|
|
1681
1723
|
const flattened: Array<Expression.Any> = []
|
|
1682
1724
|
for (const value of values) {
|
|
1683
|
-
const ast = (value as
|
|
1725
|
+
const ast = (value as Expression.Any & { readonly [ExpressionAst.TypeId]: ExpressionAst.Any })[ExpressionAst.TypeId]
|
|
1684
1726
|
if (ast.kind === kind) {
|
|
1685
1727
|
flattened.push(...ast.values)
|
|
1686
1728
|
} else {
|
|
@@ -1726,7 +1768,33 @@ const profile: QueryDialectProfile<Dialect, TextDb, NumericDb, BoolDb, Timestamp
|
|
|
1726
1768
|
if (operations.every((operation) => typeof operation === "function")) {
|
|
1727
1769
|
return pipeArguments(this, arguments)
|
|
1728
1770
|
}
|
|
1729
|
-
|
|
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
|
|
1730
1798
|
}
|
|
1731
1799
|
})
|
|
1732
1800
|
|
|
@@ -1747,9 +1815,6 @@ const profile: QueryDialectProfile<Dialect, TextDb, NumericDb, BoolDb, Timestamp
|
|
|
1747
1815
|
const partitionBy = [...(spec?.partitionBy ?? [])] as unknown as PartitionBy
|
|
1748
1816
|
const orderBy = (spec?.orderBy ?? []).map((term) => {
|
|
1749
1817
|
const direction = term.direction ?? "asc"
|
|
1750
|
-
if (direction !== "asc" && direction !== "desc") {
|
|
1751
|
-
throw new Error("window order direction must be asc or desc")
|
|
1752
|
-
}
|
|
1753
1818
|
return {
|
|
1754
1819
|
value: term.value,
|
|
1755
1820
|
direction
|
|
@@ -1890,7 +1955,8 @@ type BinaryPredicateExpression<
|
|
|
1890
1955
|
>(
|
|
1891
1956
|
...args: ComparableArgs<Left, Right, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb, "eq">
|
|
1892
1957
|
): BinaryPredicateExpression<Left, Right, "eq"> => {
|
|
1893
|
-
const
|
|
1958
|
+
const left = args[0] as Left
|
|
1959
|
+
const right = args[1] as Right
|
|
1894
1960
|
return buildBinaryPredicate(left as ExpressionInput, right as ExpressionInput, "eq")
|
|
1895
1961
|
}
|
|
1896
1962
|
|
|
@@ -1900,7 +1966,8 @@ type BinaryPredicateExpression<
|
|
|
1900
1966
|
>(
|
|
1901
1967
|
...args: ComparableArgs<Left, Right, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb, "neq">
|
|
1902
1968
|
): BinaryPredicateExpression<Left, Right, "neq"> => {
|
|
1903
|
-
const
|
|
1969
|
+
const left = args[0] as Left
|
|
1970
|
+
const right = args[1] as Right
|
|
1904
1971
|
return buildBinaryPredicate(left as ExpressionInput, right as ExpressionInput, "neq")
|
|
1905
1972
|
}
|
|
1906
1973
|
|
|
@@ -1910,7 +1977,8 @@ type BinaryPredicateExpression<
|
|
|
1910
1977
|
>(
|
|
1911
1978
|
...args: ComparableArgs<Left, Right, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb, "lt">
|
|
1912
1979
|
): BinaryPredicateExpression<Left, Right, "lt"> => {
|
|
1913
|
-
const
|
|
1980
|
+
const left = args[0] as Left
|
|
1981
|
+
const right = args[1] as Right
|
|
1914
1982
|
return buildBinaryPredicate(left as ExpressionInput, right as ExpressionInput, "lt")
|
|
1915
1983
|
}
|
|
1916
1984
|
|
|
@@ -1920,7 +1988,8 @@ type BinaryPredicateExpression<
|
|
|
1920
1988
|
>(
|
|
1921
1989
|
...args: ComparableArgs<Left, Right, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb, "lte">
|
|
1922
1990
|
): BinaryPredicateExpression<Left, Right, "lte"> => {
|
|
1923
|
-
const
|
|
1991
|
+
const left = args[0] as Left
|
|
1992
|
+
const right = args[1] as Right
|
|
1924
1993
|
return buildBinaryPredicate(left as ExpressionInput, right as ExpressionInput, "lte")
|
|
1925
1994
|
}
|
|
1926
1995
|
|
|
@@ -1930,7 +1999,8 @@ type BinaryPredicateExpression<
|
|
|
1930
1999
|
>(
|
|
1931
2000
|
...args: ComparableArgs<Left, Right, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb, "gt">
|
|
1932
2001
|
): BinaryPredicateExpression<Left, Right, "gt"> => {
|
|
1933
|
-
const
|
|
2002
|
+
const left = args[0] as Left
|
|
2003
|
+
const right = args[1] as Right
|
|
1934
2004
|
return buildBinaryPredicate(left as ExpressionInput, right as ExpressionInput, "gt")
|
|
1935
2005
|
}
|
|
1936
2006
|
|
|
@@ -1940,7 +2010,8 @@ type BinaryPredicateExpression<
|
|
|
1940
2010
|
>(
|
|
1941
2011
|
...args: ComparableArgs<Left, Right, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb, "gte">
|
|
1942
2012
|
): BinaryPredicateExpression<Left, Right, "gte"> => {
|
|
1943
|
-
const
|
|
2013
|
+
const left = args[0] as Left
|
|
2014
|
+
const right = args[1] as Right
|
|
1944
2015
|
return buildBinaryPredicate(left as ExpressionInput, right as ExpressionInput, "gte")
|
|
1945
2016
|
}
|
|
1946
2017
|
|
|
@@ -1950,7 +2021,8 @@ type BinaryPredicateExpression<
|
|
|
1950
2021
|
>(
|
|
1951
2022
|
...args: TextArgs<Left, Right, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb, "like">
|
|
1952
2023
|
): BinaryPredicateExpression<Left, Right, "like"> => {
|
|
1953
|
-
const
|
|
2024
|
+
const left = args[0] as Left
|
|
2025
|
+
const right = args[1] as Right
|
|
1954
2026
|
return buildBinaryPredicate(left as ExpressionInput, right as ExpressionInput, "like")
|
|
1955
2027
|
}
|
|
1956
2028
|
|
|
@@ -1960,7 +2032,8 @@ type BinaryPredicateExpression<
|
|
|
1960
2032
|
>(
|
|
1961
2033
|
...args: TextArgs<Left, Right, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb, "ilike">
|
|
1962
2034
|
): BinaryPredicateExpression<Left, Right, "ilike"> => {
|
|
1963
|
-
const
|
|
2035
|
+
const left = args[0] as Left
|
|
2036
|
+
const right = args[1] as Right
|
|
1964
2037
|
return buildBinaryPredicate(left as ExpressionInput, right as ExpressionInput, "ilike")
|
|
1965
2038
|
}
|
|
1966
2039
|
|
|
@@ -1970,7 +2043,8 @@ type BinaryPredicateExpression<
|
|
|
1970
2043
|
>(
|
|
1971
2044
|
...args: TextArgs<Left, Right, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb, "regexMatch">
|
|
1972
2045
|
): BinaryPredicateExpression<Left, Right, "regexMatch"> => {
|
|
1973
|
-
const
|
|
2046
|
+
const left = args[0] as Left
|
|
2047
|
+
const right = args[1] as Right
|
|
1974
2048
|
return buildBinaryPredicate(left as ExpressionInput, right as ExpressionInput, "regexMatch")
|
|
1975
2049
|
}
|
|
1976
2050
|
|
|
@@ -1980,7 +2054,8 @@ type BinaryPredicateExpression<
|
|
|
1980
2054
|
>(
|
|
1981
2055
|
...args: TextArgs<Left, Right, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb, "regexIMatch">
|
|
1982
2056
|
): BinaryPredicateExpression<Left, Right, "regexIMatch"> => {
|
|
1983
|
-
const
|
|
2057
|
+
const left = args[0] as Left
|
|
2058
|
+
const right = args[1] as Right
|
|
1984
2059
|
return buildBinaryPredicate(left as ExpressionInput, right as ExpressionInput, "regexIMatch")
|
|
1985
2060
|
}
|
|
1986
2061
|
|
|
@@ -1990,7 +2065,8 @@ type BinaryPredicateExpression<
|
|
|
1990
2065
|
>(
|
|
1991
2066
|
...args: TextArgs<Left, Right, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb, "regexNotMatch">
|
|
1992
2067
|
): BinaryPredicateExpression<Left, Right, "regexNotMatch"> => {
|
|
1993
|
-
const
|
|
2068
|
+
const left = args[0] as Left
|
|
2069
|
+
const right = args[1] as Right
|
|
1994
2070
|
return buildBinaryPredicate(left as ExpressionInput, right as ExpressionInput, "regexNotMatch")
|
|
1995
2071
|
}
|
|
1996
2072
|
|
|
@@ -2000,7 +2076,8 @@ type BinaryPredicateExpression<
|
|
|
2000
2076
|
>(
|
|
2001
2077
|
...args: TextArgs<Left, Right, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb, "regexNotIMatch">
|
|
2002
2078
|
): BinaryPredicateExpression<Left, Right, "regexNotIMatch"> => {
|
|
2003
|
-
const
|
|
2079
|
+
const left = args[0] as Left
|
|
2080
|
+
const right = args[1] as Right
|
|
2004
2081
|
return buildBinaryPredicate(left as ExpressionInput, right as ExpressionInput, "regexNotIMatch")
|
|
2005
2082
|
}
|
|
2006
2083
|
|
|
@@ -2010,7 +2087,8 @@ type BinaryPredicateExpression<
|
|
|
2010
2087
|
>(
|
|
2011
2088
|
...args: ComparableArgs<Left, Right, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb, "isDistinctFrom">
|
|
2012
2089
|
): BinaryPredicateExpression<Left, Right, "isDistinctFrom", "never"> => {
|
|
2013
|
-
const
|
|
2090
|
+
const left = args[0] as Left
|
|
2091
|
+
const right = args[1] as Right
|
|
2014
2092
|
return buildBinaryPredicate(left as ExpressionInput, right as ExpressionInput, "isDistinctFrom", "never")
|
|
2015
2093
|
}
|
|
2016
2094
|
|
|
@@ -2020,7 +2098,8 @@ type BinaryPredicateExpression<
|
|
|
2020
2098
|
>(
|
|
2021
2099
|
...args: ComparableArgs<Left, Right, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb, "isNotDistinctFrom">
|
|
2022
2100
|
): BinaryPredicateExpression<Left, Right, "isNotDistinctFrom", "never"> => {
|
|
2023
|
-
const
|
|
2101
|
+
const left = args[0] as Left
|
|
2102
|
+
const right = args[1] as Right
|
|
2024
2103
|
return buildBinaryPredicate(left as ExpressionInput, right as ExpressionInput, "isNotDistinctFrom", "never")
|
|
2025
2104
|
}
|
|
2026
2105
|
|
|
@@ -2171,62 +2250,62 @@ type BinaryPredicateExpression<
|
|
|
2171
2250
|
})
|
|
2172
2251
|
|
|
2173
2252
|
const range = <Kind extends string, Subtype extends Expression.DbType.Any>(
|
|
2174
|
-
kind: Kind
|
|
2253
|
+
kind: NonEmptyStringInput<Kind>,
|
|
2175
2254
|
subtype: Subtype
|
|
2176
2255
|
): Expression.DbType.Range<Dialect, Subtype, Kind> => ({
|
|
2177
2256
|
dialect: profile.dialect,
|
|
2178
|
-
kind,
|
|
2257
|
+
kind: kind as Kind,
|
|
2179
2258
|
subtype
|
|
2180
2259
|
})
|
|
2181
2260
|
|
|
2182
2261
|
const multirange = <Kind extends string, Subtype extends Expression.DbType.Any>(
|
|
2183
|
-
kind: Kind
|
|
2262
|
+
kind: NonEmptyStringInput<Kind>,
|
|
2184
2263
|
subtype: Subtype
|
|
2185
2264
|
): Expression.DbType.Multirange<Dialect, Subtype, Kind> => ({
|
|
2186
2265
|
dialect: profile.dialect,
|
|
2187
|
-
kind,
|
|
2266
|
+
kind: kind as Kind,
|
|
2188
2267
|
subtype
|
|
2189
2268
|
})
|
|
2190
2269
|
|
|
2191
2270
|
const record = <Kind extends string, Fields extends Record<string, Expression.DbType.Any>>(
|
|
2192
|
-
kind: Kind
|
|
2271
|
+
kind: NonEmptyStringInput<Kind>,
|
|
2193
2272
|
fields: Fields
|
|
2194
2273
|
): Expression.DbType.Composite<Dialect, Fields, Kind> => ({
|
|
2195
2274
|
dialect: profile.dialect,
|
|
2196
|
-
kind,
|
|
2275
|
+
kind: kind as Kind,
|
|
2197
2276
|
fields
|
|
2198
2277
|
})
|
|
2199
2278
|
|
|
2200
2279
|
const domain = <Kind extends string, Base extends Expression.DbType.Any>(
|
|
2201
|
-
kind: Kind
|
|
2280
|
+
kind: NonEmptyStringInput<Kind>,
|
|
2202
2281
|
base: Base
|
|
2203
2282
|
): Expression.DbType.Domain<Dialect, Base, Kind> => ({
|
|
2204
2283
|
dialect: profile.dialect,
|
|
2205
|
-
kind,
|
|
2284
|
+
kind: kind as Kind,
|
|
2206
2285
|
base
|
|
2207
2286
|
})
|
|
2208
2287
|
|
|
2209
2288
|
const enum_ = <Kind extends string>(
|
|
2210
|
-
kind: Kind
|
|
2289
|
+
kind: NonEmptyStringInput<Kind>
|
|
2211
2290
|
): Expression.DbType.Enum<Dialect, Kind> => ({
|
|
2212
2291
|
dialect: profile.dialect,
|
|
2213
|
-
kind,
|
|
2292
|
+
kind: kind as Kind,
|
|
2214
2293
|
variant: "enum"
|
|
2215
2294
|
})
|
|
2216
2295
|
|
|
2217
2296
|
const set = <Kind extends string>(
|
|
2218
|
-
kind: Kind
|
|
2297
|
+
kind: NonEmptyStringInput<Kind>
|
|
2219
2298
|
): Expression.DbType.Set<Dialect, Kind> => ({
|
|
2220
2299
|
dialect: profile.dialect,
|
|
2221
|
-
kind,
|
|
2300
|
+
kind: kind as Kind,
|
|
2222
2301
|
variant: "set"
|
|
2223
2302
|
})
|
|
2224
2303
|
|
|
2225
2304
|
const custom = <Kind extends string>(
|
|
2226
|
-
kind: Kind
|
|
2305
|
+
kind: NonEmptyStringInput<Kind>
|
|
2227
2306
|
): Expression.DbType.Base<Dialect, Kind> => ({
|
|
2228
2307
|
dialect: profile.dialect,
|
|
2229
|
-
kind
|
|
2308
|
+
kind: kind as Kind
|
|
2230
2309
|
})
|
|
2231
2310
|
|
|
2232
2311
|
const driverValueMapping = <Db extends Expression.DbType.Any>(
|
|
@@ -3034,9 +3113,12 @@ type BinaryPredicateExpression<
|
|
|
3034
3113
|
}
|
|
3035
3114
|
)
|
|
3036
3115
|
|
|
3037
|
-
const jsonPathExists = <
|
|
3116
|
+
const jsonPathExists = <
|
|
3117
|
+
Base extends JsonExpressionLike<any>,
|
|
3118
|
+
Query extends JsonQueryInput
|
|
3119
|
+
>(
|
|
3038
3120
|
base: Base,
|
|
3039
|
-
query:
|
|
3121
|
+
query: JsonQueryValue<Query>
|
|
3040
3122
|
) => {
|
|
3041
3123
|
if (isJsonPathValue(query)) {
|
|
3042
3124
|
return buildJsonNodeExpression(
|
|
@@ -3084,9 +3166,12 @@ type BinaryPredicateExpression<
|
|
|
3084
3166
|
}
|
|
3085
3167
|
)
|
|
3086
3168
|
|
|
3087
|
-
const jsonPathMatch = <
|
|
3169
|
+
const jsonPathMatch = <
|
|
3170
|
+
Base extends JsonExpressionLike<any>,
|
|
3171
|
+
Query extends JsonQueryInput
|
|
3172
|
+
>(
|
|
3088
3173
|
base: Base,
|
|
3089
|
-
query:
|
|
3174
|
+
query: JsonQueryValue<Query>
|
|
3090
3175
|
) => {
|
|
3091
3176
|
if (isJsonPathValue(query)) {
|
|
3092
3177
|
return buildJsonNodeExpression(
|
|
@@ -3313,7 +3398,8 @@ type BinaryPredicateExpression<
|
|
|
3313
3398
|
>(
|
|
3314
3399
|
...args: ContainmentArgs<Left, Right, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb, "contains">
|
|
3315
3400
|
): BinaryPredicateExpression<Left, Right, "contains"> => {
|
|
3316
|
-
const
|
|
3401
|
+
const left = args[0] as Left
|
|
3402
|
+
const right = args[1] as Right
|
|
3317
3403
|
return buildBinaryPredicate(left as ExpressionInput, right as ExpressionInput, "contains")
|
|
3318
3404
|
}
|
|
3319
3405
|
|
|
@@ -3323,7 +3409,8 @@ type BinaryPredicateExpression<
|
|
|
3323
3409
|
>(
|
|
3324
3410
|
...args: ContainmentArgs<Left, Right, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb, "containedBy">
|
|
3325
3411
|
): BinaryPredicateExpression<Left, Right, "containedBy"> => {
|
|
3326
|
-
const
|
|
3412
|
+
const left = args[0] as Left
|
|
3413
|
+
const right = args[1] as Right
|
|
3327
3414
|
return buildBinaryPredicate(left as ExpressionInput, right as ExpressionInput, "containedBy")
|
|
3328
3415
|
}
|
|
3329
3416
|
|
|
@@ -3333,7 +3420,8 @@ type BinaryPredicateExpression<
|
|
|
3333
3420
|
>(
|
|
3334
3421
|
...args: ContainmentArgs<Left, Right, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb, "overlaps">
|
|
3335
3422
|
): BinaryPredicateExpression<Left, Right, "overlaps"> => {
|
|
3336
|
-
const
|
|
3423
|
+
const left = args[0] as Left
|
|
3424
|
+
const right = args[1] as Right
|
|
3337
3425
|
return buildBinaryPredicate(left as ExpressionInput, right as ExpressionInput, "overlaps")
|
|
3338
3426
|
}
|
|
3339
3427
|
|
|
@@ -3760,12 +3848,9 @@ type BinaryPredicateExpression<
|
|
|
3760
3848
|
>
|
|
3761
3849
|
}
|
|
3762
3850
|
|
|
3763
|
-
const call =
|
|
3764
|
-
|
|
3765
|
-
|
|
3766
|
-
>(
|
|
3767
|
-
name: Name,
|
|
3768
|
-
...args: Args
|
|
3851
|
+
const call: FunctionCallApi = (
|
|
3852
|
+
name: string,
|
|
3853
|
+
...args: readonly ExpressionInput[]
|
|
3769
3854
|
): Expression.Any => {
|
|
3770
3855
|
const expressions = args.map((value) => toDialectExpression(value)) as readonly Expression.Any[]
|
|
3771
3856
|
return makeExpression({
|
|
@@ -4001,9 +4086,6 @@ type BinaryPredicateExpression<
|
|
|
4001
4086
|
ExpressionAst.ExcludedNode<AstOf<Value> extends ExpressionAst.ColumnNode<any, infer ColumnName extends string> ? ColumnName : string>
|
|
4002
4087
|
> => {
|
|
4003
4088
|
const ast = ((value as unknown) as Expression.Any & { readonly [ExpressionAst.TypeId]: ExpressionAst.Any })[ExpressionAst.TypeId]
|
|
4004
|
-
if (ast.kind !== "column") {
|
|
4005
|
-
throw new Error("excluded(...) only accepts bound table columns")
|
|
4006
|
-
}
|
|
4007
4089
|
return makeExpression({
|
|
4008
4090
|
runtime: undefined as Expression.RuntimeOf<Value>,
|
|
4009
4091
|
dbType: value[Expression.TypeId].dbType as Expression.DbTypeOf<Value>,
|
|
@@ -4016,7 +4098,7 @@ type BinaryPredicateExpression<
|
|
|
4016
4098
|
dependencies: {}
|
|
4017
4099
|
}, {
|
|
4018
4100
|
kind: "excluded",
|
|
4019
|
-
columnName: ast.columnName
|
|
4101
|
+
columnName: (ast as ExpressionAst.ColumnNode<any, string>).columnName
|
|
4020
4102
|
}) as unknown as AstBackedExpression<
|
|
4021
4103
|
Expression.RuntimeOf<Value>,
|
|
4022
4104
|
Expression.DbTypeOf<Value>,
|
|
@@ -4049,7 +4131,7 @@ type BinaryPredicateExpression<
|
|
|
4049
4131
|
}
|
|
4050
4132
|
if (value !== null && typeof value === "object" && Expression.TypeId in value) {
|
|
4051
4133
|
const expression = value as unknown as Expression.Any
|
|
4052
|
-
const ast = (expression as
|
|
4134
|
+
const ast = (expression as Expression.Any & { readonly [ExpressionAst.TypeId]: ExpressionAst.Any })[ExpressionAst.TypeId]
|
|
4053
4135
|
if (ast.kind === "literal") {
|
|
4054
4136
|
const normalizedValue = normalizeMutationValue(ast.value)
|
|
4055
4137
|
return makeExpression({
|
|
@@ -4118,8 +4200,8 @@ type BinaryPredicateExpression<
|
|
|
4118
4200
|
: ">="
|
|
4119
4201
|
|
|
4120
4202
|
const targetSourceDetails = (table: MutationTargetLike | SchemaTableLike) => {
|
|
4121
|
-
const sourceName = (table as
|
|
4122
|
-
const sourceBaseName = (table as
|
|
4203
|
+
const sourceName = (table as TableLike)[Table.TypeId].name
|
|
4204
|
+
const sourceBaseName = (table as TableLike)[Table.TypeId].baseName
|
|
4123
4205
|
return {
|
|
4124
4206
|
sourceName,
|
|
4125
4207
|
sourceBaseName
|
|
@@ -4209,12 +4291,7 @@ type BinaryPredicateExpression<
|
|
|
4209
4291
|
|
|
4210
4292
|
const normalizeUnnestColumns = (columns: UnnestColumnsInput): Record<string, readonly Expression.Any[]> =>
|
|
4211
4293
|
Object.fromEntries(
|
|
4212
|
-
Object.entries(columns).map(([key, values]) =>
|
|
4213
|
-
if (!Array.isArray(values)) {
|
|
4214
|
-
throw new Error("unnest(...) expects every value to be an array")
|
|
4215
|
-
}
|
|
4216
|
-
return [key, values.map((value) => toDialectExpression(value))]
|
|
4217
|
-
})
|
|
4294
|
+
Object.entries(columns).map(([key, values]) => [key, values.map((value) => toDialectExpression(value))])
|
|
4218
4295
|
) as Record<string, readonly Expression.Any[]>
|
|
4219
4296
|
|
|
4220
4297
|
const normalizeMutationTargets = (
|
|
@@ -4260,13 +4337,7 @@ type BinaryPredicateExpression<
|
|
|
4260
4337
|
const getMutationColumn = (
|
|
4261
4338
|
columns: Record<string, unknown>,
|
|
4262
4339
|
columnName: string
|
|
4263
|
-
): Expression.Any =>
|
|
4264
|
-
const column = columns[columnName]
|
|
4265
|
-
if (column === undefined || column === null || typeof column !== "object" || !(Expression.TypeId in column)) {
|
|
4266
|
-
throw new Error("effect-qb: unknown mutation column")
|
|
4267
|
-
}
|
|
4268
|
-
return column as Expression.Any
|
|
4269
|
-
}
|
|
4340
|
+
): Expression.Any => columns[columnName] as Expression.Any
|
|
4270
4341
|
|
|
4271
4342
|
const buildMutationAssignments = <Target extends MutationTargetInput, Values>(
|
|
4272
4343
|
target: Target,
|
|
@@ -4282,7 +4353,7 @@ type BinaryPredicateExpression<
|
|
|
4282
4353
|
}
|
|
4283
4354
|
const valueMap = values as Record<string, Record<string, unknown> | undefined>
|
|
4284
4355
|
return targets.flatMap((table) => {
|
|
4285
|
-
const targetName = (table as
|
|
4356
|
+
const targetName = (table as TableLike)[Table.TypeId].name
|
|
4286
4357
|
const scopedValues = valueMap[targetName] ?? {}
|
|
4287
4358
|
const columns = table as unknown as Record<string, Expression.Any>
|
|
4288
4359
|
return Object.entries(scopedValues).map(([columnName, value]) => ({
|
|
@@ -4303,20 +4374,17 @@ type BinaryPredicateExpression<
|
|
|
4303
4374
|
} => {
|
|
4304
4375
|
const firstRow = rows[0]
|
|
4305
4376
|
const firstColumns = Object.keys(firstRow)
|
|
4306
|
-
if (firstColumns.length === 0) {
|
|
4307
|
-
throw new Error("values(...) rows must specify at least one column; use insert(target) for default-only inserts instead")
|
|
4308
|
-
}
|
|
4309
4377
|
const columns = firstColumns as [string, ...string[]]
|
|
4310
|
-
const
|
|
4311
|
-
const rowKeys = Object.keys(row)
|
|
4312
|
-
if (rowKeys.length !== columns.length || columns.some((column) => !(column in row))) {
|
|
4313
|
-
throw new Error("All values(...) rows must project the same columns in the same shape")
|
|
4314
|
-
}
|
|
4378
|
+
const normalizeRow = (row: InsertRowInput<Target>) => {
|
|
4315
4379
|
const assignments = buildMutationAssignments(target, row) as readonly QueryAst.AssignmentClause[]
|
|
4316
4380
|
return {
|
|
4317
4381
|
values: columns.map((columnName) => assignments.find((assignment) => assignment.columnName === columnName)!)
|
|
4318
4382
|
} satisfies QueryAst.InsertValuesRowClause
|
|
4319
|
-
}
|
|
4383
|
+
}
|
|
4384
|
+
const normalizedRows: readonly [QueryAst.InsertValuesRowClause, ...QueryAst.InsertValuesRowClause[]] = [
|
|
4385
|
+
normalizeRow(rows[0]),
|
|
4386
|
+
...rows.slice(1).map(normalizeRow)
|
|
4387
|
+
]
|
|
4320
4388
|
const required = normalizedRows.flatMap((row) =>
|
|
4321
4389
|
row.values.flatMap((entry) => Object.keys(entry.value[Expression.TypeId].dependencies))
|
|
4322
4390
|
)
|
|
@@ -4331,9 +4399,6 @@ type BinaryPredicateExpression<
|
|
|
4331
4399
|
selection: Record<string, Expression.Any>
|
|
4332
4400
|
): readonly [string, ...string[]] => {
|
|
4333
4401
|
const columns = Object.keys(selection)
|
|
4334
|
-
if (columns.length === 0) {
|
|
4335
|
-
throw new Error("insert(...).pipe(from(subquery)) requires at least one projected column")
|
|
4336
|
-
}
|
|
4337
4402
|
return columns as [string, ...string[]]
|
|
4338
4403
|
}
|
|
4339
4404
|
|
|
@@ -4348,27 +4413,11 @@ type BinaryPredicateExpression<
|
|
|
4348
4413
|
}[]
|
|
4349
4414
|
} => {
|
|
4350
4415
|
const entries = Object.entries(values)
|
|
4351
|
-
if (entries.length === 0) {
|
|
4352
|
-
throw new Error("unnest(...) requires at least one column array")
|
|
4353
|
-
}
|
|
4354
4416
|
const columns = entries.map(([columnName]) => columnName) as [string, ...string[]]
|
|
4355
|
-
const normalized = entries.map(([columnName, items]) => {
|
|
4356
|
-
|
|
4357
|
-
|
|
4358
|
-
|
|
4359
|
-
return {
|
|
4360
|
-
columnName,
|
|
4361
|
-
values: items
|
|
4362
|
-
}
|
|
4363
|
-
})
|
|
4364
|
-
const expectedLength = normalized[0]!.values.length
|
|
4365
|
-
if (normalized.some((entry) => entry.values.length !== expectedLength)) {
|
|
4366
|
-
throw new Error("unnest(...) expects every column array to have the same length")
|
|
4367
|
-
}
|
|
4368
|
-
const knownColumns = new Set(Object.keys(target[Table.TypeId].fields))
|
|
4369
|
-
if (columns.some((columnName) => !knownColumns.has(columnName))) {
|
|
4370
|
-
throw new Error("unnest(...) received a column that does not exist on the target table")
|
|
4371
|
-
}
|
|
4417
|
+
const normalized = entries.map(([columnName, items]) => ({
|
|
4418
|
+
columnName,
|
|
4419
|
+
values: items
|
|
4420
|
+
}))
|
|
4372
4421
|
return {
|
|
4373
4422
|
columns,
|
|
4374
4423
|
values: normalized
|
|
@@ -4380,10 +4429,6 @@ type BinaryPredicateExpression<
|
|
|
4380
4429
|
columnsInput: string | readonly string[]
|
|
4381
4430
|
): readonly [string, ...string[]] => {
|
|
4382
4431
|
const columns = normalizeColumnList(columnsInput) as readonly [string, ...string[]]
|
|
4383
|
-
const knownColumns = new Set(Object.keys(target[Table.TypeId].fields))
|
|
4384
|
-
if (columns.some((columnName) => !knownColumns.has(columnName))) {
|
|
4385
|
-
throw new Error("effect-qb: unknown conflict target column")
|
|
4386
|
-
}
|
|
4387
4432
|
return columns
|
|
4388
4433
|
}
|
|
4389
4434
|
|
|
@@ -4397,7 +4442,21 @@ type BinaryPredicateExpression<
|
|
|
4397
4442
|
columns: normalizeConflictColumns(target, input)
|
|
4398
4443
|
}
|
|
4399
4444
|
}
|
|
4400
|
-
|
|
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
|
+
}
|
|
4401
4460
|
}
|
|
4402
4461
|
|
|
4403
4462
|
const defaultIndexName = (
|
|
@@ -4448,14 +4507,91 @@ type ValidateTargetColumnInput<
|
|
|
4448
4507
|
Columns extends DdlColumnInput
|
|
4449
4508
|
> = ValidateTargetColumns<Target, NormalizeDdlColumns<Columns>> extends never ? never : Columns
|
|
4450
4509
|
|
|
4451
|
-
type
|
|
4452
|
-
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>
|
|
4453
4589
|
readonly unique?: boolean
|
|
4454
4590
|
readonly ifNotExists?: never
|
|
4455
4591
|
}
|
|
4456
4592
|
|
|
4457
|
-
type DropIndexOptions = {
|
|
4458
|
-
readonly name?:
|
|
4593
|
+
type DropIndexOptions<Name extends string = string> = {
|
|
4594
|
+
readonly name?: NonEmptyStringInput<Name>
|
|
4459
4595
|
readonly ifExists?: never
|
|
4460
4596
|
}
|
|
4461
4597
|
|
|
@@ -4559,7 +4695,7 @@ type ValuesRowsDialectInput<
|
|
|
4559
4695
|
BoolDb extends Expression.DbType.Any,
|
|
4560
4696
|
TimestampDb extends Expression.DbType.Any,
|
|
4561
4697
|
NullDb extends Expression.DbType.Any
|
|
4562
|
-
> = 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
|
|
4563
4699
|
? unknown
|
|
4564
4700
|
: {
|
|
4565
4701
|
readonly __effect_qb_error__: "effect-qb: values rows cannot mix dialects"
|
|
@@ -4614,7 +4750,7 @@ type UnnestColumnsDialectInput<
|
|
|
4614
4750
|
BoolDb extends Expression.DbType.Any,
|
|
4615
4751
|
TimestampDb extends Expression.DbType.Any,
|
|
4616
4752
|
NullDb extends Expression.DbType.Any
|
|
4617
|
-
> = 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
|
|
4618
4754
|
? unknown
|
|
4619
4755
|
: {
|
|
4620
4756
|
readonly __effect_qb_error__: "effect-qb: unnest columns cannot mix dialects"
|
|
@@ -4886,6 +5022,26 @@ type ConflictTargetInput<
|
|
|
4886
5022
|
readonly constraint?: string
|
|
4887
5023
|
}>)
|
|
4888
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
|
+
|
|
4889
5045
|
type ConflictActionInput<
|
|
4890
5046
|
Target extends MutationTargetLike,
|
|
4891
5047
|
Dialect extends string,
|
|
@@ -5032,7 +5188,7 @@ type MutationOrderLimitSupported<PlanValue extends QueryPlan<any, any, any, any,
|
|
|
5032
5188
|
type MutationTargetTupleDialectConstraint<
|
|
5033
5189
|
Targets extends MutationTargetTuple,
|
|
5034
5190
|
Dialect extends string
|
|
5035
|
-
> = Exclude<TableDialectOf<Targets[number]>, Dialect> extends never ? unknown : never
|
|
5191
|
+
> = Exclude<TableDialectOf<Targets[number]>, Dialect | "standard"> extends never ? unknown : never
|
|
5036
5192
|
|
|
5037
5193
|
type TableDialectConstraint<
|
|
5038
5194
|
Target extends TableLike,
|
|
@@ -5118,7 +5274,7 @@ type KnownIncompatibleMutationDialectFromValues<
|
|
|
5118
5274
|
BoolDb extends Expression.DbType.Any,
|
|
5119
5275
|
TimestampDb extends Expression.DbType.Any,
|
|
5120
5276
|
NullDb extends Expression.DbType.Any
|
|
5121
|
-
> = Exclude<KnownMutationDialectFromValues<Values, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>, Dialect>
|
|
5277
|
+
> = Exclude<KnownMutationDialectFromValues<Values, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>, Dialect | "standard">
|
|
5122
5278
|
|
|
5123
5279
|
type MutationValuesDialectConstraint<
|
|
5124
5280
|
Values,
|
|
@@ -5170,9 +5326,11 @@ type SourceDialectConstraint<
|
|
|
5170
5326
|
Dialect extends string
|
|
5171
5327
|
> = [SourceDialectOf<CurrentSource>] extends [never]
|
|
5172
5328
|
? unknown
|
|
5173
|
-
:
|
|
5174
|
-
?
|
|
5175
|
-
:
|
|
5329
|
+
: Exclude<SourceDialectOf<CurrentSource>, Dialect | "standard"> extends never
|
|
5330
|
+
? unknown
|
|
5331
|
+
: Dialect extends "standard"
|
|
5332
|
+
? unknown
|
|
5333
|
+
: never
|
|
5176
5334
|
|
|
5177
5335
|
type SourceRequirementConstraint<
|
|
5178
5336
|
PlanValue extends QueryPlan<any, any, any, any, any, any, any, any, any, any>,
|
|
@@ -5436,7 +5594,7 @@ type AsCurriedResult<
|
|
|
5436
5594
|
function as<
|
|
5437
5595
|
Alias extends string
|
|
5438
5596
|
>(
|
|
5439
|
-
alias: Alias
|
|
5597
|
+
alias: LiteralStringInput<Alias>
|
|
5440
5598
|
): <Value extends AsCurriedInput<Dialect>>(
|
|
5441
5599
|
value: Value
|
|
5442
5600
|
) => AsCurriedResult<Value, Alias, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>
|
|
@@ -5445,7 +5603,7 @@ type AsCurriedResult<
|
|
|
5445
5603
|
Alias extends string
|
|
5446
5604
|
>(
|
|
5447
5605
|
value: Value,
|
|
5448
|
-
alias: Alias
|
|
5606
|
+
alias: LiteralStringInput<Alias>
|
|
5449
5607
|
): ProjectionAliasedExpression<DialectAsExpression<Value, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>, Alias>
|
|
5450
5608
|
function as<
|
|
5451
5609
|
Rows extends ValuesRowsInput,
|
|
@@ -5456,7 +5614,7 @@ type AsCurriedResult<
|
|
|
5456
5614
|
ValuesOutputShape<Rows, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>,
|
|
5457
5615
|
Dialect
|
|
5458
5616
|
>,
|
|
5459
|
-
alias: Alias
|
|
5617
|
+
alias: LiteralStringInput<Alias>
|
|
5460
5618
|
): ValuesSource<
|
|
5461
5619
|
Rows,
|
|
5462
5620
|
ValuesOutputShape<Rows, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>,
|
|
@@ -5468,11 +5626,11 @@ type AsCurriedResult<
|
|
|
5468
5626
|
Alias extends string
|
|
5469
5627
|
>(
|
|
5470
5628
|
value: DerivedTableCompatiblePlan<PlanValue>,
|
|
5471
|
-
alias: Alias
|
|
5629
|
+
alias: LiteralStringInput<Alias>
|
|
5472
5630
|
): DerivedSource<PlanValue, Alias>
|
|
5473
5631
|
function as(valueOrAlias: unknown, alias?: string): unknown {
|
|
5474
5632
|
if (alias === undefined) {
|
|
5475
|
-
return (value: unknown) => as(value as any, valueOrAlias as
|
|
5633
|
+
return (value: unknown) => as(value as any, valueOrAlias as never)
|
|
5476
5634
|
}
|
|
5477
5635
|
const resolvedAlias = alias
|
|
5478
5636
|
const value = valueOrAlias
|
|
@@ -5512,7 +5670,7 @@ type AsCurriedResult<
|
|
|
5512
5670
|
function with_<
|
|
5513
5671
|
Alias extends string
|
|
5514
5672
|
>(
|
|
5515
|
-
alias: Alias
|
|
5673
|
+
alias: LiteralStringInput<Alias>
|
|
5516
5674
|
): <PlanValue extends QueryPlan<any, any, any, any, any, any, any, any, any, any>>(
|
|
5517
5675
|
value: MysqlCteCompatiblePlan<PlanValue>
|
|
5518
5676
|
) => import("../../internal/query.js").CteSource<PlanValue, Alias>
|
|
@@ -5521,11 +5679,11 @@ type AsCurriedResult<
|
|
|
5521
5679
|
Alias extends string
|
|
5522
5680
|
>(
|
|
5523
5681
|
value: MysqlCteCompatiblePlan<PlanValue>,
|
|
5524
|
-
alias: Alias
|
|
5682
|
+
alias: LiteralStringInput<Alias>
|
|
5525
5683
|
): import("../../internal/query.js").CteSource<PlanValue, Alias>
|
|
5526
5684
|
function with_(valueOrAlias: unknown, alias?: string): unknown {
|
|
5527
5685
|
if (alias === undefined) {
|
|
5528
|
-
return (value: unknown) => with_(value as any, valueOrAlias as
|
|
5686
|
+
return (value: unknown) => with_(value as any, valueOrAlias as never)
|
|
5529
5687
|
}
|
|
5530
5688
|
return makeCteSource(
|
|
5531
5689
|
valueOrAlias as CompletePlan<QueryPlan<any, any, any, any, any, any, any, any, any, any>>,
|
|
@@ -5536,7 +5694,7 @@ type AsCurriedResult<
|
|
|
5536
5694
|
function withRecursive_<
|
|
5537
5695
|
Alias extends string
|
|
5538
5696
|
>(
|
|
5539
|
-
alias: Alias
|
|
5697
|
+
alias: LiteralStringInput<Alias>
|
|
5540
5698
|
): <PlanValue extends QueryPlan<any, any, any, any, any, any, any, any, any, any>>(
|
|
5541
5699
|
value: MysqlCteCompatiblePlan<PlanValue>
|
|
5542
5700
|
) => import("../../internal/query.js").CteSource<PlanValue, Alias>
|
|
@@ -5545,11 +5703,11 @@ type AsCurriedResult<
|
|
|
5545
5703
|
Alias extends string
|
|
5546
5704
|
>(
|
|
5547
5705
|
value: MysqlCteCompatiblePlan<PlanValue>,
|
|
5548
|
-
alias: Alias
|
|
5706
|
+
alias: LiteralStringInput<Alias>
|
|
5549
5707
|
): import("../../internal/query.js").CteSource<PlanValue, Alias>
|
|
5550
5708
|
function withRecursive_(valueOrAlias: unknown, alias?: string): unknown {
|
|
5551
5709
|
if (alias === undefined) {
|
|
5552
|
-
return (value: unknown) => withRecursive_(value as any, valueOrAlias as
|
|
5710
|
+
return (value: unknown) => withRecursive_(value as any, valueOrAlias as never)
|
|
5553
5711
|
}
|
|
5554
5712
|
return makeCteSource(
|
|
5555
5713
|
valueOrAlias as CompletePlan<QueryPlan<any, any, any, any, any, any, any, any, any, any>>,
|
|
@@ -5561,7 +5719,7 @@ type AsCurriedResult<
|
|
|
5561
5719
|
function lateral<
|
|
5562
5720
|
Alias extends string
|
|
5563
5721
|
>(
|
|
5564
|
-
alias: Alias
|
|
5722
|
+
alias: LiteralStringInput<Alias>
|
|
5565
5723
|
): <PlanValue extends QueryPlan<any, any, any, any, any, any, any, any, any, any>>(
|
|
5566
5724
|
value: LateralSourceCompatiblePlan<PlanValue>
|
|
5567
5725
|
) => import("../../internal/query.js").LateralSource<PlanValue, Alias>
|
|
@@ -5570,11 +5728,11 @@ type AsCurriedResult<
|
|
|
5570
5728
|
Alias extends string
|
|
5571
5729
|
>(
|
|
5572
5730
|
value: LateralSourceCompatiblePlan<PlanValue>,
|
|
5573
|
-
alias: Alias
|
|
5731
|
+
alias: LiteralStringInput<Alias>
|
|
5574
5732
|
): import("../../internal/query.js").LateralSource<PlanValue, Alias>
|
|
5575
5733
|
function lateral(valueOrAlias: unknown, alias?: string): unknown {
|
|
5576
5734
|
if (alias === undefined) {
|
|
5577
|
-
return (value: unknown) => lateral(value as any, valueOrAlias as
|
|
5735
|
+
return (value: unknown) => lateral(value as any, valueOrAlias as never)
|
|
5578
5736
|
}
|
|
5579
5737
|
return makeLateralSource(
|
|
5580
5738
|
valueOrAlias as QueryPlan<any, any, any, any, any, any, any, any, any, any>,
|
|
@@ -5601,7 +5759,7 @@ type AsCurriedResult<
|
|
|
5601
5759
|
columns: Columns
|
|
5602
5760
|
& UnnestColumnsShapeInput<Columns>
|
|
5603
5761
|
& UnnestColumnsDialectInput<Columns, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>,
|
|
5604
|
-
alias: Alias
|
|
5762
|
+
alias: LiteralStringInput<Alias>
|
|
5605
5763
|
) => UnnestSource<
|
|
5606
5764
|
UnnestOutputShape<Columns, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>,
|
|
5607
5765
|
Alias,
|
|
@@ -5617,7 +5775,7 @@ type AsCurriedResult<
|
|
|
5617
5775
|
start: Start & NumericExpressionDialectInput<Start, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>,
|
|
5618
5776
|
stop: Stop & NumericExpressionDialectInput<Stop, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>,
|
|
5619
5777
|
step?: Step & (Step extends NumericExpressionInput ? NumericExpressionDialectInput<Step, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb> : unknown),
|
|
5620
|
-
alias?: Alias
|
|
5778
|
+
alias?: LiteralStringInput<Alias>
|
|
5621
5779
|
) => Dialect extends "postgres"
|
|
5622
5780
|
? TableFunctionSource<
|
|
5623
5781
|
GenerateSeriesOutputShape<Start, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>,
|
|
@@ -5664,8 +5822,8 @@ type AsCurriedResult<
|
|
|
5664
5822
|
? SelectSelectionNonEmptyError<Selection>
|
|
5665
5823
|
: unknown
|
|
5666
5824
|
|
|
5667
|
-
export type SelectApi = <Selection extends SelectionShape>(
|
|
5668
|
-
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>
|
|
5669
5827
|
) => QueryPlan<
|
|
5670
5828
|
Selection,
|
|
5671
5829
|
ExtractRequired<Selection>,
|
|
@@ -6130,8 +6288,8 @@ type AsCurriedResult<
|
|
|
6130
6288
|
: unknown
|
|
6131
6289
|
|
|
6132
6290
|
type ReturningApi = Dialect extends "postgres"
|
|
6133
|
-
? <Selection extends SelectionShape>(
|
|
6134
|
-
selection: Selection & SelectionRootObjectConstraint<Selection> & SelectionNestedNonEmptyConstraint<Selection> & ReturningSelectionNonEmptyConstraint<Selection>
|
|
6291
|
+
? <const Selection extends SelectionShape>(
|
|
6292
|
+
selection: Selection & SelectionRootObjectConstraint<Selection> & SelectionNestedNonEmptyConstraint<Selection> & ReturningSelectionNonEmptyConstraint<Selection> & SelectionProjectionAliasCollisionConstraint<Selection>
|
|
6135
6293
|
) =>
|
|
6136
6294
|
<PlanValue extends QueryPlan<any, any, any, any, any, any, any, any, any, any>>(
|
|
6137
6295
|
plan: PlanValue & RequireMutationStatement<PlanValue>
|
|
@@ -6200,13 +6358,13 @@ type AsCurriedResult<
|
|
|
6200
6358
|
const Columns extends DdlColumnInput,
|
|
6201
6359
|
UpdateValues extends MutationInputOf<Table.UpdateOf<Target>> | undefined = MutationInputOf<Table.UpdateOf<Target>> | undefined,
|
|
6202
6360
|
Options extends ConflictActionInput<Target, Dialect, UpdateValues> = ConflictActionInput<Target, Dialect, UpdateValues>,
|
|
6203
|
-
ConflictTarget extends ConflictTargetInput<Target, Dialect, Columns> = ConflictTargetInput<Target, Dialect, Columns>
|
|
6361
|
+
const ConflictTarget extends ConflictTargetInput<Target, Dialect, Columns> = ConflictTargetInput<Target, Dialect, Columns>
|
|
6204
6362
|
>(
|
|
6205
|
-
target: ConflictTarget
|
|
6363
|
+
target: ConflictTarget & ConflictConstraintNameConstraint<ConflictTarget>,
|
|
6206
6364
|
options?: Options & ConflictActionUpdateNonEmptyConstraint<Options>
|
|
6207
|
-
|
|
6365
|
+
) =>
|
|
6208
6366
|
<PlanValue extends QueryPlan<any, any, any, any, any, any, any, any, any, any>>(
|
|
6209
|
-
plan: PlanValue & RequireInsertStatement<PlanValue>
|
|
6367
|
+
plan: PlanValue & RequireInsertStatement<PlanValue> & ConflictTargetPlanConstraint<MutationTargetOfPlan<PlanValue>, ConflictTarget>
|
|
6210
6368
|
) => QueryPlan<
|
|
6211
6369
|
SelectionOfPlan<PlanValue>,
|
|
6212
6370
|
Exclude<RequiredOfPlan<PlanValue> | ConflictRequired<UpdateValues, Options, ConflictTarget>, AvailableNames<AvailableOfPlan<PlanValue>>>,
|
|
@@ -6270,7 +6428,7 @@ type AsCurriedResult<
|
|
|
6270
6428
|
>(
|
|
6271
6429
|
target: Target & TableDialectConstraint<Target, Dialect>,
|
|
6272
6430
|
values: Values & MutationValuesDialectConstraint<Values, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>,
|
|
6273
|
-
conflictColumns:
|
|
6431
|
+
conflictColumns: ValidateConflictColumnInput<Target, Columns, false>,
|
|
6274
6432
|
updateValues?: UpdateValues & UpdateValuesNonEmptyConstraint<Exclude<UpdateValues, undefined>> & MutationValuesDialectConstraint<Exclude<UpdateValues, undefined>, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>
|
|
6275
6433
|
) => QueryPlan<
|
|
6276
6434
|
{},
|
|
@@ -6578,7 +6736,7 @@ type AsCurriedResult<
|
|
|
6578
6736
|
"rollback"
|
|
6579
6737
|
>
|
|
6580
6738
|
|
|
6581
|
-
type SavepointApi = <Name extends string>(name: Name) => QueryPlan<
|
|
6739
|
+
type SavepointApi = <Name extends string>(name: NonEmptyStringInput<Name>) => QueryPlan<
|
|
6582
6740
|
{},
|
|
6583
6741
|
never,
|
|
6584
6742
|
{},
|
|
@@ -6591,7 +6749,7 @@ type AsCurriedResult<
|
|
|
6591
6749
|
"savepoint"
|
|
6592
6750
|
>
|
|
6593
6751
|
|
|
6594
|
-
type RollbackToApi = <Name extends string>(name: Name) => QueryPlan<
|
|
6752
|
+
type RollbackToApi = <Name extends string>(name: NonEmptyStringInput<Name>) => QueryPlan<
|
|
6595
6753
|
{},
|
|
6596
6754
|
never,
|
|
6597
6755
|
{},
|
|
@@ -6604,7 +6762,7 @@ type AsCurriedResult<
|
|
|
6604
6762
|
"rollbackTo"
|
|
6605
6763
|
>
|
|
6606
6764
|
|
|
6607
|
-
type ReleaseSavepointApi = <Name extends string>(name: Name) => QueryPlan<
|
|
6765
|
+
type ReleaseSavepointApi = <Name extends string>(name: NonEmptyStringInput<Name>) => QueryPlan<
|
|
6608
6766
|
{},
|
|
6609
6767
|
never,
|
|
6610
6768
|
{},
|
|
@@ -6649,10 +6807,10 @@ type AsCurriedResult<
|
|
|
6649
6807
|
"dropTable"
|
|
6650
6808
|
>
|
|
6651
6809
|
|
|
6652
|
-
type CreateIndexApi = <Target extends SchemaTableLike, const Columns extends DdlColumnInput>(
|
|
6810
|
+
type CreateIndexApi = <Target extends SchemaTableLike, const Columns extends DdlColumnInput, Name extends string = string>(
|
|
6653
6811
|
target: Target & TableDialectConstraint<Target, Dialect>,
|
|
6654
6812
|
columns: Columns & ValidateDdlColumnInput<Target, Columns>,
|
|
6655
|
-
options?: CreateIndexOptions
|
|
6813
|
+
options?: CreateIndexOptions<Name>
|
|
6656
6814
|
) => QueryPlan<
|
|
6657
6815
|
{},
|
|
6658
6816
|
never,
|
|
@@ -6666,10 +6824,10 @@ type AsCurriedResult<
|
|
|
6666
6824
|
"createIndex"
|
|
6667
6825
|
>
|
|
6668
6826
|
|
|
6669
|
-
type DropIndexApi = <Target extends SchemaTableLike, const Columns extends DdlColumnInput>(
|
|
6827
|
+
type DropIndexApi = <Target extends SchemaTableLike, const Columns extends DdlColumnInput, Name extends string = string>(
|
|
6670
6828
|
target: Target & TableDialectConstraint<Target, Dialect>,
|
|
6671
6829
|
columns: Columns & ValidateDdlColumnInput<Target, Columns>,
|
|
6672
|
-
options?: DropIndexOptions
|
|
6830
|
+
options?: DropIndexOptions<Name>
|
|
6673
6831
|
) => QueryPlan<
|
|
6674
6832
|
{},
|
|
6675
6833
|
never,
|