effect-qb 4.0.0-beta.66 → 4.0.0-beta.98
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -2
- package/dist/index.js +9376 -0
- package/dist/mysql.js +3921 -2573
- package/dist/postgres/metadata.js +2491 -1373
- package/dist/postgres.js +5453 -5155
- package/dist/sqlite.js +6895 -5529
- package/dist/standard.js +9330 -0
- package/package.json +9 -2
- package/src/casing.ts +71 -0
- package/src/index.ts +2 -0
- package/src/internal/casing.ts +89 -0
- package/src/internal/coercion/rules.ts +13 -1
- package/src/internal/column-state.ts +21 -15
- package/src/internal/column.ts +44 -7
- package/src/internal/datatypes/define.ts +7 -1
- package/src/internal/datatypes/enrich.ts +23 -0
- package/src/internal/datatypes/lookup.ts +81 -25
- package/src/internal/datatypes/matrix.ts +903 -0
- package/src/internal/datatypes/shape.ts +2 -0
- package/src/internal/derived-table.ts +4 -36
- package/src/{mysql/internal/sql-expression-renderer.ts → internal/dialect-renderers/mysql.ts} +552 -361
- package/src/{postgres/internal/sql-expression-renderer.ts → internal/dialect-renderers/postgres.ts} +657 -400
- package/src/{sqlite/internal/sql-expression-renderer.ts → internal/dialect-renderers/sqlite.ts} +505 -347
- package/src/internal/dialect.ts +35 -0
- package/src/internal/dsl-mutation-runtime.ts +12 -162
- package/src/internal/dsl-plan-runtime.ts +10 -138
- package/src/internal/dsl-query-runtime.ts +5 -79
- package/src/internal/dsl-transaction-ddl-runtime.ts +41 -65
- package/src/internal/executor.ts +14 -16
- package/src/internal/grouping-key.ts +87 -20
- package/src/internal/implication-runtime.ts +1 -1
- package/src/internal/json/path-access.ts +351 -0
- package/src/internal/predicate/runtime.ts +3 -0
- package/src/internal/query.d.ts +38 -11
- package/src/internal/query.ts +64 -25
- package/src/internal/renderer.ts +26 -14
- package/src/internal/runtime/normalize.ts +12 -5
- package/src/internal/scalar.ts +7 -1
- package/src/internal/schema-derivation.d.ts +7 -7
- package/src/internal/schema-derivation.ts +9 -9
- package/src/internal/schema-expression.ts +2 -2
- package/src/internal/sql-expression-renderer.ts +19 -0
- package/src/internal/standard-dsl.ts +6978 -0
- package/src/internal/table-options.ts +126 -66
- package/src/internal/table.ts +652 -219
- package/src/mysql/column-extension.ts +3 -0
- package/src/mysql/column.ts +8 -9
- package/src/mysql/datatypes/index.ts +4 -2
- package/src/mysql/datatypes/spec.ts +6 -176
- package/src/mysql/errors/normalize.ts +0 -1
- package/src/mysql/executor.ts +7 -7
- package/src/mysql/internal/dialect.ts +9 -4
- package/src/mysql/internal/dsl.ts +312 -154
- package/src/mysql/internal/renderer.ts +6 -2
- package/src/mysql/json.ts +7 -2
- package/src/mysql/query-extension.ts +16 -0
- package/src/mysql/renderer.ts +37 -3
- package/src/mysql/type.ts +60 -0
- package/src/mysql.ts +7 -13
- package/src/postgres/check.ts +1 -0
- package/src/postgres/column-extension.ts +28 -0
- package/src/postgres/column.ts +2 -8
- package/src/postgres/datatypes/index.d.ts +2 -1
- package/src/postgres/datatypes/index.ts +4 -2
- package/src/postgres/datatypes/spec.ts +6 -260
- package/src/postgres/errors/normalize.ts +0 -1
- package/src/postgres/executor.ts +7 -7
- package/src/postgres/foreign-key.ts +24 -0
- package/src/postgres/function/core.ts +1 -3
- package/src/postgres/function/index.ts +1 -17
- package/src/postgres/index.ts +1 -0
- package/src/postgres/internal/dialect.ts +9 -4
- package/src/postgres/internal/dsl.ts +306 -163
- package/src/postgres/internal/renderer.ts +6 -2
- package/src/postgres/internal/schema-ddl.ts +22 -10
- package/src/postgres/internal/schema-model.ts +238 -7
- package/src/postgres/json-extension.ts +7 -0
- package/src/postgres/json.ts +762 -173
- package/src/postgres/jsonb.ts +37 -0
- package/src/postgres/primary-key.ts +24 -0
- package/src/postgres/query-extension.ts +2 -0
- package/src/postgres/renderer.ts +37 -3
- package/src/postgres/schema-management.ts +12 -11
- package/src/postgres/schema.ts +106 -15
- package/src/postgres/table.ts +205 -530
- package/src/postgres/type.ts +93 -10
- package/src/postgres/unique.ts +32 -0
- package/src/postgres.ts +20 -16
- package/src/sqlite/column-extension.ts +3 -0
- package/src/sqlite/column.ts +8 -9
- package/src/sqlite/datatypes/index.ts +4 -2
- package/src/sqlite/datatypes/spec.ts +6 -94
- package/src/sqlite/errors/normalize.ts +0 -1
- package/src/sqlite/executor.ts +7 -7
- package/src/sqlite/internal/dialect.ts +9 -4
- package/src/sqlite/internal/dsl.ts +301 -154
- package/src/sqlite/internal/renderer.ts +6 -2
- package/src/sqlite/json.ts +8 -2
- package/src/sqlite/query-extension.ts +2 -0
- package/src/sqlite/renderer.ts +37 -3
- package/src/sqlite/type.ts +40 -0
- package/src/sqlite.ts +7 -13
- package/src/standard/cast.ts +113 -0
- package/src/standard/check.ts +17 -0
- package/src/standard/column.ts +163 -0
- package/src/standard/datatypes/index.ts +83 -0
- package/src/standard/datatypes/spec.ts +12 -0
- package/src/standard/dialect.ts +40 -0
- package/src/standard/foreign-key.ts +37 -0
- package/src/standard/function/aggregate.ts +2 -0
- package/src/standard/function/core.ts +2 -0
- package/src/standard/function/index.ts +18 -0
- package/src/standard/function/string.ts +2 -0
- package/src/standard/function/temporal.ts +78 -0
- package/src/standard/function/window.ts +2 -0
- package/src/standard/index.ts +17 -0
- package/src/standard/internal/renderer.ts +45 -0
- package/src/standard/json.ts +883 -0
- package/src/standard/primary-key.ts +17 -0
- package/src/standard/query.ts +152 -0
- package/src/standard/renderer.ts +49 -0
- package/src/standard/table.ts +151 -0
- package/src/standard/unique.ts +17 -0
- package/src/standard.ts +32 -0
- package/src/internal/aggregation-validation.ts +0 -57
- package/src/internal/table.d.ts +0 -180
- package/src/mysql/table.ts +0 -186
- package/src/postgres/cast.ts +0 -45
- package/src/sqlite/table.ts +0 -175
package/src/internal/renderer.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as Query from "./query.js"
|
|
2
|
-
import
|
|
2
|
+
import * as Expression from "./scalar.js"
|
|
3
3
|
import { flattenSelection, type Projection, validateProjections } from "./projections.js"
|
|
4
|
-
import * as Plan from "./row-set.js"
|
|
5
4
|
|
|
6
5
|
/** Symbol used to attach rendered-query phantom row metadata. */
|
|
7
6
|
export const TypeId: unique symbol = Symbol.for("effect-qb/Renderer")
|
|
@@ -38,8 +37,7 @@ export type RowOf<Value extends RenderedQuery<any, any>> = Value[typeof TypeId][
|
|
|
38
37
|
*
|
|
39
38
|
* Renderers only accept complete, dialect-compatible plans. The returned
|
|
40
39
|
* `RenderedQuery` keeps the canonical `Query.ResultRow<...>` type attached for
|
|
41
|
-
* downstream executor layers
|
|
42
|
-
* matching runtime aggregate-shape validation.
|
|
40
|
+
* downstream executor layers.
|
|
43
41
|
*/
|
|
44
42
|
export interface Renderer<Dialect extends string = string> {
|
|
45
43
|
readonly dialect: Dialect
|
|
@@ -91,24 +89,38 @@ export function make<Dialect extends string>(
|
|
|
91
89
|
dialect: Dialect,
|
|
92
90
|
render: CustomRender<Dialect>
|
|
93
91
|
): Renderer<Dialect> {
|
|
92
|
+
return makeRenderer(dialect, render, true)
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/** Internal renderer factory for built-in renderers that derive projections from typed plans. */
|
|
96
|
+
export function makeTrusted<Dialect extends string>(
|
|
97
|
+
dialect: Dialect,
|
|
98
|
+
render: CustomRender<Dialect>
|
|
99
|
+
): Renderer<Dialect>
|
|
100
|
+
export function makeTrusted<Dialect extends string>(
|
|
101
|
+
dialect: Dialect,
|
|
102
|
+
render: CustomRender<Dialect>
|
|
103
|
+
): Renderer<Dialect> {
|
|
104
|
+
return makeRenderer(dialect, render, false)
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const makeRenderer = <Dialect extends string>(
|
|
108
|
+
dialect: Dialect,
|
|
109
|
+
render: CustomRender<Dialect>,
|
|
110
|
+
validate: boolean
|
|
111
|
+
): Renderer<Dialect> => {
|
|
94
112
|
if (typeof render !== "function") {
|
|
95
113
|
throw new Error(`Renderer.make requires an explicit render implementation for dialect: ${dialect}`)
|
|
96
114
|
}
|
|
97
115
|
return {
|
|
98
116
|
dialect,
|
|
99
117
|
render(plan) {
|
|
100
|
-
const required = Query.currentRequiredList(plan[Plan.TypeId].required)
|
|
101
|
-
if (required.length > 0) {
|
|
102
|
-
throw new Error(`query references sources that are not yet in scope: ${required.join(", ")}`)
|
|
103
|
-
}
|
|
104
|
-
const planDialect = plan[Plan.TypeId].dialect
|
|
105
|
-
if (planDialect !== dialect) {
|
|
106
|
-
throw new Error("effect-qb: plan dialect is not compatible with the target renderer or executor")
|
|
107
|
-
}
|
|
108
118
|
const rendered = render(plan)
|
|
109
119
|
const projections = rendered.projections ?? []
|
|
110
|
-
|
|
111
|
-
|
|
120
|
+
if (validate) {
|
|
121
|
+
validateProjections(projections)
|
|
122
|
+
validateProjectionPathsMatchSelection(plan as Query.Plan.Any, projections)
|
|
123
|
+
}
|
|
112
124
|
return {
|
|
113
125
|
sql: rendered.sql,
|
|
114
126
|
params: rendered.params ?? [],
|
|
@@ -23,6 +23,13 @@ const isPlainRecord = (value: unknown): value is Record<string, unknown> => {
|
|
|
23
23
|
|
|
24
24
|
const pad = (value: number, width = 2): string => value.toString().padStart(width, "0")
|
|
25
25
|
|
|
26
|
+
const validDate = (value: Date): Date => {
|
|
27
|
+
if (Number.isNaN(value.getTime())) {
|
|
28
|
+
throw new Error("Expected a valid Date value")
|
|
29
|
+
}
|
|
30
|
+
return value
|
|
31
|
+
}
|
|
32
|
+
|
|
26
33
|
const formatLocalDate = (value: Date): string =>
|
|
27
34
|
`${pad(value.getUTCFullYear(), 4)}-${pad(value.getUTCMonth() + 1)}-${pad(value.getUTCDate())}`
|
|
28
35
|
|
|
@@ -125,7 +132,7 @@ const normalizeDecimalString = (value: unknown): string => {
|
|
|
125
132
|
|
|
126
133
|
const normalizeLocalDate = (value: unknown): string => {
|
|
127
134
|
if (value instanceof Date) {
|
|
128
|
-
return formatLocalDate(value)
|
|
135
|
+
return formatLocalDate(validDate(value))
|
|
129
136
|
}
|
|
130
137
|
const raw = expectString(value, "local date").trim()
|
|
131
138
|
if (isValidLocalDateString(raw)) {
|
|
@@ -143,7 +150,7 @@ const normalizeLocalDate = (value: unknown): string => {
|
|
|
143
150
|
|
|
144
151
|
const normalizeLocalTime = (value: unknown): string => {
|
|
145
152
|
if (value instanceof Date) {
|
|
146
|
-
return formatLocalTime(value)
|
|
153
|
+
return formatLocalTime(validDate(value))
|
|
147
154
|
}
|
|
148
155
|
const raw = expectString(value, "local time").trim()
|
|
149
156
|
if (isValidLocalTimeString(raw)) {
|
|
@@ -154,7 +161,7 @@ const normalizeLocalTime = (value: unknown): string => {
|
|
|
154
161
|
|
|
155
162
|
const normalizeOffsetTime = (value: unknown): string => {
|
|
156
163
|
if (value instanceof Date) {
|
|
157
|
-
return `${formatLocalTime(value)}Z`
|
|
164
|
+
return `${formatLocalTime(validDate(value))}Z`
|
|
158
165
|
}
|
|
159
166
|
const raw = expectString(value, "offset time").trim()
|
|
160
167
|
if (isValidOffsetTimeString(raw)) {
|
|
@@ -165,7 +172,7 @@ const normalizeOffsetTime = (value: unknown): string => {
|
|
|
165
172
|
|
|
166
173
|
const normalizeLocalDateTime = (value: unknown): string => {
|
|
167
174
|
if (value instanceof Date) {
|
|
168
|
-
return formatLocalDateTime(value)
|
|
175
|
+
return formatLocalDateTime(validDate(value))
|
|
169
176
|
}
|
|
170
177
|
const raw = expectString(value, "local datetime").trim()
|
|
171
178
|
const canonicalLocalDateTime = raw.replace(" ", "T")
|
|
@@ -184,7 +191,7 @@ const normalizeLocalDateTime = (value: unknown): string => {
|
|
|
184
191
|
|
|
185
192
|
const normalizeInstant = (value: unknown): string => {
|
|
186
193
|
if (value instanceof Date) {
|
|
187
|
-
return value.toISOString()
|
|
194
|
+
return validDate(value).toISOString()
|
|
188
195
|
}
|
|
189
196
|
const raw = expectString(value, "instant").trim()
|
|
190
197
|
if (!/[zZ]|[+-]\d{2}:\d{2}$/.test(raw)) {
|
package/src/internal/scalar.ts
CHANGED
|
@@ -50,6 +50,7 @@ export declare namespace DbType {
|
|
|
50
50
|
readonly runtime?: RuntimeTag
|
|
51
51
|
readonly compareGroup?: string
|
|
52
52
|
readonly castTargets?: readonly string[]
|
|
53
|
+
readonly implicitTargets?: readonly string[]
|
|
53
54
|
readonly traits?: DatatypeTraits
|
|
54
55
|
readonly driverValueMapping?: DriverValueMapping
|
|
55
56
|
}
|
|
@@ -143,7 +144,12 @@ export interface DriverValueMapping {
|
|
|
143
144
|
readonly jsonSelectSql?: (sql: string, dbType: DbType.Any) => string
|
|
144
145
|
}
|
|
145
146
|
|
|
146
|
-
export type DriverValueMappings = Readonly<Record<string, DriverValueMapping
|
|
147
|
+
export type DriverValueMappings = Readonly<Partial<Record<string, DriverValueMapping>>>
|
|
148
|
+
|
|
149
|
+
export type DriverValueMappingsFor<
|
|
150
|
+
Kind extends string,
|
|
151
|
+
Family extends string
|
|
152
|
+
> = Readonly<Partial<Record<Kind | Family | RuntimeTag, DriverValueMapping>>>
|
|
147
153
|
|
|
148
154
|
/** Canonical static metadata stored on an expression. */
|
|
149
155
|
export interface State<
|
|
@@ -34,11 +34,11 @@ export type InsertRow<TableName extends string, Fields extends TableFieldMap> =
|
|
|
34
34
|
export type UpdateRow<TableName extends string, Fields extends TableFieldMap, PrimaryKey extends keyof Fields> = Simplify<Partial<{
|
|
35
35
|
[K in UpdateKeys<Fields, PrimaryKey>]: BrandedUpdateType<Fields[K], TableName, Extract<K, string>>;
|
|
36
36
|
}>>;
|
|
37
|
-
type SchemaOfVariant<Variant extends TableSchemaVariant, TableName extends string, Fields extends TableFieldMap, PrimaryKeyColumns extends keyof Fields & string> = Variant extends "select" ? Schema.
|
|
37
|
+
type SchemaOfVariant<Variant extends TableSchemaVariant, TableName extends string, Fields extends TableFieldMap, PrimaryKeyColumns extends keyof Fields & string> = Variant extends "select" ? Schema.ConstraintDecoder<SelectRow<TableName, Fields>, never> : Variant extends "insert" ? Schema.ConstraintDecoder<InsertRow<TableName, Fields>, never> : Schema.ConstraintDecoder<UpdateRow<TableName, Fields, PrimaryKeyColumns>, never>;
|
|
38
38
|
export declare const deriveSchema: <Variant extends TableSchemaVariant, TableName extends string, Fields extends TableFieldMap, PrimaryKeyColumns extends keyof Fields & string>(variant: Variant, tableName: TableName, fields: Fields, primaryKeyColumns: readonly PrimaryKeyColumns[]) => SchemaOfVariant<Variant, TableName, Fields, PrimaryKeyColumns>;
|
|
39
|
-
export declare const deriveSelectSchema: <TableName extends string, Fields extends TableFieldMap, PrimaryKeyColumns extends keyof Fields & string>(tableName: TableName, fields: Fields, primaryKeyColumns: readonly PrimaryKeyColumns[]) => Schema.
|
|
40
|
-
export declare const deriveInsertSchema: <TableName extends string, Fields extends TableFieldMap, PrimaryKeyColumns extends keyof Fields & string>(tableName: TableName, fields: Fields, primaryKeyColumns: readonly PrimaryKeyColumns[]) => Schema.
|
|
41
|
-
export declare const deriveUpdateSchema: <TableName extends string, Fields extends TableFieldMap, PrimaryKeyColumns extends keyof Fields & string>(tableName: TableName, fields: Fields, primaryKeyColumns: readonly PrimaryKeyColumns[]) => Schema.
|
|
39
|
+
export declare const deriveSelectSchema: <TableName extends string, Fields extends TableFieldMap, PrimaryKeyColumns extends keyof Fields & string>(tableName: TableName, fields: Fields, primaryKeyColumns: readonly PrimaryKeyColumns[]) => Schema.ConstraintDecoder<SelectRow<TableName, Fields>, never>;
|
|
40
|
+
export declare const deriveInsertSchema: <TableName extends string, Fields extends TableFieldMap, PrimaryKeyColumns extends keyof Fields & string>(tableName: TableName, fields: Fields, primaryKeyColumns: readonly PrimaryKeyColumns[]) => Schema.ConstraintDecoder<InsertRow<TableName, Fields>, never>;
|
|
41
|
+
export declare const deriveUpdateSchema: <TableName extends string, Fields extends TableFieldMap, PrimaryKeyColumns extends keyof Fields & string>(tableName: TableName, fields: Fields, primaryKeyColumns: readonly PrimaryKeyColumns[]) => Schema.ConstraintDecoder<UpdateRow<TableName, Fields, PrimaryKeyColumns>, never>;
|
|
42
42
|
/**
|
|
43
43
|
* Derives the `select`, `insert`, and `update` schemas for a table.
|
|
44
44
|
*
|
|
@@ -49,8 +49,8 @@ export declare const deriveUpdateSchema: <TableName extends string, Fields exten
|
|
|
49
49
|
* `deriveUpdateSchema` so individual variants are derived lazily.
|
|
50
50
|
*/
|
|
51
51
|
export declare const deriveSchemas: <TableName extends string, Fields extends TableFieldMap, PrimaryKeyColumns extends keyof Fields & string>(tableName: TableName, fields: Fields, primaryKeyColumns: readonly PrimaryKeyColumns[]) => {
|
|
52
|
-
readonly select: Schema.
|
|
53
|
-
readonly insert: Schema.
|
|
54
|
-
readonly update: Schema.
|
|
52
|
+
readonly select: Schema.ConstraintDecoder<SelectRow<TableName, Fields>, never>;
|
|
53
|
+
readonly insert: Schema.ConstraintDecoder<InsertRow<TableName, Fields>, never>;
|
|
54
|
+
readonly update: Schema.ConstraintDecoder<UpdateRow<TableName, Fields, PrimaryKeyColumns>, never>;
|
|
55
55
|
};
|
|
56
56
|
export {};
|
|
@@ -151,9 +151,9 @@ type SchemaOfVariant<
|
|
|
151
151
|
TableName extends string,
|
|
152
152
|
Fields extends TableFieldMap,
|
|
153
153
|
PrimaryKeyColumns extends keyof Fields & string
|
|
154
|
-
> = Variant extends "select" ? Schema.
|
|
155
|
-
: Variant extends "insert" ? Schema.
|
|
156
|
-
: Schema.
|
|
154
|
+
> = Variant extends "select" ? Schema.ConstraintDecoder<SelectRow<TableName, Fields>, never>
|
|
155
|
+
: Variant extends "insert" ? Schema.ConstraintDecoder<InsertRow<TableName, Fields>, never>
|
|
156
|
+
: Schema.ConstraintDecoder<UpdateRow<TableName, Fields, PrimaryKeyColumns>, never>
|
|
157
157
|
|
|
158
158
|
const fieldSchemaForVariant = (
|
|
159
159
|
variant: TableSchemaVariant,
|
|
@@ -202,7 +202,7 @@ export const deriveSelectSchema = <
|
|
|
202
202
|
tableName: TableName,
|
|
203
203
|
fields: Fields,
|
|
204
204
|
primaryKeyColumns: readonly PrimaryKeyColumns[]
|
|
205
|
-
): Schema.
|
|
205
|
+
): Schema.ConstraintDecoder<SelectRow<TableName, Fields>, never> =>
|
|
206
206
|
deriveSchema("select", tableName, fields, primaryKeyColumns)
|
|
207
207
|
|
|
208
208
|
export const deriveInsertSchema = <
|
|
@@ -213,7 +213,7 @@ export const deriveInsertSchema = <
|
|
|
213
213
|
tableName: TableName,
|
|
214
214
|
fields: Fields,
|
|
215
215
|
primaryKeyColumns: readonly PrimaryKeyColumns[]
|
|
216
|
-
): Schema.
|
|
216
|
+
): Schema.ConstraintDecoder<InsertRow<TableName, Fields>, never> =>
|
|
217
217
|
deriveSchema("insert", tableName, fields, primaryKeyColumns)
|
|
218
218
|
|
|
219
219
|
export const deriveUpdateSchema = <
|
|
@@ -224,7 +224,7 @@ export const deriveUpdateSchema = <
|
|
|
224
224
|
tableName: TableName,
|
|
225
225
|
fields: Fields,
|
|
226
226
|
primaryKeyColumns: readonly PrimaryKeyColumns[]
|
|
227
|
-
): Schema.
|
|
227
|
+
): Schema.ConstraintDecoder<UpdateRow<TableName, Fields, PrimaryKeyColumns>, never> =>
|
|
228
228
|
deriveSchema("update", tableName, fields, primaryKeyColumns)
|
|
229
229
|
|
|
230
230
|
/**
|
|
@@ -245,9 +245,9 @@ export const deriveSchemas = <
|
|
|
245
245
|
fields: Fields,
|
|
246
246
|
primaryKeyColumns: readonly PrimaryKeyColumns[]
|
|
247
247
|
): {
|
|
248
|
-
readonly select: Schema.
|
|
249
|
-
readonly insert: Schema.
|
|
250
|
-
readonly update: Schema.
|
|
248
|
+
readonly select: Schema.ConstraintDecoder<SelectRow<TableName, Fields>, never>
|
|
249
|
+
readonly insert: Schema.ConstraintDecoder<InsertRow<TableName, Fields>, never>
|
|
250
|
+
readonly update: Schema.ConstraintDecoder<UpdateRow<TableName, Fields, PrimaryKeyColumns>, never>
|
|
251
251
|
} => ({
|
|
252
252
|
select: deriveSelectSchema(tableName, fields, primaryKeyColumns),
|
|
253
253
|
insert: deriveInsertSchema(tableName, fields, primaryKeyColumns),
|
|
@@ -6,7 +6,7 @@ export const TypeId: unique symbol = Symbol.for("effect-qb/SchemaExpression")
|
|
|
6
6
|
export type TypeId = typeof TypeId
|
|
7
7
|
|
|
8
8
|
const SchemaExpressionProto = {
|
|
9
|
-
pipe(this:
|
|
9
|
+
pipe(this: Pipeable) {
|
|
10
10
|
return pipeArguments(this, arguments)
|
|
11
11
|
}
|
|
12
12
|
}
|
|
@@ -15,7 +15,7 @@ const attachPipe = <Value extends object>(value: Value): Value => {
|
|
|
15
15
|
Object.defineProperty(value, "pipe", {
|
|
16
16
|
configurable: true,
|
|
17
17
|
writable: true,
|
|
18
|
-
value: function(this:
|
|
18
|
+
value: function(this: Value) {
|
|
19
19
|
return pipeArguments(value, arguments)
|
|
20
20
|
}
|
|
21
21
|
})
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { RenderedAst, RenderState, SqlDialect } from "./dialect.js"
|
|
2
|
+
import type * as Expression from "./scalar.js"
|
|
3
|
+
import type * as QueryAst from "./query-ast.js"
|
|
4
|
+
|
|
5
|
+
export const renderQueryAst = (
|
|
6
|
+
ast: QueryAst.Ast<Record<string, unknown>, any, QueryAst.QueryStatement>,
|
|
7
|
+
state: RenderState,
|
|
8
|
+
dialect: SqlDialect
|
|
9
|
+
): RenderedAst => {
|
|
10
|
+
return dialect.renderQueryAst(ast, state, dialect)
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const renderExpression = (
|
|
14
|
+
expression: Expression.Any,
|
|
15
|
+
state: RenderState,
|
|
16
|
+
dialect: SqlDialect
|
|
17
|
+
): string => {
|
|
18
|
+
return dialect.renderExpression(expression, state, dialect)
|
|
19
|
+
}
|