effect-qb 0.17.0 → 0.19.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 +4 -0
- package/dist/index.js +8065 -0
- package/dist/mysql.js +3053 -2505
- package/dist/postgres/metadata.js +1366 -1250
- package/dist/postgres.js +2020 -2719
- package/dist/sqlite.js +3226 -2732
- package/dist/standard.js +8019 -0
- package/package.json +10 -3
- package/src/casing.ts +71 -0
- package/src/index.ts +2 -0
- package/src/internal/casing.ts +89 -0
- package/src/internal/column-state.ts +11 -6
- package/src/internal/column.ts +44 -7
- package/src/internal/datatypes/define.ts +2 -1
- package/src/internal/datatypes/enrich.ts +23 -0
- package/src/internal/datatypes/lookup.ts +14 -7
- package/src/internal/derived-table.ts +4 -36
- package/src/{mysql/internal/sql-expression-renderer.ts → internal/dialect-renderers/mysql.ts} +548 -359
- package/src/{postgres/internal/sql-expression-renderer.ts → internal/dialect-renderers/postgres.ts} +654 -399
- package/src/{sqlite/internal/sql-expression-renderer.ts → internal/dialect-renderers/sqlite.ts} +501 -345
- 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 +10 -6
- package/src/internal/grouping-key.ts +87 -20
- package/src/internal/implication-runtime.ts +1 -1
- 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 +6 -1
- package/src/internal/schema-derivation.d.ts +12 -61
- package/src/internal/schema-derivation.ts +90 -38
- package/src/internal/schema-expression.ts +2 -2
- package/src/internal/sql-expression-renderer.ts +19 -0
- package/src/internal/standard-dsl.ts +6885 -0
- package/src/internal/table-options.ts +126 -66
- package/src/internal/table.d.ts +33 -32
- package/src/internal/table.ts +406 -155
- package/src/mysql/column-extension.ts +3 -0
- package/src/mysql/column.ts +10 -11
- package/src/mysql/datatypes/index.ts +3 -2
- package/src/mysql/executor.ts +7 -5
- package/src/mysql/internal/dialect.ts +9 -4
- package/src/mysql/internal/dsl.ts +219 -155
- package/src/mysql/internal/renderer.ts +6 -2
- package/src/mysql/json.ts +37 -0
- package/src/mysql/query-extension.ts +16 -0
- package/src/mysql/renderer.ts +31 -4
- package/src/mysql.ts +4 -12
- package/src/postgres/column-extension.ts +28 -0
- package/src/postgres/column.ts +5 -11
- package/src/postgres/datatypes/index.d.ts +2 -1
- package/src/postgres/datatypes/index.ts +3 -2
- package/src/postgres/executor.ts +7 -5
- package/src/postgres/function/core.ts +1 -3
- package/src/postgres/function/index.ts +1 -17
- package/src/postgres/internal/dialect.ts +9 -4
- package/src/postgres/internal/dsl.ts +208 -160
- 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.ts +43 -7
- package/src/postgres/jsonb.ts +38 -0
- package/src/postgres/query-extension.ts +2 -0
- package/src/postgres/renderer.ts +31 -4
- package/src/postgres/schema-management.ts +17 -12
- package/src/postgres/schema.ts +98 -15
- package/src/postgres/table.ts +193 -524
- package/src/postgres/type.ts +8 -7
- package/src/postgres.ts +9 -11
- package/src/sqlite/column-extension.ts +3 -0
- package/src/sqlite/column.ts +10 -11
- package/src/sqlite/datatypes/index.ts +3 -2
- package/src/sqlite/executor.ts +7 -5
- package/src/sqlite/internal/dialect.ts +9 -4
- package/src/sqlite/internal/dsl.ts +208 -155
- package/src/sqlite/internal/renderer.ts +6 -2
- package/src/sqlite/json.ts +37 -0
- package/src/sqlite/query-extension.ts +2 -0
- package/src/sqlite/renderer.ts +31 -4
- package/src/sqlite.ts +4 -12
- package/src/standard/column.ts +163 -0
- package/src/standard/datatypes/index.ts +83 -0
- package/src/standard/datatypes/spec.ts +98 -0
- package/src/standard/dialect.ts +40 -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/internal/renderer.ts +45 -0
- package/src/standard/query.ts +152 -0
- package/src/standard/renderer.ts +21 -0
- package/src/standard/table.ts +147 -0
- package/src/standard.ts +18 -0
- package/src/internal/aggregation-validation.ts +0 -57
- package/src/mysql/table.ts +0 -183
- 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,7 +1566,7 @@ 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
|
}
|
|
@@ -1537,7 +1577,7 @@ const profile: QueryDialectProfile<Dialect, TextDb, NumericDb, BoolDb, Timestamp
|
|
|
1537
1577
|
if (value === null || value instanceof Date) {
|
|
1538
1578
|
return undefined
|
|
1539
1579
|
}
|
|
1540
|
-
return Schema.Literal(value) as
|
|
1580
|
+
return Schema.Literal(value) as Schema.Schema.Any
|
|
1541
1581
|
}
|
|
1542
1582
|
|
|
1543
1583
|
const literal = <const Value extends LiteralValue>(
|
|
@@ -1624,7 +1664,7 @@ const profile: QueryDialectProfile<Dialect, TextDb, NumericDb, BoolDb, Timestamp
|
|
|
1624
1664
|
value: Expression.Any,
|
|
1625
1665
|
target: Expression.Any
|
|
1626
1666
|
): Expression.Any => {
|
|
1627
|
-
const ast = (value as
|
|
1667
|
+
const ast = (value as Expression.Any & { readonly [ExpressionAst.TypeId]: ExpressionAst.Any })[ExpressionAst.TypeId]
|
|
1628
1668
|
if (ast.kind !== "literal") {
|
|
1629
1669
|
return value
|
|
1630
1670
|
}
|
|
@@ -1645,8 +1685,8 @@ const profile: QueryDialectProfile<Dialect, TextDb, NumericDb, BoolDb, Timestamp
|
|
|
1645
1685
|
left: Expression.Any,
|
|
1646
1686
|
right: Expression.Any
|
|
1647
1687
|
): readonly [Expression.Any, Expression.Any] => {
|
|
1648
|
-
const leftAst = (left as
|
|
1649
|
-
const rightAst = (right as
|
|
1688
|
+
const leftAst = (left as Expression.Any & { readonly [ExpressionAst.TypeId]: ExpressionAst.Any })[ExpressionAst.TypeId]
|
|
1689
|
+
const rightAst = (right as Expression.Any & { readonly [ExpressionAst.TypeId]: ExpressionAst.Any })[ExpressionAst.TypeId]
|
|
1650
1690
|
if (leftAst.kind === "literal" && rightAst.kind !== "literal") {
|
|
1651
1691
|
return [retargetLiteralExpression(left, right), right]
|
|
1652
1692
|
}
|
|
@@ -1679,7 +1719,7 @@ const profile: QueryDialectProfile<Dialect, TextDb, NumericDb, BoolDb, Timestamp
|
|
|
1679
1719
|
): readonly Expression.Any[] => {
|
|
1680
1720
|
const flattened: Array<Expression.Any> = []
|
|
1681
1721
|
for (const value of values) {
|
|
1682
|
-
const ast = (value as
|
|
1722
|
+
const ast = (value as Expression.Any & { readonly [ExpressionAst.TypeId]: ExpressionAst.Any })[ExpressionAst.TypeId]
|
|
1683
1723
|
if (ast.kind === kind) {
|
|
1684
1724
|
flattened.push(...ast.values)
|
|
1685
1725
|
} else {
|
|
@@ -1725,7 +1765,33 @@ const profile: QueryDialectProfile<Dialect, TextDb, NumericDb, BoolDb, Timestamp
|
|
|
1725
1765
|
if (operations.every((operation) => typeof operation === "function")) {
|
|
1726
1766
|
return pipeArguments(this, arguments)
|
|
1727
1767
|
}
|
|
1728
|
-
|
|
1768
|
+
const valuesForMixedPipe = (value: unknown): readonly Expression.Any[] => {
|
|
1769
|
+
if (typeof value !== "object" || value === null || !(Expression.TypeId in value)) {
|
|
1770
|
+
return []
|
|
1771
|
+
}
|
|
1772
|
+
const expression = value as Expression.Any & {
|
|
1773
|
+
readonly [ExpressionAst.TypeId]: ExpressionAst.Any
|
|
1774
|
+
}
|
|
1775
|
+
const ast = expression[ExpressionAst.TypeId]
|
|
1776
|
+
if (ast.kind === kind) {
|
|
1777
|
+
return (ast as {
|
|
1778
|
+
readonly values: readonly Expression.Any[]
|
|
1779
|
+
}).values
|
|
1780
|
+
}
|
|
1781
|
+
return [expression]
|
|
1782
|
+
}
|
|
1783
|
+
let current: unknown = this
|
|
1784
|
+
for (const operation of operations) {
|
|
1785
|
+
if (typeof operation === "function") {
|
|
1786
|
+
current = (operation as (value: unknown) => unknown)(current)
|
|
1787
|
+
continue
|
|
1788
|
+
}
|
|
1789
|
+
current = makeVariadicBooleanExpression(
|
|
1790
|
+
kind,
|
|
1791
|
+
[...valuesForMixedPipe(current), toDialectExpression(operation as ExpressionInput)] as const
|
|
1792
|
+
)
|
|
1793
|
+
}
|
|
1794
|
+
return current
|
|
1729
1795
|
}
|
|
1730
1796
|
})
|
|
1731
1797
|
|
|
@@ -1746,9 +1812,6 @@ const profile: QueryDialectProfile<Dialect, TextDb, NumericDb, BoolDb, Timestamp
|
|
|
1746
1812
|
const partitionBy = [...(spec?.partitionBy ?? [])] as unknown as PartitionBy
|
|
1747
1813
|
const orderBy = (spec?.orderBy ?? []).map((term) => {
|
|
1748
1814
|
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
1815
|
return {
|
|
1753
1816
|
value: term.value,
|
|
1754
1817
|
direction
|
|
@@ -1889,7 +1952,8 @@ type BinaryPredicateExpression<
|
|
|
1889
1952
|
>(
|
|
1890
1953
|
...args: ComparableArgs<Left, Right, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb, "eq">
|
|
1891
1954
|
): BinaryPredicateExpression<Left, Right, "eq"> => {
|
|
1892
|
-
const
|
|
1955
|
+
const left = args[0] as Left
|
|
1956
|
+
const right = args[1] as Right
|
|
1893
1957
|
return buildBinaryPredicate(left as ExpressionInput, right as ExpressionInput, "eq")
|
|
1894
1958
|
}
|
|
1895
1959
|
|
|
@@ -1899,7 +1963,8 @@ type BinaryPredicateExpression<
|
|
|
1899
1963
|
>(
|
|
1900
1964
|
...args: ComparableArgs<Left, Right, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb, "neq">
|
|
1901
1965
|
): BinaryPredicateExpression<Left, Right, "neq"> => {
|
|
1902
|
-
const
|
|
1966
|
+
const left = args[0] as Left
|
|
1967
|
+
const right = args[1] as Right
|
|
1903
1968
|
return buildBinaryPredicate(left as ExpressionInput, right as ExpressionInput, "neq")
|
|
1904
1969
|
}
|
|
1905
1970
|
|
|
@@ -1909,7 +1974,8 @@ type BinaryPredicateExpression<
|
|
|
1909
1974
|
>(
|
|
1910
1975
|
...args: ComparableArgs<Left, Right, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb, "lt">
|
|
1911
1976
|
): BinaryPredicateExpression<Left, Right, "lt"> => {
|
|
1912
|
-
const
|
|
1977
|
+
const left = args[0] as Left
|
|
1978
|
+
const right = args[1] as Right
|
|
1913
1979
|
return buildBinaryPredicate(left as ExpressionInput, right as ExpressionInput, "lt")
|
|
1914
1980
|
}
|
|
1915
1981
|
|
|
@@ -1919,7 +1985,8 @@ type BinaryPredicateExpression<
|
|
|
1919
1985
|
>(
|
|
1920
1986
|
...args: ComparableArgs<Left, Right, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb, "lte">
|
|
1921
1987
|
): BinaryPredicateExpression<Left, Right, "lte"> => {
|
|
1922
|
-
const
|
|
1988
|
+
const left = args[0] as Left
|
|
1989
|
+
const right = args[1] as Right
|
|
1923
1990
|
return buildBinaryPredicate(left as ExpressionInput, right as ExpressionInput, "lte")
|
|
1924
1991
|
}
|
|
1925
1992
|
|
|
@@ -1929,7 +1996,8 @@ type BinaryPredicateExpression<
|
|
|
1929
1996
|
>(
|
|
1930
1997
|
...args: ComparableArgs<Left, Right, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb, "gt">
|
|
1931
1998
|
): BinaryPredicateExpression<Left, Right, "gt"> => {
|
|
1932
|
-
const
|
|
1999
|
+
const left = args[0] as Left
|
|
2000
|
+
const right = args[1] as Right
|
|
1933
2001
|
return buildBinaryPredicate(left as ExpressionInput, right as ExpressionInput, "gt")
|
|
1934
2002
|
}
|
|
1935
2003
|
|
|
@@ -1939,7 +2007,8 @@ type BinaryPredicateExpression<
|
|
|
1939
2007
|
>(
|
|
1940
2008
|
...args: ComparableArgs<Left, Right, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb, "gte">
|
|
1941
2009
|
): BinaryPredicateExpression<Left, Right, "gte"> => {
|
|
1942
|
-
const
|
|
2010
|
+
const left = args[0] as Left
|
|
2011
|
+
const right = args[1] as Right
|
|
1943
2012
|
return buildBinaryPredicate(left as ExpressionInput, right as ExpressionInput, "gte")
|
|
1944
2013
|
}
|
|
1945
2014
|
|
|
@@ -1949,7 +2018,8 @@ type BinaryPredicateExpression<
|
|
|
1949
2018
|
>(
|
|
1950
2019
|
...args: TextArgs<Left, Right, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb, "like">
|
|
1951
2020
|
): BinaryPredicateExpression<Left, Right, "like"> => {
|
|
1952
|
-
const
|
|
2021
|
+
const left = args[0] as Left
|
|
2022
|
+
const right = args[1] as Right
|
|
1953
2023
|
return buildBinaryPredicate(left as ExpressionInput, right as ExpressionInput, "like")
|
|
1954
2024
|
}
|
|
1955
2025
|
|
|
@@ -1959,7 +2029,8 @@ type BinaryPredicateExpression<
|
|
|
1959
2029
|
>(
|
|
1960
2030
|
...args: TextArgs<Left, Right, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb, "ilike">
|
|
1961
2031
|
): BinaryPredicateExpression<Left, Right, "ilike"> => {
|
|
1962
|
-
const
|
|
2032
|
+
const left = args[0] as Left
|
|
2033
|
+
const right = args[1] as Right
|
|
1963
2034
|
return buildBinaryPredicate(left as ExpressionInput, right as ExpressionInput, "ilike")
|
|
1964
2035
|
}
|
|
1965
2036
|
|
|
@@ -1969,7 +2040,8 @@ type BinaryPredicateExpression<
|
|
|
1969
2040
|
>(
|
|
1970
2041
|
...args: TextArgs<Left, Right, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb, "regexMatch">
|
|
1971
2042
|
): BinaryPredicateExpression<Left, Right, "regexMatch"> => {
|
|
1972
|
-
const
|
|
2043
|
+
const left = args[0] as Left
|
|
2044
|
+
const right = args[1] as Right
|
|
1973
2045
|
return buildBinaryPredicate(left as ExpressionInput, right as ExpressionInput, "regexMatch")
|
|
1974
2046
|
}
|
|
1975
2047
|
|
|
@@ -1979,7 +2051,8 @@ type BinaryPredicateExpression<
|
|
|
1979
2051
|
>(
|
|
1980
2052
|
...args: TextArgs<Left, Right, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb, "regexIMatch">
|
|
1981
2053
|
): BinaryPredicateExpression<Left, Right, "regexIMatch"> => {
|
|
1982
|
-
const
|
|
2054
|
+
const left = args[0] as Left
|
|
2055
|
+
const right = args[1] as Right
|
|
1983
2056
|
return buildBinaryPredicate(left as ExpressionInput, right as ExpressionInput, "regexIMatch")
|
|
1984
2057
|
}
|
|
1985
2058
|
|
|
@@ -1989,7 +2062,8 @@ type BinaryPredicateExpression<
|
|
|
1989
2062
|
>(
|
|
1990
2063
|
...args: TextArgs<Left, Right, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb, "regexNotMatch">
|
|
1991
2064
|
): BinaryPredicateExpression<Left, Right, "regexNotMatch"> => {
|
|
1992
|
-
const
|
|
2065
|
+
const left = args[0] as Left
|
|
2066
|
+
const right = args[1] as Right
|
|
1993
2067
|
return buildBinaryPredicate(left as ExpressionInput, right as ExpressionInput, "regexNotMatch")
|
|
1994
2068
|
}
|
|
1995
2069
|
|
|
@@ -1999,7 +2073,8 @@ type BinaryPredicateExpression<
|
|
|
1999
2073
|
>(
|
|
2000
2074
|
...args: TextArgs<Left, Right, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb, "regexNotIMatch">
|
|
2001
2075
|
): BinaryPredicateExpression<Left, Right, "regexNotIMatch"> => {
|
|
2002
|
-
const
|
|
2076
|
+
const left = args[0] as Left
|
|
2077
|
+
const right = args[1] as Right
|
|
2003
2078
|
return buildBinaryPredicate(left as ExpressionInput, right as ExpressionInput, "regexNotIMatch")
|
|
2004
2079
|
}
|
|
2005
2080
|
|
|
@@ -2009,7 +2084,8 @@ type BinaryPredicateExpression<
|
|
|
2009
2084
|
>(
|
|
2010
2085
|
...args: ComparableArgs<Left, Right, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb, "isDistinctFrom">
|
|
2011
2086
|
): BinaryPredicateExpression<Left, Right, "isDistinctFrom", "never"> => {
|
|
2012
|
-
const
|
|
2087
|
+
const left = args[0] as Left
|
|
2088
|
+
const right = args[1] as Right
|
|
2013
2089
|
return buildBinaryPredicate(left as ExpressionInput, right as ExpressionInput, "isDistinctFrom", "never")
|
|
2014
2090
|
}
|
|
2015
2091
|
|
|
@@ -2019,7 +2095,8 @@ type BinaryPredicateExpression<
|
|
|
2019
2095
|
>(
|
|
2020
2096
|
...args: ComparableArgs<Left, Right, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb, "isNotDistinctFrom">
|
|
2021
2097
|
): BinaryPredicateExpression<Left, Right, "isNotDistinctFrom", "never"> => {
|
|
2022
|
-
const
|
|
2098
|
+
const left = args[0] as Left
|
|
2099
|
+
const right = args[1] as Right
|
|
2023
2100
|
return buildBinaryPredicate(left as ExpressionInput, right as ExpressionInput, "isNotDistinctFrom", "never")
|
|
2024
2101
|
}
|
|
2025
2102
|
|
|
@@ -2170,62 +2247,62 @@ type BinaryPredicateExpression<
|
|
|
2170
2247
|
})
|
|
2171
2248
|
|
|
2172
2249
|
const range = <Kind extends string, Subtype extends Expression.DbType.Any>(
|
|
2173
|
-
kind: Kind
|
|
2250
|
+
kind: NonEmptyStringInput<Kind>,
|
|
2174
2251
|
subtype: Subtype
|
|
2175
2252
|
): Expression.DbType.Range<Dialect, Subtype, Kind> => ({
|
|
2176
2253
|
dialect: profile.dialect,
|
|
2177
|
-
kind,
|
|
2254
|
+
kind: kind as Kind,
|
|
2178
2255
|
subtype
|
|
2179
2256
|
})
|
|
2180
2257
|
|
|
2181
2258
|
const multirange = <Kind extends string, Subtype extends Expression.DbType.Any>(
|
|
2182
|
-
kind: Kind
|
|
2259
|
+
kind: NonEmptyStringInput<Kind>,
|
|
2183
2260
|
subtype: Subtype
|
|
2184
2261
|
): Expression.DbType.Multirange<Dialect, Subtype, Kind> => ({
|
|
2185
2262
|
dialect: profile.dialect,
|
|
2186
|
-
kind,
|
|
2263
|
+
kind: kind as Kind,
|
|
2187
2264
|
subtype
|
|
2188
2265
|
})
|
|
2189
2266
|
|
|
2190
2267
|
const record = <Kind extends string, Fields extends Record<string, Expression.DbType.Any>>(
|
|
2191
|
-
kind: Kind
|
|
2268
|
+
kind: NonEmptyStringInput<Kind>,
|
|
2192
2269
|
fields: Fields
|
|
2193
2270
|
): Expression.DbType.Composite<Dialect, Fields, Kind> => ({
|
|
2194
2271
|
dialect: profile.dialect,
|
|
2195
|
-
kind,
|
|
2272
|
+
kind: kind as Kind,
|
|
2196
2273
|
fields
|
|
2197
2274
|
})
|
|
2198
2275
|
|
|
2199
2276
|
const domain = <Kind extends string, Base extends Expression.DbType.Any>(
|
|
2200
|
-
kind: Kind
|
|
2277
|
+
kind: NonEmptyStringInput<Kind>,
|
|
2201
2278
|
base: Base
|
|
2202
2279
|
): Expression.DbType.Domain<Dialect, Base, Kind> => ({
|
|
2203
2280
|
dialect: profile.dialect,
|
|
2204
|
-
kind,
|
|
2281
|
+
kind: kind as Kind,
|
|
2205
2282
|
base
|
|
2206
2283
|
})
|
|
2207
2284
|
|
|
2208
2285
|
const enum_ = <Kind extends string>(
|
|
2209
|
-
kind: Kind
|
|
2286
|
+
kind: NonEmptyStringInput<Kind>
|
|
2210
2287
|
): Expression.DbType.Enum<Dialect, Kind> => ({
|
|
2211
2288
|
dialect: profile.dialect,
|
|
2212
|
-
kind,
|
|
2289
|
+
kind: kind as Kind,
|
|
2213
2290
|
variant: "enum"
|
|
2214
2291
|
})
|
|
2215
2292
|
|
|
2216
2293
|
const set = <Kind extends string>(
|
|
2217
|
-
kind: Kind
|
|
2294
|
+
kind: NonEmptyStringInput<Kind>
|
|
2218
2295
|
): Expression.DbType.Set<Dialect, Kind> => ({
|
|
2219
2296
|
dialect: profile.dialect,
|
|
2220
|
-
kind,
|
|
2297
|
+
kind: kind as Kind,
|
|
2221
2298
|
variant: "set"
|
|
2222
2299
|
})
|
|
2223
2300
|
|
|
2224
2301
|
const custom = <Kind extends string>(
|
|
2225
|
-
kind: Kind
|
|
2302
|
+
kind: NonEmptyStringInput<Kind>
|
|
2226
2303
|
): Expression.DbType.Base<Dialect, Kind> => ({
|
|
2227
2304
|
dialect: profile.dialect,
|
|
2228
|
-
kind
|
|
2305
|
+
kind: kind as Kind
|
|
2229
2306
|
})
|
|
2230
2307
|
|
|
2231
2308
|
const driverValueMapping = <Db extends Expression.DbType.Any>(
|
|
@@ -3033,9 +3110,12 @@ type BinaryPredicateExpression<
|
|
|
3033
3110
|
}
|
|
3034
3111
|
)
|
|
3035
3112
|
|
|
3036
|
-
const jsonPathExists = <
|
|
3113
|
+
const jsonPathExists = <
|
|
3114
|
+
Base extends JsonExpressionLike<any>,
|
|
3115
|
+
Query extends JsonQueryInput
|
|
3116
|
+
>(
|
|
3037
3117
|
base: Base,
|
|
3038
|
-
query:
|
|
3118
|
+
query: JsonQueryValue<Query>
|
|
3039
3119
|
) => {
|
|
3040
3120
|
if (isJsonPathValue(query)) {
|
|
3041
3121
|
return buildJsonNodeExpression(
|
|
@@ -3083,9 +3163,12 @@ type BinaryPredicateExpression<
|
|
|
3083
3163
|
}
|
|
3084
3164
|
)
|
|
3085
3165
|
|
|
3086
|
-
const jsonPathMatch = <
|
|
3166
|
+
const jsonPathMatch = <
|
|
3167
|
+
Base extends JsonExpressionLike<any>,
|
|
3168
|
+
Query extends JsonQueryInput
|
|
3169
|
+
>(
|
|
3087
3170
|
base: Base,
|
|
3088
|
-
query:
|
|
3171
|
+
query: JsonQueryValue<Query>
|
|
3089
3172
|
) => {
|
|
3090
3173
|
if (isJsonPathValue(query)) {
|
|
3091
3174
|
return buildJsonNodeExpression(
|
|
@@ -3312,7 +3395,8 @@ type BinaryPredicateExpression<
|
|
|
3312
3395
|
>(
|
|
3313
3396
|
...args: ContainmentArgs<Left, Right, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb, "contains">
|
|
3314
3397
|
): BinaryPredicateExpression<Left, Right, "contains"> => {
|
|
3315
|
-
const
|
|
3398
|
+
const left = args[0] as Left
|
|
3399
|
+
const right = args[1] as Right
|
|
3316
3400
|
return buildBinaryPredicate(left as ExpressionInput, right as ExpressionInput, "contains")
|
|
3317
3401
|
}
|
|
3318
3402
|
|
|
@@ -3322,7 +3406,8 @@ type BinaryPredicateExpression<
|
|
|
3322
3406
|
>(
|
|
3323
3407
|
...args: ContainmentArgs<Left, Right, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb, "containedBy">
|
|
3324
3408
|
): BinaryPredicateExpression<Left, Right, "containedBy"> => {
|
|
3325
|
-
const
|
|
3409
|
+
const left = args[0] as Left
|
|
3410
|
+
const right = args[1] as Right
|
|
3326
3411
|
return buildBinaryPredicate(left as ExpressionInput, right as ExpressionInput, "containedBy")
|
|
3327
3412
|
}
|
|
3328
3413
|
|
|
@@ -3332,7 +3417,8 @@ type BinaryPredicateExpression<
|
|
|
3332
3417
|
>(
|
|
3333
3418
|
...args: ContainmentArgs<Left, Right, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb, "overlaps">
|
|
3334
3419
|
): BinaryPredicateExpression<Left, Right, "overlaps"> => {
|
|
3335
|
-
const
|
|
3420
|
+
const left = args[0] as Left
|
|
3421
|
+
const right = args[1] as Right
|
|
3336
3422
|
return buildBinaryPredicate(left as ExpressionInput, right as ExpressionInput, "overlaps")
|
|
3337
3423
|
}
|
|
3338
3424
|
|
|
@@ -3759,12 +3845,9 @@ type BinaryPredicateExpression<
|
|
|
3759
3845
|
>
|
|
3760
3846
|
}
|
|
3761
3847
|
|
|
3762
|
-
const call =
|
|
3763
|
-
|
|
3764
|
-
|
|
3765
|
-
>(
|
|
3766
|
-
name: Name,
|
|
3767
|
-
...args: Args
|
|
3848
|
+
const call: FunctionCallApi = (
|
|
3849
|
+
name: string,
|
|
3850
|
+
...args: readonly ExpressionInput[]
|
|
3768
3851
|
): Expression.Any => {
|
|
3769
3852
|
const expressions = args.map((value) => toDialectExpression(value)) as readonly Expression.Any[]
|
|
3770
3853
|
return makeExpression({
|
|
@@ -4000,9 +4083,6 @@ type BinaryPredicateExpression<
|
|
|
4000
4083
|
ExpressionAst.ExcludedNode<AstOf<Value> extends ExpressionAst.ColumnNode<any, infer ColumnName extends string> ? ColumnName : string>
|
|
4001
4084
|
> => {
|
|
4002
4085
|
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
4086
|
return makeExpression({
|
|
4007
4087
|
runtime: undefined as Expression.RuntimeOf<Value>,
|
|
4008
4088
|
dbType: value[Expression.TypeId].dbType as Expression.DbTypeOf<Value>,
|
|
@@ -4015,7 +4095,7 @@ type BinaryPredicateExpression<
|
|
|
4015
4095
|
dependencies: {}
|
|
4016
4096
|
}, {
|
|
4017
4097
|
kind: "excluded",
|
|
4018
|
-
columnName: ast.columnName
|
|
4098
|
+
columnName: (ast as ExpressionAst.ColumnNode<any, string>).columnName
|
|
4019
4099
|
}) as unknown as AstBackedExpression<
|
|
4020
4100
|
Expression.RuntimeOf<Value>,
|
|
4021
4101
|
Expression.DbTypeOf<Value>,
|
|
@@ -4048,7 +4128,7 @@ type BinaryPredicateExpression<
|
|
|
4048
4128
|
}
|
|
4049
4129
|
if (value !== null && typeof value === "object" && Expression.TypeId in value) {
|
|
4050
4130
|
const expression = value as unknown as Expression.Any
|
|
4051
|
-
const ast = (expression as
|
|
4131
|
+
const ast = (expression as Expression.Any & { readonly [ExpressionAst.TypeId]: ExpressionAst.Any })[ExpressionAst.TypeId]
|
|
4052
4132
|
if (ast.kind === "literal") {
|
|
4053
4133
|
const normalizedValue = normalizeMutationValue(ast.value)
|
|
4054
4134
|
return makeExpression({
|
|
@@ -4117,8 +4197,8 @@ type BinaryPredicateExpression<
|
|
|
4117
4197
|
: ">="
|
|
4118
4198
|
|
|
4119
4199
|
const targetSourceDetails = (table: MutationTargetLike | SchemaTableLike) => {
|
|
4120
|
-
const sourceName = (table as
|
|
4121
|
-
const sourceBaseName = (table as
|
|
4200
|
+
const sourceName = (table as TableLike)[Table.TypeId].name
|
|
4201
|
+
const sourceBaseName = (table as TableLike)[Table.TypeId].baseName
|
|
4122
4202
|
return {
|
|
4123
4203
|
sourceName,
|
|
4124
4204
|
sourceBaseName
|
|
@@ -4208,12 +4288,7 @@ type BinaryPredicateExpression<
|
|
|
4208
4288
|
|
|
4209
4289
|
const normalizeUnnestColumns = (columns: UnnestColumnsInput): Record<string, readonly Expression.Any[]> =>
|
|
4210
4290
|
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
|
-
})
|
|
4291
|
+
Object.entries(columns).map(([key, values]) => [key, values.map((value) => toDialectExpression(value))])
|
|
4217
4292
|
) as Record<string, readonly Expression.Any[]>
|
|
4218
4293
|
|
|
4219
4294
|
const normalizeMutationTargets = (
|
|
@@ -4259,13 +4334,7 @@ type BinaryPredicateExpression<
|
|
|
4259
4334
|
const getMutationColumn = (
|
|
4260
4335
|
columns: Record<string, unknown>,
|
|
4261
4336
|
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
|
-
}
|
|
4337
|
+
): Expression.Any => columns[columnName] as Expression.Any
|
|
4269
4338
|
|
|
4270
4339
|
const buildMutationAssignments = <Target extends MutationTargetInput, Values>(
|
|
4271
4340
|
target: Target,
|
|
@@ -4281,7 +4350,7 @@ type BinaryPredicateExpression<
|
|
|
4281
4350
|
}
|
|
4282
4351
|
const valueMap = values as Record<string, Record<string, unknown> | undefined>
|
|
4283
4352
|
return targets.flatMap((table) => {
|
|
4284
|
-
const targetName = (table as
|
|
4353
|
+
const targetName = (table as TableLike)[Table.TypeId].name
|
|
4285
4354
|
const scopedValues = valueMap[targetName] ?? {}
|
|
4286
4355
|
const columns = table as unknown as Record<string, Expression.Any>
|
|
4287
4356
|
return Object.entries(scopedValues).map(([columnName, value]) => ({
|
|
@@ -4302,20 +4371,17 @@ type BinaryPredicateExpression<
|
|
|
4302
4371
|
} => {
|
|
4303
4372
|
const firstRow = rows[0]
|
|
4304
4373
|
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
4374
|
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
|
-
}
|
|
4375
|
+
const normalizeRow = (row: InsertRowInput<Target>) => {
|
|
4314
4376
|
const assignments = buildMutationAssignments(target, row) as readonly QueryAst.AssignmentClause[]
|
|
4315
4377
|
return {
|
|
4316
4378
|
values: columns.map((columnName) => assignments.find((assignment) => assignment.columnName === columnName)!)
|
|
4317
4379
|
} satisfies QueryAst.InsertValuesRowClause
|
|
4318
|
-
}
|
|
4380
|
+
}
|
|
4381
|
+
const normalizedRows: readonly [QueryAst.InsertValuesRowClause, ...QueryAst.InsertValuesRowClause[]] = [
|
|
4382
|
+
normalizeRow(rows[0]),
|
|
4383
|
+
...rows.slice(1).map(normalizeRow)
|
|
4384
|
+
]
|
|
4319
4385
|
const required = normalizedRows.flatMap((row) =>
|
|
4320
4386
|
row.values.flatMap((entry) => Object.keys(entry.value[Expression.TypeId].dependencies))
|
|
4321
4387
|
)
|
|
@@ -4330,9 +4396,6 @@ type BinaryPredicateExpression<
|
|
|
4330
4396
|
selection: Record<string, Expression.Any>
|
|
4331
4397
|
): readonly [string, ...string[]] => {
|
|
4332
4398
|
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
4399
|
return columns as [string, ...string[]]
|
|
4337
4400
|
}
|
|
4338
4401
|
|
|
@@ -4347,27 +4410,11 @@ type BinaryPredicateExpression<
|
|
|
4347
4410
|
}[]
|
|
4348
4411
|
} => {
|
|
4349
4412
|
const entries = Object.entries(values)
|
|
4350
|
-
if (entries.length === 0) {
|
|
4351
|
-
throw new Error("unnest(...) requires at least one column array")
|
|
4352
|
-
}
|
|
4353
4413
|
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
|
-
}
|
|
4414
|
+
const normalized = entries.map(([columnName, items]) => ({
|
|
4415
|
+
columnName,
|
|
4416
|
+
values: items
|
|
4417
|
+
}))
|
|
4371
4418
|
return {
|
|
4372
4419
|
columns,
|
|
4373
4420
|
values: normalized
|
|
@@ -4379,10 +4426,6 @@ type BinaryPredicateExpression<
|
|
|
4379
4426
|
columnsInput: string | readonly string[]
|
|
4380
4427
|
): readonly [string, ...string[]] => {
|
|
4381
4428
|
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
4429
|
return columns
|
|
4387
4430
|
}
|
|
4388
4431
|
|
|
@@ -4396,7 +4439,21 @@ type BinaryPredicateExpression<
|
|
|
4396
4439
|
columns: normalizeConflictColumns(target, input)
|
|
4397
4440
|
}
|
|
4398
4441
|
}
|
|
4399
|
-
|
|
4442
|
+
if (!Array.isArray(input) && "constraint" in input) {
|
|
4443
|
+
return {
|
|
4444
|
+
kind: "constraint",
|
|
4445
|
+
name: input.constraint
|
|
4446
|
+
}
|
|
4447
|
+
}
|
|
4448
|
+
const columnTarget = input as {
|
|
4449
|
+
readonly columns: string | readonly string[]
|
|
4450
|
+
readonly where?: PredicateInput
|
|
4451
|
+
}
|
|
4452
|
+
return {
|
|
4453
|
+
kind: "columns",
|
|
4454
|
+
columns: normalizeConflictColumns(target, columnTarget.columns),
|
|
4455
|
+
where: columnTarget.where === undefined ? undefined : toDialectExpression(columnTarget.where)
|
|
4456
|
+
}
|
|
4400
4457
|
}
|
|
4401
4458
|
|
|
4402
4459
|
const defaultIndexName = (
|
|
@@ -4447,14 +4504,14 @@ type ValidateTargetColumnInput<
|
|
|
4447
4504
|
Columns extends DdlColumnInput
|
|
4448
4505
|
> = ValidateTargetColumns<Target, NormalizeDdlColumns<Columns>> extends never ? never : Columns
|
|
4449
4506
|
|
|
4450
|
-
type CreateIndexOptions = {
|
|
4451
|
-
readonly name?:
|
|
4507
|
+
type CreateIndexOptions<Name extends string = string> = {
|
|
4508
|
+
readonly name?: NonEmptyStringInput<Name>
|
|
4452
4509
|
readonly unique?: boolean
|
|
4453
4510
|
readonly ifNotExists?: never
|
|
4454
4511
|
}
|
|
4455
4512
|
|
|
4456
|
-
type DropIndexOptions = {
|
|
4457
|
-
readonly name?:
|
|
4513
|
+
type DropIndexOptions<Name extends string = string> = {
|
|
4514
|
+
readonly name?: NonEmptyStringInput<Name>
|
|
4458
4515
|
readonly ifExists?: never
|
|
4459
4516
|
}
|
|
4460
4517
|
|
|
@@ -4558,7 +4615,7 @@ type ValuesRowsDialectInput<
|
|
|
4558
4615
|
BoolDb extends Expression.DbType.Any,
|
|
4559
4616
|
TimestampDb extends Expression.DbType.Any,
|
|
4560
4617
|
NullDb extends Expression.DbType.Any
|
|
4561
|
-
> = Exclude<ValuesRowsDialect<Rows, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>, Dialect> extends never
|
|
4618
|
+
> = Exclude<ValuesRowsDialect<Rows, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>, Dialect | "standard"> extends never
|
|
4562
4619
|
? unknown
|
|
4563
4620
|
: {
|
|
4564
4621
|
readonly __effect_qb_error__: "effect-qb: values rows cannot mix dialects"
|
|
@@ -4613,7 +4670,7 @@ type UnnestColumnsDialectInput<
|
|
|
4613
4670
|
BoolDb extends Expression.DbType.Any,
|
|
4614
4671
|
TimestampDb extends Expression.DbType.Any,
|
|
4615
4672
|
NullDb extends Expression.DbType.Any
|
|
4616
|
-
> = Exclude<UnnestColumnsDialect<Columns, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>, Dialect> extends never
|
|
4673
|
+
> = Exclude<UnnestColumnsDialect<Columns, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>, Dialect | "standard"> extends never
|
|
4617
4674
|
? unknown
|
|
4618
4675
|
: {
|
|
4619
4676
|
readonly __effect_qb_error__: "effect-qb: unnest columns cannot mix dialects"
|
|
@@ -4885,6 +4942,11 @@ type ConflictTargetInput<
|
|
|
4885
4942
|
readonly constraint?: string
|
|
4886
4943
|
}>)
|
|
4887
4944
|
|
|
4945
|
+
type ConflictConstraintNameConstraint<Target> =
|
|
4946
|
+
Target extends { readonly constraint: infer Constraint extends string }
|
|
4947
|
+
? { readonly constraint: NonEmptyStringInput<Constraint> }
|
|
4948
|
+
: unknown
|
|
4949
|
+
|
|
4888
4950
|
type ConflictActionInput<
|
|
4889
4951
|
Target extends MutationTargetLike,
|
|
4890
4952
|
Dialect extends string,
|
|
@@ -5031,7 +5093,7 @@ type MutationOrderLimitSupported<PlanValue extends QueryPlan<any, any, any, any,
|
|
|
5031
5093
|
type MutationTargetTupleDialectConstraint<
|
|
5032
5094
|
Targets extends MutationTargetTuple,
|
|
5033
5095
|
Dialect extends string
|
|
5034
|
-
> = Exclude<TableDialectOf<Targets[number]>, Dialect> extends never ? unknown : never
|
|
5096
|
+
> = Exclude<TableDialectOf<Targets[number]>, Dialect | "standard"> extends never ? unknown : never
|
|
5035
5097
|
|
|
5036
5098
|
type DuplicateMutationTargetSourceName<
|
|
5037
5099
|
Targets extends readonly MutationTargetLike[],
|
|
@@ -5112,7 +5174,7 @@ type KnownIncompatibleMutationDialectFromValues<
|
|
|
5112
5174
|
BoolDb extends Expression.DbType.Any,
|
|
5113
5175
|
TimestampDb extends Expression.DbType.Any,
|
|
5114
5176
|
NullDb extends Expression.DbType.Any
|
|
5115
|
-
> = Exclude<KnownMutationDialectFromValues<Values, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>, Dialect>
|
|
5177
|
+
> = Exclude<KnownMutationDialectFromValues<Values, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>, Dialect | "standard">
|
|
5116
5178
|
|
|
5117
5179
|
type MutationValuesDialectConstraint<
|
|
5118
5180
|
Values,
|
|
@@ -5164,9 +5226,11 @@ type SourceDialectConstraint<
|
|
|
5164
5226
|
Dialect extends string
|
|
5165
5227
|
> = [SourceDialectOf<CurrentSource>] extends [never]
|
|
5166
5228
|
? unknown
|
|
5167
|
-
:
|
|
5168
|
-
?
|
|
5169
|
-
:
|
|
5229
|
+
: Exclude<SourceDialectOf<CurrentSource>, Dialect | "standard"> extends never
|
|
5230
|
+
? unknown
|
|
5231
|
+
: Dialect extends "standard"
|
|
5232
|
+
? unknown
|
|
5233
|
+
: never
|
|
5170
5234
|
|
|
5171
5235
|
type SourceRequirementConstraint<
|
|
5172
5236
|
PlanValue extends QueryPlan<any, any, any, any, any, any, any, any, any, any>,
|
|
@@ -5430,7 +5494,7 @@ type AsCurriedResult<
|
|
|
5430
5494
|
function as<
|
|
5431
5495
|
Alias extends string
|
|
5432
5496
|
>(
|
|
5433
|
-
alias: Alias
|
|
5497
|
+
alias: LiteralStringInput<Alias>
|
|
5434
5498
|
): <Value extends AsCurriedInput<Dialect>>(
|
|
5435
5499
|
value: Value
|
|
5436
5500
|
) => AsCurriedResult<Value, Alias, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>
|
|
@@ -5439,7 +5503,7 @@ type AsCurriedResult<
|
|
|
5439
5503
|
Alias extends string
|
|
5440
5504
|
>(
|
|
5441
5505
|
value: Value,
|
|
5442
|
-
alias: Alias
|
|
5506
|
+
alias: LiteralStringInput<Alias>
|
|
5443
5507
|
): ProjectionAliasedExpression<DialectAsExpression<Value, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>, Alias>
|
|
5444
5508
|
function as<
|
|
5445
5509
|
Rows extends ValuesRowsInput,
|
|
@@ -5450,7 +5514,7 @@ type AsCurriedResult<
|
|
|
5450
5514
|
ValuesOutputShape<Rows, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>,
|
|
5451
5515
|
Dialect
|
|
5452
5516
|
>,
|
|
5453
|
-
alias: Alias
|
|
5517
|
+
alias: LiteralStringInput<Alias>
|
|
5454
5518
|
): ValuesSource<
|
|
5455
5519
|
Rows,
|
|
5456
5520
|
ValuesOutputShape<Rows, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>,
|
|
@@ -5462,11 +5526,11 @@ type AsCurriedResult<
|
|
|
5462
5526
|
Alias extends string
|
|
5463
5527
|
>(
|
|
5464
5528
|
value: DerivedTableCompatiblePlan<PlanValue>,
|
|
5465
|
-
alias: Alias
|
|
5529
|
+
alias: LiteralStringInput<Alias>
|
|
5466
5530
|
): DerivedSource<PlanValue, Alias>
|
|
5467
5531
|
function as(valueOrAlias: unknown, alias?: string): unknown {
|
|
5468
5532
|
if (alias === undefined) {
|
|
5469
|
-
return (value: unknown) => as(value as any, valueOrAlias as
|
|
5533
|
+
return (value: unknown) => as(value as any, valueOrAlias as never)
|
|
5470
5534
|
}
|
|
5471
5535
|
const resolvedAlias = alias
|
|
5472
5536
|
const value = valueOrAlias
|
|
@@ -5506,7 +5570,7 @@ type AsCurriedResult<
|
|
|
5506
5570
|
function with_<
|
|
5507
5571
|
Alias extends string
|
|
5508
5572
|
>(
|
|
5509
|
-
alias: Alias
|
|
5573
|
+
alias: LiteralStringInput<Alias>
|
|
5510
5574
|
): <PlanValue extends QueryPlan<any, any, any, any, any, any, any, any, any, any>>(
|
|
5511
5575
|
value: MysqlCteCompatiblePlan<PlanValue>
|
|
5512
5576
|
) => import("../../internal/query.js").CteSource<PlanValue, Alias>
|
|
@@ -5515,11 +5579,11 @@ type AsCurriedResult<
|
|
|
5515
5579
|
Alias extends string
|
|
5516
5580
|
>(
|
|
5517
5581
|
value: MysqlCteCompatiblePlan<PlanValue>,
|
|
5518
|
-
alias: Alias
|
|
5582
|
+
alias: LiteralStringInput<Alias>
|
|
5519
5583
|
): import("../../internal/query.js").CteSource<PlanValue, Alias>
|
|
5520
5584
|
function with_(valueOrAlias: unknown, alias?: string): unknown {
|
|
5521
5585
|
if (alias === undefined) {
|
|
5522
|
-
return (value: unknown) => with_(value as any, valueOrAlias as
|
|
5586
|
+
return (value: unknown) => with_(value as any, valueOrAlias as never)
|
|
5523
5587
|
}
|
|
5524
5588
|
return makeCteSource(
|
|
5525
5589
|
valueOrAlias as CompletePlan<QueryPlan<any, any, any, any, any, any, any, any, any, any>>,
|
|
@@ -5530,7 +5594,7 @@ type AsCurriedResult<
|
|
|
5530
5594
|
function withRecursive_<
|
|
5531
5595
|
Alias extends string
|
|
5532
5596
|
>(
|
|
5533
|
-
alias: Alias
|
|
5597
|
+
alias: LiteralStringInput<Alias>
|
|
5534
5598
|
): <PlanValue extends QueryPlan<any, any, any, any, any, any, any, any, any, any>>(
|
|
5535
5599
|
value: MysqlCteCompatiblePlan<PlanValue>
|
|
5536
5600
|
) => import("../../internal/query.js").CteSource<PlanValue, Alias>
|
|
@@ -5539,11 +5603,11 @@ type AsCurriedResult<
|
|
|
5539
5603
|
Alias extends string
|
|
5540
5604
|
>(
|
|
5541
5605
|
value: MysqlCteCompatiblePlan<PlanValue>,
|
|
5542
|
-
alias: Alias
|
|
5606
|
+
alias: LiteralStringInput<Alias>
|
|
5543
5607
|
): import("../../internal/query.js").CteSource<PlanValue, Alias>
|
|
5544
5608
|
function withRecursive_(valueOrAlias: unknown, alias?: string): unknown {
|
|
5545
5609
|
if (alias === undefined) {
|
|
5546
|
-
return (value: unknown) => withRecursive_(value as any, valueOrAlias as
|
|
5610
|
+
return (value: unknown) => withRecursive_(value as any, valueOrAlias as never)
|
|
5547
5611
|
}
|
|
5548
5612
|
return makeCteSource(
|
|
5549
5613
|
valueOrAlias as CompletePlan<QueryPlan<any, any, any, any, any, any, any, any, any, any>>,
|
|
@@ -5555,7 +5619,7 @@ type AsCurriedResult<
|
|
|
5555
5619
|
function lateral<
|
|
5556
5620
|
Alias extends string
|
|
5557
5621
|
>(
|
|
5558
|
-
alias: Alias
|
|
5622
|
+
alias: LiteralStringInput<Alias>
|
|
5559
5623
|
): <PlanValue extends QueryPlan<any, any, any, any, any, any, any, any, any, any>>(
|
|
5560
5624
|
value: LateralSourceCompatiblePlan<PlanValue>
|
|
5561
5625
|
) => import("../../internal/query.js").LateralSource<PlanValue, Alias>
|
|
@@ -5564,11 +5628,11 @@ type AsCurriedResult<
|
|
|
5564
5628
|
Alias extends string
|
|
5565
5629
|
>(
|
|
5566
5630
|
value: LateralSourceCompatiblePlan<PlanValue>,
|
|
5567
|
-
alias: Alias
|
|
5631
|
+
alias: LiteralStringInput<Alias>
|
|
5568
5632
|
): import("../../internal/query.js").LateralSource<PlanValue, Alias>
|
|
5569
5633
|
function lateral(valueOrAlias: unknown, alias?: string): unknown {
|
|
5570
5634
|
if (alias === undefined) {
|
|
5571
|
-
return (value: unknown) => lateral(value as any, valueOrAlias as
|
|
5635
|
+
return (value: unknown) => lateral(value as any, valueOrAlias as never)
|
|
5572
5636
|
}
|
|
5573
5637
|
return makeLateralSource(
|
|
5574
5638
|
valueOrAlias as QueryPlan<any, any, any, any, any, any, any, any, any, any>,
|
|
@@ -5595,7 +5659,7 @@ type AsCurriedResult<
|
|
|
5595
5659
|
columns: Columns
|
|
5596
5660
|
& UnnestColumnsShapeInput<Columns>
|
|
5597
5661
|
& UnnestColumnsDialectInput<Columns, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>,
|
|
5598
|
-
alias: Alias
|
|
5662
|
+
alias: LiteralStringInput<Alias>
|
|
5599
5663
|
) => UnnestSource<
|
|
5600
5664
|
UnnestOutputShape<Columns, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>,
|
|
5601
5665
|
Alias,
|
|
@@ -5611,7 +5675,7 @@ type AsCurriedResult<
|
|
|
5611
5675
|
start: Start & NumericExpressionDialectInput<Start, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>,
|
|
5612
5676
|
stop: Stop & NumericExpressionDialectInput<Stop, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>,
|
|
5613
5677
|
step?: Step & (Step extends NumericExpressionInput ? NumericExpressionDialectInput<Step, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb> : unknown),
|
|
5614
|
-
alias?: Alias
|
|
5678
|
+
alias?: LiteralStringInput<Alias>
|
|
5615
5679
|
) => Dialect extends "postgres"
|
|
5616
5680
|
? TableFunctionSource<
|
|
5617
5681
|
GenerateSeriesOutputShape<Start, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>,
|
|
@@ -5658,8 +5722,8 @@ type AsCurriedResult<
|
|
|
5658
5722
|
? SelectSelectionNonEmptyError<Selection>
|
|
5659
5723
|
: unknown
|
|
5660
5724
|
|
|
5661
|
-
export type SelectApi = <Selection extends SelectionShape>(
|
|
5662
|
-
selection: Selection & SelectionRootObjectConstraint<Selection> & SelectionNestedNonEmptyConstraint<Selection> & SelectSelectionNonEmptyConstraint<Selection>
|
|
5725
|
+
export type SelectApi = <const Selection extends SelectionShape>(
|
|
5726
|
+
selection: Selection & SelectionRootObjectConstraint<Selection> & SelectionNestedNonEmptyConstraint<Selection> & SelectSelectionNonEmptyConstraint<Selection> & SelectionProjectionAliasCollisionConstraint<Selection>
|
|
5663
5727
|
) => QueryPlan<
|
|
5664
5728
|
Selection,
|
|
5665
5729
|
ExtractRequired<Selection>,
|
|
@@ -6124,8 +6188,8 @@ type AsCurriedResult<
|
|
|
6124
6188
|
: unknown
|
|
6125
6189
|
|
|
6126
6190
|
type ReturningApi = Dialect extends "postgres"
|
|
6127
|
-
? <Selection extends SelectionShape>(
|
|
6128
|
-
selection: Selection & SelectionRootObjectConstraint<Selection> & SelectionNestedNonEmptyConstraint<Selection> & ReturningSelectionNonEmptyConstraint<Selection>
|
|
6191
|
+
? <const Selection extends SelectionShape>(
|
|
6192
|
+
selection: Selection & SelectionRootObjectConstraint<Selection> & SelectionNestedNonEmptyConstraint<Selection> & ReturningSelectionNonEmptyConstraint<Selection> & SelectionProjectionAliasCollisionConstraint<Selection>
|
|
6129
6193
|
) =>
|
|
6130
6194
|
<PlanValue extends QueryPlan<any, any, any, any, any, any, any, any, any, any>>(
|
|
6131
6195
|
plan: PlanValue & RequireMutationStatement<PlanValue>
|
|
@@ -6194,9 +6258,9 @@ type AsCurriedResult<
|
|
|
6194
6258
|
const Columns extends DdlColumnInput,
|
|
6195
6259
|
UpdateValues extends MutationInputOf<Table.UpdateOf<Target>> | undefined = MutationInputOf<Table.UpdateOf<Target>> | undefined,
|
|
6196
6260
|
Options extends ConflictActionInput<Target, Dialect, UpdateValues> = ConflictActionInput<Target, Dialect, UpdateValues>,
|
|
6197
|
-
ConflictTarget extends ConflictTargetInput<Target, Dialect, Columns> = ConflictTargetInput<Target, Dialect, Columns>
|
|
6261
|
+
const ConflictTarget extends ConflictTargetInput<Target, Dialect, Columns> = ConflictTargetInput<Target, Dialect, Columns>
|
|
6198
6262
|
>(
|
|
6199
|
-
target: ConflictTarget
|
|
6263
|
+
target: ConflictTarget & ConflictConstraintNameConstraint<ConflictTarget>,
|
|
6200
6264
|
options?: Options & ConflictActionUpdateNonEmptyConstraint<Options>
|
|
6201
6265
|
) =>
|
|
6202
6266
|
<PlanValue extends QueryPlan<any, any, any, any, any, any, any, any, any, any>>(
|
|
@@ -6358,7 +6422,7 @@ type AsCurriedResult<
|
|
|
6358
6422
|
target: Target,
|
|
6359
6423
|
source: Source & (
|
|
6360
6424
|
SourceRequiredOf<Source> extends never ? unknown : SourceRequirementError<Source>
|
|
6361
|
-
),
|
|
6425
|
+
) & SourceDialectConstraint<Source, Dialect>,
|
|
6362
6426
|
on: On,
|
|
6363
6427
|
options: MergeOptions<Target, MatchedValues, InsertValues, MatchedPredicate, NotMatchedPredicate>
|
|
6364
6428
|
) => QueryPlan<
|
|
@@ -6572,7 +6636,7 @@ type AsCurriedResult<
|
|
|
6572
6636
|
"rollback"
|
|
6573
6637
|
>
|
|
6574
6638
|
|
|
6575
|
-
type SavepointApi = <Name extends string>(name: Name) => QueryPlan<
|
|
6639
|
+
type SavepointApi = <Name extends string>(name: NonEmptyStringInput<Name>) => QueryPlan<
|
|
6576
6640
|
{},
|
|
6577
6641
|
never,
|
|
6578
6642
|
{},
|
|
@@ -6585,7 +6649,7 @@ type AsCurriedResult<
|
|
|
6585
6649
|
"savepoint"
|
|
6586
6650
|
>
|
|
6587
6651
|
|
|
6588
|
-
type RollbackToApi = <Name extends string>(name: Name) => QueryPlan<
|
|
6652
|
+
type RollbackToApi = <Name extends string>(name: NonEmptyStringInput<Name>) => QueryPlan<
|
|
6589
6653
|
{},
|
|
6590
6654
|
never,
|
|
6591
6655
|
{},
|
|
@@ -6598,7 +6662,7 @@ type AsCurriedResult<
|
|
|
6598
6662
|
"rollbackTo"
|
|
6599
6663
|
>
|
|
6600
6664
|
|
|
6601
|
-
type ReleaseSavepointApi = <Name extends string>(name: Name) => QueryPlan<
|
|
6665
|
+
type ReleaseSavepointApi = <Name extends string>(name: NonEmptyStringInput<Name>) => QueryPlan<
|
|
6602
6666
|
{},
|
|
6603
6667
|
never,
|
|
6604
6668
|
{},
|
|
@@ -6643,10 +6707,10 @@ type AsCurriedResult<
|
|
|
6643
6707
|
"dropTable"
|
|
6644
6708
|
>
|
|
6645
6709
|
|
|
6646
|
-
type CreateIndexApi = <Target extends SchemaTableLike, const Columns extends DdlColumnInput>(
|
|
6710
|
+
type CreateIndexApi = <Target extends SchemaTableLike, const Columns extends DdlColumnInput, Name extends string = string>(
|
|
6647
6711
|
target: Target,
|
|
6648
6712
|
columns: Columns & ValidateDdlColumnInput<Target, Columns>,
|
|
6649
|
-
options?: CreateIndexOptions
|
|
6713
|
+
options?: CreateIndexOptions<Name>
|
|
6650
6714
|
) => QueryPlan<
|
|
6651
6715
|
{},
|
|
6652
6716
|
never,
|
|
@@ -6660,10 +6724,10 @@ type AsCurriedResult<
|
|
|
6660
6724
|
"createIndex"
|
|
6661
6725
|
>
|
|
6662
6726
|
|
|
6663
|
-
type DropIndexApi = <Target extends SchemaTableLike, const Columns extends DdlColumnInput>(
|
|
6727
|
+
type DropIndexApi = <Target extends SchemaTableLike, const Columns extends DdlColumnInput, Name extends string = string>(
|
|
6664
6728
|
target: Target,
|
|
6665
6729
|
columns: Columns & ValidateDdlColumnInput<Target, Columns>,
|
|
6666
|
-
options?: DropIndexOptions
|
|
6730
|
+
options?: DropIndexOptions<Name>
|
|
6667
6731
|
) => QueryPlan<
|
|
6668
6732
|
{},
|
|
6669
6733
|
never,
|