effect-qb 4.0.0-beta.66 → 4.0.0-beta.92
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -2
- package/dist/index.js +9373 -0
- package/dist/mysql.js +3917 -2572
- package/dist/postgres/metadata.js +2491 -1373
- package/dist/postgres.js +5450 -5155
- package/dist/sqlite.js +6891 -5528
- package/dist/standard.js +9327 -0
- package/package.json +9 -2
- package/src/casing.ts +71 -0
- package/src/index.ts +2 -0
- package/src/internal/casing.ts +89 -0
- package/src/internal/coercion/rules.ts +13 -1
- package/src/internal/column-state.ts +21 -15
- package/src/internal/column.ts +44 -7
- package/src/internal/datatypes/define.ts +7 -1
- package/src/internal/datatypes/enrich.ts +23 -0
- package/src/internal/datatypes/lookup.ts +81 -25
- package/src/internal/datatypes/matrix.ts +903 -0
- package/src/internal/datatypes/shape.ts +2 -0
- package/src/internal/derived-table.ts +4 -36
- package/src/{mysql/internal/sql-expression-renderer.ts → internal/dialect-renderers/mysql.ts} +552 -361
- package/src/{postgres/internal/sql-expression-renderer.ts → internal/dialect-renderers/postgres.ts} +657 -400
- package/src/{sqlite/internal/sql-expression-renderer.ts → internal/dialect-renderers/sqlite.ts} +505 -347
- package/src/internal/dialect.ts +35 -0
- package/src/internal/dsl-mutation-runtime.ts +12 -162
- package/src/internal/dsl-plan-runtime.ts +10 -138
- package/src/internal/dsl-query-runtime.ts +5 -79
- package/src/internal/dsl-transaction-ddl-runtime.ts +41 -65
- package/src/internal/executor.ts +14 -16
- package/src/internal/grouping-key.ts +87 -20
- package/src/internal/implication-runtime.ts +1 -1
- package/src/internal/json/path-access.ts +351 -0
- package/src/internal/predicate/runtime.ts +3 -0
- package/src/internal/query.d.ts +38 -11
- package/src/internal/query.ts +64 -25
- package/src/internal/renderer.ts +26 -14
- package/src/internal/runtime/normalize.ts +12 -5
- package/src/internal/scalar.ts +7 -1
- package/src/internal/schema-derivation.d.ts +7 -7
- package/src/internal/schema-derivation.ts +9 -9
- package/src/internal/schema-expression.ts +2 -2
- package/src/internal/sql-expression-renderer.ts +19 -0
- package/src/internal/standard-dsl.ts +6975 -0
- package/src/internal/table-options.ts +126 -66
- package/src/internal/table.ts +652 -219
- package/src/mysql/column-extension.ts +3 -0
- package/src/mysql/column.ts +8 -9
- package/src/mysql/datatypes/index.ts +4 -2
- package/src/mysql/datatypes/spec.ts +6 -176
- package/src/mysql/executor.ts +7 -7
- package/src/mysql/internal/dialect.ts +9 -4
- package/src/mysql/internal/dsl.ts +309 -154
- package/src/mysql/internal/renderer.ts +6 -2
- package/src/mysql/json.ts +7 -2
- package/src/mysql/query-extension.ts +16 -0
- package/src/mysql/renderer.ts +37 -3
- package/src/mysql/type.ts +60 -0
- package/src/mysql.ts +7 -13
- package/src/postgres/check.ts +1 -0
- package/src/postgres/column-extension.ts +28 -0
- package/src/postgres/column.ts +2 -8
- package/src/postgres/datatypes/index.d.ts +2 -1
- package/src/postgres/datatypes/index.ts +4 -2
- package/src/postgres/datatypes/spec.ts +6 -260
- package/src/postgres/executor.ts +7 -7
- package/src/postgres/foreign-key.ts +24 -0
- package/src/postgres/function/core.ts +1 -3
- package/src/postgres/function/index.ts +1 -17
- package/src/postgres/index.ts +1 -0
- package/src/postgres/internal/dialect.ts +9 -4
- package/src/postgres/internal/dsl.ts +303 -163
- package/src/postgres/internal/renderer.ts +6 -2
- package/src/postgres/internal/schema-ddl.ts +22 -10
- package/src/postgres/internal/schema-model.ts +238 -7
- package/src/postgres/json-extension.ts +7 -0
- package/src/postgres/json.ts +762 -173
- package/src/postgres/jsonb.ts +37 -0
- package/src/postgres/primary-key.ts +24 -0
- package/src/postgres/query-extension.ts +2 -0
- package/src/postgres/renderer.ts +37 -3
- package/src/postgres/schema-management.ts +12 -11
- package/src/postgres/schema.ts +106 -15
- package/src/postgres/table.ts +205 -530
- package/src/postgres/type.ts +93 -10
- package/src/postgres/unique.ts +32 -0
- package/src/postgres.ts +20 -16
- package/src/sqlite/column-extension.ts +3 -0
- package/src/sqlite/column.ts +8 -9
- package/src/sqlite/datatypes/index.ts +4 -2
- package/src/sqlite/datatypes/spec.ts +6 -94
- package/src/sqlite/executor.ts +7 -7
- package/src/sqlite/internal/dialect.ts +9 -4
- package/src/sqlite/internal/dsl.ts +298 -154
- package/src/sqlite/internal/renderer.ts +6 -2
- package/src/sqlite/json.ts +8 -2
- package/src/sqlite/query-extension.ts +2 -0
- package/src/sqlite/renderer.ts +37 -3
- package/src/sqlite/type.ts +40 -0
- package/src/sqlite.ts +7 -13
- package/src/standard/cast.ts +113 -0
- package/src/standard/check.ts +17 -0
- package/src/standard/column.ts +163 -0
- package/src/standard/datatypes/index.ts +83 -0
- package/src/standard/datatypes/spec.ts +12 -0
- package/src/standard/dialect.ts +40 -0
- package/src/standard/foreign-key.ts +37 -0
- package/src/standard/function/aggregate.ts +2 -0
- package/src/standard/function/core.ts +2 -0
- package/src/standard/function/index.ts +18 -0
- package/src/standard/function/string.ts +2 -0
- package/src/standard/function/temporal.ts +78 -0
- package/src/standard/function/window.ts +2 -0
- package/src/standard/index.ts +17 -0
- package/src/standard/internal/renderer.ts +45 -0
- package/src/standard/json.ts +883 -0
- package/src/standard/primary-key.ts +17 -0
- package/src/standard/query.ts +152 -0
- package/src/standard/renderer.ts +49 -0
- package/src/standard/table.ts +151 -0
- package/src/standard/unique.ts +17 -0
- package/src/standard.ts +32 -0
- package/src/internal/aggregation-validation.ts +0 -57
- package/src/internal/table.d.ts +0 -180
- package/src/mysql/table.ts +0 -186
- package/src/postgres/cast.ts +0 -45
- package/src/sqlite/table.ts +0 -175
|
@@ -56,10 +56,12 @@ export interface DatatypeTraits {
|
|
|
56
56
|
export interface DatatypeFamilySpec<
|
|
57
57
|
CompareGroup extends string = string,
|
|
58
58
|
CastTargets extends readonly string[] = readonly string[],
|
|
59
|
+
ImplicitTargets extends readonly string[] = readonly string[],
|
|
59
60
|
Traits extends DatatypeTraits = DatatypeTraits
|
|
60
61
|
> {
|
|
61
62
|
readonly compareGroup: CompareGroup
|
|
62
63
|
readonly castTargets: CastTargets
|
|
64
|
+
readonly implicitTargets?: ImplicitTargets
|
|
63
65
|
readonly traits: Traits
|
|
64
66
|
}
|
|
65
67
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { pipeArguments } from "effect/Pipeable"
|
|
1
|
+
import { pipeArguments, type Pipeable } from "effect/Pipeable"
|
|
2
2
|
|
|
3
3
|
import * as Expression from "./scalar.js"
|
|
4
4
|
import * as Plan from "./row-set.js"
|
|
@@ -10,16 +10,15 @@ import {
|
|
|
10
10
|
type LateralSource,
|
|
11
11
|
type QueryPlan,
|
|
12
12
|
getAst,
|
|
13
|
-
getQueryState,
|
|
14
13
|
makeExpression,
|
|
15
14
|
currentRequiredList,
|
|
16
15
|
type SelectionOfPlan
|
|
17
16
|
} from "./query.js"
|
|
18
17
|
import * as ExpressionAst from "./expression-ast.js"
|
|
19
|
-
import { flattenSelection
|
|
18
|
+
import { flattenSelection } from "./projections.js"
|
|
20
19
|
|
|
21
20
|
const DerivedProto = {
|
|
22
|
-
pipe(this:
|
|
21
|
+
pipe(this: Pipeable) {
|
|
23
22
|
return pipeArguments(this, arguments)
|
|
24
23
|
}
|
|
25
24
|
}
|
|
@@ -28,7 +27,7 @@ const attachPipe = <Value extends object>(value: Value): Value => {
|
|
|
28
27
|
Object.defineProperty(value, "pipe", {
|
|
29
28
|
configurable: true,
|
|
30
29
|
writable: true,
|
|
31
|
-
value: function(this:
|
|
30
|
+
value: function(this: Value) {
|
|
32
31
|
return pipeArguments(value, arguments)
|
|
33
32
|
}
|
|
34
33
|
})
|
|
@@ -55,26 +54,6 @@ const setPath = (
|
|
|
55
54
|
current[path[path.length - 1]!] = value
|
|
56
55
|
}
|
|
57
56
|
|
|
58
|
-
const pathAlias = (path: readonly string[]): string => path.join("__")
|
|
59
|
-
|
|
60
|
-
const assertSourceComplete = (
|
|
61
|
-
plan: QueryPlan<any, any, any, any, any, any, any, any, any, any>
|
|
62
|
-
): void => {
|
|
63
|
-
const required = currentRequiredList(plan[Plan.TypeId].required)
|
|
64
|
-
if (required.length > 0) {
|
|
65
|
-
throw new Error(`query references sources that are not yet in scope: ${required.join(", ")}`)
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
const assertInlineSourceStatement = (
|
|
70
|
-
plan: QueryPlan<any, any, any, any, any, any, any, any, any, any>
|
|
71
|
-
): void => {
|
|
72
|
-
const statement = getQueryState(plan).statement
|
|
73
|
-
if (statement !== "select" && statement !== "set") {
|
|
74
|
-
throw new Error("inline derived sources only accept select-like query plans")
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
57
|
const reboundedColumns = <
|
|
79
58
|
PlanValue extends QueryPlan<any, any, any, any, any, any, any, any, any, any>,
|
|
80
59
|
Alias extends string
|
|
@@ -85,14 +64,7 @@ const reboundedColumns = <
|
|
|
85
64
|
const ast = getAst(plan)
|
|
86
65
|
const selection = {} as Record<string, unknown>
|
|
87
66
|
const projections = flattenSelection(ast.select as Record<string, unknown>)
|
|
88
|
-
validateProjections(projections)
|
|
89
67
|
for (const projection of projections) {
|
|
90
|
-
const expectedAlias = pathAlias(projection.path)
|
|
91
|
-
if (projection.alias !== expectedAlias) {
|
|
92
|
-
throw new Error(
|
|
93
|
-
`Derived subqueries currently require path-based output aliases; expected '${expectedAlias}' for path '${projection.path.join(".")}'`
|
|
94
|
-
)
|
|
95
|
-
}
|
|
96
68
|
const expression = projection.expression
|
|
97
69
|
setPath(selection, projection.path, makeExpression({
|
|
98
70
|
runtime: undefined as never,
|
|
@@ -120,8 +92,6 @@ export const makeDerivedSource = <
|
|
|
120
92
|
plan: CompletePlan<PlanValue>,
|
|
121
93
|
alias: Alias
|
|
122
94
|
): DerivedSource<PlanValue, Alias> => {
|
|
123
|
-
assertInlineSourceStatement(plan)
|
|
124
|
-
assertSourceComplete(plan)
|
|
125
95
|
const columns = reboundedColumns(plan, alias)
|
|
126
96
|
const derived = attachPipe(Object.create(DerivedProto)) as Record<string, unknown>
|
|
127
97
|
Object.assign(derived, columns)
|
|
@@ -143,7 +113,6 @@ export const makeCteSource = <
|
|
|
143
113
|
alias: Alias,
|
|
144
114
|
recursive = false
|
|
145
115
|
): CteSource<PlanValue, Alias> => {
|
|
146
|
-
assertSourceComplete(plan)
|
|
147
116
|
const columns = reboundedColumns(plan, alias)
|
|
148
117
|
const cte = attachPipe(Object.create(DerivedProto)) as Record<string, unknown>
|
|
149
118
|
Object.assign(cte, columns)
|
|
@@ -165,7 +134,6 @@ export const makeLateralSource = <
|
|
|
165
134
|
plan: PlanValue,
|
|
166
135
|
alias: Alias
|
|
167
136
|
): LateralSource<PlanValue, Alias> => {
|
|
168
|
-
assertInlineSourceStatement(plan)
|
|
169
137
|
const columns = reboundedColumns(plan, alias)
|
|
170
138
|
const lateral = attachPipe(Object.create(DerivedProto)) as Record<string, unknown>
|
|
171
139
|
Object.assign(lateral, columns)
|