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 { sqliteDatatypes } from "../datatypes/index.js"
|
|
@@ -6,6 +6,12 @@ import { sqliteDatatypes } 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,
|
|
@@ -1543,7 +1583,7 @@ const profile: QueryDialectProfile<Dialect, TextDb, NumericDb, BoolDb, Timestamp
|
|
|
1543
1583
|
type: sqliteDatatypes
|
|
1544
1584
|
}
|
|
1545
1585
|
const ValuesInputProto = {
|
|
1546
|
-
pipe(this:
|
|
1586
|
+
pipe(this: Pipeable) {
|
|
1547
1587
|
return pipeArguments(this, arguments)
|
|
1548
1588
|
}
|
|
1549
1589
|
}
|
|
@@ -1554,7 +1594,7 @@ const profile: QueryDialectProfile<Dialect, TextDb, NumericDb, BoolDb, Timestamp
|
|
|
1554
1594
|
if (value === null || value instanceof Date) {
|
|
1555
1595
|
return undefined
|
|
1556
1596
|
}
|
|
1557
|
-
return Schema.Literal(value) as
|
|
1597
|
+
return Schema.Literal(value) as Schema.Schema.Any
|
|
1558
1598
|
}
|
|
1559
1599
|
|
|
1560
1600
|
const literal = <const Value extends LiteralValue>(
|
|
@@ -1641,7 +1681,7 @@ const profile: QueryDialectProfile<Dialect, TextDb, NumericDb, BoolDb, Timestamp
|
|
|
1641
1681
|
value: Expression.Any,
|
|
1642
1682
|
target: Expression.Any
|
|
1643
1683
|
): Expression.Any => {
|
|
1644
|
-
const ast = (value as
|
|
1684
|
+
const ast = (value as Expression.Any & { readonly [ExpressionAst.TypeId]: ExpressionAst.Any })[ExpressionAst.TypeId]
|
|
1645
1685
|
if (ast.kind !== "literal") {
|
|
1646
1686
|
return value
|
|
1647
1687
|
}
|
|
@@ -1662,8 +1702,8 @@ const profile: QueryDialectProfile<Dialect, TextDb, NumericDb, BoolDb, Timestamp
|
|
|
1662
1702
|
left: Expression.Any,
|
|
1663
1703
|
right: Expression.Any
|
|
1664
1704
|
): readonly [Expression.Any, Expression.Any] => {
|
|
1665
|
-
const leftAst = (left as
|
|
1666
|
-
const rightAst = (right as
|
|
1705
|
+
const leftAst = (left as Expression.Any & { readonly [ExpressionAst.TypeId]: ExpressionAst.Any })[ExpressionAst.TypeId]
|
|
1706
|
+
const rightAst = (right as Expression.Any & { readonly [ExpressionAst.TypeId]: ExpressionAst.Any })[ExpressionAst.TypeId]
|
|
1667
1707
|
if (leftAst.kind === "literal" && rightAst.kind !== "literal") {
|
|
1668
1708
|
return [retargetLiteralExpression(left, right), right]
|
|
1669
1709
|
}
|
|
@@ -1696,7 +1736,7 @@ const profile: QueryDialectProfile<Dialect, TextDb, NumericDb, BoolDb, Timestamp
|
|
|
1696
1736
|
): readonly Expression.Any[] => {
|
|
1697
1737
|
const flattened: Array<Expression.Any> = []
|
|
1698
1738
|
for (const value of values) {
|
|
1699
|
-
const ast = (value as
|
|
1739
|
+
const ast = (value as Expression.Any & { readonly [ExpressionAst.TypeId]: ExpressionAst.Any })[ExpressionAst.TypeId]
|
|
1700
1740
|
if (ast.kind === kind) {
|
|
1701
1741
|
flattened.push(...ast.values)
|
|
1702
1742
|
} else {
|
|
@@ -1742,7 +1782,33 @@ const profile: QueryDialectProfile<Dialect, TextDb, NumericDb, BoolDb, Timestamp
|
|
|
1742
1782
|
if (operations.every((operation) => typeof operation === "function")) {
|
|
1743
1783
|
return pipeArguments(this, arguments)
|
|
1744
1784
|
}
|
|
1745
|
-
|
|
1785
|
+
const valuesForMixedPipe = (value: unknown): readonly Expression.Any[] => {
|
|
1786
|
+
if (typeof value !== "object" || value === null || !(Expression.TypeId in value)) {
|
|
1787
|
+
return []
|
|
1788
|
+
}
|
|
1789
|
+
const expression = value as Expression.Any & {
|
|
1790
|
+
readonly [ExpressionAst.TypeId]: ExpressionAst.Any
|
|
1791
|
+
}
|
|
1792
|
+
const ast = expression[ExpressionAst.TypeId]
|
|
1793
|
+
if (ast.kind === kind) {
|
|
1794
|
+
return (ast as {
|
|
1795
|
+
readonly values: readonly Expression.Any[]
|
|
1796
|
+
}).values
|
|
1797
|
+
}
|
|
1798
|
+
return [expression]
|
|
1799
|
+
}
|
|
1800
|
+
let current: unknown = this
|
|
1801
|
+
for (const operation of operations) {
|
|
1802
|
+
if (typeof operation === "function") {
|
|
1803
|
+
current = (operation as (value: unknown) => unknown)(current)
|
|
1804
|
+
continue
|
|
1805
|
+
}
|
|
1806
|
+
current = makeVariadicBooleanExpression(
|
|
1807
|
+
kind,
|
|
1808
|
+
[...valuesForMixedPipe(current), toDialectExpression(operation as ExpressionInput)] as const
|
|
1809
|
+
)
|
|
1810
|
+
}
|
|
1811
|
+
return current
|
|
1746
1812
|
}
|
|
1747
1813
|
})
|
|
1748
1814
|
|
|
@@ -1763,9 +1829,6 @@ const profile: QueryDialectProfile<Dialect, TextDb, NumericDb, BoolDb, Timestamp
|
|
|
1763
1829
|
const partitionBy = [...(spec?.partitionBy ?? [])] as unknown as PartitionBy
|
|
1764
1830
|
const orderBy = (spec?.orderBy ?? []).map((term) => {
|
|
1765
1831
|
const direction = term.direction ?? "asc"
|
|
1766
|
-
if (direction !== "asc" && direction !== "desc") {
|
|
1767
|
-
throw new Error("window order direction must be asc or desc")
|
|
1768
|
-
}
|
|
1769
1832
|
return {
|
|
1770
1833
|
value: term.value,
|
|
1771
1834
|
direction
|
|
@@ -1906,7 +1969,8 @@ type BinaryPredicateExpression<
|
|
|
1906
1969
|
>(
|
|
1907
1970
|
...args: ComparableArgs<Left, Right, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb, "eq">
|
|
1908
1971
|
): BinaryPredicateExpression<Left, Right, "eq"> => {
|
|
1909
|
-
const
|
|
1972
|
+
const left = args[0] as Left
|
|
1973
|
+
const right = args[1] as Right
|
|
1910
1974
|
return buildBinaryPredicate(left as ExpressionInput, right as ExpressionInput, "eq")
|
|
1911
1975
|
}
|
|
1912
1976
|
|
|
@@ -1916,7 +1980,8 @@ type BinaryPredicateExpression<
|
|
|
1916
1980
|
>(
|
|
1917
1981
|
...args: ComparableArgs<Left, Right, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb, "neq">
|
|
1918
1982
|
): BinaryPredicateExpression<Left, Right, "neq"> => {
|
|
1919
|
-
const
|
|
1983
|
+
const left = args[0] as Left
|
|
1984
|
+
const right = args[1] as Right
|
|
1920
1985
|
return buildBinaryPredicate(left as ExpressionInput, right as ExpressionInput, "neq")
|
|
1921
1986
|
}
|
|
1922
1987
|
|
|
@@ -1926,7 +1991,8 @@ type BinaryPredicateExpression<
|
|
|
1926
1991
|
>(
|
|
1927
1992
|
...args: ComparableArgs<Left, Right, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb, "lt">
|
|
1928
1993
|
): BinaryPredicateExpression<Left, Right, "lt"> => {
|
|
1929
|
-
const
|
|
1994
|
+
const left = args[0] as Left
|
|
1995
|
+
const right = args[1] as Right
|
|
1930
1996
|
return buildBinaryPredicate(left as ExpressionInput, right as ExpressionInput, "lt")
|
|
1931
1997
|
}
|
|
1932
1998
|
|
|
@@ -1936,7 +2002,8 @@ type BinaryPredicateExpression<
|
|
|
1936
2002
|
>(
|
|
1937
2003
|
...args: ComparableArgs<Left, Right, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb, "lte">
|
|
1938
2004
|
): BinaryPredicateExpression<Left, Right, "lte"> => {
|
|
1939
|
-
const
|
|
2005
|
+
const left = args[0] as Left
|
|
2006
|
+
const right = args[1] as Right
|
|
1940
2007
|
return buildBinaryPredicate(left as ExpressionInput, right as ExpressionInput, "lte")
|
|
1941
2008
|
}
|
|
1942
2009
|
|
|
@@ -1946,7 +2013,8 @@ type BinaryPredicateExpression<
|
|
|
1946
2013
|
>(
|
|
1947
2014
|
...args: ComparableArgs<Left, Right, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb, "gt">
|
|
1948
2015
|
): BinaryPredicateExpression<Left, Right, "gt"> => {
|
|
1949
|
-
const
|
|
2016
|
+
const left = args[0] as Left
|
|
2017
|
+
const right = args[1] as Right
|
|
1950
2018
|
return buildBinaryPredicate(left as ExpressionInput, right as ExpressionInput, "gt")
|
|
1951
2019
|
}
|
|
1952
2020
|
|
|
@@ -1956,7 +2024,8 @@ type BinaryPredicateExpression<
|
|
|
1956
2024
|
>(
|
|
1957
2025
|
...args: ComparableArgs<Left, Right, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb, "gte">
|
|
1958
2026
|
): BinaryPredicateExpression<Left, Right, "gte"> => {
|
|
1959
|
-
const
|
|
2027
|
+
const left = args[0] as Left
|
|
2028
|
+
const right = args[1] as Right
|
|
1960
2029
|
return buildBinaryPredicate(left as ExpressionInput, right as ExpressionInput, "gte")
|
|
1961
2030
|
}
|
|
1962
2031
|
|
|
@@ -1966,7 +2035,8 @@ type BinaryPredicateExpression<
|
|
|
1966
2035
|
>(
|
|
1967
2036
|
...args: TextArgs<Left, Right, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb, "like">
|
|
1968
2037
|
): BinaryPredicateExpression<Left, Right, "like"> => {
|
|
1969
|
-
const
|
|
2038
|
+
const left = args[0] as Left
|
|
2039
|
+
const right = args[1] as Right
|
|
1970
2040
|
return buildBinaryPredicate(left as ExpressionInput, right as ExpressionInput, "like")
|
|
1971
2041
|
}
|
|
1972
2042
|
|
|
@@ -1976,7 +2046,8 @@ type BinaryPredicateExpression<
|
|
|
1976
2046
|
>(
|
|
1977
2047
|
...args: TextArgs<Left, Right, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb, "ilike">
|
|
1978
2048
|
): BinaryPredicateExpression<Left, Right, "ilike"> => {
|
|
1979
|
-
const
|
|
2049
|
+
const left = args[0] as Left
|
|
2050
|
+
const right = args[1] as Right
|
|
1980
2051
|
return buildBinaryPredicate(left as ExpressionInput, right as ExpressionInput, "ilike")
|
|
1981
2052
|
}
|
|
1982
2053
|
|
|
@@ -1986,7 +2057,8 @@ type BinaryPredicateExpression<
|
|
|
1986
2057
|
>(
|
|
1987
2058
|
...args: TextArgs<Left, Right, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb, "regexMatch">
|
|
1988
2059
|
): BinaryPredicateExpression<Left, Right, "regexMatch"> => {
|
|
1989
|
-
const
|
|
2060
|
+
const left = args[0] as Left
|
|
2061
|
+
const right = args[1] as Right
|
|
1990
2062
|
return buildBinaryPredicate(left as ExpressionInput, right as ExpressionInput, "regexMatch")
|
|
1991
2063
|
}
|
|
1992
2064
|
|
|
@@ -1996,7 +2068,8 @@ type BinaryPredicateExpression<
|
|
|
1996
2068
|
>(
|
|
1997
2069
|
...args: TextArgs<Left, Right, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb, "regexIMatch">
|
|
1998
2070
|
): BinaryPredicateExpression<Left, Right, "regexIMatch"> => {
|
|
1999
|
-
const
|
|
2071
|
+
const left = args[0] as Left
|
|
2072
|
+
const right = args[1] as Right
|
|
2000
2073
|
return buildBinaryPredicate(left as ExpressionInput, right as ExpressionInput, "regexIMatch")
|
|
2001
2074
|
}
|
|
2002
2075
|
|
|
@@ -2006,7 +2079,8 @@ type BinaryPredicateExpression<
|
|
|
2006
2079
|
>(
|
|
2007
2080
|
...args: TextArgs<Left, Right, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb, "regexNotMatch">
|
|
2008
2081
|
): BinaryPredicateExpression<Left, Right, "regexNotMatch"> => {
|
|
2009
|
-
const
|
|
2082
|
+
const left = args[0] as Left
|
|
2083
|
+
const right = args[1] as Right
|
|
2010
2084
|
return buildBinaryPredicate(left as ExpressionInput, right as ExpressionInput, "regexNotMatch")
|
|
2011
2085
|
}
|
|
2012
2086
|
|
|
@@ -2016,7 +2090,8 @@ type BinaryPredicateExpression<
|
|
|
2016
2090
|
>(
|
|
2017
2091
|
...args: TextArgs<Left, Right, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb, "regexNotIMatch">
|
|
2018
2092
|
): BinaryPredicateExpression<Left, Right, "regexNotIMatch"> => {
|
|
2019
|
-
const
|
|
2093
|
+
const left = args[0] as Left
|
|
2094
|
+
const right = args[1] as Right
|
|
2020
2095
|
return buildBinaryPredicate(left as ExpressionInput, right as ExpressionInput, "regexNotIMatch")
|
|
2021
2096
|
}
|
|
2022
2097
|
|
|
@@ -2026,7 +2101,8 @@ type BinaryPredicateExpression<
|
|
|
2026
2101
|
>(
|
|
2027
2102
|
...args: ComparableArgs<Left, Right, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb, "isDistinctFrom">
|
|
2028
2103
|
): BinaryPredicateExpression<Left, Right, "isDistinctFrom", "never"> => {
|
|
2029
|
-
const
|
|
2104
|
+
const left = args[0] as Left
|
|
2105
|
+
const right = args[1] as Right
|
|
2030
2106
|
return buildBinaryPredicate(left as ExpressionInput, right as ExpressionInput, "isDistinctFrom", "never")
|
|
2031
2107
|
}
|
|
2032
2108
|
|
|
@@ -2036,7 +2112,8 @@ type BinaryPredicateExpression<
|
|
|
2036
2112
|
>(
|
|
2037
2113
|
...args: ComparableArgs<Left, Right, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb, "isNotDistinctFrom">
|
|
2038
2114
|
): BinaryPredicateExpression<Left, Right, "isNotDistinctFrom", "never"> => {
|
|
2039
|
-
const
|
|
2115
|
+
const left = args[0] as Left
|
|
2116
|
+
const right = args[1] as Right
|
|
2040
2117
|
return buildBinaryPredicate(left as ExpressionInput, right as ExpressionInput, "isNotDistinctFrom", "never")
|
|
2041
2118
|
}
|
|
2042
2119
|
|
|
@@ -2187,62 +2264,62 @@ type BinaryPredicateExpression<
|
|
|
2187
2264
|
})
|
|
2188
2265
|
|
|
2189
2266
|
const range = <Kind extends string, Subtype extends Expression.DbType.Any>(
|
|
2190
|
-
kind: Kind
|
|
2267
|
+
kind: NonEmptyStringInput<Kind>,
|
|
2191
2268
|
subtype: Subtype
|
|
2192
2269
|
): Expression.DbType.Range<Dialect, Subtype, Kind> => ({
|
|
2193
2270
|
dialect: profile.dialect,
|
|
2194
|
-
kind,
|
|
2271
|
+
kind: kind as Kind,
|
|
2195
2272
|
subtype
|
|
2196
2273
|
})
|
|
2197
2274
|
|
|
2198
2275
|
const multirange = <Kind extends string, Subtype extends Expression.DbType.Any>(
|
|
2199
|
-
kind: Kind
|
|
2276
|
+
kind: NonEmptyStringInput<Kind>,
|
|
2200
2277
|
subtype: Subtype
|
|
2201
2278
|
): Expression.DbType.Multirange<Dialect, Subtype, Kind> => ({
|
|
2202
2279
|
dialect: profile.dialect,
|
|
2203
|
-
kind,
|
|
2280
|
+
kind: kind as Kind,
|
|
2204
2281
|
subtype
|
|
2205
2282
|
})
|
|
2206
2283
|
|
|
2207
2284
|
const record = <Kind extends string, Fields extends Record<string, Expression.DbType.Any>>(
|
|
2208
|
-
kind: Kind
|
|
2285
|
+
kind: NonEmptyStringInput<Kind>,
|
|
2209
2286
|
fields: Fields
|
|
2210
2287
|
): Expression.DbType.Composite<Dialect, Fields, Kind> => ({
|
|
2211
2288
|
dialect: profile.dialect,
|
|
2212
|
-
kind,
|
|
2289
|
+
kind: kind as Kind,
|
|
2213
2290
|
fields
|
|
2214
2291
|
})
|
|
2215
2292
|
|
|
2216
2293
|
const domain = <Kind extends string, Base extends Expression.DbType.Any>(
|
|
2217
|
-
kind: Kind
|
|
2294
|
+
kind: NonEmptyStringInput<Kind>,
|
|
2218
2295
|
base: Base
|
|
2219
2296
|
): Expression.DbType.Domain<Dialect, Base, Kind> => ({
|
|
2220
2297
|
dialect: profile.dialect,
|
|
2221
|
-
kind,
|
|
2298
|
+
kind: kind as Kind,
|
|
2222
2299
|
base
|
|
2223
2300
|
})
|
|
2224
2301
|
|
|
2225
2302
|
const enum_ = <Kind extends string>(
|
|
2226
|
-
kind: Kind
|
|
2303
|
+
kind: NonEmptyStringInput<Kind>
|
|
2227
2304
|
): Expression.DbType.Enum<Dialect, Kind> => ({
|
|
2228
2305
|
dialect: profile.dialect,
|
|
2229
|
-
kind,
|
|
2306
|
+
kind: kind as Kind,
|
|
2230
2307
|
variant: "enum"
|
|
2231
2308
|
})
|
|
2232
2309
|
|
|
2233
2310
|
const set = <Kind extends string>(
|
|
2234
|
-
kind: Kind
|
|
2311
|
+
kind: NonEmptyStringInput<Kind>
|
|
2235
2312
|
): Expression.DbType.Set<Dialect, Kind> => ({
|
|
2236
2313
|
dialect: profile.dialect,
|
|
2237
|
-
kind,
|
|
2314
|
+
kind: kind as Kind,
|
|
2238
2315
|
variant: "set"
|
|
2239
2316
|
})
|
|
2240
2317
|
|
|
2241
2318
|
const custom = <Kind extends string>(
|
|
2242
|
-
kind: Kind
|
|
2319
|
+
kind: NonEmptyStringInput<Kind>
|
|
2243
2320
|
): Expression.DbType.Base<Dialect, Kind> => ({
|
|
2244
2321
|
dialect: profile.dialect,
|
|
2245
|
-
kind
|
|
2322
|
+
kind: kind as Kind
|
|
2246
2323
|
})
|
|
2247
2324
|
|
|
2248
2325
|
const driverValueMapping = <Db extends Expression.DbType.Any>(
|
|
@@ -3050,9 +3127,12 @@ type BinaryPredicateExpression<
|
|
|
3050
3127
|
}
|
|
3051
3128
|
)
|
|
3052
3129
|
|
|
3053
|
-
const jsonPathExists = <
|
|
3130
|
+
const jsonPathExists = <
|
|
3131
|
+
Base extends JsonExpressionLike<any>,
|
|
3132
|
+
Query extends JsonQueryInput
|
|
3133
|
+
>(
|
|
3054
3134
|
base: Base,
|
|
3055
|
-
query:
|
|
3135
|
+
query: JsonQueryValue<Query>
|
|
3056
3136
|
) => {
|
|
3057
3137
|
if (isJsonPathValue(query)) {
|
|
3058
3138
|
return buildJsonNodeExpression(
|
|
@@ -3100,9 +3180,12 @@ type BinaryPredicateExpression<
|
|
|
3100
3180
|
}
|
|
3101
3181
|
)
|
|
3102
3182
|
|
|
3103
|
-
const jsonPathMatch = <
|
|
3183
|
+
const jsonPathMatch = <
|
|
3184
|
+
Base extends JsonExpressionLike<any>,
|
|
3185
|
+
Query extends JsonQueryInput
|
|
3186
|
+
>(
|
|
3104
3187
|
base: Base,
|
|
3105
|
-
query:
|
|
3188
|
+
query: JsonQueryValue<Query>
|
|
3106
3189
|
) => {
|
|
3107
3190
|
if (isJsonPathValue(query)) {
|
|
3108
3191
|
return buildJsonNodeExpression(
|
|
@@ -3329,7 +3412,8 @@ type BinaryPredicateExpression<
|
|
|
3329
3412
|
>(
|
|
3330
3413
|
...args: ContainmentArgs<Left, Right, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb, "contains">
|
|
3331
3414
|
): BinaryPredicateExpression<Left, Right, "contains"> => {
|
|
3332
|
-
const
|
|
3415
|
+
const left = args[0] as Left
|
|
3416
|
+
const right = args[1] as Right
|
|
3333
3417
|
return buildBinaryPredicate(left as ExpressionInput, right as ExpressionInput, "contains")
|
|
3334
3418
|
}
|
|
3335
3419
|
|
|
@@ -3339,7 +3423,8 @@ type BinaryPredicateExpression<
|
|
|
3339
3423
|
>(
|
|
3340
3424
|
...args: ContainmentArgs<Left, Right, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb, "containedBy">
|
|
3341
3425
|
): BinaryPredicateExpression<Left, Right, "containedBy"> => {
|
|
3342
|
-
const
|
|
3426
|
+
const left = args[0] as Left
|
|
3427
|
+
const right = args[1] as Right
|
|
3343
3428
|
return buildBinaryPredicate(left as ExpressionInput, right as ExpressionInput, "containedBy")
|
|
3344
3429
|
}
|
|
3345
3430
|
|
|
@@ -3349,7 +3434,8 @@ type BinaryPredicateExpression<
|
|
|
3349
3434
|
>(
|
|
3350
3435
|
...args: ContainmentArgs<Left, Right, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb, "overlaps">
|
|
3351
3436
|
): BinaryPredicateExpression<Left, Right, "overlaps"> => {
|
|
3352
|
-
const
|
|
3437
|
+
const left = args[0] as Left
|
|
3438
|
+
const right = args[1] as Right
|
|
3353
3439
|
return buildBinaryPredicate(left as ExpressionInput, right as ExpressionInput, "overlaps")
|
|
3354
3440
|
}
|
|
3355
3441
|
|
|
@@ -3776,12 +3862,9 @@ type BinaryPredicateExpression<
|
|
|
3776
3862
|
>
|
|
3777
3863
|
}
|
|
3778
3864
|
|
|
3779
|
-
const call =
|
|
3780
|
-
|
|
3781
|
-
|
|
3782
|
-
>(
|
|
3783
|
-
name: Name,
|
|
3784
|
-
...args: Args
|
|
3865
|
+
const call: FunctionCallApi = (
|
|
3866
|
+
name: string,
|
|
3867
|
+
...args: readonly ExpressionInput[]
|
|
3785
3868
|
): Expression.Any => {
|
|
3786
3869
|
const expressions = args.map((value) => toDialectExpression(value)) as readonly Expression.Any[]
|
|
3787
3870
|
return makeExpression({
|
|
@@ -4017,9 +4100,6 @@ type BinaryPredicateExpression<
|
|
|
4017
4100
|
ExpressionAst.ExcludedNode<AstOf<Value> extends ExpressionAst.ColumnNode<any, infer ColumnName extends string> ? ColumnName : string>
|
|
4018
4101
|
> => {
|
|
4019
4102
|
const ast = ((value as unknown) as Expression.Any & { readonly [ExpressionAst.TypeId]: ExpressionAst.Any })[ExpressionAst.TypeId]
|
|
4020
|
-
if (ast.kind !== "column") {
|
|
4021
|
-
throw new Error("excluded(...) only accepts bound table columns")
|
|
4022
|
-
}
|
|
4023
4103
|
return makeExpression({
|
|
4024
4104
|
runtime: undefined as Expression.RuntimeOf<Value>,
|
|
4025
4105
|
dbType: value[Expression.TypeId].dbType as Expression.DbTypeOf<Value>,
|
|
@@ -4032,7 +4112,7 @@ type BinaryPredicateExpression<
|
|
|
4032
4112
|
dependencies: {}
|
|
4033
4113
|
}, {
|
|
4034
4114
|
kind: "excluded",
|
|
4035
|
-
columnName: ast.columnName
|
|
4115
|
+
columnName: (ast as ExpressionAst.ColumnNode<any, string>).columnName
|
|
4036
4116
|
}) as unknown as AstBackedExpression<
|
|
4037
4117
|
Expression.RuntimeOf<Value>,
|
|
4038
4118
|
Expression.DbTypeOf<Value>,
|
|
@@ -4065,7 +4145,7 @@ type BinaryPredicateExpression<
|
|
|
4065
4145
|
}
|
|
4066
4146
|
if (value !== null && typeof value === "object" && Expression.TypeId in value) {
|
|
4067
4147
|
const expression = value as unknown as Expression.Any
|
|
4068
|
-
const ast = (expression as
|
|
4148
|
+
const ast = (expression as Expression.Any & { readonly [ExpressionAst.TypeId]: ExpressionAst.Any })[ExpressionAst.TypeId]
|
|
4069
4149
|
if (ast.kind === "literal") {
|
|
4070
4150
|
const normalizedValue = normalizeMutationValue(ast.value)
|
|
4071
4151
|
return makeExpression({
|
|
@@ -4134,8 +4214,8 @@ type BinaryPredicateExpression<
|
|
|
4134
4214
|
: ">="
|
|
4135
4215
|
|
|
4136
4216
|
const targetSourceDetails = (table: MutationTargetLike | SchemaTableLike) => {
|
|
4137
|
-
const sourceName = (table as
|
|
4138
|
-
const sourceBaseName = (table as
|
|
4217
|
+
const sourceName = (table as TableLike)[Table.TypeId].name
|
|
4218
|
+
const sourceBaseName = (table as TableLike)[Table.TypeId].baseName
|
|
4139
4219
|
return {
|
|
4140
4220
|
sourceName,
|
|
4141
4221
|
sourceBaseName
|
|
@@ -4225,12 +4305,7 @@ type BinaryPredicateExpression<
|
|
|
4225
4305
|
|
|
4226
4306
|
const normalizeUnnestColumns = (columns: UnnestColumnsInput): Record<string, readonly Expression.Any[]> =>
|
|
4227
4307
|
Object.fromEntries(
|
|
4228
|
-
Object.entries(columns).map(([key, values]) =>
|
|
4229
|
-
if (!Array.isArray(values)) {
|
|
4230
|
-
throw new Error("unnest(...) expects every value to be an array")
|
|
4231
|
-
}
|
|
4232
|
-
return [key, values.map((value) => toDialectExpression(value))]
|
|
4233
|
-
})
|
|
4308
|
+
Object.entries(columns).map(([key, values]) => [key, values.map((value) => toDialectExpression(value))])
|
|
4234
4309
|
) as Record<string, readonly Expression.Any[]>
|
|
4235
4310
|
|
|
4236
4311
|
const normalizeMutationTargets = (
|
|
@@ -4276,13 +4351,7 @@ type BinaryPredicateExpression<
|
|
|
4276
4351
|
const getMutationColumn = (
|
|
4277
4352
|
columns: Record<string, unknown>,
|
|
4278
4353
|
columnName: string
|
|
4279
|
-
): Expression.Any =>
|
|
4280
|
-
const column = columns[columnName]
|
|
4281
|
-
if (column === undefined || column === null || typeof column !== "object" || !(Expression.TypeId in column)) {
|
|
4282
|
-
throw new Error("effect-qb: unknown mutation column")
|
|
4283
|
-
}
|
|
4284
|
-
return column as Expression.Any
|
|
4285
|
-
}
|
|
4354
|
+
): Expression.Any => columns[columnName] as Expression.Any
|
|
4286
4355
|
|
|
4287
4356
|
const buildMutationAssignments = <Target extends MutationTargetInput, Values>(
|
|
4288
4357
|
target: Target,
|
|
@@ -4298,7 +4367,7 @@ type BinaryPredicateExpression<
|
|
|
4298
4367
|
}
|
|
4299
4368
|
const valueMap = values as Record<string, Record<string, unknown> | undefined>
|
|
4300
4369
|
return targets.flatMap((table) => {
|
|
4301
|
-
const targetName = (table as
|
|
4370
|
+
const targetName = (table as TableLike)[Table.TypeId].name
|
|
4302
4371
|
const scopedValues = valueMap[targetName] ?? {}
|
|
4303
4372
|
const columns = table as unknown as Record<string, Expression.Any>
|
|
4304
4373
|
return Object.entries(scopedValues).map(([columnName, value]) => ({
|
|
@@ -4319,20 +4388,17 @@ type BinaryPredicateExpression<
|
|
|
4319
4388
|
} => {
|
|
4320
4389
|
const firstRow = rows[0]
|
|
4321
4390
|
const firstColumns = Object.keys(firstRow)
|
|
4322
|
-
if (firstColumns.length === 0) {
|
|
4323
|
-
throw new Error("values(...) rows must specify at least one column; use insert(target) for default-only inserts instead")
|
|
4324
|
-
}
|
|
4325
4391
|
const columns = firstColumns as [string, ...string[]]
|
|
4326
|
-
const
|
|
4327
|
-
const rowKeys = Object.keys(row)
|
|
4328
|
-
if (rowKeys.length !== columns.length || columns.some((column) => !(column in row))) {
|
|
4329
|
-
throw new Error("All values(...) rows must project the same columns in the same shape")
|
|
4330
|
-
}
|
|
4392
|
+
const normalizeRow = (row: InsertRowInput<Target>) => {
|
|
4331
4393
|
const assignments = buildMutationAssignments(target, row) as readonly QueryAst.AssignmentClause[]
|
|
4332
4394
|
return {
|
|
4333
4395
|
values: columns.map((columnName) => assignments.find((assignment) => assignment.columnName === columnName)!)
|
|
4334
4396
|
} satisfies QueryAst.InsertValuesRowClause
|
|
4335
|
-
}
|
|
4397
|
+
}
|
|
4398
|
+
const normalizedRows: readonly [QueryAst.InsertValuesRowClause, ...QueryAst.InsertValuesRowClause[]] = [
|
|
4399
|
+
normalizeRow(rows[0]),
|
|
4400
|
+
...rows.slice(1).map(normalizeRow)
|
|
4401
|
+
]
|
|
4336
4402
|
const required = normalizedRows.flatMap((row) =>
|
|
4337
4403
|
row.values.flatMap((entry) => Object.keys(entry.value[Expression.TypeId].dependencies))
|
|
4338
4404
|
)
|
|
@@ -4347,9 +4413,6 @@ type BinaryPredicateExpression<
|
|
|
4347
4413
|
selection: Record<string, Expression.Any>
|
|
4348
4414
|
): readonly [string, ...string[]] => {
|
|
4349
4415
|
const columns = Object.keys(selection)
|
|
4350
|
-
if (columns.length === 0) {
|
|
4351
|
-
throw new Error("insert(...).pipe(from(subquery)) requires at least one projected column")
|
|
4352
|
-
}
|
|
4353
4416
|
return columns as [string, ...string[]]
|
|
4354
4417
|
}
|
|
4355
4418
|
|
|
@@ -4364,27 +4427,11 @@ type BinaryPredicateExpression<
|
|
|
4364
4427
|
}[]
|
|
4365
4428
|
} => {
|
|
4366
4429
|
const entries = Object.entries(values)
|
|
4367
|
-
if (entries.length === 0) {
|
|
4368
|
-
throw new Error("unnest(...) requires at least one column array")
|
|
4369
|
-
}
|
|
4370
4430
|
const columns = entries.map(([columnName]) => columnName) as [string, ...string[]]
|
|
4371
|
-
const normalized = entries.map(([columnName, items]) => {
|
|
4372
|
-
|
|
4373
|
-
|
|
4374
|
-
|
|
4375
|
-
return {
|
|
4376
|
-
columnName,
|
|
4377
|
-
values: items
|
|
4378
|
-
}
|
|
4379
|
-
})
|
|
4380
|
-
const expectedLength = normalized[0]!.values.length
|
|
4381
|
-
if (normalized.some((entry) => entry.values.length !== expectedLength)) {
|
|
4382
|
-
throw new Error("unnest(...) expects every column array to have the same length")
|
|
4383
|
-
}
|
|
4384
|
-
const knownColumns = new Set(Object.keys(target[Table.TypeId].fields))
|
|
4385
|
-
if (columns.some((columnName) => !knownColumns.has(columnName))) {
|
|
4386
|
-
throw new Error("unnest(...) received a column that does not exist on the target table")
|
|
4387
|
-
}
|
|
4431
|
+
const normalized = entries.map(([columnName, items]) => ({
|
|
4432
|
+
columnName,
|
|
4433
|
+
values: items
|
|
4434
|
+
}))
|
|
4388
4435
|
return {
|
|
4389
4436
|
columns,
|
|
4390
4437
|
values: normalized
|
|
@@ -4396,10 +4443,6 @@ type BinaryPredicateExpression<
|
|
|
4396
4443
|
columnsInput: string | readonly string[]
|
|
4397
4444
|
): readonly [string, ...string[]] => {
|
|
4398
4445
|
const columns = normalizeColumnList(columnsInput) as readonly [string, ...string[]]
|
|
4399
|
-
const knownColumns = new Set(Object.keys(target[Table.TypeId].fields))
|
|
4400
|
-
if (columns.some((columnName) => !knownColumns.has(columnName))) {
|
|
4401
|
-
throw new Error("effect-qb: unknown conflict target column")
|
|
4402
|
-
}
|
|
4403
4446
|
return columns
|
|
4404
4447
|
}
|
|
4405
4448
|
|
|
@@ -4414,7 +4457,10 @@ type BinaryPredicateExpression<
|
|
|
4414
4457
|
}
|
|
4415
4458
|
}
|
|
4416
4459
|
if (!Array.isArray(input) && "constraint" in input) {
|
|
4417
|
-
|
|
4460
|
+
return {
|
|
4461
|
+
kind: "constraint",
|
|
4462
|
+
name: input.constraint
|
|
4463
|
+
}
|
|
4418
4464
|
}
|
|
4419
4465
|
const columnTarget = input as {
|
|
4420
4466
|
readonly columns: string | readonly string[]
|
|
@@ -4475,14 +4521,14 @@ type ValidateTargetColumnInput<
|
|
|
4475
4521
|
Columns extends DdlColumnInput
|
|
4476
4522
|
> = ValidateTargetColumns<Target, NormalizeDdlColumns<Columns>> extends never ? never : Columns
|
|
4477
4523
|
|
|
4478
|
-
type CreateIndexOptions = {
|
|
4479
|
-
readonly name?:
|
|
4524
|
+
type CreateIndexOptions<Name extends string = string> = {
|
|
4525
|
+
readonly name?: NonEmptyStringInput<Name>
|
|
4480
4526
|
readonly unique?: boolean
|
|
4481
4527
|
readonly ifNotExists?: boolean
|
|
4482
4528
|
}
|
|
4483
4529
|
|
|
4484
|
-
type DropIndexOptions = {
|
|
4485
|
-
readonly name?:
|
|
4530
|
+
type DropIndexOptions<Name extends string = string> = {
|
|
4531
|
+
readonly name?: NonEmptyStringInput<Name>
|
|
4486
4532
|
readonly ifExists?: boolean
|
|
4487
4533
|
}
|
|
4488
4534
|
|
|
@@ -4581,7 +4627,7 @@ type ValuesRowsDialectInput<
|
|
|
4581
4627
|
BoolDb extends Expression.DbType.Any,
|
|
4582
4628
|
TimestampDb extends Expression.DbType.Any,
|
|
4583
4629
|
NullDb extends Expression.DbType.Any
|
|
4584
|
-
> = Exclude<ValuesRowsDialect<Rows, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>, Dialect> extends never
|
|
4630
|
+
> = Exclude<ValuesRowsDialect<Rows, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>, Dialect | "standard"> extends never
|
|
4585
4631
|
? unknown
|
|
4586
4632
|
: {
|
|
4587
4633
|
readonly __effect_qb_error__: "effect-qb: values rows cannot mix dialects"
|
|
@@ -4636,7 +4682,7 @@ type UnnestColumnsDialectInput<
|
|
|
4636
4682
|
BoolDb extends Expression.DbType.Any,
|
|
4637
4683
|
TimestampDb extends Expression.DbType.Any,
|
|
4638
4684
|
NullDb extends Expression.DbType.Any
|
|
4639
|
-
> = Exclude<UnnestColumnsDialect<Columns, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>, Dialect> extends never
|
|
4685
|
+
> = Exclude<UnnestColumnsDialect<Columns, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>, Dialect | "standard"> extends never
|
|
4640
4686
|
? unknown
|
|
4641
4687
|
: {
|
|
4642
4688
|
readonly __effect_qb_error__: "effect-qb: unnest columns cannot mix dialects"
|
|
@@ -4971,6 +5017,11 @@ type ConflictTargetInput<
|
|
|
4971
5017
|
readonly constraint?: string
|
|
4972
5018
|
}>)
|
|
4973
5019
|
|
|
5020
|
+
type ConflictConstraintNameConstraint<Target> =
|
|
5021
|
+
Target extends { readonly constraint: infer Constraint extends string }
|
|
5022
|
+
? { readonly constraint: NonEmptyStringInput<Constraint> }
|
|
5023
|
+
: unknown
|
|
5024
|
+
|
|
4974
5025
|
type ConflictActionInput<
|
|
4975
5026
|
Target extends MutationTargetLike,
|
|
4976
5027
|
Dialect extends string,
|
|
@@ -5122,7 +5173,7 @@ type MutationOrderLimitSupported<PlanValue extends QueryPlan<any, any, any, any,
|
|
|
5122
5173
|
type MutationTargetTupleDialectConstraint<
|
|
5123
5174
|
Targets extends MutationTargetTuple,
|
|
5124
5175
|
Dialect extends string
|
|
5125
|
-
> = Exclude<TableDialectOf<Targets[number]>, Dialect> extends never ? unknown : never
|
|
5176
|
+
> = Exclude<TableDialectOf<Targets[number]>, Dialect | "standard"> extends never ? unknown : never
|
|
5126
5177
|
|
|
5127
5178
|
type MutationRequiredFromValues<Values extends Record<string, unknown>> = {
|
|
5128
5179
|
[K in keyof Values]: Values[K] extends Expression.Any ? RequiredFromDependencies<DependenciesOf<Values[K]>> : never
|
|
@@ -5176,7 +5227,7 @@ type KnownIncompatibleMutationDialectFromValues<
|
|
|
5176
5227
|
BoolDb extends Expression.DbType.Any,
|
|
5177
5228
|
TimestampDb extends Expression.DbType.Any,
|
|
5178
5229
|
NullDb extends Expression.DbType.Any
|
|
5179
|
-
> = Exclude<KnownMutationDialectFromValues<Values, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>, Dialect>
|
|
5230
|
+
> = Exclude<KnownMutationDialectFromValues<Values, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>, Dialect | "standard">
|
|
5180
5231
|
|
|
5181
5232
|
type MutationValuesDialectConstraint<
|
|
5182
5233
|
Values,
|
|
@@ -5228,9 +5279,11 @@ type SourceDialectConstraint<
|
|
|
5228
5279
|
Dialect extends string
|
|
5229
5280
|
> = [SourceDialectOf<CurrentSource>] extends [never]
|
|
5230
5281
|
? unknown
|
|
5231
|
-
:
|
|
5232
|
-
?
|
|
5233
|
-
:
|
|
5282
|
+
: Exclude<SourceDialectOf<CurrentSource>, Dialect | "standard"> extends never
|
|
5283
|
+
? unknown
|
|
5284
|
+
: Dialect extends "standard"
|
|
5285
|
+
? unknown
|
|
5286
|
+
: never
|
|
5234
5287
|
|
|
5235
5288
|
type SourceRequirementConstraint<
|
|
5236
5289
|
PlanValue extends QueryPlan<any, any, any, any, any, any, any, any, any, any>,
|
|
@@ -5494,7 +5547,7 @@ type AsCurriedResult<
|
|
|
5494
5547
|
function as<
|
|
5495
5548
|
Alias extends string
|
|
5496
5549
|
>(
|
|
5497
|
-
alias: Alias
|
|
5550
|
+
alias: LiteralStringInput<Alias>
|
|
5498
5551
|
): <Value extends AsCurriedInput<Dialect>>(
|
|
5499
5552
|
value: Value
|
|
5500
5553
|
) => AsCurriedResult<Value, Alias, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>
|
|
@@ -5503,7 +5556,7 @@ type AsCurriedResult<
|
|
|
5503
5556
|
Alias extends string
|
|
5504
5557
|
>(
|
|
5505
5558
|
value: Value,
|
|
5506
|
-
alias: Alias
|
|
5559
|
+
alias: LiteralStringInput<Alias>
|
|
5507
5560
|
): ProjectionAliasedExpression<DialectAsExpression<Value, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>, Alias>
|
|
5508
5561
|
function as<
|
|
5509
5562
|
Rows extends ValuesRowsInput,
|
|
@@ -5514,7 +5567,7 @@ type AsCurriedResult<
|
|
|
5514
5567
|
ValuesOutputShape<Rows, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>,
|
|
5515
5568
|
Dialect
|
|
5516
5569
|
>,
|
|
5517
|
-
alias: Alias
|
|
5570
|
+
alias: LiteralStringInput<Alias>
|
|
5518
5571
|
): ValuesSource<
|
|
5519
5572
|
Rows,
|
|
5520
5573
|
ValuesOutputShape<Rows, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>,
|
|
@@ -5526,11 +5579,11 @@ type AsCurriedResult<
|
|
|
5526
5579
|
Alias extends string
|
|
5527
5580
|
>(
|
|
5528
5581
|
value: DerivedTableCompatiblePlan<PlanValue>,
|
|
5529
|
-
alias: Alias
|
|
5582
|
+
alias: LiteralStringInput<Alias>
|
|
5530
5583
|
): DerivedSource<PlanValue, Alias>
|
|
5531
5584
|
function as(valueOrAlias: unknown, alias?: string): unknown {
|
|
5532
5585
|
if (alias === undefined) {
|
|
5533
|
-
return (value: unknown) => as(value as any, valueOrAlias as
|
|
5586
|
+
return (value: unknown) => as(value as any, valueOrAlias as never)
|
|
5534
5587
|
}
|
|
5535
5588
|
const resolvedAlias = alias
|
|
5536
5589
|
const value = valueOrAlias
|
|
@@ -5570,7 +5623,7 @@ type AsCurriedResult<
|
|
|
5570
5623
|
function with_<
|
|
5571
5624
|
Alias extends string
|
|
5572
5625
|
>(
|
|
5573
|
-
alias: Alias
|
|
5626
|
+
alias: LiteralStringInput<Alias>
|
|
5574
5627
|
): <PlanValue extends QueryPlan<any, any, any, any, any, any, any, any, any, any>>(
|
|
5575
5628
|
value: SqliteCteCompatiblePlan<PlanValue>
|
|
5576
5629
|
) => import("../../internal/query.js").CteSource<PlanValue, Alias>
|
|
@@ -5579,11 +5632,11 @@ type AsCurriedResult<
|
|
|
5579
5632
|
Alias extends string
|
|
5580
5633
|
>(
|
|
5581
5634
|
value: SqliteCteCompatiblePlan<PlanValue>,
|
|
5582
|
-
alias: Alias
|
|
5635
|
+
alias: LiteralStringInput<Alias>
|
|
5583
5636
|
): import("../../internal/query.js").CteSource<PlanValue, Alias>
|
|
5584
5637
|
function with_(valueOrAlias: unknown, alias?: string): unknown {
|
|
5585
5638
|
if (alias === undefined) {
|
|
5586
|
-
return (value: unknown) => with_(value as any, valueOrAlias as
|
|
5639
|
+
return (value: unknown) => with_(value as any, valueOrAlias as never)
|
|
5587
5640
|
}
|
|
5588
5641
|
return makeCteSource(
|
|
5589
5642
|
valueOrAlias as CompletePlan<QueryPlan<any, any, any, any, any, any, any, any, any, any>>,
|
|
@@ -5594,7 +5647,7 @@ type AsCurriedResult<
|
|
|
5594
5647
|
function withRecursive_<
|
|
5595
5648
|
Alias extends string
|
|
5596
5649
|
>(
|
|
5597
|
-
alias: Alias
|
|
5650
|
+
alias: LiteralStringInput<Alias>
|
|
5598
5651
|
): <PlanValue extends QueryPlan<any, any, any, any, any, any, any, any, any, any>>(
|
|
5599
5652
|
value: SqliteCteCompatiblePlan<PlanValue>
|
|
5600
5653
|
) => import("../../internal/query.js").CteSource<PlanValue, Alias>
|
|
@@ -5603,11 +5656,11 @@ type AsCurriedResult<
|
|
|
5603
5656
|
Alias extends string
|
|
5604
5657
|
>(
|
|
5605
5658
|
value: SqliteCteCompatiblePlan<PlanValue>,
|
|
5606
|
-
alias: Alias
|
|
5659
|
+
alias: LiteralStringInput<Alias>
|
|
5607
5660
|
): import("../../internal/query.js").CteSource<PlanValue, Alias>
|
|
5608
5661
|
function withRecursive_(valueOrAlias: unknown, alias?: string): unknown {
|
|
5609
5662
|
if (alias === undefined) {
|
|
5610
|
-
return (value: unknown) => withRecursive_(value as any, valueOrAlias as
|
|
5663
|
+
return (value: unknown) => withRecursive_(value as any, valueOrAlias as never)
|
|
5611
5664
|
}
|
|
5612
5665
|
return makeCteSource(
|
|
5613
5666
|
valueOrAlias as CompletePlan<QueryPlan<any, any, any, any, any, any, any, any, any, any>>,
|
|
@@ -5619,7 +5672,7 @@ type AsCurriedResult<
|
|
|
5619
5672
|
function lateral<
|
|
5620
5673
|
Alias extends string
|
|
5621
5674
|
>(
|
|
5622
|
-
alias: Alias
|
|
5675
|
+
alias: LiteralStringInput<Alias>
|
|
5623
5676
|
): <PlanValue extends QueryPlan<any, any, any, any, any, any, any, any, any, any>>(
|
|
5624
5677
|
value: LateralSourceCompatiblePlan<PlanValue>
|
|
5625
5678
|
) => import("../../internal/query.js").LateralSource<PlanValue, Alias>
|
|
@@ -5628,11 +5681,11 @@ type AsCurriedResult<
|
|
|
5628
5681
|
Alias extends string
|
|
5629
5682
|
>(
|
|
5630
5683
|
value: LateralSourceCompatiblePlan<PlanValue>,
|
|
5631
|
-
alias: Alias
|
|
5684
|
+
alias: LiteralStringInput<Alias>
|
|
5632
5685
|
): import("../../internal/query.js").LateralSource<PlanValue, Alias>
|
|
5633
5686
|
function lateral(valueOrAlias: unknown, alias?: string): unknown {
|
|
5634
5687
|
if (alias === undefined) {
|
|
5635
|
-
return (value: unknown) => lateral(value as any, valueOrAlias as
|
|
5688
|
+
return (value: unknown) => lateral(value as any, valueOrAlias as never)
|
|
5636
5689
|
}
|
|
5637
5690
|
return makeLateralSource(
|
|
5638
5691
|
valueOrAlias as QueryPlan<any, any, any, any, any, any, any, any, any, any>,
|
|
@@ -5659,7 +5712,7 @@ type AsCurriedResult<
|
|
|
5659
5712
|
columns: Columns
|
|
5660
5713
|
& UnnestColumnsShapeInput<Columns>
|
|
5661
5714
|
& UnnestColumnsDialectInput<Columns, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>,
|
|
5662
|
-
alias: Alias
|
|
5715
|
+
alias: LiteralStringInput<Alias>
|
|
5663
5716
|
) => UnnestSource<
|
|
5664
5717
|
UnnestOutputShape<Columns, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>,
|
|
5665
5718
|
Alias,
|
|
@@ -5675,7 +5728,7 @@ type AsCurriedResult<
|
|
|
5675
5728
|
start: Start & NumericExpressionDialectInput<Start, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>,
|
|
5676
5729
|
stop: Stop & NumericExpressionDialectInput<Stop, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>,
|
|
5677
5730
|
step?: Step & (Step extends NumericExpressionInput ? NumericExpressionDialectInput<Step, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb> : unknown),
|
|
5678
|
-
alias?: Alias
|
|
5731
|
+
alias?: LiteralStringInput<Alias>
|
|
5679
5732
|
) => Dialect extends "postgres"
|
|
5680
5733
|
? TableFunctionSource<
|
|
5681
5734
|
GenerateSeriesOutputShape<Start, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>,
|
|
@@ -5722,8 +5775,8 @@ type AsCurriedResult<
|
|
|
5722
5775
|
? SelectSelectionNonEmptyError<Selection>
|
|
5723
5776
|
: unknown
|
|
5724
5777
|
|
|
5725
|
-
export type SelectApi = <Selection extends SelectionShape>(
|
|
5726
|
-
selection: Selection & SelectionRootObjectConstraint<Selection> & SelectionNestedNonEmptyConstraint<Selection> & SelectSelectionNonEmptyConstraint<Selection>
|
|
5778
|
+
export type SelectApi = <const Selection extends SelectionShape>(
|
|
5779
|
+
selection: Selection & SelectionRootObjectConstraint<Selection> & SelectionNestedNonEmptyConstraint<Selection> & SelectSelectionNonEmptyConstraint<Selection> & SelectionProjectionAliasCollisionConstraint<Selection>
|
|
5727
5780
|
) => QueryPlan<
|
|
5728
5781
|
Selection,
|
|
5729
5782
|
ExtractRequired<Selection>,
|
|
@@ -6188,8 +6241,8 @@ type AsCurriedResult<
|
|
|
6188
6241
|
: unknown
|
|
6189
6242
|
|
|
6190
6243
|
type ReturningApi = Dialect extends "postgres" | "sqlite"
|
|
6191
|
-
? <Selection extends SelectionShape>(
|
|
6192
|
-
selection: Selection & SelectionRootObjectConstraint<Selection> & SelectionNestedNonEmptyConstraint<Selection> & ReturningSelectionNonEmptyConstraint<Selection>
|
|
6244
|
+
? <const Selection extends SelectionShape>(
|
|
6245
|
+
selection: Selection & SelectionRootObjectConstraint<Selection> & SelectionNestedNonEmptyConstraint<Selection> & ReturningSelectionNonEmptyConstraint<Selection> & SelectionProjectionAliasCollisionConstraint<Selection>
|
|
6193
6246
|
) =>
|
|
6194
6247
|
<PlanValue extends QueryPlan<any, any, any, any, any, any, any, any, any, any>>(
|
|
6195
6248
|
plan: PlanValue & RequireMutationStatement<PlanValue>
|
|
@@ -6258,9 +6311,9 @@ type AsCurriedResult<
|
|
|
6258
6311
|
const Columns extends DdlColumnInput,
|
|
6259
6312
|
UpdateValues extends MutationInputOf<Table.UpdateOf<Target>> | undefined = MutationInputOf<Table.UpdateOf<Target>> | undefined,
|
|
6260
6313
|
Options extends ConflictActionInput<Target, Dialect, UpdateValues> = ConflictActionInput<Target, Dialect, UpdateValues>,
|
|
6261
|
-
ConflictTarget extends ConflictTargetInput<Target, Dialect, Columns> = ConflictTargetInput<Target, Dialect, Columns>
|
|
6314
|
+
const ConflictTarget extends ConflictTargetInput<Target, Dialect, Columns> = ConflictTargetInput<Target, Dialect, Columns>
|
|
6262
6315
|
>(
|
|
6263
|
-
target: ConflictTarget
|
|
6316
|
+
target: ConflictTarget & ConflictConstraintNameConstraint<ConflictTarget>,
|
|
6264
6317
|
options?: Options & ConflictActionUpdateNonEmptyConstraint<Options>
|
|
6265
6318
|
) =>
|
|
6266
6319
|
<PlanValue extends QueryPlan<any, any, any, any, any, any, any, any, any, any>>(
|
|
@@ -6422,7 +6475,7 @@ type AsCurriedResult<
|
|
|
6422
6475
|
target: Target,
|
|
6423
6476
|
source: Source & (
|
|
6424
6477
|
SourceRequiredOf<Source> extends never ? unknown : SourceRequirementError<Source>
|
|
6425
|
-
),
|
|
6478
|
+
) & SourceDialectConstraint<Source, Dialect>,
|
|
6426
6479
|
on: On,
|
|
6427
6480
|
options: MergeOptions<Target, MatchedValues, InsertValues, MatchedPredicate, NotMatchedPredicate>
|
|
6428
6481
|
) => QueryPlan<
|
|
@@ -6636,7 +6689,7 @@ type AsCurriedResult<
|
|
|
6636
6689
|
"rollback"
|
|
6637
6690
|
>
|
|
6638
6691
|
|
|
6639
|
-
type SavepointApi = <Name extends string>(name: Name) => QueryPlan<
|
|
6692
|
+
type SavepointApi = <Name extends string>(name: NonEmptyStringInput<Name>) => QueryPlan<
|
|
6640
6693
|
{},
|
|
6641
6694
|
never,
|
|
6642
6695
|
{},
|
|
@@ -6649,7 +6702,7 @@ type AsCurriedResult<
|
|
|
6649
6702
|
"savepoint"
|
|
6650
6703
|
>
|
|
6651
6704
|
|
|
6652
|
-
type RollbackToApi = <Name extends string>(name: Name) => QueryPlan<
|
|
6705
|
+
type RollbackToApi = <Name extends string>(name: NonEmptyStringInput<Name>) => QueryPlan<
|
|
6653
6706
|
{},
|
|
6654
6707
|
never,
|
|
6655
6708
|
{},
|
|
@@ -6662,7 +6715,7 @@ type AsCurriedResult<
|
|
|
6662
6715
|
"rollbackTo"
|
|
6663
6716
|
>
|
|
6664
6717
|
|
|
6665
|
-
type ReleaseSavepointApi = <Name extends string>(name: Name) => QueryPlan<
|
|
6718
|
+
type ReleaseSavepointApi = <Name extends string>(name: NonEmptyStringInput<Name>) => QueryPlan<
|
|
6666
6719
|
{},
|
|
6667
6720
|
never,
|
|
6668
6721
|
{},
|
|
@@ -6707,10 +6760,10 @@ type AsCurriedResult<
|
|
|
6707
6760
|
"dropTable"
|
|
6708
6761
|
>
|
|
6709
6762
|
|
|
6710
|
-
type CreateIndexApi = <Target extends SchemaTableLike, const Columns extends DdlColumnInput>(
|
|
6763
|
+
type CreateIndexApi = <Target extends SchemaTableLike, const Columns extends DdlColumnInput, Name extends string = string>(
|
|
6711
6764
|
target: Target,
|
|
6712
6765
|
columns: Columns & ValidateDdlColumnInput<Target, Columns>,
|
|
6713
|
-
options?: CreateIndexOptions
|
|
6766
|
+
options?: CreateIndexOptions<Name>
|
|
6714
6767
|
) => QueryPlan<
|
|
6715
6768
|
{},
|
|
6716
6769
|
never,
|
|
@@ -6724,10 +6777,10 @@ type AsCurriedResult<
|
|
|
6724
6777
|
"createIndex"
|
|
6725
6778
|
>
|
|
6726
6779
|
|
|
6727
|
-
type DropIndexApi = <Target extends SchemaTableLike, const Columns extends DdlColumnInput>(
|
|
6780
|
+
type DropIndexApi = <Target extends SchemaTableLike, const Columns extends DdlColumnInput, Name extends string = string>(
|
|
6728
6781
|
target: Target,
|
|
6729
6782
|
columns: Columns & ValidateDdlColumnInput<Target, Columns>,
|
|
6730
|
-
options?: DropIndexOptions
|
|
6783
|
+
options?: DropIndexOptions<Name>
|
|
6731
6784
|
) => QueryPlan<
|
|
6732
6785
|
{},
|
|
6733
6786
|
never,
|