effect-qb 0.19.0 → 0.20.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 +7 -1
- package/dist/index.js +1990 -679
- package/dist/mysql.js +1490 -617
- package/dist/postgres/metadata.js +1334 -263
- package/dist/postgres.js +3376 -2307
- package/dist/sqlite.js +1573 -628
- package/dist/standard.js +1984 -673
- package/package.json +2 -4
- package/src/internal/coercion/rules.ts +13 -1
- package/src/internal/column-state.d.ts +3 -3
- package/src/internal/column-state.ts +13 -12
- package/src/internal/column.ts +8 -8
- package/src/internal/datatypes/define.ts +5 -0
- package/src/internal/datatypes/lookup.ts +67 -18
- package/src/internal/datatypes/matrix.ts +903 -0
- package/src/internal/datatypes/shape.ts +2 -0
- package/src/internal/dialect-renderers/mysql.ts +6 -4
- package/src/internal/dialect-renderers/postgres.ts +6 -4
- package/src/internal/dialect-renderers/sqlite.ts +6 -4
- package/src/internal/dialect.ts +1 -1
- package/src/internal/executor.ts +56 -43
- package/src/internal/json/path-access.ts +351 -0
- package/src/internal/query.d.ts +1 -1
- package/src/internal/query.ts +1 -1
- package/src/internal/runtime/driver-value-mapping.ts +3 -3
- package/src/internal/runtime/schema.ts +28 -38
- package/src/internal/runtime/value.ts +20 -23
- package/src/internal/scalar.d.ts +1 -1
- package/src/internal/scalar.ts +2 -1
- package/src/internal/schema-derivation.d.ts +7 -7
- package/src/internal/schema-derivation.ts +11 -11
- package/src/internal/standard-dsl.ts +121 -28
- package/src/internal/table.ts +451 -120
- package/src/mysql/column.ts +6 -6
- package/src/mysql/datatypes/index.ts +1 -0
- package/src/mysql/datatypes/spec.ts +6 -176
- package/src/mysql/errors/normalize.ts +0 -1
- package/src/mysql/executor.ts +4 -6
- package/src/mysql/function/temporal.ts +1 -1
- package/src/mysql/internal/dsl.ts +116 -16
- package/src/mysql/json.ts +1 -33
- package/src/mysql/renderer.ts +13 -6
- package/src/mysql/type.ts +60 -0
- package/src/mysql.ts +3 -1
- package/src/postgres/check.ts +1 -0
- package/src/postgres/column.ts +11 -11
- package/src/postgres/datatypes/index.ts +1 -0
- package/src/postgres/datatypes/spec.ts +6 -260
- package/src/postgres/errors/normalize.ts +0 -1
- package/src/postgres/executor.ts +4 -6
- package/src/postgres/foreign-key.ts +24 -0
- package/src/postgres/function/temporal.ts +1 -1
- package/src/postgres/index.ts +1 -0
- package/src/postgres/internal/dsl.ts +122 -21
- package/src/postgres/json-extension.ts +7 -0
- package/src/postgres/json.ts +726 -173
- package/src/postgres/jsonb.ts +0 -1
- package/src/postgres/primary-key.ts +24 -0
- package/src/postgres/renderer.ts +13 -6
- package/src/postgres/schema-management.ts +1 -6
- package/src/postgres/schema.ts +16 -8
- package/src/postgres/table.ts +111 -113
- package/src/postgres/type.ts +86 -4
- package/src/postgres/unique.ts +32 -0
- package/src/postgres.ts +12 -6
- package/src/sqlite/column.ts +6 -6
- package/src/sqlite/datatypes/index.ts +1 -0
- package/src/sqlite/datatypes/spec.ts +6 -94
- package/src/sqlite/errors/normalize.ts +0 -1
- package/src/sqlite/executor.ts +4 -6
- package/src/sqlite/function/temporal.ts +1 -1
- package/src/sqlite/internal/dsl.ts +100 -5
- package/src/sqlite/json.ts +1 -32
- package/src/sqlite/renderer.ts +13 -6
- package/src/sqlite/type.ts +40 -0
- package/src/sqlite.ts +3 -1
- package/src/standard/cast.ts +113 -0
- package/src/standard/check.ts +17 -0
- package/src/standard/column.ts +10 -10
- package/src/standard/datatypes/index.ts +2 -2
- package/src/standard/datatypes/spec.ts +10 -96
- package/src/standard/foreign-key.ts +37 -0
- package/src/standard/function/temporal.ts +1 -1
- package/src/standard/index.ts +17 -0
- package/src/standard/json.ts +883 -0
- package/src/standard/primary-key.ts +17 -0
- package/src/standard/renderer.ts +31 -3
- package/src/standard/table.ts +25 -21
- package/src/standard/unique.ts +17 -0
- package/src/standard.ts +14 -0
- package/src/internal/table.d.ts +0 -174
- package/src/postgres/cast.ts +0 -45
package/src/mysql.ts
CHANGED
|
@@ -4,11 +4,13 @@ export * as Column from "./mysql/column-extension.js"
|
|
|
4
4
|
export * as Datatypes from "./mysql/datatypes/index.js"
|
|
5
5
|
/** MySQL error catalog and error normalization helpers. */
|
|
6
6
|
export * as Errors from "./mysql/errors/index.js"
|
|
7
|
-
/** MySQL-
|
|
7
|
+
/** MySQL-specific JSON expression helpers. Portable JSON helpers are exported from the root package. */
|
|
8
8
|
export * as Json from "./mysql/json.js"
|
|
9
9
|
/** MySQL-specialized typed query execution contracts. */
|
|
10
10
|
export * as Executor from "./mysql/executor.js"
|
|
11
11
|
/** MySQL-specific query helpers. Portable queries are exported from the root package. */
|
|
12
12
|
export * as Query from "./mysql/query-extension.js"
|
|
13
|
+
/** MySQL-only database-type constructors for casts and typed references. */
|
|
14
|
+
export { type as Type } from "./mysql/type.js"
|
|
13
15
|
/** MySQL-specialized built-in renderer entrypoint. */
|
|
14
16
|
export * as Renderer from "./mysql/renderer.js"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { noInherit } from "./table.js"
|
package/src/postgres/column.ts
CHANGED
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
import { postgresDatatypes } from "./datatypes/index.js"
|
|
24
24
|
|
|
25
25
|
const primitive = <Type, Db extends Expression.DbType.Any>(
|
|
26
|
-
schema: Schema.Schema<Type
|
|
26
|
+
schema: Schema.Schema<Type>,
|
|
27
27
|
dbType: Db
|
|
28
28
|
): ColumnDefinition<Type, Type, Type, Db, false, false, false, false, false, undefined> =>
|
|
29
29
|
makeColumnDefinition(schema as Schema.Schema<NonNullable<Type>>, {
|
|
@@ -51,15 +51,15 @@ const renderNumericDdlType = (
|
|
|
51
51
|
const boundedString = (length?: number): Schema.Schema<string> =>
|
|
52
52
|
length === undefined
|
|
53
53
|
? Schema.String
|
|
54
|
-
: Schema.String.
|
|
54
|
+
: Schema.String.check(Schema.isMaxLength(length))
|
|
55
55
|
|
|
56
|
-
const finiteNumber = Schema.Number.
|
|
56
|
+
const finiteNumber = Schema.Number.check(Schema.isFinite())
|
|
57
57
|
|
|
58
|
-
export const custom = <SchemaType extends Schema.
|
|
58
|
+
export const custom = <SchemaType extends Schema.Top, Db extends Expression.DbType.Any>(
|
|
59
59
|
schema: SchemaType,
|
|
60
60
|
dbType: Db
|
|
61
61
|
) =>
|
|
62
|
-
makeColumnDefinition(schema as Schema.Schema<NonNullable<Schema.Schema.Type<SchemaType
|
|
62
|
+
makeColumnDefinition(schema as unknown as Schema.Schema<NonNullable<Schema.Schema.Type<SchemaType>>>, {
|
|
63
63
|
dbType: enrichDbType(postgresDatatypes, dbType),
|
|
64
64
|
nullable: false,
|
|
65
65
|
hasDefault: false,
|
|
@@ -71,7 +71,7 @@ export const custom = <SchemaType extends Schema.Schema.Any, Db extends Expressi
|
|
|
71
71
|
identity: undefined
|
|
72
72
|
})
|
|
73
73
|
|
|
74
|
-
export const uuid = () => primitive(Schema.
|
|
74
|
+
export const uuid = () => primitive(Schema.String.check(Schema.isUUID()), postgresDatatypes.uuid())
|
|
75
75
|
export const text = () => primitive(Schema.String, postgresDatatypes.text())
|
|
76
76
|
export const int = () => primitive(Schema.Int, postgresDatatypes.int4())
|
|
77
77
|
export const int2 = () => primitive(Schema.Int, postgresDatatypes.int2())
|
|
@@ -97,7 +97,7 @@ export const time = () => primitive(LocalTimeStringSchema, postgresDatatypes.tim
|
|
|
97
97
|
export const timetz = () => primitive(OffsetTimeStringSchema, postgresDatatypes.timetz())
|
|
98
98
|
export const timestamptz = () => primitive(InstantStringSchema, postgresDatatypes.timestamptz())
|
|
99
99
|
export const interval = () => primitive(Schema.String, postgresDatatypes.interval())
|
|
100
|
-
export const bytea = () => primitive(Schema.
|
|
100
|
+
export const bytea = () => primitive(Schema.Uint8Array, postgresDatatypes.bytea())
|
|
101
101
|
export const name = () => primitive(Schema.String, postgresDatatypes.name())
|
|
102
102
|
export const oid = () => primitive(Schema.Int, postgresDatatypes.oid())
|
|
103
103
|
export const regclass = () => primitive(Schema.String, postgresDatatypes.regclass())
|
|
@@ -129,8 +129,8 @@ export const varchar = (length?: number) =>
|
|
|
129
129
|
ddlType: length === undefined ? "varchar" : `varchar(${length})`,
|
|
130
130
|
identity: undefined
|
|
131
131
|
})
|
|
132
|
-
export const json = <SchemaType extends Schema.
|
|
133
|
-
makeColumnDefinition(schema as Schema.Schema<NonNullable<Schema.Schema.Type<SchemaType
|
|
132
|
+
export const json = <SchemaType extends Schema.Top>(schema: SchemaType) =>
|
|
133
|
+
makeColumnDefinition(schema as unknown as Schema.Schema<NonNullable<Schema.Schema.Type<SchemaType>>>, {
|
|
134
134
|
dbType: postgresDatatypes.json(),
|
|
135
135
|
nullable: false,
|
|
136
136
|
hasDefault: false,
|
|
@@ -141,8 +141,8 @@ export const json = <SchemaType extends Schema.Schema.Any>(schema: SchemaType) =
|
|
|
141
141
|
ddlType: undefined,
|
|
142
142
|
identity: undefined
|
|
143
143
|
})
|
|
144
|
-
export const jsonb = <SchemaType extends Schema.
|
|
145
|
-
makeColumnDefinition(schema as Schema.Schema<NonNullable<Schema.Schema.Type<SchemaType
|
|
144
|
+
export const jsonb = <SchemaType extends Schema.Top>(schema: SchemaType) =>
|
|
145
|
+
makeColumnDefinition(schema as unknown as Schema.Schema<NonNullable<Schema.Schema.Type<SchemaType>>>, {
|
|
146
146
|
dbType: postgresDatatypes.jsonb(),
|
|
147
147
|
nullable: false,
|
|
148
148
|
hasDefault: false,
|
|
@@ -15,6 +15,7 @@ const withMetadata = <Kind extends keyof typeof postgresDatatypeKinds & string>(
|
|
|
15
15
|
runtime: kindSpec.runtime,
|
|
16
16
|
compareGroup: familySpec?.compareGroup,
|
|
17
17
|
castTargets: familySpec?.castTargets,
|
|
18
|
+
implicitTargets: (familySpec as { readonly implicitTargets?: readonly string[] }).implicitTargets,
|
|
18
19
|
traits: familySpec?.traits
|
|
19
20
|
}
|
|
20
21
|
}
|
|
@@ -1,264 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import {
|
|
2
|
+
postgresDatatypeFamilies as matrixPostgresDatatypeFamilies,
|
|
3
|
+
postgresDatatypeKinds as matrixPostgresDatatypeKinds
|
|
4
|
+
} from "../../internal/datatypes/matrix.js"
|
|
2
5
|
|
|
3
|
-
export const postgresDatatypeFamilies =
|
|
4
|
-
|
|
5
|
-
compareGroup: "text",
|
|
6
|
-
castTargets: [
|
|
7
|
-
"text",
|
|
8
|
-
"numeric",
|
|
9
|
-
"boolean",
|
|
10
|
-
"date",
|
|
11
|
-
"time",
|
|
12
|
-
"timestamp",
|
|
13
|
-
"interval",
|
|
14
|
-
"binary",
|
|
15
|
-
"uuid",
|
|
16
|
-
"json",
|
|
17
|
-
"xml",
|
|
18
|
-
"bit",
|
|
19
|
-
"oid",
|
|
20
|
-
"identifier",
|
|
21
|
-
"network",
|
|
22
|
-
"spatial",
|
|
23
|
-
"textsearch",
|
|
24
|
-
"range",
|
|
25
|
-
"multirange",
|
|
26
|
-
"array",
|
|
27
|
-
"money",
|
|
28
|
-
"null"
|
|
29
|
-
],
|
|
30
|
-
traits: {
|
|
31
|
-
textual: true,
|
|
32
|
-
ordered: true
|
|
33
|
-
}
|
|
34
|
-
},
|
|
35
|
-
numeric: {
|
|
36
|
-
compareGroup: "numeric",
|
|
37
|
-
castTargets: ["numeric", "text", "boolean", "date", "time", "timestamp", "interval", "uuid", "bit", "oid", "money"],
|
|
38
|
-
traits: {
|
|
39
|
-
ordered: true
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
|
-
boolean: {
|
|
43
|
-
compareGroup: "boolean",
|
|
44
|
-
castTargets: ["boolean", "text", "numeric"],
|
|
45
|
-
traits: {}
|
|
46
|
-
},
|
|
47
|
-
date: {
|
|
48
|
-
compareGroup: "date",
|
|
49
|
-
castTargets: ["date", "timestamp", "text"],
|
|
50
|
-
traits: {
|
|
51
|
-
ordered: true
|
|
52
|
-
}
|
|
53
|
-
},
|
|
54
|
-
time: {
|
|
55
|
-
compareGroup: "time",
|
|
56
|
-
castTargets: ["time", "timestamp", "text"],
|
|
57
|
-
traits: {
|
|
58
|
-
ordered: true
|
|
59
|
-
}
|
|
60
|
-
},
|
|
61
|
-
timestamp: {
|
|
62
|
-
compareGroup: "timestamp",
|
|
63
|
-
castTargets: ["timestamp", "date", "text"],
|
|
64
|
-
traits: {
|
|
65
|
-
ordered: true
|
|
66
|
-
}
|
|
67
|
-
},
|
|
68
|
-
interval: {
|
|
69
|
-
compareGroup: "interval",
|
|
70
|
-
castTargets: ["interval", "text"],
|
|
71
|
-
traits: {
|
|
72
|
-
ordered: true
|
|
73
|
-
}
|
|
74
|
-
},
|
|
75
|
-
binary: {
|
|
76
|
-
compareGroup: "binary",
|
|
77
|
-
castTargets: ["binary", "text"],
|
|
78
|
-
traits: {}
|
|
79
|
-
},
|
|
80
|
-
uuid: {
|
|
81
|
-
compareGroup: "uuid",
|
|
82
|
-
castTargets: ["uuid", "text"],
|
|
83
|
-
traits: {
|
|
84
|
-
ordered: true
|
|
85
|
-
}
|
|
86
|
-
},
|
|
87
|
-
json: {
|
|
88
|
-
compareGroup: "json",
|
|
89
|
-
castTargets: ["json", "text"],
|
|
90
|
-
traits: {}
|
|
91
|
-
},
|
|
92
|
-
xml: {
|
|
93
|
-
compareGroup: "xml",
|
|
94
|
-
castTargets: ["xml", "text"],
|
|
95
|
-
traits: {}
|
|
96
|
-
},
|
|
97
|
-
bit: {
|
|
98
|
-
compareGroup: "bit",
|
|
99
|
-
castTargets: ["bit", "text", "numeric"],
|
|
100
|
-
traits: {}
|
|
101
|
-
},
|
|
102
|
-
oid: {
|
|
103
|
-
compareGroup: "oid",
|
|
104
|
-
castTargets: ["oid", "text", "numeric"],
|
|
105
|
-
traits: {
|
|
106
|
-
ordered: true
|
|
107
|
-
}
|
|
108
|
-
},
|
|
109
|
-
identifier: {
|
|
110
|
-
compareGroup: "identifier",
|
|
111
|
-
castTargets: ["identifier", "text"],
|
|
112
|
-
traits: {}
|
|
113
|
-
},
|
|
114
|
-
network: {
|
|
115
|
-
compareGroup: "network",
|
|
116
|
-
castTargets: ["network", "text"],
|
|
117
|
-
traits: {}
|
|
118
|
-
},
|
|
119
|
-
spatial: {
|
|
120
|
-
compareGroup: "spatial",
|
|
121
|
-
castTargets: ["spatial", "text"],
|
|
122
|
-
traits: {}
|
|
123
|
-
},
|
|
124
|
-
textsearch: {
|
|
125
|
-
compareGroup: "textsearch",
|
|
126
|
-
castTargets: ["textsearch", "text"],
|
|
127
|
-
traits: {}
|
|
128
|
-
},
|
|
129
|
-
range: {
|
|
130
|
-
compareGroup: "range",
|
|
131
|
-
castTargets: ["range", "text"],
|
|
132
|
-
traits: {}
|
|
133
|
-
},
|
|
134
|
-
multirange: {
|
|
135
|
-
compareGroup: "multirange",
|
|
136
|
-
castTargets: ["multirange", "text"],
|
|
137
|
-
traits: {}
|
|
138
|
-
},
|
|
139
|
-
enum: {
|
|
140
|
-
compareGroup: "enum",
|
|
141
|
-
castTargets: ["enum", "text"],
|
|
142
|
-
traits: {
|
|
143
|
-
textual: true,
|
|
144
|
-
ordered: true
|
|
145
|
-
}
|
|
146
|
-
},
|
|
147
|
-
record: {
|
|
148
|
-
compareGroup: "record",
|
|
149
|
-
castTargets: ["record", "text"],
|
|
150
|
-
traits: {}
|
|
151
|
-
},
|
|
152
|
-
array: {
|
|
153
|
-
compareGroup: "array",
|
|
154
|
-
castTargets: ["array", "text"],
|
|
155
|
-
traits: {}
|
|
156
|
-
},
|
|
157
|
-
money: {
|
|
158
|
-
compareGroup: "money",
|
|
159
|
-
castTargets: ["money", "text", "numeric"],
|
|
160
|
-
traits: {
|
|
161
|
-
ordered: true
|
|
162
|
-
}
|
|
163
|
-
},
|
|
164
|
-
null: {
|
|
165
|
-
compareGroup: "null",
|
|
166
|
-
castTargets: [
|
|
167
|
-
"text",
|
|
168
|
-
"numeric",
|
|
169
|
-
"boolean",
|
|
170
|
-
"date",
|
|
171
|
-
"time",
|
|
172
|
-
"timestamp",
|
|
173
|
-
"interval",
|
|
174
|
-
"binary",
|
|
175
|
-
"uuid",
|
|
176
|
-
"json",
|
|
177
|
-
"xml",
|
|
178
|
-
"bit",
|
|
179
|
-
"oid",
|
|
180
|
-
"identifier",
|
|
181
|
-
"network",
|
|
182
|
-
"spatial",
|
|
183
|
-
"textsearch",
|
|
184
|
-
"range",
|
|
185
|
-
"multirange",
|
|
186
|
-
"array",
|
|
187
|
-
"money",
|
|
188
|
-
"null"
|
|
189
|
-
],
|
|
190
|
-
traits: {}
|
|
191
|
-
}
|
|
192
|
-
} as const satisfies Record<string, DatatypeFamilySpec>
|
|
193
|
-
|
|
194
|
-
export const postgresDatatypeKinds = {
|
|
195
|
-
text: { family: "text", runtime: "string" },
|
|
196
|
-
varchar: { family: "text", runtime: "string" },
|
|
197
|
-
char: { family: "text", runtime: "string" },
|
|
198
|
-
citext: { family: "text", runtime: "string" },
|
|
199
|
-
name: { family: "text", runtime: "string" },
|
|
200
|
-
uuid: { family: "uuid", runtime: "string" },
|
|
201
|
-
int2: { family: "numeric", runtime: "number" },
|
|
202
|
-
int4: { family: "numeric", runtime: "number" },
|
|
203
|
-
int8: { family: "numeric", runtime: "bigintString" },
|
|
204
|
-
numeric: { family: "numeric", runtime: "decimalString" },
|
|
205
|
-
float4: { family: "numeric", runtime: "number" },
|
|
206
|
-
float8: { family: "numeric", runtime: "number" },
|
|
207
|
-
money: { family: "money", runtime: "number" },
|
|
208
|
-
bool: { family: "boolean", runtime: "boolean" },
|
|
209
|
-
date: { family: "date", runtime: "localDate" },
|
|
210
|
-
time: { family: "time", runtime: "localTime" },
|
|
211
|
-
timetz: { family: "time", runtime: "offsetTime" },
|
|
212
|
-
timestamp: { family: "timestamp", runtime: "localDateTime" },
|
|
213
|
-
timestamptz: { family: "timestamp", runtime: "instant" },
|
|
214
|
-
interval: { family: "interval", runtime: "string" },
|
|
215
|
-
bytea: { family: "binary", runtime: "bytes" },
|
|
216
|
-
json: { family: "json", runtime: "json" },
|
|
217
|
-
jsonb: { family: "json", runtime: "json" },
|
|
218
|
-
xml: { family: "xml", runtime: "string" },
|
|
219
|
-
bit: { family: "bit", runtime: "string" },
|
|
220
|
-
varbit: { family: "bit", runtime: "string" },
|
|
221
|
-
oid: { family: "oid", runtime: "number" },
|
|
222
|
-
xid: { family: "oid", runtime: "number" },
|
|
223
|
-
xid8: { family: "oid", runtime: "bigintString" },
|
|
224
|
-
cid: { family: "oid", runtime: "number" },
|
|
225
|
-
tid: { family: "identifier", runtime: "string" },
|
|
226
|
-
regclass: { family: "identifier", runtime: "string" },
|
|
227
|
-
regtype: { family: "identifier", runtime: "string" },
|
|
228
|
-
regproc: { family: "identifier", runtime: "string" },
|
|
229
|
-
regprocedure: { family: "identifier", runtime: "string" },
|
|
230
|
-
regoper: { family: "identifier", runtime: "string" },
|
|
231
|
-
regoperator: { family: "identifier", runtime: "string" },
|
|
232
|
-
regconfig: { family: "identifier", runtime: "string" },
|
|
233
|
-
regdictionary: { family: "identifier", runtime: "string" },
|
|
234
|
-
pg_lsn: { family: "identifier", runtime: "string" },
|
|
235
|
-
txid_snapshot: { family: "identifier", runtime: "string" },
|
|
236
|
-
inet: { family: "network", runtime: "string" },
|
|
237
|
-
cidr: { family: "network", runtime: "string" },
|
|
238
|
-
macaddr: { family: "network", runtime: "string" },
|
|
239
|
-
macaddr8: { family: "network", runtime: "string" },
|
|
240
|
-
point: { family: "spatial", runtime: "unknown" },
|
|
241
|
-
line: { family: "spatial", runtime: "unknown" },
|
|
242
|
-
lseg: { family: "spatial", runtime: "unknown" },
|
|
243
|
-
box: { family: "spatial", runtime: "unknown" },
|
|
244
|
-
path: { family: "spatial", runtime: "unknown" },
|
|
245
|
-
polygon: { family: "spatial", runtime: "unknown" },
|
|
246
|
-
circle: { family: "spatial", runtime: "unknown" },
|
|
247
|
-
tsvector: { family: "textsearch", runtime: "string" },
|
|
248
|
-
tsquery: { family: "textsearch", runtime: "string" },
|
|
249
|
-
int4range: { family: "range", runtime: "unknown" },
|
|
250
|
-
int8range: { family: "range", runtime: "unknown" },
|
|
251
|
-
numrange: { family: "range", runtime: "unknown" },
|
|
252
|
-
tsrange: { family: "range", runtime: "unknown" },
|
|
253
|
-
tstzrange: { family: "range", runtime: "unknown" },
|
|
254
|
-
daterange: { family: "range", runtime: "unknown" },
|
|
255
|
-
int4multirange: { family: "multirange", runtime: "unknown" },
|
|
256
|
-
int8multirange: { family: "multirange", runtime: "unknown" },
|
|
257
|
-
nummultirange: { family: "multirange", runtime: "unknown" },
|
|
258
|
-
tsmultirange: { family: "multirange", runtime: "unknown" },
|
|
259
|
-
tstzmultirange: { family: "multirange", runtime: "unknown" },
|
|
260
|
-
datemultirange: { family: "multirange", runtime: "unknown" }
|
|
261
|
-
} as const satisfies Record<string, DatatypeKindSpec>
|
|
6
|
+
export const postgresDatatypeFamilies = matrixPostgresDatatypeFamilies
|
|
7
|
+
export const postgresDatatypeKinds = matrixPostgresDatatypeKinds
|
|
262
8
|
|
|
263
9
|
export type PostgresDatatypeFamily = keyof typeof postgresDatatypeFamilies
|
|
264
10
|
export type PostgresDatatypeKind = keyof typeof postgresDatatypeKinds
|
package/src/postgres/executor.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as Effect from "effect/Effect"
|
|
2
|
-
import * as SqlClient from "
|
|
2
|
+
import * as SqlClient from "effect/unstable/sql/SqlClient"
|
|
3
3
|
import * as Stream from "effect/Stream"
|
|
4
4
|
|
|
5
5
|
import * as CoreExecutor from "../internal/executor.js"
|
|
@@ -41,8 +41,6 @@ export type PostgresQueryError<PlanValue extends CoreQuery.QueryPlan<any, any, a
|
|
|
41
41
|
|
|
42
42
|
/** Runs an effect within the ambient Postgres SQL transaction service. */
|
|
43
43
|
export const withTransaction = CoreExecutor.withTransaction
|
|
44
|
-
/** Runs an effect in a nested Postgres SQL transaction scope. */
|
|
45
|
-
export const withSavepoint = CoreExecutor.withSavepoint
|
|
46
44
|
|
|
47
45
|
/** Postgres executor whose error channel narrows based on the query plan. */
|
|
48
46
|
export interface QueryExecutor<Context = never> {
|
|
@@ -142,10 +140,10 @@ const fromDriver = <
|
|
|
142
140
|
stream(plan) {
|
|
143
141
|
const rendered = renderer.render(plan)
|
|
144
142
|
return Stream.mapError(
|
|
145
|
-
Stream.
|
|
143
|
+
Stream.mapArrayEffect(
|
|
146
144
|
sqlDriver.stream(rendered),
|
|
147
145
|
(rows) => Effect.try({
|
|
148
|
-
try: () => CoreExecutor.
|
|
146
|
+
try: () => CoreExecutor.decodeRows(rendered, plan, rows, { driverMode, valueMappings }) as never,
|
|
149
147
|
catch: (error) => error as RowDecodeError
|
|
150
148
|
})
|
|
151
149
|
),
|
|
@@ -175,7 +173,7 @@ const sqlClientDriver = (): Driver<any, SqlClient.SqlClient> =>
|
|
|
175
173
|
* Creates the standard Postgres executor pipeline.
|
|
176
174
|
*
|
|
177
175
|
* By default this uses the built-in Postgres renderer plus the ambient
|
|
178
|
-
*
|
|
176
|
+
* `effect/unstable/sql` `SqlClient`. Advanced callers can override the renderer,
|
|
179
177
|
* driver, or both.
|
|
180
178
|
*/
|
|
181
179
|
export function make(): QueryExecutor<SqlClient.SqlClient>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import * as BaseTable from "../internal/table.js"
|
|
2
|
+
import type { TableOptionSpec } from "../internal/table-options.js"
|
|
3
|
+
|
|
4
|
+
type ForeignKeySpec = Extract<TableOptionSpec, { readonly kind: "foreignKey" }>
|
|
5
|
+
|
|
6
|
+
export const deferrable = <Spec extends ForeignKeySpec, TableContext extends BaseTable.TableDefinition<any, any, any, "schema", any>>(
|
|
7
|
+
option: BaseTable.TableOption<Spec, TableContext>
|
|
8
|
+
): BaseTable.TableOption<Spec & { readonly deferrable: true }, TableContext> =>
|
|
9
|
+
BaseTable.mapOption(option, (spec) => ({
|
|
10
|
+
...spec,
|
|
11
|
+
deferrable: true
|
|
12
|
+
} as Spec & { readonly deferrable: true }))
|
|
13
|
+
|
|
14
|
+
export const initiallyDeferred = <Spec extends ForeignKeySpec, TableContext extends BaseTable.TableDefinition<any, any, any, "schema", any>>(
|
|
15
|
+
option: BaseTable.TableOption<Spec, TableContext>
|
|
16
|
+
): BaseTable.TableOption<Spec & {
|
|
17
|
+
readonly deferrable: true
|
|
18
|
+
readonly initiallyDeferred: true
|
|
19
|
+
}, TableContext> =>
|
|
20
|
+
BaseTable.mapOption(option, (spec) => ({
|
|
21
|
+
...spec,
|
|
22
|
+
deferrable: true,
|
|
23
|
+
initiallyDeferred: true
|
|
24
|
+
} as Spec & { readonly deferrable: true; readonly initiallyDeferred: true }))
|
|
@@ -39,7 +39,7 @@ const makeTemporal = <
|
|
|
39
39
|
>(
|
|
40
40
|
name: Name,
|
|
41
41
|
dbType: Db,
|
|
42
|
-
runtimeSchema: Schema.Schema<Runtime
|
|
42
|
+
runtimeSchema: Schema.Schema<Runtime>
|
|
43
43
|
): TemporalExpression<Runtime, Db, Name> =>
|
|
44
44
|
makeExpression({
|
|
45
45
|
runtime: undefined as unknown as Runtime,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { include, key, keys, uniqueIndex, using, where } from "./table.js"
|