effect-qb 0.12.3 → 0.14.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 +6 -1283
- package/dist/mysql.js +6376 -4978
- package/dist/postgres/metadata.js +2724 -0
- package/dist/postgres.js +5475 -3636
- package/package.json +13 -8
- package/src/internal/column-state.ts +88 -6
- package/src/internal/column.ts +569 -34
- package/src/internal/datatypes/define.ts +0 -30
- package/src/internal/executor.ts +45 -11
- package/src/internal/expression-ast.ts +15 -0
- package/src/internal/expression.ts +3 -1
- package/src/internal/implication-runtime.ts +171 -0
- package/src/internal/mysql-query.ts +7173 -0
- package/src/internal/mysql-renderer.ts +2 -2
- package/src/internal/plan.ts +14 -4
- package/src/internal/{query-factory.ts → postgres-query.ts} +669 -230
- package/src/internal/postgres-renderer.ts +2 -2
- package/src/internal/postgres-schema-model.ts +144 -0
- package/src/internal/predicate-analysis.ts +10 -0
- package/src/internal/predicate-context.ts +112 -36
- package/src/internal/predicate-formula.ts +31 -19
- package/src/internal/predicate-normalize.ts +177 -106
- package/src/internal/predicate-runtime.ts +676 -0
- package/src/internal/query.ts +471 -41
- package/src/internal/renderer.ts +2 -2
- package/src/internal/runtime-schema.ts +74 -20
- package/src/internal/schema-ddl.ts +55 -0
- package/src/internal/schema-derivation.ts +93 -21
- package/src/internal/schema-expression.ts +44 -0
- package/src/internal/sql-expression-renderer.ts +123 -35
- package/src/internal/table-options.ts +88 -7
- package/src/internal/table.ts +106 -42
- package/src/mysql/column.ts +3 -1
- package/src/mysql/datatypes/index.ts +17 -2
- package/src/mysql/executor.ts +20 -17
- package/src/mysql/function/aggregate.ts +6 -0
- package/src/mysql/function/core.ts +5 -0
- package/src/mysql/function/index.ts +20 -0
- package/src/mysql/function/json.ts +4 -0
- package/src/mysql/function/string.ts +6 -0
- package/src/mysql/function/temporal.ts +103 -0
- package/src/mysql/function/window.ts +7 -0
- package/src/mysql/private/query.ts +1 -0
- package/src/mysql/query.ts +6 -26
- package/src/mysql.ts +2 -0
- package/src/postgres/cast.ts +31 -0
- package/src/postgres/column.ts +27 -1
- package/src/postgres/datatypes/index.ts +40 -5
- package/src/postgres/executor.ts +19 -17
- package/src/postgres/function/aggregate.ts +6 -0
- package/src/postgres/function/core.ts +16 -0
- package/src/postgres/function/index.ts +20 -0
- package/src/postgres/function/json.ts +501 -0
- package/src/postgres/function/string.ts +6 -0
- package/src/postgres/function/temporal.ts +107 -0
- package/src/postgres/function/window.ts +7 -0
- package/src/postgres/metadata.ts +31 -0
- package/src/postgres/private/query.ts +1 -0
- package/src/postgres/query.ts +6 -28
- package/src/postgres/schema-expression.ts +16 -0
- package/src/postgres/schema-management.ts +204 -0
- package/src/postgres/schema.ts +35 -0
- package/src/postgres/table.ts +307 -41
- package/src/postgres/type.ts +4 -0
- package/src/postgres.ts +16 -0
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { pipeArguments } from "effect/Pipeable"
|
|
2
2
|
import * as Schema from "effect/Schema"
|
|
3
3
|
|
|
4
|
+
import { postgresDatatypes } from "../postgres/datatypes/index.js"
|
|
5
|
+
|
|
4
6
|
import * as Expression from "./expression.js"
|
|
5
7
|
import * as Plan from "./plan.js"
|
|
6
8
|
import * as Table from "./table.js"
|
|
@@ -54,6 +56,7 @@ import {
|
|
|
54
56
|
type OrderDirection,
|
|
55
57
|
type OutstandingOfPlan,
|
|
56
58
|
type PlanDialectOf,
|
|
59
|
+
type PresenceWitnessKeysOfSource,
|
|
57
60
|
type PredicateInput,
|
|
58
61
|
type QueryPlan,
|
|
59
62
|
type OutputOfSelection,
|
|
@@ -76,6 +79,7 @@ import {
|
|
|
76
79
|
type MutationTargetOfPlan,
|
|
77
80
|
type MergeCapabilities,
|
|
78
81
|
type MutationTargetInput,
|
|
82
|
+
type MutationValuesInput,
|
|
79
83
|
type SourceOf,
|
|
80
84
|
type SourceDialectOf,
|
|
81
85
|
type SourceLike,
|
|
@@ -98,6 +102,7 @@ import {
|
|
|
98
102
|
type ResultRow
|
|
99
103
|
} from "./query.js"
|
|
100
104
|
import * as ExpressionAst from "./expression-ast.js"
|
|
105
|
+
import { presenceWitnessesOfSourceLike } from "./implication-runtime.js"
|
|
101
106
|
import type { JsonNode } from "./json/ast.js"
|
|
102
107
|
import type { JsonPathUsageError } from "./json/errors.js"
|
|
103
108
|
import * as JsonPath from "./json/path.js"
|
|
@@ -116,7 +121,9 @@ import type {
|
|
|
116
121
|
NormalizeJsonLiteral
|
|
117
122
|
} from "./json/types.js"
|
|
118
123
|
import type { AssumeTrue } from "./predicate-analysis.js"
|
|
124
|
+
import type { FormulaOfPredicate } from "./predicate-normalize.js"
|
|
119
125
|
import type { TrueFormula } from "./predicate-formula.js"
|
|
126
|
+
import { assumeFormulaTrue, formulaOfExpression as formulaOfExpressionRuntime, trueFormula } from "./predicate-runtime.js"
|
|
120
127
|
import { dedupeGroupedExpressions } from "./grouping-key.js"
|
|
121
128
|
import { makeCteSource, makeDerivedSource, makeLateralSource } from "./derived-table.js"
|
|
122
129
|
import * as ProjectionAlias from "./projection-alias.js"
|
|
@@ -246,6 +253,19 @@ type DialectDbTypeOfInput<
|
|
|
246
253
|
NullDb extends Expression.DbType.Any
|
|
247
254
|
> = Expression.DbTypeOf<DialectAsExpression<Value, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>>
|
|
248
255
|
|
|
256
|
+
type JoinPresenceFormula<
|
|
257
|
+
Kind extends QueryAst.JoinKind,
|
|
258
|
+
Predicate extends PredicateInput,
|
|
259
|
+
Dialect extends string,
|
|
260
|
+
TextDb extends Expression.DbType.Any,
|
|
261
|
+
NumericDb extends Expression.DbType.Any,
|
|
262
|
+
BoolDb extends Expression.DbType.Any,
|
|
263
|
+
TimestampDb extends Expression.DbType.Any,
|
|
264
|
+
NullDb extends Expression.DbType.Any
|
|
265
|
+
> = Kind extends "inner" | "left"
|
|
266
|
+
? FormulaOfPredicate<DialectAsExpression<Predicate, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>>
|
|
267
|
+
: TrueFormula
|
|
268
|
+
|
|
249
269
|
type ComparableInput<
|
|
250
270
|
Left extends ExpressionInput,
|
|
251
271
|
Right extends ExpressionInput,
|
|
@@ -757,7 +777,7 @@ type DialectStringExpressionTuple<
|
|
|
757
777
|
}
|
|
758
778
|
|
|
759
779
|
/** Names of sources already available to a plan. */
|
|
760
|
-
type AvailableNames<Available extends Record<string, Plan.
|
|
780
|
+
type AvailableNames<Available extends Record<string, Plan.AnySource>> = Extract<keyof Available, string>
|
|
761
781
|
|
|
762
782
|
type PlanAssumptionsAfterWhere<
|
|
763
783
|
PlanValue extends QueryPlan<any, any, any, any, any, any, any, any, any, any>,
|
|
@@ -773,6 +793,37 @@ type PlanAssumptionsAfterWhere<
|
|
|
773
793
|
DialectAsExpression<Predicate, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>
|
|
774
794
|
>
|
|
775
795
|
|
|
796
|
+
type PlanAssumptionsAfterHaving<
|
|
797
|
+
PlanValue extends QueryPlan<any, any, any, any, any, any, any, any, any, any>,
|
|
798
|
+
Predicate extends HavingPredicateInput,
|
|
799
|
+
Dialect extends string,
|
|
800
|
+
TextDb extends Expression.DbType.Any,
|
|
801
|
+
NumericDb extends Expression.DbType.Any,
|
|
802
|
+
BoolDb extends Expression.DbType.Any,
|
|
803
|
+
TimestampDb extends Expression.DbType.Any,
|
|
804
|
+
NullDb extends Expression.DbType.Any
|
|
805
|
+
> = AssumeTrue<
|
|
806
|
+
AssumptionsOfPlan<PlanValue>,
|
|
807
|
+
DialectAsExpression<Predicate, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>
|
|
808
|
+
>
|
|
809
|
+
|
|
810
|
+
type PlanAssumptionsAfterJoin<
|
|
811
|
+
PlanValue extends QueryPlan<any, any, any, any, any, any, any, any, any, any>,
|
|
812
|
+
Predicate extends PredicateInput,
|
|
813
|
+
Kind extends QueryAst.JoinKind,
|
|
814
|
+
Dialect extends string,
|
|
815
|
+
TextDb extends Expression.DbType.Any,
|
|
816
|
+
NumericDb extends Expression.DbType.Any,
|
|
817
|
+
BoolDb extends Expression.DbType.Any,
|
|
818
|
+
TimestampDb extends Expression.DbType.Any,
|
|
819
|
+
NullDb extends Expression.DbType.Any
|
|
820
|
+
> = Kind extends "inner"
|
|
821
|
+
? AssumeTrue<
|
|
822
|
+
AssumptionsOfPlan<PlanValue>,
|
|
823
|
+
DialectAsExpression<Predicate, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>
|
|
824
|
+
>
|
|
825
|
+
: AssumptionsOfPlan<PlanValue>
|
|
826
|
+
|
|
776
827
|
type ScalarSubqueryInput<
|
|
777
828
|
PlanValue extends QueryPlan<any, any, any, any, any, any, any, any, any, any>,
|
|
778
829
|
EngineDialect extends string
|
|
@@ -803,6 +854,53 @@ type AstBackedExpression<
|
|
|
803
854
|
readonly [ExpressionAst.TypeId]: Ast
|
|
804
855
|
}
|
|
805
856
|
|
|
857
|
+
type AppendDialectExpressionTuple<
|
|
858
|
+
Current extends readonly Expression.Any[],
|
|
859
|
+
More extends readonly ExpressionInput[],
|
|
860
|
+
Dialect extends string,
|
|
861
|
+
TextDb extends Expression.DbType.Any,
|
|
862
|
+
NumericDb extends Expression.DbType.Any,
|
|
863
|
+
BoolDb extends Expression.DbType.Any,
|
|
864
|
+
TimestampDb extends Expression.DbType.Any,
|
|
865
|
+
NullDb extends Expression.DbType.Any
|
|
866
|
+
> = readonly [
|
|
867
|
+
...Current,
|
|
868
|
+
...DialectExpressionTuple<More, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>
|
|
869
|
+
]
|
|
870
|
+
|
|
871
|
+
type VariadicBooleanExpression<
|
|
872
|
+
Kind extends "and" | "or",
|
|
873
|
+
Values extends readonly Expression.Any[],
|
|
874
|
+
Dialect extends string,
|
|
875
|
+
TextDb extends Expression.DbType.Any,
|
|
876
|
+
NumericDb extends Expression.DbType.Any,
|
|
877
|
+
BoolDb extends Expression.DbType.Any,
|
|
878
|
+
TimestampDb extends Expression.DbType.Any,
|
|
879
|
+
NullDb extends Expression.DbType.Any
|
|
880
|
+
> = AstBackedExpression<
|
|
881
|
+
boolean,
|
|
882
|
+
BoolDb,
|
|
883
|
+
MergeNullabilityTuple<Values>,
|
|
884
|
+
TupleDialect<Values>,
|
|
885
|
+
MergeAggregationTuple<Values>,
|
|
886
|
+
TupleSource<Values>,
|
|
887
|
+
TupleDependencies<Values>,
|
|
888
|
+
ExpressionAst.VariadicNode<Kind, Values>
|
|
889
|
+
> & {
|
|
890
|
+
pipe<More extends readonly [ExpressionInput, ...ExpressionInput[]]>(
|
|
891
|
+
...values: More
|
|
892
|
+
): VariadicBooleanExpression<
|
|
893
|
+
Kind,
|
|
894
|
+
AppendDialectExpressionTuple<Values, More, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>,
|
|
895
|
+
Dialect,
|
|
896
|
+
TextDb,
|
|
897
|
+
NumericDb,
|
|
898
|
+
BoolDb,
|
|
899
|
+
TimestampDb,
|
|
900
|
+
NullDb
|
|
901
|
+
>
|
|
902
|
+
}
|
|
903
|
+
|
|
806
904
|
type JsonRuntime<Value> = NormalizeJsonLiteral<Value> extends never
|
|
807
905
|
? unknown
|
|
808
906
|
: NormalizeJsonLiteral<Value>
|
|
@@ -845,6 +943,29 @@ type JsonExpressionLike<Runtime = unknown> = Expression.Expression<
|
|
|
845
943
|
Expression.SourceNullabilityMode
|
|
846
944
|
>
|
|
847
945
|
|
|
946
|
+
type JsonDbOfExpression<Value extends JsonExpressionLike<any>> = Expression.DbTypeOf<Value>
|
|
947
|
+
|
|
948
|
+
type JsonKindOfInput<
|
|
949
|
+
Value,
|
|
950
|
+
Fallback extends string = "json"
|
|
951
|
+
> = Value extends Expression.Any
|
|
952
|
+
? Expression.DbTypeOf<Value> extends Expression.DbType.Json<any, infer Kind> ? Kind : Fallback
|
|
953
|
+
: Fallback
|
|
954
|
+
|
|
955
|
+
type JsonConcatKind<
|
|
956
|
+
Left,
|
|
957
|
+
Right,
|
|
958
|
+
EngineDialect extends string
|
|
959
|
+
> = EngineDialect extends "postgres"
|
|
960
|
+
? "jsonb"
|
|
961
|
+
: JsonKindOfInput<Left> extends "jsonb"
|
|
962
|
+
? "jsonb"
|
|
963
|
+
: JsonKindOfInput<Right> extends "jsonb"
|
|
964
|
+
? "jsonb"
|
|
965
|
+
: "json"
|
|
966
|
+
|
|
967
|
+
type JsonbKindForDialect<EngineDialect extends string> = EngineDialect extends "postgres" ? "jsonb" : "json"
|
|
968
|
+
|
|
848
969
|
type JsonValueInput = JsonLiteralInput | Expression.Any
|
|
849
970
|
|
|
850
971
|
type JsonPathInput = JsonPath.Path<any> | JsonPath.CanonicalSegment
|
|
@@ -1268,17 +1389,24 @@ type NumberWindowExpression<
|
|
|
1268
1389
|
* that manufacture new expressions are specialized to the supplied dialect DB
|
|
1269
1390
|
* types instead of relying on the Postgres-default root module.
|
|
1270
1391
|
*/
|
|
1271
|
-
export
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1392
|
+
export const postgresQuery = (() => {
|
|
1393
|
+
type Dialect = "postgres"
|
|
1394
|
+
type TextDb = Expression.DbType.PgText
|
|
1395
|
+
type NumericDb = Expression.DbType.PgFloat8
|
|
1396
|
+
type BoolDb = Expression.DbType.PgBool
|
|
1397
|
+
type TimestampDb = Expression.DbType.PgTimestamp
|
|
1398
|
+
type NullDb = Expression.DbType.Base<"postgres", "null">
|
|
1399
|
+
type TypeWitnesses = typeof postgresDatatypes
|
|
1400
|
+
|
|
1401
|
+
const profile: QueryDialectProfile<Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb, TypeWitnesses> = {
|
|
1402
|
+
dialect: "postgres",
|
|
1403
|
+
textDb: { dialect: "postgres", kind: "text" } as TextDb,
|
|
1404
|
+
numericDb: { dialect: "postgres", kind: "float8" } as NumericDb,
|
|
1405
|
+
boolDb: { dialect: "postgres", kind: "bool" } as BoolDb,
|
|
1406
|
+
timestampDb: { dialect: "postgres", kind: "timestamp" } as TimestampDb,
|
|
1407
|
+
nullDb: { dialect: "postgres", kind: "null" } as NullDb,
|
|
1408
|
+
type: postgresDatatypes
|
|
1409
|
+
}
|
|
1282
1410
|
const ValuesInputProto = {
|
|
1283
1411
|
pipe(this: unknown) {
|
|
1284
1412
|
return pipeArguments(this, arguments)
|
|
@@ -1318,6 +1446,51 @@ export function makeDialectQuery<
|
|
|
1318
1446
|
value
|
|
1319
1447
|
})
|
|
1320
1448
|
|
|
1449
|
+
const column = <
|
|
1450
|
+
Name extends string,
|
|
1451
|
+
Db extends Expression.DbType.Any
|
|
1452
|
+
>(
|
|
1453
|
+
name: Name,
|
|
1454
|
+
dbType: Db,
|
|
1455
|
+
nullable = false
|
|
1456
|
+
): Expression.Expression<
|
|
1457
|
+
Expression.RuntimeOfDbType<Db> | null,
|
|
1458
|
+
Db,
|
|
1459
|
+
Expression.Nullability,
|
|
1460
|
+
Dialect,
|
|
1461
|
+
"scalar",
|
|
1462
|
+
never,
|
|
1463
|
+
{},
|
|
1464
|
+
"resolved"
|
|
1465
|
+
> & {
|
|
1466
|
+
readonly [ExpressionAst.TypeId]: ExpressionAst.ColumnNode<"", Name>
|
|
1467
|
+
} =>
|
|
1468
|
+
makeExpression({
|
|
1469
|
+
runtime: undefined as unknown as Expression.RuntimeOfDbType<Db> | (typeof nullable extends true ? null : never),
|
|
1470
|
+
dbType,
|
|
1471
|
+
nullability: (nullable ? "maybe" : "never") as typeof nullable extends true ? "maybe" : "never",
|
|
1472
|
+
dialect: profile.dialect as Dialect,
|
|
1473
|
+
aggregation: "scalar",
|
|
1474
|
+
source: undefined as never,
|
|
1475
|
+
sourceNullability: "resolved" as const,
|
|
1476
|
+
dependencies: {}
|
|
1477
|
+
}, {
|
|
1478
|
+
kind: "column",
|
|
1479
|
+
tableName: "",
|
|
1480
|
+
columnName: name
|
|
1481
|
+
}) as Expression.Expression<
|
|
1482
|
+
Expression.RuntimeOfDbType<Db> | null,
|
|
1483
|
+
Db,
|
|
1484
|
+
Expression.Nullability,
|
|
1485
|
+
Dialect,
|
|
1486
|
+
"scalar",
|
|
1487
|
+
never,
|
|
1488
|
+
{},
|
|
1489
|
+
"resolved"
|
|
1490
|
+
> & {
|
|
1491
|
+
readonly [ExpressionAst.TypeId]: ExpressionAst.ColumnNode<"", Name>
|
|
1492
|
+
}
|
|
1493
|
+
|
|
1321
1494
|
const toDialectExpression = <Value extends ExpressionInput>(
|
|
1322
1495
|
value: Value
|
|
1323
1496
|
): DialectAsExpression<Value, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb> => {
|
|
@@ -1349,6 +1522,69 @@ export function makeDialectQuery<
|
|
|
1349
1522
|
? literal(value)
|
|
1350
1523
|
: value) as DialectAsNumericExpression<Value, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>
|
|
1351
1524
|
|
|
1525
|
+
const flattenVariadicBooleanExpressions = <
|
|
1526
|
+
Kind extends "and" | "or",
|
|
1527
|
+
Values extends readonly Expression.Any[]
|
|
1528
|
+
>(
|
|
1529
|
+
kind: Kind,
|
|
1530
|
+
values: Values
|
|
1531
|
+
): readonly Expression.Any[] => {
|
|
1532
|
+
const flattened: Array<Expression.Any> = []
|
|
1533
|
+
for (const value of values) {
|
|
1534
|
+
const ast = (value as unknown as { readonly [ExpressionAst.TypeId]: ExpressionAst.Any })[ExpressionAst.TypeId]
|
|
1535
|
+
if (ast.kind === kind) {
|
|
1536
|
+
flattened.push(...ast.values)
|
|
1537
|
+
} else {
|
|
1538
|
+
flattened.push(value)
|
|
1539
|
+
}
|
|
1540
|
+
}
|
|
1541
|
+
return flattened
|
|
1542
|
+
}
|
|
1543
|
+
|
|
1544
|
+
const makeVariadicBooleanExpression = <
|
|
1545
|
+
Kind extends "and" | "or",
|
|
1546
|
+
Values extends readonly Expression.Any[]
|
|
1547
|
+
>(
|
|
1548
|
+
kind: Kind,
|
|
1549
|
+
values: Values
|
|
1550
|
+
): VariadicBooleanExpression<Kind, Values, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb> => {
|
|
1551
|
+
const expressions = flattenVariadicBooleanExpressions(kind, values) as Values
|
|
1552
|
+
const expression = makeExpression({
|
|
1553
|
+
runtime: true as boolean,
|
|
1554
|
+
dbType: profile.boolDb as BoolDb,
|
|
1555
|
+
nullability: mergeNullabilityManyRuntime(expressions) as MergeNullabilityTuple<Values>,
|
|
1556
|
+
dialect: (expressions.find((value) => value[Expression.TypeId].dialect !== undefined)?.[Expression.TypeId].dialect ?? profile.dialect) as TupleDialect<Values>,
|
|
1557
|
+
aggregation: mergeAggregationManyRuntime(expressions) as MergeAggregationTuple<Values>,
|
|
1558
|
+
source: mergeManySources(expressions) as TupleSource<Values>,
|
|
1559
|
+
sourceNullability: "propagate" as const,
|
|
1560
|
+
dependencies: mergeManyDependencies(expressions) as TupleDependencies<Values>
|
|
1561
|
+
}, {
|
|
1562
|
+
kind,
|
|
1563
|
+
values: expressions
|
|
1564
|
+
}) as VariadicBooleanExpression<Kind, Values, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>
|
|
1565
|
+
|
|
1566
|
+
Object.defineProperty(expression, "pipe", {
|
|
1567
|
+
configurable: true,
|
|
1568
|
+
writable: true,
|
|
1569
|
+
value(this: Expression.Any) {
|
|
1570
|
+
if (arguments.length === 0) {
|
|
1571
|
+
return this
|
|
1572
|
+
}
|
|
1573
|
+
const operations = Array.from(arguments)
|
|
1574
|
+
if (operations.every((operation) => typeof operation !== "function")) {
|
|
1575
|
+
const appended = operations.map((operation) => toDialectExpression(operation as ExpressionInput)) as readonly Expression.Any[]
|
|
1576
|
+
return makeVariadicBooleanExpression(kind, [...expressions, ...appended] as const)
|
|
1577
|
+
}
|
|
1578
|
+
if (operations.every((operation) => typeof operation === "function")) {
|
|
1579
|
+
return pipeArguments(this, arguments)
|
|
1580
|
+
}
|
|
1581
|
+
throw new TypeError(`Cannot mix query expressions and pipe functions inside ${kind}(...).pipe(...)`)
|
|
1582
|
+
}
|
|
1583
|
+
})
|
|
1584
|
+
|
|
1585
|
+
return expression
|
|
1586
|
+
}
|
|
1587
|
+
|
|
1352
1588
|
const extractRequiredFromDialectInputRuntime = (value: ExpressionInput): readonly string[] => {
|
|
1353
1589
|
const expression = toDialectExpression(value)
|
|
1354
1590
|
return Object.keys(expression[Expression.TypeId].dependencies)
|
|
@@ -1584,6 +1820,46 @@ export function makeDialectQuery<
|
|
|
1584
1820
|
return buildBinaryPredicate(left as ExpressionInput, right as ExpressionInput, "ilike")
|
|
1585
1821
|
}
|
|
1586
1822
|
|
|
1823
|
+
const regexMatch = <
|
|
1824
|
+
Left extends StringExpressionInput,
|
|
1825
|
+
Right extends StringExpressionInput
|
|
1826
|
+
>(
|
|
1827
|
+
...args: TextArgs<Left, Right, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb, "regexMatch">
|
|
1828
|
+
): BinaryPredicateExpression<Left, Right, "regexMatch"> => {
|
|
1829
|
+
const [left, right] = args as [Left, Right]
|
|
1830
|
+
return buildBinaryPredicate(left as ExpressionInput, right as ExpressionInput, "regexMatch")
|
|
1831
|
+
}
|
|
1832
|
+
|
|
1833
|
+
const regexIMatch = <
|
|
1834
|
+
Left extends StringExpressionInput,
|
|
1835
|
+
Right extends StringExpressionInput
|
|
1836
|
+
>(
|
|
1837
|
+
...args: TextArgs<Left, Right, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb, "regexIMatch">
|
|
1838
|
+
): BinaryPredicateExpression<Left, Right, "regexIMatch"> => {
|
|
1839
|
+
const [left, right] = args as [Left, Right]
|
|
1840
|
+
return buildBinaryPredicate(left as ExpressionInput, right as ExpressionInput, "regexIMatch")
|
|
1841
|
+
}
|
|
1842
|
+
|
|
1843
|
+
const regexNotMatch = <
|
|
1844
|
+
Left extends StringExpressionInput,
|
|
1845
|
+
Right extends StringExpressionInput
|
|
1846
|
+
>(
|
|
1847
|
+
...args: TextArgs<Left, Right, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb, "regexNotMatch">
|
|
1848
|
+
): BinaryPredicateExpression<Left, Right, "regexNotMatch"> => {
|
|
1849
|
+
const [left, right] = args as [Left, Right]
|
|
1850
|
+
return buildBinaryPredicate(left as ExpressionInput, right as ExpressionInput, "regexNotMatch")
|
|
1851
|
+
}
|
|
1852
|
+
|
|
1853
|
+
const regexNotIMatch = <
|
|
1854
|
+
Left extends StringExpressionInput,
|
|
1855
|
+
Right extends StringExpressionInput
|
|
1856
|
+
>(
|
|
1857
|
+
...args: TextArgs<Left, Right, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb, "regexNotIMatch">
|
|
1858
|
+
): BinaryPredicateExpression<Left, Right, "regexNotIMatch"> => {
|
|
1859
|
+
const [left, right] = args as [Left, Right]
|
|
1860
|
+
return buildBinaryPredicate(left as ExpressionInput, right as ExpressionInput, "regexNotIMatch")
|
|
1861
|
+
}
|
|
1862
|
+
|
|
1587
1863
|
const isDistinctFrom = <
|
|
1588
1864
|
Left extends ExpressionInput,
|
|
1589
1865
|
Right extends ExpressionInput
|
|
@@ -1812,6 +2088,13 @@ export function makeDialectQuery<
|
|
|
1812
2088
|
variant: "set"
|
|
1813
2089
|
})
|
|
1814
2090
|
|
|
2091
|
+
const custom = <Kind extends string>(
|
|
2092
|
+
kind: Kind
|
|
2093
|
+
): Expression.DbType.Base<Dialect, Kind> => ({
|
|
2094
|
+
dialect: profile.dialect,
|
|
2095
|
+
kind
|
|
2096
|
+
})
|
|
2097
|
+
|
|
1815
2098
|
const type = {
|
|
1816
2099
|
...profile.type,
|
|
1817
2100
|
array,
|
|
@@ -1820,7 +2103,8 @@ export function makeDialectQuery<
|
|
|
1820
2103
|
record,
|
|
1821
2104
|
domain,
|
|
1822
2105
|
enum: enum_,
|
|
1823
|
-
set
|
|
2106
|
+
set,
|
|
2107
|
+
custom
|
|
1824
2108
|
}
|
|
1825
2109
|
|
|
1826
2110
|
const makeJsonDb = <Kind extends string>(
|
|
@@ -1828,11 +2112,11 @@ export function makeDialectQuery<
|
|
|
1828
2112
|
): JsonDb<Dialect, Kind> => ({
|
|
1829
2113
|
dialect: profile.dialect,
|
|
1830
2114
|
kind,
|
|
1831
|
-
variant: "json"
|
|
2115
|
+
variant: (kind === "jsonb" ? "jsonb" : "json") as Kind extends "jsonb" ? "jsonb" : "json"
|
|
1832
2116
|
})
|
|
1833
2117
|
|
|
1834
2118
|
const jsonDb = makeJsonDb("json")
|
|
1835
|
-
const jsonbDb = makeJsonDb(
|
|
2119
|
+
const jsonbDb = makeJsonDb("jsonb" as JsonbKindForDialect<Dialect>)
|
|
1836
2120
|
|
|
1837
2121
|
const isExpressionValue = (value: unknown): value is Expression.Any =>
|
|
1838
2122
|
value !== null && typeof value === "object" && Expression.TypeId in value
|
|
@@ -1901,6 +2185,14 @@ export function makeDialectQuery<
|
|
|
1901
2185
|
SourceNullability
|
|
1902
2186
|
>
|
|
1903
2187
|
|
|
2188
|
+
const jsonDbTypeOf = <Base extends JsonExpressionLike<any>>(
|
|
2189
|
+
base: Base
|
|
2190
|
+
): JsonDbOfExpression<Base> => base[Expression.TypeId].dbType as JsonDbOfExpression<Base>
|
|
2191
|
+
|
|
2192
|
+
const resolveJsonMergeDbType = (
|
|
2193
|
+
..._values: readonly Expression.Any[]
|
|
2194
|
+
): Expression.DbType.Json<any, any> => jsonbDb
|
|
2195
|
+
|
|
1904
2196
|
const makeJsonLiteralExpression = <Value extends JsonLiteralInput>(
|
|
1905
2197
|
value: Value,
|
|
1906
2198
|
dbType: Expression.DbType.Json<any, any> = jsonDb
|
|
@@ -1961,7 +2253,7 @@ export function makeDialectQuery<
|
|
|
1961
2253
|
target: Target & JsonPathGuard<Expression.RuntimeOf<Base>, Target, "json.get">
|
|
1962
2254
|
): JsonExpression<
|
|
1963
2255
|
JsonPathOutputOf<Expression.RuntimeOf<Base>, Target, "json.get">,
|
|
1964
|
-
|
|
2256
|
+
JsonDbOfExpression<Base>,
|
|
1965
2257
|
JsonNullabilityOf<JsonPathOutputOf<Expression.RuntimeOf<Base>, Target, "json.get">>,
|
|
1966
2258
|
DialectOf<Base>,
|
|
1967
2259
|
AggregationOf<Base>,
|
|
@@ -1977,7 +2269,7 @@ export function makeDialectQuery<
|
|
|
1977
2269
|
[base],
|
|
1978
2270
|
{
|
|
1979
2271
|
runtime: undefined as unknown as JsonPathOutputOf<Expression.RuntimeOf<Base>, Target, "json.get">,
|
|
1980
|
-
dbType:
|
|
2272
|
+
dbType: jsonDbTypeOf(base),
|
|
1981
2273
|
nullability: undefined as unknown as JsonNullabilityOf<JsonPathOutputOf<Expression.RuntimeOf<Base>, Target, "json.get">>
|
|
1982
2274
|
},
|
|
1983
2275
|
{
|
|
@@ -1987,7 +2279,7 @@ export function makeDialectQuery<
|
|
|
1987
2279
|
}
|
|
1988
2280
|
) as JsonExpression<
|
|
1989
2281
|
JsonPathOutputOf<Expression.RuntimeOf<Base>, Target, "json.get">,
|
|
1990
|
-
|
|
2282
|
+
JsonDbOfExpression<Base>,
|
|
1991
2283
|
JsonNullabilityOf<JsonPathOutputOf<Expression.RuntimeOf<Base>, Target, "json.get">>,
|
|
1992
2284
|
DialectOf<Base>,
|
|
1993
2285
|
AggregationOf<Base>,
|
|
@@ -2056,7 +2348,7 @@ export function makeDialectQuery<
|
|
|
2056
2348
|
[base],
|
|
2057
2349
|
{
|
|
2058
2350
|
runtime: undefined as unknown as JsonPathOutputOf<Expression.RuntimeOf<Base>, Target, "json.access">,
|
|
2059
|
-
dbType:
|
|
2351
|
+
dbType: jsonDbTypeOf(base),
|
|
2060
2352
|
nullability: undefined as unknown as JsonNullabilityOf<JsonPathOutputOf<Expression.RuntimeOf<Base>, Target, "json.access">>
|
|
2061
2353
|
},
|
|
2062
2354
|
{
|
|
@@ -2079,7 +2371,7 @@ export function makeDialectQuery<
|
|
|
2079
2371
|
[base],
|
|
2080
2372
|
{
|
|
2081
2373
|
runtime: undefined as unknown as JsonPathOutputOf<Expression.RuntimeOf<Base>, Target, "json.traverse">,
|
|
2082
|
-
dbType:
|
|
2374
|
+
dbType: jsonDbTypeOf(base),
|
|
2083
2375
|
nullability: undefined as unknown as JsonNullabilityOf<JsonPathOutputOf<Expression.RuntimeOf<Base>, Target, "json.traverse">>
|
|
2084
2376
|
},
|
|
2085
2377
|
{
|
|
@@ -2225,7 +2517,7 @@ export function makeDialectQuery<
|
|
|
2225
2517
|
target: Target & JsonDeleteGuard<Expression.RuntimeOf<Base>, Target, "json.delete">
|
|
2226
2518
|
): JsonExpression<
|
|
2227
2519
|
JsonDeleteOutputOf<Expression.RuntimeOf<Base>, Target, "json.delete">,
|
|
2228
|
-
|
|
2520
|
+
JsonDbOfExpression<Base>,
|
|
2229
2521
|
JsonNullabilityOf<JsonDeleteOutputOf<Expression.RuntimeOf<Base>, Target, "json.delete">>,
|
|
2230
2522
|
DialectOf<Base>,
|
|
2231
2523
|
AggregationOf<Base>,
|
|
@@ -2238,7 +2530,7 @@ export function makeDialectQuery<
|
|
|
2238
2530
|
[base],
|
|
2239
2531
|
{
|
|
2240
2532
|
runtime: undefined as unknown as JsonDeleteOutputOf<Expression.RuntimeOf<Base>, Target, "json.delete">,
|
|
2241
|
-
dbType:
|
|
2533
|
+
dbType: jsonDbTypeOf(base),
|
|
2242
2534
|
nullability: undefined as unknown as JsonNullabilityOf<JsonDeleteOutputOf<Expression.RuntimeOf<Base>, Target, "json.delete">>
|
|
2243
2535
|
},
|
|
2244
2536
|
{
|
|
@@ -2248,7 +2540,7 @@ export function makeDialectQuery<
|
|
|
2248
2540
|
}
|
|
2249
2541
|
) as JsonExpression<
|
|
2250
2542
|
JsonDeleteOutputOf<Expression.RuntimeOf<Base>, Target, "json.delete">,
|
|
2251
|
-
|
|
2543
|
+
JsonDbOfExpression<Base>,
|
|
2252
2544
|
JsonNullabilityOf<JsonDeleteOutputOf<Expression.RuntimeOf<Base>, Target, "json.delete">>,
|
|
2253
2545
|
DialectOf<Base>,
|
|
2254
2546
|
AggregationOf<Base>,
|
|
@@ -2266,7 +2558,7 @@ export function makeDialectQuery<
|
|
|
2266
2558
|
target: Target & JsonDeleteGuard<Expression.RuntimeOf<Base>, Target, "json.remove">
|
|
2267
2559
|
): JsonExpression<
|
|
2268
2560
|
JsonDeleteOutputOf<Expression.RuntimeOf<Base>, Target, "json.remove">,
|
|
2269
|
-
|
|
2561
|
+
JsonDbOfExpression<Base>,
|
|
2270
2562
|
JsonNullabilityOf<JsonDeleteOutputOf<Expression.RuntimeOf<Base>, Target, "json.remove">>,
|
|
2271
2563
|
DialectOf<Base>,
|
|
2272
2564
|
AggregationOf<Base>,
|
|
@@ -2279,7 +2571,7 @@ export function makeDialectQuery<
|
|
|
2279
2571
|
[base],
|
|
2280
2572
|
{
|
|
2281
2573
|
runtime: undefined as unknown as JsonDeleteOutputOf<Expression.RuntimeOf<Base>, Target, "json.remove">,
|
|
2282
|
-
dbType:
|
|
2574
|
+
dbType: jsonDbTypeOf(base),
|
|
2283
2575
|
nullability: undefined as unknown as JsonNullabilityOf<JsonDeleteOutputOf<Expression.RuntimeOf<Base>, Target, "json.remove">>
|
|
2284
2576
|
},
|
|
2285
2577
|
{
|
|
@@ -2289,7 +2581,7 @@ export function makeDialectQuery<
|
|
|
2289
2581
|
}
|
|
2290
2582
|
) as JsonExpression<
|
|
2291
2583
|
JsonDeleteOutputOf<Expression.RuntimeOf<Base>, Target, "json.remove">,
|
|
2292
|
-
|
|
2584
|
+
JsonDbOfExpression<Base>,
|
|
2293
2585
|
JsonNullabilityOf<JsonDeleteOutputOf<Expression.RuntimeOf<Base>, Target, "json.remove">>,
|
|
2294
2586
|
DialectOf<Base>,
|
|
2295
2587
|
AggregationOf<Base>,
|
|
@@ -2312,7 +2604,7 @@ export function makeDialectQuery<
|
|
|
2312
2604
|
} = {}
|
|
2313
2605
|
): JsonExpression<
|
|
2314
2606
|
JsonSetOutputOf<Expression.RuntimeOf<Base>, Target, Next, "json.set">,
|
|
2315
|
-
|
|
2607
|
+
JsonDbOfExpression<Base>,
|
|
2316
2608
|
JsonNullabilityOf<JsonSetOutputOf<Expression.RuntimeOf<Base>, Target, Next, "json.set">>,
|
|
2317
2609
|
DialectOf<Base>,
|
|
2318
2610
|
AggregationOf<Base>,
|
|
@@ -2326,7 +2618,7 @@ export function makeDialectQuery<
|
|
|
2326
2618
|
[base, newValue],
|
|
2327
2619
|
{
|
|
2328
2620
|
runtime: undefined as unknown as JsonSetOutputOf<Expression.RuntimeOf<Base>, Target, Next, "json.set">,
|
|
2329
|
-
dbType:
|
|
2621
|
+
dbType: jsonDbTypeOf(base),
|
|
2330
2622
|
nullability: undefined as unknown as JsonNullabilityOf<JsonSetOutputOf<Expression.RuntimeOf<Base>, Target, Next, "json.set">>
|
|
2331
2623
|
},
|
|
2332
2624
|
{
|
|
@@ -2338,7 +2630,7 @@ export function makeDialectQuery<
|
|
|
2338
2630
|
}
|
|
2339
2631
|
) as JsonExpression<
|
|
2340
2632
|
JsonSetOutputOf<Expression.RuntimeOf<Base>, Target, Next, "json.set">,
|
|
2341
|
-
|
|
2633
|
+
JsonDbOfExpression<Base>,
|
|
2342
2634
|
JsonNullabilityOf<JsonSetOutputOf<Expression.RuntimeOf<Base>, Target, Next, "json.set">>,
|
|
2343
2635
|
DialectOf<Base>,
|
|
2344
2636
|
AggregationOf<Base>,
|
|
@@ -2362,7 +2654,7 @@ export function makeDialectQuery<
|
|
|
2362
2654
|
} = {}
|
|
2363
2655
|
): JsonExpression<
|
|
2364
2656
|
JsonInsertOutputOf<Expression.RuntimeOf<Base>, Target, Next, InsertAfter, "json.insert">,
|
|
2365
|
-
|
|
2657
|
+
JsonDbOfExpression<Base>,
|
|
2366
2658
|
JsonNullabilityOf<JsonInsertOutputOf<Expression.RuntimeOf<Base>, Target, Next, InsertAfter, "json.insert">>,
|
|
2367
2659
|
DialectOf<Base>,
|
|
2368
2660
|
AggregationOf<Base>,
|
|
@@ -2377,7 +2669,7 @@ export function makeDialectQuery<
|
|
|
2377
2669
|
[base, insert],
|
|
2378
2670
|
{
|
|
2379
2671
|
runtime: undefined as unknown as JsonInsertOutputOf<Expression.RuntimeOf<Base>, Target, Next, InsertAfter, "json.insert">,
|
|
2380
|
-
dbType:
|
|
2672
|
+
dbType: jsonDbTypeOf(base),
|
|
2381
2673
|
nullability: undefined as unknown as JsonNullabilityOf<JsonInsertOutputOf<Expression.RuntimeOf<Base>, Target, Next, InsertAfter, "json.insert">>
|
|
2382
2674
|
},
|
|
2383
2675
|
{
|
|
@@ -2389,7 +2681,7 @@ export function makeDialectQuery<
|
|
|
2389
2681
|
}
|
|
2390
2682
|
) as JsonExpression<
|
|
2391
2683
|
JsonInsertOutputOf<Expression.RuntimeOf<Base>, Target, Next, InsertAfter, "json.insert">,
|
|
2392
|
-
|
|
2684
|
+
JsonDbOfExpression<Base>,
|
|
2393
2685
|
JsonNullabilityOf<JsonInsertOutputOf<Expression.RuntimeOf<Base>, Target, Next, InsertAfter, "json.insert">>,
|
|
2394
2686
|
DialectOf<Base>,
|
|
2395
2687
|
AggregationOf<Base>,
|
|
@@ -2399,7 +2691,11 @@ export function makeDialectQuery<
|
|
|
2399
2691
|
>
|
|
2400
2692
|
}
|
|
2401
2693
|
|
|
2402
|
-
const
|
|
2694
|
+
const jsonConcatAs = <
|
|
2695
|
+
Db extends Expression.DbType.Json<any, any>
|
|
2696
|
+
>(
|
|
2697
|
+
dbType: Db
|
|
2698
|
+
) => <
|
|
2403
2699
|
Left extends JsonValueInput,
|
|
2404
2700
|
Right extends JsonValueInput
|
|
2405
2701
|
>(
|
|
@@ -2407,7 +2703,7 @@ export function makeDialectQuery<
|
|
|
2407
2703
|
right: Right
|
|
2408
2704
|
): JsonExpression<
|
|
2409
2705
|
JsonConcatResult<JsonOutputOfInput<Left>, JsonOutputOfInput<Right>>,
|
|
2410
|
-
|
|
2706
|
+
Db,
|
|
2411
2707
|
"maybe",
|
|
2412
2708
|
Dialect,
|
|
2413
2709
|
Expression.AggregationKind,
|
|
@@ -2421,7 +2717,7 @@ export function makeDialectQuery<
|
|
|
2421
2717
|
[leftExpression, rightExpression],
|
|
2422
2718
|
{
|
|
2423
2719
|
runtime: undefined as unknown as JsonConcatResult<JsonOutputOfInput<Left>, JsonOutputOfInput<Right>>,
|
|
2424
|
-
dbType
|
|
2720
|
+
dbType,
|
|
2425
2721
|
nullability: "maybe" as const
|
|
2426
2722
|
},
|
|
2427
2723
|
{
|
|
@@ -2431,7 +2727,7 @@ export function makeDialectQuery<
|
|
|
2431
2727
|
}
|
|
2432
2728
|
) as JsonExpression<
|
|
2433
2729
|
JsonConcatResult<JsonOutputOfInput<Left>, JsonOutputOfInput<Right>>,
|
|
2434
|
-
|
|
2730
|
+
Db,
|
|
2435
2731
|
"maybe",
|
|
2436
2732
|
Dialect,
|
|
2437
2733
|
Expression.AggregationKind,
|
|
@@ -2441,7 +2737,11 @@ export function makeDialectQuery<
|
|
|
2441
2737
|
>
|
|
2442
2738
|
}
|
|
2443
2739
|
|
|
2444
|
-
const
|
|
2740
|
+
const jsonMergeAs = <
|
|
2741
|
+
Db extends Expression.DbType.Json<any, any>
|
|
2742
|
+
>(
|
|
2743
|
+
dbType: Db
|
|
2744
|
+
) => <
|
|
2445
2745
|
Left extends JsonValueInput,
|
|
2446
2746
|
Right extends JsonValueInput
|
|
2447
2747
|
>(
|
|
@@ -2454,7 +2754,7 @@ export function makeDialectQuery<
|
|
|
2454
2754
|
[leftExpression, rightExpression],
|
|
2455
2755
|
{
|
|
2456
2756
|
runtime: undefined as unknown as JsonConcatResult<JsonOutputOfInput<Left>, JsonOutputOfInput<Right>>,
|
|
2457
|
-
dbType
|
|
2757
|
+
dbType,
|
|
2458
2758
|
nullability: "maybe" as const
|
|
2459
2759
|
},
|
|
2460
2760
|
{
|
|
@@ -2465,6 +2765,9 @@ export function makeDialectQuery<
|
|
|
2465
2765
|
)
|
|
2466
2766
|
}
|
|
2467
2767
|
|
|
2768
|
+
const jsonConcat = jsonConcatAs(resolveJsonMergeDbType())
|
|
2769
|
+
const jsonMerge = jsonMergeAs(resolveJsonMergeDbType())
|
|
2770
|
+
|
|
2468
2771
|
const jsonKeyExists = <
|
|
2469
2772
|
Base extends JsonExpressionLike<any>,
|
|
2470
2773
|
Key extends string
|
|
@@ -2486,7 +2789,11 @@ export function makeDialectQuery<
|
|
|
2486
2789
|
}
|
|
2487
2790
|
)
|
|
2488
2791
|
|
|
2489
|
-
const
|
|
2792
|
+
const jsonBuildObjectAs = <
|
|
2793
|
+
Db extends Expression.DbType.Json<any, any>
|
|
2794
|
+
>(
|
|
2795
|
+
dbType: Db
|
|
2796
|
+
) => <
|
|
2490
2797
|
Shape extends Record<string, JsonValueInput>
|
|
2491
2798
|
>(
|
|
2492
2799
|
shape: Shape
|
|
@@ -2499,7 +2806,7 @@ export function makeDialectQuery<
|
|
|
2499
2806
|
entries.map((entry) => entry.value),
|
|
2500
2807
|
{
|
|
2501
2808
|
runtime: {} as JsonObjectOutput<Shape>,
|
|
2502
|
-
dbType
|
|
2809
|
+
dbType,
|
|
2503
2810
|
nullability: "never" as const,
|
|
2504
2811
|
sourceNullability: "resolved" as const
|
|
2505
2812
|
},
|
|
@@ -2510,7 +2817,11 @@ export function makeDialectQuery<
|
|
|
2510
2817
|
)
|
|
2511
2818
|
}
|
|
2512
2819
|
|
|
2513
|
-
const
|
|
2820
|
+
const jsonBuildArrayAs = <
|
|
2821
|
+
Db extends Expression.DbType.Json<any, any>
|
|
2822
|
+
>(
|
|
2823
|
+
dbType: Db
|
|
2824
|
+
) => <
|
|
2514
2825
|
Values extends readonly JsonValueInput[]
|
|
2515
2826
|
>(
|
|
2516
2827
|
...values: Values
|
|
@@ -2520,7 +2831,7 @@ export function makeDialectQuery<
|
|
|
2520
2831
|
expressions,
|
|
2521
2832
|
{
|
|
2522
2833
|
runtime: [] as JsonArrayOutput<Values>,
|
|
2523
|
-
dbType
|
|
2834
|
+
dbType,
|
|
2524
2835
|
nullability: "never" as const,
|
|
2525
2836
|
sourceNullability: "resolved" as const
|
|
2526
2837
|
},
|
|
@@ -2531,6 +2842,11 @@ export function makeDialectQuery<
|
|
|
2531
2842
|
)
|
|
2532
2843
|
}
|
|
2533
2844
|
|
|
2845
|
+
const jsonBuildObject = jsonBuildObjectAs(jsonDb)
|
|
2846
|
+
const jsonBuildArray = jsonBuildArrayAs(jsonDb)
|
|
2847
|
+
const jsonbBuildObject = jsonBuildObjectAs(jsonbDb)
|
|
2848
|
+
const jsonbBuildArray = jsonBuildArrayAs(jsonbDb)
|
|
2849
|
+
|
|
2534
2850
|
const jsonToJson = <Value extends JsonValueInput>(
|
|
2535
2851
|
value: Value
|
|
2536
2852
|
) => toJsonValueExpression(value, "jsonToJson", jsonDb) as JsonExpression<
|
|
@@ -2548,7 +2864,7 @@ export function makeDialectQuery<
|
|
|
2548
2864
|
value: Value
|
|
2549
2865
|
) => toJsonValueExpression(value, "jsonToJsonb", jsonbDb) as JsonExpression<
|
|
2550
2866
|
JsonOutputOfInput<Value>,
|
|
2551
|
-
JsonDb<Dialect,
|
|
2867
|
+
JsonDb<Dialect, JsonbKindForDialect<Dialect>>,
|
|
2552
2868
|
JsonNullabilityOf<JsonOutputOfInput<Value>>,
|
|
2553
2869
|
string,
|
|
2554
2870
|
Expression.AggregationKind,
|
|
@@ -2645,7 +2961,7 @@ export function makeDialectQuery<
|
|
|
2645
2961
|
[base],
|
|
2646
2962
|
{
|
|
2647
2963
|
runtime: undefined as unknown as JsonStripNullsResult<Expression.RuntimeOf<Base>>,
|
|
2648
|
-
dbType:
|
|
2964
|
+
dbType: jsonDbTypeOf(base),
|
|
2649
2965
|
nullability: undefined as unknown as JsonNullabilityOf<JsonStripNullsResult<Expression.RuntimeOf<Base>>>
|
|
2650
2966
|
},
|
|
2651
2967
|
{
|
|
@@ -2728,83 +3044,79 @@ export function makeDialectQuery<
|
|
|
2728
3044
|
pathMatch: jsonPathMatch
|
|
2729
3045
|
}
|
|
2730
3046
|
|
|
3047
|
+
const jsonb = {
|
|
3048
|
+
key: JsonPath.key,
|
|
3049
|
+
index: JsonPath.index,
|
|
3050
|
+
wildcard: JsonPath.wildcard,
|
|
3051
|
+
slice: JsonPath.slice,
|
|
3052
|
+
descend: JsonPath.descend,
|
|
3053
|
+
path: JsonPath.path,
|
|
3054
|
+
get: jsonGet,
|
|
3055
|
+
access: jsonAccess,
|
|
3056
|
+
traverse: jsonTraverse,
|
|
3057
|
+
text: jsonText,
|
|
3058
|
+
accessText: jsonAccessText,
|
|
3059
|
+
traverseText: jsonTraverseText,
|
|
3060
|
+
contains: jsonContains,
|
|
3061
|
+
containedBy: jsonContainedBy,
|
|
3062
|
+
hasKey: jsonHasKey,
|
|
3063
|
+
keyExists: jsonKeyExists,
|
|
3064
|
+
hasAnyKeys: jsonHasAnyKeys,
|
|
3065
|
+
hasAllKeys: jsonHasAllKeys,
|
|
3066
|
+
delete: jsonDelete,
|
|
3067
|
+
remove: jsonRemove,
|
|
3068
|
+
set: jsonSet,
|
|
3069
|
+
insert: jsonInsert,
|
|
3070
|
+
concat: jsonConcatAs(jsonbDb),
|
|
3071
|
+
merge: jsonMergeAs(jsonbDb),
|
|
3072
|
+
buildObject: jsonbBuildObject,
|
|
3073
|
+
buildArray: jsonbBuildArray,
|
|
3074
|
+
toJsonb: jsonToJsonb,
|
|
3075
|
+
typeOf: jsonTypeOf,
|
|
3076
|
+
length: jsonLength,
|
|
3077
|
+
keys: jsonKeys,
|
|
3078
|
+
stripNulls: jsonStripNulls,
|
|
3079
|
+
pathExists: jsonPathExists,
|
|
3080
|
+
pathMatch: jsonPathMatch
|
|
3081
|
+
}
|
|
3082
|
+
|
|
2731
3083
|
const and = <
|
|
2732
3084
|
Values extends readonly [ExpressionInput, ...ExpressionInput[]]
|
|
2733
3085
|
>(
|
|
2734
3086
|
...values: Values
|
|
2735
|
-
):
|
|
2736
|
-
|
|
3087
|
+
): VariadicBooleanExpression<
|
|
3088
|
+
"and",
|
|
3089
|
+
{ readonly [K in keyof Values]: DialectAsExpression<Values[K], Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb> } & readonly Expression.Any[],
|
|
3090
|
+
Dialect,
|
|
3091
|
+
TextDb,
|
|
3092
|
+
NumericDb,
|
|
2737
3093
|
BoolDb,
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
|
|
2744
|
-
|
|
2745
|
-
const expressions = values.map((value) => toDialectExpression(value)) as readonly Expression.Any[]
|
|
2746
|
-
return makeExpression({
|
|
2747
|
-
runtime: true as boolean,
|
|
2748
|
-
dbType: profile.boolDb as BoolDb,
|
|
2749
|
-
nullability: mergeNullabilityManyRuntime(expressions) as MergeNullabilityTuple<{ readonly [K in keyof Values]: DialectAsExpression<Values[K], Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb> } & readonly Expression.Any[]>,
|
|
2750
|
-
dialect: (expressions.find((value) => value[Expression.TypeId].dialect !== undefined)?.[Expression.TypeId].dialect ?? profile.dialect) as TupleDialect<{ readonly [K in keyof Values]: DialectAsExpression<Values[K], Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb> } & readonly Expression.Any[]>,
|
|
2751
|
-
aggregation: mergeAggregationManyRuntime(expressions) as MergeAggregationTuple<{ readonly [K in keyof Values]: DialectAsExpression<Values[K], Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb> } & readonly Expression.Any[]>,
|
|
2752
|
-
source: mergeManySources(expressions) as TupleSource<{ readonly [K in keyof Values]: DialectAsExpression<Values[K], Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb> } & readonly Expression.Any[]>,
|
|
2753
|
-
sourceNullability: "propagate" as const,
|
|
2754
|
-
dependencies: mergeManyDependencies(expressions) as TupleDependencies<{ readonly [K in keyof Values]: DialectAsExpression<Values[K], Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb> } & readonly Expression.Any[]>
|
|
2755
|
-
}, {
|
|
2756
|
-
kind: "and",
|
|
2757
|
-
values: expressions
|
|
2758
|
-
}) as AstBackedExpression<
|
|
2759
|
-
boolean,
|
|
2760
|
-
BoolDb,
|
|
2761
|
-
MergeNullabilityTuple<{ readonly [K in keyof Values]: DialectAsExpression<Values[K], Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb> } & readonly Expression.Any[]>,
|
|
2762
|
-
TupleDialect<{ readonly [K in keyof Values]: DialectAsExpression<Values[K], Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb> } & readonly Expression.Any[]>,
|
|
2763
|
-
MergeAggregationTuple<{ readonly [K in keyof Values]: DialectAsExpression<Values[K], Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb> } & readonly Expression.Any[]>,
|
|
2764
|
-
TupleSource<{ readonly [K in keyof Values]: DialectAsExpression<Values[K], Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb> } & readonly Expression.Any[]>,
|
|
2765
|
-
TupleDependencies<{ readonly [K in keyof Values]: DialectAsExpression<Values[K], Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb> } & readonly Expression.Any[]>,
|
|
2766
|
-
ExpressionAst.VariadicNode<"and", { readonly [K in keyof Values]: DialectAsExpression<Values[K], Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb> } & readonly Expression.Any[]>
|
|
2767
|
-
>
|
|
2768
|
-
}
|
|
3094
|
+
TimestampDb,
|
|
3095
|
+
NullDb
|
|
3096
|
+
> =>
|
|
3097
|
+
makeVariadicBooleanExpression(
|
|
3098
|
+
"and",
|
|
3099
|
+
values.map((value) => toDialectExpression(value)) as { readonly [K in keyof Values]: DialectAsExpression<Values[K], Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb> } & readonly Expression.Any[]
|
|
3100
|
+
)
|
|
2769
3101
|
|
|
2770
3102
|
const or = <
|
|
2771
3103
|
Values extends readonly [ExpressionInput, ...ExpressionInput[]]
|
|
2772
3104
|
>(
|
|
2773
3105
|
...values: Values
|
|
2774
|
-
):
|
|
2775
|
-
|
|
3106
|
+
): VariadicBooleanExpression<
|
|
3107
|
+
"or",
|
|
3108
|
+
{ readonly [K in keyof Values]: DialectAsExpression<Values[K], Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb> } & readonly Expression.Any[],
|
|
3109
|
+
Dialect,
|
|
3110
|
+
TextDb,
|
|
3111
|
+
NumericDb,
|
|
2776
3112
|
BoolDb,
|
|
2777
|
-
|
|
2778
|
-
|
|
2779
|
-
|
|
2780
|
-
|
|
2781
|
-
|
|
2782
|
-
|
|
2783
|
-
|
|
2784
|
-
const expressions = values.map((value) => toDialectExpression(value)) as readonly Expression.Any[]
|
|
2785
|
-
return makeExpression({
|
|
2786
|
-
runtime: true as boolean,
|
|
2787
|
-
dbType: profile.boolDb as BoolDb,
|
|
2788
|
-
nullability: mergeNullabilityManyRuntime(expressions) as MergeNullabilityTuple<{ readonly [K in keyof Values]: DialectAsExpression<Values[K], Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb> } & readonly Expression.Any[]>,
|
|
2789
|
-
dialect: (expressions.find((value) => value[Expression.TypeId].dialect !== undefined)?.[Expression.TypeId].dialect ?? profile.dialect) as TupleDialect<{ readonly [K in keyof Values]: DialectAsExpression<Values[K], Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb> } & readonly Expression.Any[]>,
|
|
2790
|
-
aggregation: mergeAggregationManyRuntime(expressions) as MergeAggregationTuple<{ readonly [K in keyof Values]: DialectAsExpression<Values[K], Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb> } & readonly Expression.Any[]>,
|
|
2791
|
-
source: mergeManySources(expressions) as TupleSource<{ readonly [K in keyof Values]: DialectAsExpression<Values[K], Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb> } & readonly Expression.Any[]>,
|
|
2792
|
-
sourceNullability: "propagate" as const,
|
|
2793
|
-
dependencies: mergeManyDependencies(expressions) as TupleDependencies<{ readonly [K in keyof Values]: DialectAsExpression<Values[K], Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb> } & readonly Expression.Any[]>
|
|
2794
|
-
}, {
|
|
2795
|
-
kind: "or",
|
|
2796
|
-
values: expressions
|
|
2797
|
-
}) as AstBackedExpression<
|
|
2798
|
-
boolean,
|
|
2799
|
-
BoolDb,
|
|
2800
|
-
MergeNullabilityTuple<{ readonly [K in keyof Values]: DialectAsExpression<Values[K], Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb> } & readonly Expression.Any[]>,
|
|
2801
|
-
TupleDialect<{ readonly [K in keyof Values]: DialectAsExpression<Values[K], Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb> } & readonly Expression.Any[]>,
|
|
2802
|
-
MergeAggregationTuple<{ readonly [K in keyof Values]: DialectAsExpression<Values[K], Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb> } & readonly Expression.Any[]>,
|
|
2803
|
-
TupleSource<{ readonly [K in keyof Values]: DialectAsExpression<Values[K], Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb> } & readonly Expression.Any[]>,
|
|
2804
|
-
TupleDependencies<{ readonly [K in keyof Values]: DialectAsExpression<Values[K], Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb> } & readonly Expression.Any[]>,
|
|
2805
|
-
ExpressionAst.VariadicNode<"or", { readonly [K in keyof Values]: DialectAsExpression<Values[K], Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb> } & readonly Expression.Any[]>
|
|
2806
|
-
>
|
|
2807
|
-
}
|
|
3113
|
+
TimestampDb,
|
|
3114
|
+
NullDb
|
|
3115
|
+
> =>
|
|
3116
|
+
makeVariadicBooleanExpression(
|
|
3117
|
+
"or",
|
|
3118
|
+
values.map((value) => toDialectExpression(value)) as { readonly [K in keyof Values]: DialectAsExpression<Values[K], Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb> } & readonly Expression.Any[]
|
|
3119
|
+
)
|
|
2808
3120
|
|
|
2809
3121
|
const not = <Value extends ExpressionInput>(
|
|
2810
3122
|
value: Value
|
|
@@ -3370,6 +3682,84 @@ export function makeDialectQuery<
|
|
|
3370
3682
|
>
|
|
3371
3683
|
}
|
|
3372
3684
|
|
|
3685
|
+
const call = <
|
|
3686
|
+
Name extends string,
|
|
3687
|
+
Args extends readonly ExpressionInput[]
|
|
3688
|
+
>(
|
|
3689
|
+
name: Name,
|
|
3690
|
+
...args: Args
|
|
3691
|
+
): Expression.Any => {
|
|
3692
|
+
const expressions = args.map((value) => toDialectExpression(value)) as readonly Expression.Any[]
|
|
3693
|
+
return makeExpression({
|
|
3694
|
+
runtime: undefined as never,
|
|
3695
|
+
dbType: profile.textDb,
|
|
3696
|
+
nullability: "maybe",
|
|
3697
|
+
dialect: (expressions.find((value) => value[Expression.TypeId].dialect !== undefined)?.[Expression.TypeId].dialect ?? profile.dialect) as Dialect,
|
|
3698
|
+
aggregation: mergeAggregationManyRuntime(expressions),
|
|
3699
|
+
source: mergeManySources(expressions),
|
|
3700
|
+
sourceNullability: "resolved" as const,
|
|
3701
|
+
dependencies: mergeManyDependencies(expressions)
|
|
3702
|
+
}, {
|
|
3703
|
+
kind: "function",
|
|
3704
|
+
name,
|
|
3705
|
+
args: expressions
|
|
3706
|
+
}) as Expression.Any
|
|
3707
|
+
}
|
|
3708
|
+
|
|
3709
|
+
const uuidGenerateV4 = (): Expression.Expression<
|
|
3710
|
+
string,
|
|
3711
|
+
Expression.DbType.PgUuid,
|
|
3712
|
+
"never",
|
|
3713
|
+
Dialect,
|
|
3714
|
+
"scalar",
|
|
3715
|
+
never,
|
|
3716
|
+
{},
|
|
3717
|
+
"resolved"
|
|
3718
|
+
> & {
|
|
3719
|
+
readonly [ExpressionAst.TypeId]: ExpressionAst.FunctionCallNode<"uuid_generate_v4", readonly []>
|
|
3720
|
+
} => makeExpression({
|
|
3721
|
+
runtime: undefined as unknown as string,
|
|
3722
|
+
dbType: { dialect: "postgres", kind: "uuid" } as Expression.DbType.PgUuid,
|
|
3723
|
+
nullability: "never",
|
|
3724
|
+
dialect: profile.dialect as Dialect,
|
|
3725
|
+
aggregation: "scalar",
|
|
3726
|
+
source: undefined as never,
|
|
3727
|
+
sourceNullability: "resolved" as const,
|
|
3728
|
+
dependencies: {}
|
|
3729
|
+
}, {
|
|
3730
|
+
kind: "function",
|
|
3731
|
+
name: "uuid_generate_v4",
|
|
3732
|
+
args: []
|
|
3733
|
+
})
|
|
3734
|
+
|
|
3735
|
+
const nextVal = <Value extends ExpressionInput>(
|
|
3736
|
+
value: Value
|
|
3737
|
+
): Expression.Expression<
|
|
3738
|
+
Expression.RuntimeOfDbType<Expression.DbType.PgInt8>,
|
|
3739
|
+
Expression.DbType.PgInt8,
|
|
3740
|
+
"never",
|
|
3741
|
+
Dialect,
|
|
3742
|
+
"scalar",
|
|
3743
|
+
never,
|
|
3744
|
+
{},
|
|
3745
|
+
"resolved"
|
|
3746
|
+
> & {
|
|
3747
|
+
readonly [ExpressionAst.TypeId]: ExpressionAst.FunctionCallNode<"nextval", readonly [Expression.Any]>
|
|
3748
|
+
} => makeExpression({
|
|
3749
|
+
runtime: undefined as unknown as Expression.RuntimeOfDbType<Expression.DbType.PgInt8>,
|
|
3750
|
+
dbType: { dialect: "postgres", kind: "int8" } as Expression.DbType.PgInt8,
|
|
3751
|
+
nullability: "never",
|
|
3752
|
+
dialect: profile.dialect as Dialect,
|
|
3753
|
+
aggregation: "scalar",
|
|
3754
|
+
source: undefined as never,
|
|
3755
|
+
sourceNullability: "resolved" as const,
|
|
3756
|
+
dependencies: {}
|
|
3757
|
+
}, {
|
|
3758
|
+
kind: "function",
|
|
3759
|
+
name: "nextval",
|
|
3760
|
+
args: [toDialectExpression(value as any)]
|
|
3761
|
+
})
|
|
3762
|
+
|
|
3373
3763
|
type RuntimeCaseBranch = {
|
|
3374
3764
|
readonly when: Expression.Any
|
|
3375
3765
|
readonly then: Expression.Any
|
|
@@ -3802,7 +4192,7 @@ export function makeDialectQuery<
|
|
|
3802
4192
|
const firstRow = rows[0]
|
|
3803
4193
|
const firstColumns = Object.keys(firstRow)
|
|
3804
4194
|
if (firstColumns.length === 0) {
|
|
3805
|
-
throw new Error("values(...) rows must specify at least one column; use
|
|
4195
|
+
throw new Error("values(...) rows must specify at least one column; use insert(target) for default-only inserts instead")
|
|
3806
4196
|
}
|
|
3807
4197
|
const columns = firstColumns as [string, ...string[]]
|
|
3808
4198
|
const normalizedRows = rows.map((row) => {
|
|
@@ -3916,10 +4306,12 @@ type DdlColumnInput = string | readonly string[]
|
|
|
3916
4306
|
type NormalizeDdlColumns<Columns extends DdlColumnInput> =
|
|
3917
4307
|
Columns extends readonly [infer Head extends string, ...infer Tail extends string[]]
|
|
3918
4308
|
? readonly [Head, ...Tail]
|
|
4309
|
+
: Columns extends [infer Head extends string, ...infer Tail extends string[]]
|
|
4310
|
+
? readonly [Head, ...Tail]
|
|
3919
4311
|
: Columns extends readonly string[]
|
|
3920
|
-
? Columns extends
|
|
3921
|
-
?
|
|
3922
|
-
:
|
|
4312
|
+
? Columns[number] extends never
|
|
4313
|
+
? never
|
|
4314
|
+
: readonly [Columns[number], ...Columns[number][]]
|
|
3923
4315
|
: Columns extends string
|
|
3924
4316
|
? readonly [Columns]
|
|
3925
4317
|
: never
|
|
@@ -4072,12 +4464,6 @@ type InsertPlanSelectionShapeError<
|
|
|
4072
4464
|
readonly __effect_qb_hint__: "Project a flat object like select({ id: ..., email: ... }) with column-name keys"
|
|
4073
4465
|
}
|
|
4074
4466
|
|
|
4075
|
-
type DefaultValuesError<Target extends MutationTargetLike> = Target & {
|
|
4076
|
-
readonly __effect_qb_error__: "effect-qb: defaultValues(...) requires every insert column to be optional or generated"
|
|
4077
|
-
readonly __effect_qb_required_columns__: RequiredKeys<Table.InsertOf<Target>>
|
|
4078
|
-
readonly __effect_qb_hint__: "Use insert(...) for required columns, or mark columns nullable/hasDefault/generated"
|
|
4079
|
-
}
|
|
4080
|
-
|
|
4081
4467
|
type MysqlConflictTargetError<Target> = Target & {
|
|
4082
4468
|
readonly __effect_qb_error__: "effect-qb: mysql does not support named or predicate-scoped conflict targets"
|
|
4083
4469
|
readonly __effect_qb_hint__: "Use a column tuple target, or rely on MySQL duplicate-key resolution without target predicates"
|
|
@@ -4304,7 +4690,7 @@ type AstOf<Value extends Expression.Any> =
|
|
|
4304
4690
|
? Ast
|
|
4305
4691
|
: never
|
|
4306
4692
|
|
|
4307
|
-
type AvailableNames<Available extends Record<string, Plan.
|
|
4693
|
+
type AvailableNames<Available extends Record<string, Plan.AnySource>> = Extract<keyof Available, string>
|
|
4308
4694
|
|
|
4309
4695
|
type RequiredFromInput<Value extends ExpressionInput> =
|
|
4310
4696
|
Value extends Expression.Any
|
|
@@ -4362,7 +4748,7 @@ type SelectFromResult<
|
|
|
4362
4748
|
> = QueryPlan<
|
|
4363
4749
|
SelectionOfPlan<PlanValue>,
|
|
4364
4750
|
Exclude<RequiredOfPlan<PlanValue>, SourceNameOf<CurrentSource>>,
|
|
4365
|
-
AddAvailable<{}, SourceNameOf<CurrentSource>>,
|
|
4751
|
+
AddAvailable<{}, SourceNameOf<CurrentSource>, "required", TrueFormula, PresenceWitnessKeysOfSource<CurrentSource>>,
|
|
4366
4752
|
PlanDialectOf<PlanValue> | SourceDialectOf<CurrentSource>,
|
|
4367
4753
|
GroupedOfPlan<PlanValue>,
|
|
4368
4754
|
SourceNameOf<CurrentSource>,
|
|
@@ -4378,7 +4764,13 @@ type UpdateFromResult<
|
|
|
4378
4764
|
> = QueryPlan<
|
|
4379
4765
|
SelectionOfPlan<PlanValue>,
|
|
4380
4766
|
Exclude<RequiredOfPlan<PlanValue>, SourceNameOf<CurrentSource>>,
|
|
4381
|
-
AddAvailable<
|
|
4767
|
+
AddAvailable<
|
|
4768
|
+
AvailableOfPlan<PlanValue>,
|
|
4769
|
+
SourceNameOf<CurrentSource>,
|
|
4770
|
+
"required",
|
|
4771
|
+
TrueFormula,
|
|
4772
|
+
PresenceWitnessKeysOfSource<CurrentSource>
|
|
4773
|
+
>,
|
|
4382
4774
|
PlanDialectOf<PlanValue> | SourceDialectOf<CurrentSource>,
|
|
4383
4775
|
GroupedOfPlan<PlanValue>,
|
|
4384
4776
|
ScopedNamesOfPlan<PlanValue> | SourceNameOf<CurrentSource>,
|
|
@@ -4453,7 +4845,7 @@ type FromPlanResult<
|
|
|
4453
4845
|
|
|
4454
4846
|
type MergeRequiredFromPredicate<
|
|
4455
4847
|
Predicate extends PredicateInput | undefined,
|
|
4456
|
-
Available extends Record<string, Plan.
|
|
4848
|
+
Available extends Record<string, Plan.AnySource>
|
|
4457
4849
|
> = Predicate extends PredicateInput ? AddExpressionRequired<never, Available, Predicate> : never
|
|
4458
4850
|
|
|
4459
4851
|
type AsCurriedInput<Dialect extends string> =
|
|
@@ -4558,34 +4950,77 @@ type AsCurriedResult<
|
|
|
4558
4950
|
return makeDerivedSource(value as CompletePlan<QueryPlan<any, any, any, any, any, any, any, any, any, any>>, resolvedAlias)
|
|
4559
4951
|
}
|
|
4560
4952
|
|
|
4953
|
+
function with_<
|
|
4954
|
+
Alias extends string
|
|
4955
|
+
>(
|
|
4956
|
+
alias: Alias
|
|
4957
|
+
): <PlanValue extends QueryPlan<any, any, any, any, any, any, any, any, any, any>>(
|
|
4958
|
+
value: CompletePlan<PlanValue>
|
|
4959
|
+
) => import("./query.js").CteSource<PlanValue, Alias>
|
|
4561
4960
|
function with_<
|
|
4562
4961
|
PlanValue extends QueryPlan<any, any, any, any, any, any, any, any, any, any>,
|
|
4563
4962
|
Alias extends string
|
|
4564
4963
|
>(
|
|
4565
4964
|
value: CompletePlan<PlanValue>,
|
|
4566
4965
|
alias: Alias
|
|
4567
|
-
): import("./query.js").CteSource<PlanValue, Alias>
|
|
4568
|
-
|
|
4966
|
+
): import("./query.js").CteSource<PlanValue, Alias>
|
|
4967
|
+
function with_(valueOrAlias: unknown, alias?: string): unknown {
|
|
4968
|
+
if (alias === undefined) {
|
|
4969
|
+
return (value: unknown) => with_(value as any, valueOrAlias as string)
|
|
4970
|
+
}
|
|
4971
|
+
return makeCteSource(
|
|
4972
|
+
valueOrAlias as CompletePlan<QueryPlan<any, any, any, any, any, any, any, any, any, any>>,
|
|
4973
|
+
alias
|
|
4974
|
+
)
|
|
4569
4975
|
}
|
|
4570
4976
|
|
|
4977
|
+
function withRecursive_<
|
|
4978
|
+
Alias extends string
|
|
4979
|
+
>(
|
|
4980
|
+
alias: Alias
|
|
4981
|
+
): <PlanValue extends QueryPlan<any, any, any, any, any, any, any, any, any, any>>(
|
|
4982
|
+
value: CompletePlan<PlanValue>
|
|
4983
|
+
) => import("./query.js").CteSource<PlanValue, Alias>
|
|
4571
4984
|
function withRecursive_<
|
|
4572
4985
|
PlanValue extends QueryPlan<any, any, any, any, any, any, any, any, any, any>,
|
|
4573
4986
|
Alias extends string
|
|
4574
4987
|
>(
|
|
4575
4988
|
value: CompletePlan<PlanValue>,
|
|
4576
4989
|
alias: Alias
|
|
4577
|
-
): import("./query.js").CteSource<PlanValue, Alias>
|
|
4578
|
-
|
|
4990
|
+
): import("./query.js").CteSource<PlanValue, Alias>
|
|
4991
|
+
function withRecursive_(valueOrAlias: unknown, alias?: string): unknown {
|
|
4992
|
+
if (alias === undefined) {
|
|
4993
|
+
return (value: unknown) => withRecursive_(value as any, valueOrAlias as string)
|
|
4994
|
+
}
|
|
4995
|
+
return makeCteSource(
|
|
4996
|
+
valueOrAlias as CompletePlan<QueryPlan<any, any, any, any, any, any, any, any, any, any>>,
|
|
4997
|
+
alias,
|
|
4998
|
+
true
|
|
4999
|
+
)
|
|
4579
5000
|
}
|
|
4580
5001
|
|
|
5002
|
+
function lateral<
|
|
5003
|
+
Alias extends string
|
|
5004
|
+
>(
|
|
5005
|
+
alias: Alias
|
|
5006
|
+
): <PlanValue extends QueryPlan<any, any, any, any, any, any, any, any, any, any>>(
|
|
5007
|
+
value: PlanValue
|
|
5008
|
+
) => import("./query.js").LateralSource<PlanValue, Alias>
|
|
4581
5009
|
function lateral<
|
|
4582
5010
|
PlanValue extends QueryPlan<any, any, any, any, any, any, any, any, any, any>,
|
|
4583
5011
|
Alias extends string
|
|
4584
5012
|
>(
|
|
4585
5013
|
value: PlanValue,
|
|
4586
5014
|
alias: Alias
|
|
4587
|
-
): import("./query.js").LateralSource<PlanValue, Alias>
|
|
4588
|
-
|
|
5015
|
+
): import("./query.js").LateralSource<PlanValue, Alias>
|
|
5016
|
+
function lateral(valueOrAlias: unknown, alias?: string): unknown {
|
|
5017
|
+
if (alias === undefined) {
|
|
5018
|
+
return (value: unknown) => lateral(value as any, valueOrAlias as string)
|
|
5019
|
+
}
|
|
5020
|
+
return makeLateralSource(
|
|
5021
|
+
valueOrAlias as QueryPlan<any, any, any, any, any, any, any, any, any, any>,
|
|
5022
|
+
alias
|
|
5023
|
+
)
|
|
4589
5024
|
}
|
|
4590
5025
|
|
|
4591
5026
|
const values = <
|
|
@@ -5038,7 +5473,10 @@ type AsCurriedResult<
|
|
|
5038
5473
|
predicate: predicateExpression
|
|
5039
5474
|
}]
|
|
5040
5475
|
},
|
|
5041
|
-
|
|
5476
|
+
assumeFormulaTrue(
|
|
5477
|
+
currentQuery.assumptions,
|
|
5478
|
+
formulaOfExpressionRuntime(predicateExpression)
|
|
5479
|
+
) as PlanAssumptionsAfterWhere<PlanValue, Predicate, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>,
|
|
5042
5480
|
currentQuery.capabilities,
|
|
5043
5481
|
currentQuery.statement as StatementOfPlan<PlanValue>)
|
|
5044
5482
|
}
|
|
@@ -5071,6 +5509,7 @@ type AsCurriedResult<
|
|
|
5071
5509
|
|
|
5072
5510
|
const sourceLike = source as SourceLike
|
|
5073
5511
|
const { sourceName, sourceBaseName } = sourceDetails(sourceLike)
|
|
5512
|
+
const presenceWitnesses = presenceWitnessesOfSourceLike(sourceLike)
|
|
5074
5513
|
|
|
5075
5514
|
if (currentQuery.statement === "select") {
|
|
5076
5515
|
const nextAst = {
|
|
@@ -5090,9 +5529,11 @@ type AsCurriedResult<
|
|
|
5090
5529
|
[sourceName]: {
|
|
5091
5530
|
name: sourceName,
|
|
5092
5531
|
mode: "required",
|
|
5093
|
-
baseName: sourceBaseName
|
|
5532
|
+
baseName: sourceBaseName,
|
|
5533
|
+
_presentFormula: trueFormula(),
|
|
5534
|
+
_presenceWitnesses: presenceWitnesses
|
|
5094
5535
|
}
|
|
5095
|
-
} as AddAvailable<{}, string
|
|
5536
|
+
} as AddAvailable<{}, string, "required", TrueFormula, PresenceWitnessKeysOfSource<Extract<CurrentSource, SourceLike>>>,
|
|
5096
5537
|
dialect: current.dialect
|
|
5097
5538
|
}, nextAst, currentQuery.assumptions, currentQuery.capabilities, currentQuery.statement) as FromPlanResult<PlanValue, CurrentSource, Dialect>
|
|
5098
5539
|
}
|
|
@@ -5103,7 +5544,9 @@ type AsCurriedResult<
|
|
|
5103
5544
|
[sourceName]: {
|
|
5104
5545
|
name: sourceName,
|
|
5105
5546
|
mode: "required" as const,
|
|
5106
|
-
baseName: sourceBaseName
|
|
5547
|
+
baseName: sourceBaseName,
|
|
5548
|
+
_presentFormula: trueFormula(),
|
|
5549
|
+
_presenceWitnesses: presenceWitnesses
|
|
5107
5550
|
}
|
|
5108
5551
|
}
|
|
5109
5552
|
const nextAst = {
|
|
@@ -5143,7 +5586,7 @@ type AsCurriedResult<
|
|
|
5143
5586
|
GroupedOfPlan<PlanValue>,
|
|
5144
5587
|
ScopedNamesOfPlan<PlanValue>,
|
|
5145
5588
|
AddExpressionRequired<OutstandingOfPlan<PlanValue>, AvailableOfPlan<PlanValue>, Predicate>,
|
|
5146
|
-
|
|
5589
|
+
PlanAssumptionsAfterHaving<PlanValue, Predicate, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>,
|
|
5147
5590
|
CapabilitiesOfPlan<PlanValue>,
|
|
5148
5591
|
StatementOfPlan<PlanValue>
|
|
5149
5592
|
> => {
|
|
@@ -5164,7 +5607,12 @@ type AsCurriedResult<
|
|
|
5164
5607
|
kind: "having",
|
|
5165
5608
|
predicate: predicateExpression
|
|
5166
5609
|
}]
|
|
5167
|
-
},
|
|
5610
|
+
}, assumeFormulaTrue(
|
|
5611
|
+
currentQuery.assumptions,
|
|
5612
|
+
formulaOfExpressionRuntime(predicateExpression)
|
|
5613
|
+
) as PlanAssumptionsAfterHaving<PlanValue, Predicate, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>,
|
|
5614
|
+
currentQuery.capabilities,
|
|
5615
|
+
currentQuery.statement as StatementOfPlan<PlanValue>)
|
|
5168
5616
|
}
|
|
5169
5617
|
|
|
5170
5618
|
const innerJoin = <CurrentTable extends SourceLike, Predicate extends PredicateInput>(
|
|
@@ -5203,7 +5651,13 @@ type AsCurriedResult<
|
|
|
5203
5651
|
): QueryPlan<
|
|
5204
5652
|
SelectionOfPlan<PlanValue>,
|
|
5205
5653
|
AddJoinRequired<RequiredOfPlan<PlanValue>, AvailableOfPlan<PlanValue>, SourceNameOf<CurrentTable>, never, "cross">,
|
|
5206
|
-
AddAvailable<
|
|
5654
|
+
AddAvailable<
|
|
5655
|
+
AvailableOfPlan<PlanValue>,
|
|
5656
|
+
SourceNameOf<CurrentTable>,
|
|
5657
|
+
"required",
|
|
5658
|
+
TrueFormula,
|
|
5659
|
+
PresenceWitnessKeysOfSource<CurrentTable>
|
|
5660
|
+
>,
|
|
5207
5661
|
PlanDialectOf<PlanValue> | SourceDialectOf<CurrentTable>,
|
|
5208
5662
|
GroupedOfPlan<PlanValue>,
|
|
5209
5663
|
ScopedNamesOfPlan<PlanValue> | SourceNameOf<CurrentTable>,
|
|
@@ -5216,6 +5670,7 @@ type AsCurriedResult<
|
|
|
5216
5670
|
const currentAst = getAst(plan)
|
|
5217
5671
|
const currentQuery = getQueryState(plan)
|
|
5218
5672
|
const { sourceName, sourceBaseName } = sourceDetails(table)
|
|
5673
|
+
const presenceWitnesses = presenceWitnessesOfSourceLike(table)
|
|
5219
5674
|
const nextAvailable = Object.assign(
|
|
5220
5675
|
{},
|
|
5221
5676
|
current.available as AvailableOfPlan<PlanValue>,
|
|
@@ -5223,10 +5678,18 @@ type AsCurriedResult<
|
|
|
5223
5678
|
[sourceName]: {
|
|
5224
5679
|
name: sourceName,
|
|
5225
5680
|
mode: "required",
|
|
5226
|
-
baseName: sourceBaseName
|
|
5681
|
+
baseName: sourceBaseName,
|
|
5682
|
+
_presentFormula: trueFormula(),
|
|
5683
|
+
_presenceWitnesses: presenceWitnesses
|
|
5227
5684
|
}
|
|
5228
5685
|
}
|
|
5229
|
-
) as AddAvailable<
|
|
5686
|
+
) as AddAvailable<
|
|
5687
|
+
AvailableOfPlan<PlanValue>,
|
|
5688
|
+
SourceNameOf<CurrentTable>,
|
|
5689
|
+
"required",
|
|
5690
|
+
TrueFormula,
|
|
5691
|
+
PresenceWitnessKeysOfSource<CurrentTable>
|
|
5692
|
+
>
|
|
5230
5693
|
return makePlan({
|
|
5231
5694
|
selection: current.selection,
|
|
5232
5695
|
required: currentRequiredList(current.required).filter((name) =>
|
|
@@ -5262,12 +5725,18 @@ type AsCurriedResult<
|
|
|
5262
5725
|
): QueryPlan<
|
|
5263
5726
|
SelectionOfPlan<PlanValue>,
|
|
5264
5727
|
AddJoinRequired<RequiredOfPlan<PlanValue>, AvailableOfPlan<PlanValue>, SourceNameOf<CurrentTable>, Predicate, Kind>,
|
|
5265
|
-
AvailableAfterJoin<
|
|
5728
|
+
AvailableAfterJoin<
|
|
5729
|
+
AvailableOfPlan<PlanValue>,
|
|
5730
|
+
SourceNameOf<CurrentTable>,
|
|
5731
|
+
Kind,
|
|
5732
|
+
JoinPresenceFormula<Kind, Predicate, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>,
|
|
5733
|
+
PresenceWitnessKeysOfSource<CurrentTable>
|
|
5734
|
+
>,
|
|
5266
5735
|
PlanDialectOf<PlanValue> | SourceDialectOf<CurrentTable> | DialectOfDialectInput<Predicate, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>,
|
|
5267
5736
|
GroupedOfPlan<PlanValue>,
|
|
5268
5737
|
ScopedNamesOfPlan<PlanValue> | SourceNameOf<CurrentTable>,
|
|
5269
5738
|
AddJoinRequired<OutstandingOfPlan<PlanValue>, AvailableOfPlan<PlanValue>, SourceNameOf<CurrentTable>, Predicate, Kind>,
|
|
5270
|
-
|
|
5739
|
+
PlanAssumptionsAfterJoin<PlanValue, Predicate, Kind, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>,
|
|
5271
5740
|
MergeCapabilities<CapabilitiesOfPlan<PlanValue>, SourceCapabilitiesOf<CurrentTable>>,
|
|
5272
5741
|
StatementOfPlan<PlanValue>
|
|
5273
5742
|
> => {
|
|
@@ -5275,13 +5744,17 @@ type AsCurriedResult<
|
|
|
5275
5744
|
const currentAst = getAst(plan)
|
|
5276
5745
|
const currentQuery = getQueryState(plan)
|
|
5277
5746
|
const onExpression = toDialectExpression(on)
|
|
5747
|
+
const onFormula = formulaOfExpressionRuntime(onExpression)
|
|
5278
5748
|
const { sourceName, sourceBaseName } = sourceDetails(table)
|
|
5749
|
+
const presenceWitnesses = presenceWitnessesOfSourceLike(table)
|
|
5279
5750
|
const baseAvailable = (kind === "right" || kind === "full"
|
|
5280
5751
|
? Object.fromEntries(
|
|
5281
|
-
Object.entries(current.available as Record<string, Plan.
|
|
5752
|
+
Object.entries(current.available as Record<string, Plan.AnySource>).map(([name, source]) => [name, {
|
|
5282
5753
|
name: source.name,
|
|
5283
5754
|
mode: "optional" as const,
|
|
5284
|
-
baseName: source.baseName
|
|
5755
|
+
baseName: source.baseName,
|
|
5756
|
+
_presentFormula: source._presentFormula,
|
|
5757
|
+
_presenceWitnesses: source._presenceWitnesses
|
|
5285
5758
|
}])
|
|
5286
5759
|
)
|
|
5287
5760
|
: current.available) as AvailableOfPlan<PlanValue>
|
|
@@ -5290,9 +5763,17 @@ type AsCurriedResult<
|
|
|
5290
5763
|
[sourceName]: {
|
|
5291
5764
|
name: sourceName,
|
|
5292
5765
|
mode: (kind === "left" || kind === "full" ? "optional" : "required") as JoinSourceMode<Kind>,
|
|
5293
|
-
baseName: sourceBaseName
|
|
5766
|
+
baseName: sourceBaseName,
|
|
5767
|
+
_presentFormula: (kind === "inner" || kind === "left") ? onFormula : trueFormula(),
|
|
5768
|
+
_presenceWitnesses: presenceWitnesses
|
|
5294
5769
|
}
|
|
5295
|
-
} as AvailableAfterJoin<
|
|
5770
|
+
} as AvailableAfterJoin<
|
|
5771
|
+
AvailableOfPlan<PlanValue>,
|
|
5772
|
+
SourceNameOf<CurrentTable>,
|
|
5773
|
+
Kind,
|
|
5774
|
+
JoinPresenceFormula<Kind, Predicate, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>,
|
|
5775
|
+
PresenceWitnessKeysOfSource<CurrentTable>
|
|
5776
|
+
>
|
|
5296
5777
|
return makePlan({
|
|
5297
5778
|
selection: current.selection,
|
|
5298
5779
|
required: [...currentRequiredList(current.required), ...extractRequiredFromDialectInputRuntime(on)].filter((name, index, values) =>
|
|
@@ -5308,7 +5789,13 @@ type AsCurriedResult<
|
|
|
5308
5789
|
source: table,
|
|
5309
5790
|
on: onExpression
|
|
5310
5791
|
}]
|
|
5311
|
-
},
|
|
5792
|
+
}, (
|
|
5793
|
+
kind === "inner"
|
|
5794
|
+
? assumeFormulaTrue(currentQuery.assumptions, onFormula)
|
|
5795
|
+
: currentQuery.assumptions
|
|
5796
|
+
) as PlanAssumptionsAfterJoin<PlanValue, Predicate, Kind, Dialect, TextDb, NumericDb, BoolDb, TimestampDb, NullDb>,
|
|
5797
|
+
currentQuery.capabilities as MergeCapabilities<CapabilitiesOfPlan<PlanValue>, SourceCapabilitiesOf<CurrentTable>>,
|
|
5798
|
+
currentQuery.statement as StatementOfPlan<PlanValue>)
|
|
5312
5799
|
}
|
|
5313
5800
|
|
|
5314
5801
|
const orderBy = <Value extends ExpressionInput>(
|
|
@@ -5463,13 +5950,6 @@ type AsCurriedResult<
|
|
|
5463
5950
|
|
|
5464
5951
|
const distinctOn = ((...values: readonly ExpressionInput[]) => {
|
|
5465
5952
|
const expressions = values.map((value) => toDialectExpression(value)) as Expression.Any[]
|
|
5466
|
-
if (profile.dialect !== "postgres") {
|
|
5467
|
-
return {
|
|
5468
|
-
__effect_qb_error__: "effect-qb: distinctOn(...) is only supported by the postgres dialect",
|
|
5469
|
-
__effect_qb_dialect__: profile.dialect,
|
|
5470
|
-
__effect_qb_hint__: "Use postgres.Query.distinctOn(...) or regular distinct()/grouping logic"
|
|
5471
|
-
} as DistinctOnUnsupportedError<Dialect>
|
|
5472
|
-
}
|
|
5473
5953
|
return <PlanValue extends QueryPlan<any, any, any, any, any, any, any, any, any, any>>(
|
|
5474
5954
|
plan: PlanValue & RequireSelectStatement<PlanValue>
|
|
5475
5955
|
): QueryPlan<
|
|
@@ -5656,10 +6136,10 @@ type AsCurriedResult<
|
|
|
5656
6136
|
>
|
|
5657
6137
|
function insert<
|
|
5658
6138
|
Target extends MutationTargetLike,
|
|
5659
|
-
Values extends
|
|
6139
|
+
Values extends Record<string, unknown>
|
|
5660
6140
|
>(
|
|
5661
6141
|
target: Target,
|
|
5662
|
-
values: Values
|
|
6142
|
+
values: MutationValuesInput<"insert", Target, Values>
|
|
5663
6143
|
): QueryPlan<
|
|
5664
6144
|
{},
|
|
5665
6145
|
Exclude<MutationRequiredFromValues<Values>, SourceNameOf<Target>>,
|
|
@@ -5714,55 +6194,6 @@ type AsCurriedResult<
|
|
|
5714
6194
|
}, undefined as unknown as TrueFormula, "write", "insert", target, insertState)
|
|
5715
6195
|
}
|
|
5716
6196
|
|
|
5717
|
-
const defaultValues = <
|
|
5718
|
-
Target extends MutationTargetLike
|
|
5719
|
-
>(
|
|
5720
|
-
target: RequiredKeys<Table.InsertOf<Target>> extends never ? Target : DefaultValuesError<Target>
|
|
5721
|
-
): QueryPlan<
|
|
5722
|
-
{},
|
|
5723
|
-
never,
|
|
5724
|
-
AddAvailable<{}, SourceNameOf<Target>>,
|
|
5725
|
-
TableDialectOf<Target>,
|
|
5726
|
-
never,
|
|
5727
|
-
SourceNameOf<Target>,
|
|
5728
|
-
never,
|
|
5729
|
-
TrueFormula,
|
|
5730
|
-
"write",
|
|
5731
|
-
"insert",
|
|
5732
|
-
Target,
|
|
5733
|
-
"ready"
|
|
5734
|
-
> => {
|
|
5735
|
-
const { sourceName, sourceBaseName } = targetSourceDetails(target as Target)
|
|
5736
|
-
return makePlan({
|
|
5737
|
-
selection: {},
|
|
5738
|
-
required: [] as never,
|
|
5739
|
-
available: {
|
|
5740
|
-
[sourceName]: {
|
|
5741
|
-
name: sourceName,
|
|
5742
|
-
mode: "required",
|
|
5743
|
-
baseName: sourceBaseName
|
|
5744
|
-
}
|
|
5745
|
-
} as AddAvailable<{}, SourceNameOf<Target>>,
|
|
5746
|
-
dialect: (target as Target)[Plan.TypeId].dialect as TableDialectOf<Target>
|
|
5747
|
-
}, {
|
|
5748
|
-
kind: "insert",
|
|
5749
|
-
select: {},
|
|
5750
|
-
into: {
|
|
5751
|
-
kind: "from",
|
|
5752
|
-
tableName: sourceName,
|
|
5753
|
-
baseTableName: sourceBaseName,
|
|
5754
|
-
source: target as Target
|
|
5755
|
-
},
|
|
5756
|
-
values: [],
|
|
5757
|
-
conflict: undefined,
|
|
5758
|
-
where: [],
|
|
5759
|
-
having: [],
|
|
5760
|
-
joins: [],
|
|
5761
|
-
groupBy: [],
|
|
5762
|
-
orderBy: []
|
|
5763
|
-
}, undefined as unknown as TrueFormula, "write", "insert", target as Target, "ready")
|
|
5764
|
-
}
|
|
5765
|
-
|
|
5766
6197
|
const attachInsertSource = (
|
|
5767
6198
|
plan: QueryPlan<any, any, any, any, any, any, any, any, any, "insert", MutationTargetLike, "missing">,
|
|
5768
6199
|
source: AnyValuesInput | AnyValuesSource | AnyUnnestSource | CompletePlan<QueryPlan<any, any, any, any, any, any, any, any, any, any>>
|
|
@@ -5833,7 +6264,7 @@ type AsCurriedResult<
|
|
|
5833
6264
|
|
|
5834
6265
|
const onConflict = <
|
|
5835
6266
|
Target extends MutationTargetLike,
|
|
5836
|
-
Columns extends DdlColumnInput,
|
|
6267
|
+
const Columns extends DdlColumnInput,
|
|
5837
6268
|
UpdateValues extends MutationInputOf<Table.UpdateOf<Target>> | undefined = MutationInputOf<Table.UpdateOf<Target>> | undefined,
|
|
5838
6269
|
Options extends ConflictActionInput<Target, Dialect, UpdateValues> = ConflictActionInput<Target, Dialect, UpdateValues>
|
|
5839
6270
|
>(
|
|
@@ -5891,37 +6322,37 @@ type AsCurriedResult<
|
|
|
5891
6322
|
}
|
|
5892
6323
|
|
|
5893
6324
|
function update<
|
|
5894
|
-
|
|
5895
|
-
Values extends
|
|
6325
|
+
Targets extends MutationTargetTuple,
|
|
6326
|
+
Values extends UpdateInputOfTarget<Targets>
|
|
5896
6327
|
>(
|
|
5897
|
-
target:
|
|
6328
|
+
target: Dialect extends "mysql" ? Targets : never,
|
|
5898
6329
|
values: Values
|
|
5899
6330
|
): QueryPlan<
|
|
5900
6331
|
{},
|
|
5901
|
-
Exclude<
|
|
5902
|
-
|
|
5903
|
-
TableDialectOf<
|
|
6332
|
+
Exclude<NestedMutationRequiredFromValues<Values>, MutationTargetNamesOf<Targets>>,
|
|
6333
|
+
AddAvailableMany<{}, MutationTargetNamesOf<Targets>>,
|
|
6334
|
+
TableDialectOf<Targets[0]>,
|
|
5904
6335
|
never,
|
|
5905
|
-
|
|
5906
|
-
Exclude<
|
|
6336
|
+
MutationTargetNamesOf<Targets>,
|
|
6337
|
+
Exclude<NestedMutationRequiredFromValues<Values>, MutationTargetNamesOf<Targets>>,
|
|
5907
6338
|
TrueFormula,
|
|
5908
6339
|
"write",
|
|
5909
6340
|
"update"
|
|
5910
6341
|
>
|
|
5911
6342
|
function update<
|
|
5912
|
-
|
|
5913
|
-
Values extends
|
|
6343
|
+
Target extends MutationTargetLike,
|
|
6344
|
+
Values extends Record<string, unknown>
|
|
5914
6345
|
>(
|
|
5915
|
-
target:
|
|
5916
|
-
values: Values
|
|
6346
|
+
target: Target,
|
|
6347
|
+
values: MutationValuesInput<"update", Target, Values>
|
|
5917
6348
|
): QueryPlan<
|
|
5918
6349
|
{},
|
|
5919
|
-
Exclude<
|
|
5920
|
-
|
|
5921
|
-
TableDialectOf<
|
|
6350
|
+
Exclude<MutationRequiredFromValues<Values>, SourceNameOf<Target>>,
|
|
6351
|
+
AddAvailable<{}, SourceNameOf<Target>>,
|
|
6352
|
+
TableDialectOf<Target>,
|
|
5922
6353
|
never,
|
|
5923
|
-
|
|
5924
|
-
Exclude<
|
|
6354
|
+
SourceNameOf<Target>,
|
|
6355
|
+
Exclude<MutationRequiredFromValues<Values>, SourceNameOf<Target>>,
|
|
5925
6356
|
TrueFormula,
|
|
5926
6357
|
"write",
|
|
5927
6358
|
"update"
|
|
@@ -5959,7 +6390,7 @@ type AsCurriedResult<
|
|
|
5959
6390
|
const upsert = <
|
|
5960
6391
|
Target extends MutationTargetLike,
|
|
5961
6392
|
Values extends MutationInputOf<Table.InsertOf<Target>>,
|
|
5962
|
-
Columns extends DdlColumnInput,
|
|
6393
|
+
const Columns extends DdlColumnInput,
|
|
5963
6394
|
UpdateValues extends MutationInputOf<Table.UpdateOf<Target>>
|
|
5964
6395
|
>(
|
|
5965
6396
|
target: Target,
|
|
@@ -6560,10 +6991,10 @@ type AsCurriedResult<
|
|
|
6560
6991
|
|
|
6561
6992
|
const createIndex = <
|
|
6562
6993
|
Target extends SchemaTableLike,
|
|
6563
|
-
Columns extends DdlColumnInput
|
|
6994
|
+
const Columns extends DdlColumnInput
|
|
6564
6995
|
>(
|
|
6565
6996
|
target: Target,
|
|
6566
|
-
columns: ValidateDdlColumns<Target, NormalizeDdlColumns<Columns>>,
|
|
6997
|
+
columns: Columns & ValidateDdlColumns<Target, NormalizeDdlColumns<Columns>>,
|
|
6567
6998
|
options: CreateIndexOptions = {}
|
|
6568
6999
|
): QueryPlan<
|
|
6569
7000
|
{},
|
|
@@ -6610,10 +7041,10 @@ type AsCurriedResult<
|
|
|
6610
7041
|
|
|
6611
7042
|
const dropIndex = <
|
|
6612
7043
|
Target extends SchemaTableLike,
|
|
6613
|
-
Columns extends DdlColumnInput
|
|
7044
|
+
const Columns extends DdlColumnInput
|
|
6614
7045
|
>(
|
|
6615
7046
|
target: Target,
|
|
6616
|
-
columns: ValidateDdlColumns<Target, NormalizeDdlColumns<Columns>>,
|
|
7047
|
+
columns: Columns & ValidateDdlColumns<Target, NormalizeDdlColumns<Columns>>,
|
|
6617
7048
|
options: DropIndexOptions = {}
|
|
6618
7049
|
): QueryPlan<
|
|
6619
7050
|
{},
|
|
@@ -6658,9 +7089,11 @@ type AsCurriedResult<
|
|
|
6658
7089
|
|
|
6659
7090
|
const api = {
|
|
6660
7091
|
literal,
|
|
7092
|
+
column,
|
|
6661
7093
|
cast,
|
|
6662
7094
|
type,
|
|
6663
7095
|
json,
|
|
7096
|
+
jsonb,
|
|
6664
7097
|
eq,
|
|
6665
7098
|
neq,
|
|
6666
7099
|
lt,
|
|
@@ -6673,6 +7106,10 @@ type AsCurriedResult<
|
|
|
6673
7106
|
lower,
|
|
6674
7107
|
like,
|
|
6675
7108
|
ilike,
|
|
7109
|
+
regexMatch,
|
|
7110
|
+
regexIMatch,
|
|
7111
|
+
regexNotMatch,
|
|
7112
|
+
regexNotIMatch,
|
|
6676
7113
|
and,
|
|
6677
7114
|
or,
|
|
6678
7115
|
not,
|
|
@@ -6681,6 +7118,9 @@ type AsCurriedResult<
|
|
|
6681
7118
|
case: case_,
|
|
6682
7119
|
match,
|
|
6683
7120
|
coalesce,
|
|
7121
|
+
call,
|
|
7122
|
+
uuidGenerateV4,
|
|
7123
|
+
nextVal,
|
|
6684
7124
|
in: in_,
|
|
6685
7125
|
notIn,
|
|
6686
7126
|
between,
|
|
@@ -6711,7 +7151,6 @@ type AsCurriedResult<
|
|
|
6711
7151
|
unnest,
|
|
6712
7152
|
generateSeries,
|
|
6713
7153
|
returning,
|
|
6714
|
-
defaultValues,
|
|
6715
7154
|
onConflict,
|
|
6716
7155
|
insert,
|
|
6717
7156
|
update,
|
|
@@ -6753,5 +7192,5 @@ type AsCurriedResult<
|
|
|
6753
7192
|
groupBy
|
|
6754
7193
|
}
|
|
6755
7194
|
|
|
6756
|
-
|
|
6757
|
-
}
|
|
7195
|
+
return api
|
|
7196
|
+
})()
|