@sqlbraid/core 1.0.0 → 1.0.3
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/LICENSE +1 -1
- package/README.md +3 -12
- package/dist/driver.d.ts +39 -0
- package/dist/driver.d.ts.map +1 -1
- package/dist/driver.js +64 -1
- package/dist/driver.js.map +1 -1
- package/dist/index.d.ts +731 -564
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +664 -574
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,661 +1,358 @@
|
|
|
1
|
-
//#region src/
|
|
2
|
-
|
|
1
|
+
//#region src/errors.ts
|
|
2
|
+
/** Thrown when a driver value cannot be represented without losing database information. */
|
|
3
|
+
var ResultExactnessError = class ResultExactnessError extends Error {
|
|
4
|
+
static {
|
|
5
|
+
this.code = "BRAID_RESULT_EXACTNESS";
|
|
6
|
+
}
|
|
7
|
+
constructor(message = "Result value does not have an exact representation.") {
|
|
8
|
+
super(message);
|
|
9
|
+
this.code = ResultExactnessError.code;
|
|
10
|
+
this.name = "ResultExactnessError";
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* The intentionally small compatibility boundary for SQLBraid-owned errors.
|
|
15
|
+
*
|
|
16
|
+
* Keep this registry explicit. In particular, a BRAID_ token in a driver
|
|
17
|
+
* message or an internal compiler fallback is not public merely because it
|
|
18
|
+
* happens to use the project prefix.
|
|
19
|
+
*/
|
|
20
|
+
const PUBLIC_ERROR_DEFINITIONS = Object.freeze([
|
|
3
21
|
{
|
|
4
|
-
|
|
5
|
-
|
|
22
|
+
code: "BRAID_RESULT_EXACTNESS",
|
|
23
|
+
category: "runtime",
|
|
24
|
+
owner: "ResultExactnessError"
|
|
6
25
|
},
|
|
7
26
|
{
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
27
|
+
code: "BRAID_CALL_MAP",
|
|
28
|
+
category: "runtime",
|
|
29
|
+
owner: "RoutineMappingError"
|
|
11
30
|
},
|
|
12
31
|
{
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
32
|
+
code: "BRAID_RESULT_KIND",
|
|
33
|
+
category: "runtime",
|
|
34
|
+
owner: "@sqlbraid/runtime:DatabaseResultKindError"
|
|
16
35
|
},
|
|
17
36
|
{
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
37
|
+
code: "BRAID_RESULT_VALIDATION",
|
|
38
|
+
category: "runtime",
|
|
39
|
+
owner: "@sqlbraid/runtime:DatabaseResultValidationError"
|
|
21
40
|
},
|
|
22
41
|
{
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
42
|
+
code: "BRAID_BATCH_ABORTED",
|
|
43
|
+
category: "runtime",
|
|
44
|
+
owner: "runtime batch lifecycle/synthetic observer error"
|
|
26
45
|
},
|
|
27
46
|
{
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
47
|
+
code: "BRAID_TX_SCOPE",
|
|
48
|
+
category: "runtime",
|
|
49
|
+
owner: "@sqlbraid/runtime:DatabaseScopeError"
|
|
31
50
|
},
|
|
32
51
|
{
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
52
|
+
code: "BRAID_TX_CLOSED",
|
|
53
|
+
category: "runtime",
|
|
54
|
+
owner: "@sqlbraid/runtime:DatabaseScopeError"
|
|
36
55
|
},
|
|
37
56
|
{
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
57
|
+
code: "BRAID_SESSION_SCOPE",
|
|
58
|
+
category: "runtime",
|
|
59
|
+
owner: "@sqlbraid/runtime:DatabaseScopeError"
|
|
41
60
|
},
|
|
42
61
|
{
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
62
|
+
code: "BRAID_SESSION_CLOSED",
|
|
63
|
+
category: "runtime",
|
|
64
|
+
owner: "@sqlbraid/runtime:DatabaseScopeError"
|
|
46
65
|
},
|
|
47
66
|
{
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
67
|
+
code: "BRAID_CONNECTION_POISONED",
|
|
68
|
+
category: "runtime",
|
|
69
|
+
owner: "@sqlbraid/runtime:DatabaseScopeError"
|
|
51
70
|
},
|
|
52
71
|
{
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
72
|
+
code: "BRAID_STREAM_SCOPE",
|
|
73
|
+
category: "runtime",
|
|
74
|
+
owner: "@sqlbraid/runtime:DatabaseScopeError"
|
|
56
75
|
},
|
|
57
76
|
{
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
77
|
+
code: "BRAID_REENTRY",
|
|
78
|
+
category: "runtime",
|
|
79
|
+
owner: "@sqlbraid/runtime:DatabaseScopeError"
|
|
61
80
|
},
|
|
62
81
|
{
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
82
|
+
code: "BRAID_TX_OPTIONS_NESTED",
|
|
83
|
+
category: "runtime",
|
|
84
|
+
owner: "@sqlbraid/runtime:DatabaseScopeError"
|
|
66
85
|
},
|
|
67
86
|
{
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
87
|
+
code: "BRAID_MIGRATE_SOURCE",
|
|
88
|
+
category: "runtime",
|
|
89
|
+
owner: "@sqlbraid/migrate:MigrationError"
|
|
71
90
|
},
|
|
72
91
|
{
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
92
|
+
code: "BRAID_MIGRATE_UNINITIALIZED",
|
|
93
|
+
category: "runtime",
|
|
94
|
+
owner: "@sqlbraid/migrate:MigrationStartupError"
|
|
76
95
|
},
|
|
77
96
|
{
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
97
|
+
code: "BRAID_MIGRATE_PENDING",
|
|
98
|
+
category: "runtime",
|
|
99
|
+
owner: "@sqlbraid/migrate:MigrationStartupError"
|
|
81
100
|
},
|
|
82
101
|
{
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
102
|
+
code: "BRAID_MIGRATE_AHEAD",
|
|
103
|
+
category: "runtime",
|
|
104
|
+
owner: "@sqlbraid/migrate:MigrationStartupError"
|
|
86
105
|
},
|
|
87
106
|
{
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
107
|
+
code: "BRAID_MIGRATE_CHECKSUM",
|
|
108
|
+
category: "runtime",
|
|
109
|
+
owner: "@sqlbraid/migrate:MigrationStartupError"
|
|
91
110
|
},
|
|
92
111
|
{
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
112
|
+
code: "BRAID_MIGRATE_ORDER",
|
|
113
|
+
category: "runtime",
|
|
114
|
+
owner: "@sqlbraid/migrate:MigrationError"
|
|
96
115
|
},
|
|
97
116
|
{
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
117
|
+
code: "BRAID_MIGRATE_DIRTY",
|
|
118
|
+
category: "runtime",
|
|
119
|
+
owner: "@sqlbraid/migrate:MigrationError"
|
|
101
120
|
},
|
|
102
121
|
{
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
122
|
+
code: "BRAID_MIGRATE_BUSY",
|
|
123
|
+
category: "runtime",
|
|
124
|
+
owner: "@sqlbraid/migrate:MigrationError"
|
|
106
125
|
},
|
|
107
126
|
{
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
}
|
|
112
|
-
].map((entry) => Object.freeze(entry)));
|
|
113
|
-
|
|
114
|
-
//#endregion
|
|
115
|
-
//#region src/capabilities.ts
|
|
116
|
-
const definitions = [
|
|
127
|
+
code: "BRAID_MIGRATE_SCHEMA_DRIFT",
|
|
128
|
+
category: "runtime",
|
|
129
|
+
owner: "@sqlbraid/migrate:MigrationStartupError"
|
|
130
|
+
},
|
|
117
131
|
{
|
|
118
|
-
|
|
119
|
-
|
|
132
|
+
code: "BRAID_CALL_UNSUPPORTED",
|
|
133
|
+
category: "adapter",
|
|
134
|
+
owner: "UnsupportedFeatureError",
|
|
135
|
+
features: ["routine.call"]
|
|
120
136
|
},
|
|
121
137
|
{
|
|
122
|
-
|
|
123
|
-
|
|
138
|
+
code: "BRAID_RESULT_SETS_UNSUPPORTED",
|
|
139
|
+
category: "adapter",
|
|
140
|
+
owner: "UnsupportedFeatureError",
|
|
141
|
+
features: ["routine.result-sets"]
|
|
124
142
|
},
|
|
125
143
|
{
|
|
126
|
-
|
|
127
|
-
|
|
144
|
+
code: "BRAID_STREAM_UNSUPPORTED",
|
|
145
|
+
category: "adapter",
|
|
146
|
+
owner: "UnsupportedFeatureError",
|
|
147
|
+
features: ["statement.stream"]
|
|
128
148
|
},
|
|
129
149
|
{
|
|
130
|
-
|
|
131
|
-
|
|
150
|
+
code: "BRAID_CANCEL_UNSUPPORTED",
|
|
151
|
+
category: "adapter",
|
|
152
|
+
owner: "UnsupportedFeatureError",
|
|
153
|
+
features: ["statement.cancel"]
|
|
132
154
|
},
|
|
133
155
|
{
|
|
134
|
-
|
|
135
|
-
|
|
156
|
+
code: "BRAID_SESSION_UNSUPPORTED",
|
|
157
|
+
category: "adapter",
|
|
158
|
+
owner: "UnsupportedFeatureError",
|
|
159
|
+
features: ["session.pinned"]
|
|
136
160
|
},
|
|
137
161
|
{
|
|
138
|
-
|
|
139
|
-
|
|
162
|
+
code: "BRAID_TX_UNSUPPORTED",
|
|
163
|
+
category: "adapter",
|
|
164
|
+
owner: "UnsupportedFeatureError",
|
|
165
|
+
features: ["transaction", "transaction.savepoint"]
|
|
140
166
|
},
|
|
141
167
|
{
|
|
142
|
-
|
|
143
|
-
|
|
168
|
+
code: "BRAID_TX_OPTIONS_INVALID",
|
|
169
|
+
category: "runtime",
|
|
170
|
+
owner: "TypeError with code"
|
|
144
171
|
},
|
|
145
172
|
{
|
|
146
|
-
|
|
147
|
-
|
|
173
|
+
code: "BRAID_TX_OPTION_UNSUPPORTED",
|
|
174
|
+
category: "adapter",
|
|
175
|
+
owner: "UnsupportedFeatureError",
|
|
176
|
+
features: [
|
|
177
|
+
"transaction.read-only",
|
|
178
|
+
"transaction.isolation.read-uncommitted",
|
|
179
|
+
"transaction.isolation.read-committed",
|
|
180
|
+
"transaction.isolation.repeatable-read",
|
|
181
|
+
"transaction.isolation.serializable"
|
|
182
|
+
]
|
|
148
183
|
},
|
|
149
184
|
{
|
|
150
|
-
|
|
151
|
-
|
|
185
|
+
code: "BRAID_CALL_RESULT_SETS",
|
|
186
|
+
category: "adapter",
|
|
187
|
+
owner: "UnsupportedFeatureError",
|
|
188
|
+
features: ["routine.result-sets"]
|
|
152
189
|
},
|
|
153
190
|
{
|
|
154
|
-
|
|
155
|
-
|
|
191
|
+
code: "BRAID_CALL_CURSOR_TX_REQUIRED",
|
|
192
|
+
category: "adapter",
|
|
193
|
+
owner: "UnsupportedFeatureError",
|
|
194
|
+
features: ["routine.out-cursor"]
|
|
156
195
|
},
|
|
157
196
|
{
|
|
158
|
-
|
|
159
|
-
|
|
197
|
+
code: "BRAID_CALL_OUT_UNSUPPORTED",
|
|
198
|
+
category: "adapter",
|
|
199
|
+
owner: "UnsupportedFeatureError",
|
|
200
|
+
features: ["routine.out", "routine.inout"]
|
|
160
201
|
},
|
|
161
202
|
{
|
|
162
|
-
|
|
163
|
-
|
|
203
|
+
code: "BRAID_CALL_RETURN_UNSUPPORTED",
|
|
204
|
+
category: "adapter",
|
|
205
|
+
owner: "UnsupportedFeatureError",
|
|
206
|
+
features: ["routine.return-value"]
|
|
164
207
|
},
|
|
165
208
|
{
|
|
166
|
-
|
|
167
|
-
|
|
209
|
+
code: "BRAID_CALL_PROCEDURE_INVALID",
|
|
210
|
+
category: "adapter",
|
|
211
|
+
owner: "AdapterError"
|
|
168
212
|
},
|
|
169
213
|
{
|
|
170
|
-
|
|
171
|
-
|
|
214
|
+
code: "BRAID_CALL_CURSOR_UNSUPPORTED",
|
|
215
|
+
category: "adapter",
|
|
216
|
+
owner: "UnsupportedFeatureError",
|
|
217
|
+
features: ["routine.out-cursor"]
|
|
172
218
|
},
|
|
173
219
|
{
|
|
174
|
-
|
|
175
|
-
|
|
220
|
+
code: "BRAID_RESOURCE_CLEANUP",
|
|
221
|
+
category: "adapter",
|
|
222
|
+
owner: "adapter cleanup error with code",
|
|
223
|
+
features: ["resource.cleanup", "resource.discard"]
|
|
176
224
|
},
|
|
177
225
|
{
|
|
178
|
-
|
|
179
|
-
|
|
226
|
+
code: "BRAID_BIND_HINT_UNSUPPORTED",
|
|
227
|
+
category: "adapter",
|
|
228
|
+
owner: "UnsupportedFeatureError",
|
|
229
|
+
features: ["statement.bind-hint"]
|
|
180
230
|
},
|
|
181
231
|
{
|
|
182
|
-
|
|
183
|
-
|
|
232
|
+
code: "BRAID_BIND_VALUE_UNSUPPORTED",
|
|
233
|
+
category: "adapter",
|
|
234
|
+
owner: "AdapterError"
|
|
184
235
|
},
|
|
185
236
|
{
|
|
186
|
-
|
|
187
|
-
|
|
237
|
+
code: "BRAID_INTEGER_MODE_UNSUPPORTED",
|
|
238
|
+
category: "adapter",
|
|
239
|
+
owner: "UnsupportedFeatureError",
|
|
240
|
+
features: ["result.exact-integer"]
|
|
188
241
|
},
|
|
189
242
|
{
|
|
190
|
-
|
|
191
|
-
|
|
243
|
+
code: "BRAID_CALL_LOB_UNSUPPORTED",
|
|
244
|
+
category: "adapter",
|
|
245
|
+
owner: "UnsupportedFeatureError",
|
|
246
|
+
features: ["routine.out"]
|
|
192
247
|
},
|
|
193
248
|
{
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
id: "data.oracle-collection",
|
|
199
|
-
family: "representation"
|
|
200
|
-
},
|
|
201
|
-
{
|
|
202
|
-
id: "data.vector",
|
|
203
|
-
family: "representation"
|
|
204
|
-
},
|
|
205
|
-
{
|
|
206
|
-
id: "data.binary",
|
|
207
|
-
family: "representation"
|
|
208
|
-
},
|
|
209
|
-
{
|
|
210
|
-
id: "data.uuid",
|
|
211
|
-
family: "representation"
|
|
212
|
-
},
|
|
213
|
-
{
|
|
214
|
-
id: "data.temporal-native",
|
|
215
|
-
family: "representation"
|
|
216
|
-
},
|
|
217
|
-
{
|
|
218
|
-
id: "data.temporal-lossless",
|
|
219
|
-
family: "representation"
|
|
220
|
-
},
|
|
221
|
-
{
|
|
222
|
-
id: "data.timezone",
|
|
223
|
-
family: "representation"
|
|
224
|
-
},
|
|
225
|
-
{
|
|
226
|
-
id: "metadata.command-safe",
|
|
227
|
-
family: "metadata"
|
|
228
|
-
},
|
|
229
|
-
{
|
|
230
|
-
id: "dml.insert-returning",
|
|
231
|
-
family: "support"
|
|
232
|
-
},
|
|
233
|
-
{
|
|
234
|
-
id: "dml.update-returning",
|
|
235
|
-
family: "support"
|
|
236
|
-
},
|
|
237
|
-
{
|
|
238
|
-
id: "dml.delete-returning",
|
|
239
|
-
family: "support"
|
|
240
|
-
},
|
|
241
|
-
{
|
|
242
|
-
id: "dml.merge-returning",
|
|
243
|
-
family: "support"
|
|
244
|
-
},
|
|
245
|
-
{
|
|
246
|
-
id: "dml.upsert-returning",
|
|
247
|
-
family: "support"
|
|
248
|
-
},
|
|
249
|
-
{
|
|
250
|
-
id: "session.pinned",
|
|
251
|
-
family: "support"
|
|
252
|
-
},
|
|
253
|
-
{
|
|
254
|
-
id: "statement.prepare",
|
|
255
|
-
family: "support"
|
|
256
|
-
},
|
|
257
|
-
{
|
|
258
|
-
id: "statement.cancel",
|
|
259
|
-
family: "support"
|
|
260
|
-
},
|
|
261
|
-
{
|
|
262
|
-
id: "statement.stream",
|
|
263
|
-
family: "support"
|
|
264
|
-
},
|
|
265
|
-
{
|
|
266
|
-
id: "statement.bulk",
|
|
267
|
-
family: "support"
|
|
268
|
-
},
|
|
269
|
-
{
|
|
270
|
-
id: "execution.bulk-fidelity",
|
|
271
|
-
family: "support"
|
|
272
|
-
},
|
|
273
|
-
{
|
|
274
|
-
id: "transaction",
|
|
275
|
-
family: "support"
|
|
276
|
-
},
|
|
277
|
-
{
|
|
278
|
-
id: "transaction.savepoint",
|
|
279
|
-
family: "support"
|
|
280
|
-
},
|
|
281
|
-
{
|
|
282
|
-
id: "transaction.read-only",
|
|
283
|
-
family: "support"
|
|
284
|
-
},
|
|
285
|
-
{
|
|
286
|
-
id: "transaction.isolation.read-uncommitted",
|
|
287
|
-
family: "support"
|
|
288
|
-
},
|
|
289
|
-
{
|
|
290
|
-
id: "transaction.isolation.read-committed",
|
|
291
|
-
family: "support"
|
|
292
|
-
},
|
|
293
|
-
{
|
|
294
|
-
id: "transaction.isolation.repeatable-read",
|
|
295
|
-
family: "support"
|
|
296
|
-
},
|
|
297
|
-
{
|
|
298
|
-
id: "transaction.isolation.serializable",
|
|
299
|
-
family: "support"
|
|
300
|
-
},
|
|
301
|
-
{
|
|
302
|
-
id: "routine.call",
|
|
303
|
-
family: "support"
|
|
304
|
-
},
|
|
305
|
-
{
|
|
306
|
-
id: "routine.out",
|
|
307
|
-
family: "support"
|
|
308
|
-
},
|
|
309
|
-
{
|
|
310
|
-
id: "routine.inout",
|
|
311
|
-
family: "support"
|
|
249
|
+
code: "BRAID_BULK_UNSUPPORTED",
|
|
250
|
+
category: "adapter",
|
|
251
|
+
owner: "UnsupportedFeatureError",
|
|
252
|
+
features: ["statement.bulk"]
|
|
312
253
|
},
|
|
313
254
|
{
|
|
314
|
-
|
|
315
|
-
|
|
255
|
+
code: "BRAID_PREPARE_UNSUPPORTED",
|
|
256
|
+
category: "adapter",
|
|
257
|
+
owner: "UnsupportedFeatureError",
|
|
258
|
+
features: ["statement.prepare"]
|
|
316
259
|
},
|
|
317
260
|
{
|
|
318
|
-
|
|
319
|
-
|
|
261
|
+
code: "BRAID_DIALECT_MISMATCH",
|
|
262
|
+
category: "adapter",
|
|
263
|
+
owner: "UnsupportedFeatureError",
|
|
264
|
+
features: ["dialect"]
|
|
320
265
|
},
|
|
321
266
|
{
|
|
322
|
-
|
|
323
|
-
|
|
267
|
+
code: "BRAID_RESULT_KIND_AMBIGUOUS",
|
|
268
|
+
category: "adapter",
|
|
269
|
+
owner: "UnsupportedFeatureError",
|
|
270
|
+
features: ["result.rows", "result.command"]
|
|
324
271
|
},
|
|
325
272
|
{
|
|
326
|
-
|
|
327
|
-
|
|
273
|
+
code: "BRAID_PREPARED_NAME",
|
|
274
|
+
category: "runtime",
|
|
275
|
+
owner: "prepared query validation"
|
|
328
276
|
},
|
|
329
277
|
{
|
|
330
|
-
|
|
331
|
-
|
|
278
|
+
code: "BRAID_PREPARED_SHAPE",
|
|
279
|
+
category: "runtime",
|
|
280
|
+
owner: "prepared query validation"
|
|
332
281
|
},
|
|
333
282
|
{
|
|
334
|
-
|
|
335
|
-
|
|
283
|
+
code: "BRAID_BIND_TYPE_REQUIRED",
|
|
284
|
+
category: "adapter",
|
|
285
|
+
owner: "AdapterError"
|
|
336
286
|
},
|
|
337
287
|
{
|
|
338
|
-
|
|
339
|
-
family: "metadata"
|
|
340
|
-
}
|
|
341
|
-
];
|
|
342
|
-
const WELL_KNOWN_CAPABILITIES = Object.freeze(definitions.map((entry) => Object.freeze(entry)));
|
|
343
|
-
const WELL_KNOWN_CAPABILITY_IDS = Object.freeze(definitions.map(({ id }) => id));
|
|
344
|
-
const wellKnownCapabilityIds = new Set(WELL_KNOWN_CAPABILITY_IDS);
|
|
345
|
-
function isWellKnownCapabilityId(value) {
|
|
346
|
-
return wellKnownCapabilityIds.has(value);
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
//#endregion
|
|
350
|
-
//#region src/index.ts
|
|
351
|
-
const SQL_FRAGMENT = Symbol.for("sqlbraid.fragment");
|
|
352
|
-
const SQL_BOUND_PARAMETER = Symbol.for("sqlbraid.bound-parameter");
|
|
353
|
-
const knownBoundParameters = /* @__PURE__ */ new WeakSet();
|
|
354
|
-
const SQL_ROUTINE_PARAMETER = Symbol.for("sqlbraid.routine-parameter");
|
|
355
|
-
const knownRoutineParameters = /* @__PURE__ */ new WeakSet();
|
|
356
|
-
var ResultExactnessError = class ResultExactnessError extends Error {
|
|
357
|
-
static {
|
|
358
|
-
this.code = "BRAID_RESULT_EXACTNESS";
|
|
359
|
-
}
|
|
360
|
-
constructor(message = "Result value does not have an exact representation.") {
|
|
361
|
-
super(message);
|
|
362
|
-
this.code = ResultExactnessError.code;
|
|
363
|
-
this.name = "ResultExactnessError";
|
|
364
|
-
}
|
|
365
|
-
};
|
|
366
|
-
/**
|
|
367
|
-
* The intentionally small compatibility boundary for SQLBraid-owned errors.
|
|
368
|
-
*
|
|
369
|
-
* Keep this registry explicit. In particular, a BRAID_ token in a driver
|
|
370
|
-
* message or an internal compiler fallback is not public merely because it
|
|
371
|
-
* happens to use the project prefix.
|
|
372
|
-
*/
|
|
373
|
-
const PUBLIC_ERROR_DEFINITIONS = Object.freeze([
|
|
374
|
-
{
|
|
375
|
-
code: "BRAID_RESULT_EXACTNESS",
|
|
288
|
+
code: "BRAID_EMPTY_LIST",
|
|
376
289
|
category: "runtime",
|
|
377
|
-
owner: "
|
|
290
|
+
owner: "SqlRenderError"
|
|
378
291
|
},
|
|
379
292
|
{
|
|
380
|
-
code: "
|
|
293
|
+
code: "BRAID_EMPTY_SET",
|
|
381
294
|
category: "runtime",
|
|
382
|
-
owner: "
|
|
295
|
+
owner: "SqlRenderError"
|
|
383
296
|
},
|
|
384
297
|
{
|
|
385
|
-
code: "
|
|
298
|
+
code: "BRAID_DIALECT",
|
|
386
299
|
category: "runtime",
|
|
387
|
-
owner: "
|
|
300
|
+
owner: "SqlRenderError"
|
|
388
301
|
},
|
|
389
302
|
{
|
|
390
|
-
code: "
|
|
391
|
-
category: "
|
|
392
|
-
owner: "
|
|
303
|
+
code: "BRAID_ASYNC_CONTEXT",
|
|
304
|
+
category: "compiler",
|
|
305
|
+
owner: "compiler diagnostic"
|
|
393
306
|
},
|
|
394
307
|
{
|
|
395
|
-
code: "
|
|
308
|
+
code: "BRAID_DIRECTIVE_UNTERMINATED",
|
|
396
309
|
category: "runtime",
|
|
397
|
-
owner: "
|
|
310
|
+
owner: "SqlRenderError"
|
|
398
311
|
},
|
|
399
312
|
{
|
|
400
|
-
code: "
|
|
313
|
+
code: "BRAID_DIRECTIVE",
|
|
401
314
|
category: "runtime",
|
|
402
|
-
owner: "
|
|
315
|
+
owner: "SqlRenderError"
|
|
403
316
|
},
|
|
404
317
|
{
|
|
405
|
-
code: "
|
|
318
|
+
code: "BRAID_CONDITION",
|
|
406
319
|
category: "runtime",
|
|
407
|
-
owner: "
|
|
320
|
+
owner: "SqlRenderError"
|
|
408
321
|
},
|
|
409
322
|
{
|
|
410
|
-
code: "
|
|
323
|
+
code: "BRAID_ATTRIBUTES",
|
|
411
324
|
category: "runtime",
|
|
412
|
-
owner: "
|
|
325
|
+
owner: "SqlRenderError"
|
|
413
326
|
},
|
|
414
327
|
{
|
|
415
|
-
code: "
|
|
328
|
+
code: "BRAID_STRUCTURE",
|
|
416
329
|
category: "runtime",
|
|
417
|
-
owner: "
|
|
330
|
+
owner: "SqlRenderError"
|
|
418
331
|
},
|
|
419
332
|
{
|
|
420
|
-
code: "
|
|
333
|
+
code: "BRAID_HOLE_CONTEXT",
|
|
421
334
|
category: "runtime",
|
|
422
|
-
owner: "
|
|
335
|
+
owner: "SqlRenderError"
|
|
423
336
|
},
|
|
424
337
|
{
|
|
425
|
-
code: "
|
|
338
|
+
code: "BRAID_SQL_LEX",
|
|
426
339
|
category: "runtime",
|
|
427
|
-
owner: "
|
|
340
|
+
owner: "SqlRenderError"
|
|
428
341
|
},
|
|
429
342
|
{
|
|
430
|
-
code: "
|
|
343
|
+
code: "BRAID_DEPTH",
|
|
431
344
|
category: "runtime",
|
|
432
|
-
owner: "
|
|
345
|
+
owner: "SqlRenderError"
|
|
433
346
|
},
|
|
434
347
|
{
|
|
435
|
-
code: "
|
|
348
|
+
code: "BRAID_STRUCTURE_LIMIT",
|
|
436
349
|
category: "runtime",
|
|
437
|
-
owner: "
|
|
350
|
+
owner: "SqlRenderError"
|
|
438
351
|
},
|
|
439
352
|
{
|
|
440
|
-
code: "
|
|
441
|
-
category: "
|
|
442
|
-
owner: "
|
|
443
|
-
features: ["routine.call"]
|
|
444
|
-
},
|
|
445
|
-
{
|
|
446
|
-
code: "BRAID_RESULT_SETS_UNSUPPORTED",
|
|
447
|
-
category: "adapter",
|
|
448
|
-
owner: "UnsupportedFeatureError",
|
|
449
|
-
features: ["routine.result-sets"]
|
|
450
|
-
},
|
|
451
|
-
{
|
|
452
|
-
code: "BRAID_STREAM_UNSUPPORTED",
|
|
453
|
-
category: "adapter",
|
|
454
|
-
owner: "UnsupportedFeatureError",
|
|
455
|
-
features: ["statement.stream"]
|
|
456
|
-
},
|
|
457
|
-
{
|
|
458
|
-
code: "BRAID_CANCEL_UNSUPPORTED",
|
|
459
|
-
category: "adapter",
|
|
460
|
-
owner: "UnsupportedFeatureError",
|
|
461
|
-
features: ["statement.cancel"]
|
|
462
|
-
},
|
|
463
|
-
{
|
|
464
|
-
code: "BRAID_SESSION_UNSUPPORTED",
|
|
465
|
-
category: "adapter",
|
|
466
|
-
owner: "UnsupportedFeatureError",
|
|
467
|
-
features: ["session.pinned"]
|
|
468
|
-
},
|
|
469
|
-
{
|
|
470
|
-
code: "BRAID_TX_UNSUPPORTED",
|
|
471
|
-
category: "adapter",
|
|
472
|
-
owner: "UnsupportedFeatureError",
|
|
473
|
-
features: ["transaction", "transaction.savepoint"]
|
|
474
|
-
},
|
|
475
|
-
{
|
|
476
|
-
code: "BRAID_TX_OPTIONS_INVALID",
|
|
477
|
-
category: "runtime",
|
|
478
|
-
owner: "TypeError with code"
|
|
479
|
-
},
|
|
480
|
-
{
|
|
481
|
-
code: "BRAID_TX_OPTION_UNSUPPORTED",
|
|
482
|
-
category: "adapter",
|
|
483
|
-
owner: "UnsupportedFeatureError",
|
|
484
|
-
features: [
|
|
485
|
-
"transaction.read-only",
|
|
486
|
-
"transaction.isolation.read-uncommitted",
|
|
487
|
-
"transaction.isolation.read-committed",
|
|
488
|
-
"transaction.isolation.repeatable-read",
|
|
489
|
-
"transaction.isolation.serializable"
|
|
490
|
-
]
|
|
491
|
-
},
|
|
492
|
-
{
|
|
493
|
-
code: "BRAID_CALL_RESULT_SETS",
|
|
494
|
-
category: "adapter",
|
|
495
|
-
owner: "UnsupportedFeatureError",
|
|
496
|
-
features: ["routine.result-sets"]
|
|
497
|
-
},
|
|
498
|
-
{
|
|
499
|
-
code: "BRAID_CALL_CURSOR_TX_REQUIRED",
|
|
500
|
-
category: "adapter",
|
|
501
|
-
owner: "UnsupportedFeatureError",
|
|
502
|
-
features: ["routine.out-cursor"]
|
|
503
|
-
},
|
|
504
|
-
{
|
|
505
|
-
code: "BRAID_CALL_OUT_UNSUPPORTED",
|
|
506
|
-
category: "adapter",
|
|
507
|
-
owner: "UnsupportedFeatureError",
|
|
508
|
-
features: ["routine.out", "routine.inout"]
|
|
509
|
-
},
|
|
510
|
-
{
|
|
511
|
-
code: "BRAID_CALL_RETURN_UNSUPPORTED",
|
|
512
|
-
category: "adapter",
|
|
513
|
-
owner: "UnsupportedFeatureError",
|
|
514
|
-
features: ["routine.call", "routine.return-value"]
|
|
515
|
-
},
|
|
516
|
-
{
|
|
517
|
-
code: "BRAID_CALL_CURSOR_UNSUPPORTED",
|
|
518
|
-
category: "adapter",
|
|
519
|
-
owner: "UnsupportedFeatureError",
|
|
520
|
-
features: ["routine.out-cursor"]
|
|
521
|
-
},
|
|
522
|
-
{
|
|
523
|
-
code: "BRAID_RESOURCE_CLEANUP",
|
|
524
|
-
category: "adapter",
|
|
525
|
-
owner: "adapter cleanup error with code",
|
|
526
|
-
features: ["resource.cleanup", "resource.discard"]
|
|
527
|
-
},
|
|
528
|
-
{
|
|
529
|
-
code: "BRAID_BIND_HINT_UNSUPPORTED",
|
|
530
|
-
category: "adapter",
|
|
531
|
-
owner: "UnsupportedFeatureError",
|
|
532
|
-
features: ["statement.bind-hint"]
|
|
533
|
-
},
|
|
534
|
-
{
|
|
535
|
-
code: "BRAID_BIND_VALUE_UNSUPPORTED",
|
|
536
|
-
category: "adapter",
|
|
537
|
-
owner: "AdapterError"
|
|
538
|
-
},
|
|
539
|
-
{
|
|
540
|
-
code: "BRAID_INTEGER_MODE_UNSUPPORTED",
|
|
541
|
-
category: "adapter",
|
|
542
|
-
owner: "UnsupportedFeatureError",
|
|
543
|
-
features: ["result.exact-integer"]
|
|
544
|
-
},
|
|
545
|
-
{
|
|
546
|
-
code: "BRAID_CALL_LOB_UNSUPPORTED",
|
|
547
|
-
category: "adapter",
|
|
548
|
-
owner: "UnsupportedFeatureError",
|
|
549
|
-
features: ["routine.out"]
|
|
550
|
-
},
|
|
551
|
-
{
|
|
552
|
-
code: "BRAID_BULK_UNSUPPORTED",
|
|
553
|
-
category: "adapter",
|
|
554
|
-
owner: "UnsupportedFeatureError",
|
|
555
|
-
features: ["statement.bulk"]
|
|
556
|
-
},
|
|
557
|
-
{
|
|
558
|
-
code: "BRAID_PREPARE_UNSUPPORTED",
|
|
559
|
-
category: "adapter",
|
|
560
|
-
owner: "UnsupportedFeatureError",
|
|
561
|
-
features: ["statement.prepare"]
|
|
562
|
-
},
|
|
563
|
-
{
|
|
564
|
-
code: "BRAID_DIALECT_MISMATCH",
|
|
565
|
-
category: "adapter",
|
|
566
|
-
owner: "UnsupportedFeatureError",
|
|
567
|
-
features: ["dialect"]
|
|
568
|
-
},
|
|
569
|
-
{
|
|
570
|
-
code: "BRAID_RESULT_KIND_AMBIGUOUS",
|
|
571
|
-
category: "adapter",
|
|
572
|
-
owner: "UnsupportedFeatureError",
|
|
573
|
-
features: ["result.rows", "result.command"]
|
|
574
|
-
},
|
|
575
|
-
{
|
|
576
|
-
code: "BRAID_PREPARED_NAME",
|
|
577
|
-
category: "runtime",
|
|
578
|
-
owner: "prepared query validation"
|
|
579
|
-
},
|
|
580
|
-
{
|
|
581
|
-
code: "BRAID_PREPARED_SHAPE",
|
|
582
|
-
category: "runtime",
|
|
583
|
-
owner: "prepared query validation"
|
|
584
|
-
},
|
|
585
|
-
{
|
|
586
|
-
code: "BRAID_BIND_TYPE_REQUIRED",
|
|
587
|
-
category: "adapter",
|
|
588
|
-
owner: "AdapterError"
|
|
589
|
-
},
|
|
590
|
-
{
|
|
591
|
-
code: "BRAID_EMPTY_LIST",
|
|
592
|
-
category: "runtime",
|
|
593
|
-
owner: "SqlRenderError"
|
|
594
|
-
},
|
|
595
|
-
{
|
|
596
|
-
code: "BRAID_EMPTY_SET",
|
|
597
|
-
category: "runtime",
|
|
598
|
-
owner: "SqlRenderError"
|
|
599
|
-
},
|
|
600
|
-
{
|
|
601
|
-
code: "BRAID_DIALECT",
|
|
602
|
-
category: "runtime",
|
|
603
|
-
owner: "SqlRenderError"
|
|
604
|
-
},
|
|
605
|
-
{
|
|
606
|
-
code: "BRAID_ASYNC_CONTEXT",
|
|
607
|
-
category: "compiler",
|
|
608
|
-
owner: "compiler diagnostic"
|
|
609
|
-
},
|
|
610
|
-
{
|
|
611
|
-
code: "BRAID_DIRECTIVE_UNTERMINATED",
|
|
612
|
-
category: "runtime",
|
|
613
|
-
owner: "SqlRenderError"
|
|
614
|
-
},
|
|
615
|
-
{
|
|
616
|
-
code: "BRAID_DIRECTIVE",
|
|
617
|
-
category: "runtime",
|
|
618
|
-
owner: "SqlRenderError"
|
|
619
|
-
},
|
|
620
|
-
{
|
|
621
|
-
code: "BRAID_CONDITION",
|
|
622
|
-
category: "runtime",
|
|
623
|
-
owner: "SqlRenderError"
|
|
624
|
-
},
|
|
625
|
-
{
|
|
626
|
-
code: "BRAID_ATTRIBUTES",
|
|
627
|
-
category: "runtime",
|
|
628
|
-
owner: "SqlRenderError"
|
|
629
|
-
},
|
|
630
|
-
{
|
|
631
|
-
code: "BRAID_STRUCTURE",
|
|
632
|
-
category: "runtime",
|
|
633
|
-
owner: "SqlRenderError"
|
|
634
|
-
},
|
|
635
|
-
{
|
|
636
|
-
code: "BRAID_HOLE_CONTEXT",
|
|
637
|
-
category: "runtime",
|
|
638
|
-
owner: "SqlRenderError"
|
|
639
|
-
},
|
|
640
|
-
{
|
|
641
|
-
code: "BRAID_SQL_LEX",
|
|
642
|
-
category: "runtime",
|
|
643
|
-
owner: "SqlRenderError"
|
|
644
|
-
},
|
|
645
|
-
{
|
|
646
|
-
code: "BRAID_DEPTH",
|
|
647
|
-
category: "runtime",
|
|
648
|
-
owner: "SqlRenderError"
|
|
649
|
-
},
|
|
650
|
-
{
|
|
651
|
-
code: "BRAID_STRUCTURE_LIMIT",
|
|
652
|
-
category: "runtime",
|
|
653
|
-
owner: "SqlRenderError"
|
|
654
|
-
},
|
|
655
|
-
{
|
|
656
|
-
code: "BRAID_SQL_LIMIT",
|
|
657
|
-
category: "runtime",
|
|
658
|
-
owner: "SqlRenderError"
|
|
353
|
+
code: "BRAID_SQL_LIMIT",
|
|
354
|
+
category: "runtime",
|
|
355
|
+
owner: "SqlRenderError"
|
|
659
356
|
},
|
|
660
357
|
{
|
|
661
358
|
code: "BRAID_BIND_LIMIT",
|
|
@@ -663,9 +360,47 @@ const PUBLIC_ERROR_DEFINITIONS = Object.freeze([
|
|
|
663
360
|
owner: "SqlRenderError"
|
|
664
361
|
}
|
|
665
362
|
]);
|
|
363
|
+
/** Public adapter capability failure. Unsupported features reject explicitly rather than being buffered or simulated. */
|
|
364
|
+
var UnsupportedFeatureError = class extends Error {
|
|
365
|
+
constructor(feature, code, message, options) {
|
|
366
|
+
super(`${code}: ${message}`, options);
|
|
367
|
+
this.feature = feature;
|
|
368
|
+
this.code = code;
|
|
369
|
+
this.name = "UnsupportedFeatureError";
|
|
370
|
+
}
|
|
371
|
+
};
|
|
372
|
+
/** Return true only for a registered, semantically valid feature/code pair. */
|
|
373
|
+
function isPublicUnsupportedFeatureError(error) {
|
|
374
|
+
if (!(error instanceof UnsupportedFeatureError)) return false;
|
|
375
|
+
return PUBLIC_ERROR_DEFINITIONS.find((candidate) => candidate.owner === "UnsupportedFeatureError" && candidate.code === error.code)?.features?.includes(error.feature) === true;
|
|
376
|
+
}
|
|
377
|
+
/** An adapter-owned input/transport failure that retains TypeError semantics. */
|
|
378
|
+
var AdapterError = class extends TypeError {
|
|
379
|
+
constructor(code, message, options) {
|
|
380
|
+
super(`${code}: ${message}`, options);
|
|
381
|
+
this.code = code;
|
|
382
|
+
this.name = "AdapterError";
|
|
383
|
+
}
|
|
384
|
+
};
|
|
385
|
+
/** Rendering/authoring failure with a stable diagnostic code, raised before driver execution. */
|
|
386
|
+
var SqlRenderError = class extends Error {
|
|
387
|
+
constructor(code, message) {
|
|
388
|
+
super(message);
|
|
389
|
+
this.name = "SqlRenderError";
|
|
390
|
+
this.code = code;
|
|
391
|
+
}
|
|
392
|
+
};
|
|
393
|
+
|
|
394
|
+
//#endregion
|
|
395
|
+
//#region src/numeric.ts
|
|
666
396
|
function exactnessFailure(message) {
|
|
667
397
|
throw new ResultExactnessError(message);
|
|
668
398
|
}
|
|
399
|
+
/**
|
|
400
|
+
* Decode an exact integer from driver output, optionally enforcing bigint bounds.
|
|
401
|
+
*
|
|
402
|
+
* @throws {ResultExactnessError} When the value is not an exact integer or violates the requested range.
|
|
403
|
+
*/
|
|
669
404
|
function decodeExactInteger(value, range) {
|
|
670
405
|
let result;
|
|
671
406
|
if (typeof value === "bigint") result = value;
|
|
@@ -714,12 +449,24 @@ function safeDatabaseCount(value) {
|
|
|
714
449
|
} catch {}
|
|
715
450
|
return exactnessFailure("Database count is not a safe non-negative integer.");
|
|
716
451
|
}
|
|
452
|
+
/**
|
|
453
|
+
* Preserve an exact decimal as text; numeric JavaScript values are rejected because they may already be rounded.
|
|
454
|
+
*
|
|
455
|
+
* @throws {ResultExactnessError} When the value cannot prove exact decimal fidelity.
|
|
456
|
+
*/
|
|
717
457
|
function decodeExactDecimal(value, options) {
|
|
718
458
|
if (typeof value === "string") return value;
|
|
719
459
|
if (typeof value === "bigint" && options?.allowBigInt === true) return value.toString();
|
|
720
460
|
return exactnessFailure("Result value does not have an exact decimal representation.");
|
|
721
461
|
}
|
|
722
|
-
|
|
462
|
+
|
|
463
|
+
//#endregion
|
|
464
|
+
//#region src/parameter.ts
|
|
465
|
+
const SQL_BOUND_PARAMETER = Symbol.for("sqlbraid.bound-parameter");
|
|
466
|
+
const knownBoundParameters = /* @__PURE__ */ new WeakSet();
|
|
467
|
+
const SQL_ROUTINE_PARAMETER = Symbol.for("sqlbraid.routine-parameter");
|
|
468
|
+
const knownRoutineParameters = /* @__PURE__ */ new WeakSet();
|
|
469
|
+
function validHintNumber$1(value) {
|
|
723
470
|
return typeof value === "number" && Number.isFinite(value) && Number.isInteger(value) && value >= 0;
|
|
724
471
|
}
|
|
725
472
|
function validHintInteger(value) {
|
|
@@ -728,14 +475,15 @@ function validHintInteger(value) {
|
|
|
728
475
|
function isParameterTypeHint(value) {
|
|
729
476
|
if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
|
|
730
477
|
const candidate = value;
|
|
731
|
-
return typeof candidate.databaseType === "string" && candidate.databaseType.trim().length > 0 && (candidate.length === void 0 || candidate.length === "max" || validHintNumber(candidate.length)) && (candidate.precision === void 0 || validHintNumber(candidate.precision)) && (candidate.scale === void 0 || validHintInteger(candidate.scale));
|
|
478
|
+
return typeof candidate.databaseType === "string" && candidate.databaseType.trim().length > 0 && (candidate.length === void 0 || candidate.length === "max" || validHintNumber$1(candidate.length)) && (candidate.precision === void 0 || validHintNumber$1(candidate.precision)) && (candidate.scale === void 0 || validHintInteger(candidate.scale));
|
|
732
479
|
}
|
|
480
|
+
/** Validate and freeze an explicit database parameter-type hint. */
|
|
733
481
|
function createParameterTypeHint(hint) {
|
|
734
482
|
if (!isParameterTypeHint(hint)) throw new TypeError("sql.bind hint must be an object with valid structural fields.");
|
|
735
483
|
const candidate = hint;
|
|
736
484
|
if (typeof candidate.databaseType !== "string" || !candidate.databaseType.trim()) throw new TypeError("sql.bind hint databaseType must be a non-empty string.");
|
|
737
|
-
if (candidate.length !== void 0 && candidate.length !== "max" && !validHintNumber(candidate.length)) throw new TypeError("sql.bind hint length must be a non-negative integer or \"max\".");
|
|
738
|
-
if (candidate.precision !== void 0 && !validHintNumber(candidate.precision)) throw new TypeError("sql.bind hint precision must be a non-negative integer.");
|
|
485
|
+
if (candidate.length !== void 0 && candidate.length !== "max" && !validHintNumber$1(candidate.length)) throw new TypeError("sql.bind hint length must be a non-negative integer or \"max\".");
|
|
486
|
+
if (candidate.precision !== void 0 && !validHintNumber$1(candidate.precision)) throw new TypeError("sql.bind hint precision must be a non-negative integer.");
|
|
739
487
|
if (candidate.scale !== void 0 && !validHintInteger(candidate.scale)) throw new TypeError("sql.bind hint scale must be an integer.");
|
|
740
488
|
const normalized = {
|
|
741
489
|
databaseType: candidate.databaseType,
|
|
@@ -745,6 +493,7 @@ function createParameterTypeHint(hint) {
|
|
|
745
493
|
};
|
|
746
494
|
return Object.freeze(normalized);
|
|
747
495
|
}
|
|
496
|
+
/** Create the value-only marker consumed by adapter binding for an explicitly typed input. */
|
|
748
497
|
function createBoundParameter(value, hint) {
|
|
749
498
|
const normalizedHint = createParameterTypeHint(hint);
|
|
750
499
|
const bound = Object.freeze({
|
|
@@ -755,6 +504,7 @@ function createBoundParameter(value, hint) {
|
|
|
755
504
|
knownBoundParameters.add(bound);
|
|
756
505
|
return bound;
|
|
757
506
|
}
|
|
507
|
+
/** Recognize only bound-parameter objects created by SQLBraid's own constructor. */
|
|
758
508
|
function isBoundParameter(value) {
|
|
759
509
|
if (typeof value !== "object" || value === null || !knownBoundParameters.has(value) || !Object.hasOwn(value, SQL_BOUND_PARAMETER)) return false;
|
|
760
510
|
const candidate = value;
|
|
@@ -764,6 +514,7 @@ function normalizeOutputName(name) {
|
|
|
764
514
|
if (typeof name !== "string" || !name.trim()) throw new TypeError("Routine outputName must be a non-empty string.");
|
|
765
515
|
return name;
|
|
766
516
|
}
|
|
517
|
+
/** Create a value-only OUT parameter descriptor; the adapter supplies the native carrier. */
|
|
767
518
|
function createRoutineOutParameter(name, hint) {
|
|
768
519
|
const normalizedHint = hint === void 0 ? void 0 : createParameterTypeHint(hint);
|
|
769
520
|
const parameter = Object.freeze({
|
|
@@ -776,6 +527,7 @@ function createRoutineOutParameter(name, hint) {
|
|
|
776
527
|
knownRoutineParameters.add(parameter);
|
|
777
528
|
return parameter;
|
|
778
529
|
}
|
|
530
|
+
/** Create a value-only INOUT parameter descriptor; input value and output channel stay distinct. */
|
|
779
531
|
function createRoutineInOutParameter(name, value, hint) {
|
|
780
532
|
const normalizedHint = hint === void 0 ? void 0 : createParameterTypeHint(hint);
|
|
781
533
|
const parameter = Object.freeze({
|
|
@@ -788,17 +540,35 @@ function createRoutineInOutParameter(name, value, hint) {
|
|
|
788
540
|
knownRoutineParameters.add(parameter);
|
|
789
541
|
return parameter;
|
|
790
542
|
}
|
|
543
|
+
/** Recognize only routine OUT/INOUT descriptors created by SQLBraid's own constructor. */
|
|
791
544
|
function isRoutineParameter(value) {
|
|
792
545
|
if (typeof value !== "object" || value === null || Array.isArray(value) || !knownRoutineParameters.has(value)) return false;
|
|
793
546
|
const candidate = value;
|
|
794
547
|
return candidate[SQL_ROUTINE_PARAMETER] === true && Object.hasOwn(candidate, "value") && (candidate.direction === "out" || candidate.direction === "inout") && typeof candidate.outputName === "string" && Boolean(candidate.outputName.trim()) && (candidate.hint === void 0 || isParameterTypeHint(candidate.hint));
|
|
795
548
|
}
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
*/
|
|
800
|
-
|
|
801
|
-
|
|
549
|
+
|
|
550
|
+
//#endregion
|
|
551
|
+
//#region src/routine.ts
|
|
552
|
+
/** Identifies which routine channel or row failed during Standard Schema mapping. */
|
|
553
|
+
var RoutineMappingError = class RoutineMappingError extends Error {
|
|
554
|
+
static {
|
|
555
|
+
this.code = "BRAID_CALL_MAP";
|
|
556
|
+
}
|
|
557
|
+
constructor(message, location, options) {
|
|
558
|
+
super(message, options);
|
|
559
|
+
this.code = RoutineMappingError.code;
|
|
560
|
+
this.name = "RoutineMappingError";
|
|
561
|
+
this.location = Object.freeze(location);
|
|
562
|
+
}
|
|
563
|
+
};
|
|
564
|
+
|
|
565
|
+
//#endregion
|
|
566
|
+
//#region src/statement.ts
|
|
567
|
+
function validHintNumber(value) {
|
|
568
|
+
return typeof value === "number" && Number.isFinite(value) && Number.isInteger(value) && value >= 0;
|
|
569
|
+
}
|
|
570
|
+
function createRenderedBulk(bulk) {
|
|
571
|
+
if (bulk === null || typeof bulk !== "object" || Array.isArray(bulk)) throw new TypeError("RenderedBulk must be an object.");
|
|
802
572
|
const statement = createRenderedStatement(bulk.statement);
|
|
803
573
|
if (!Array.isArray(bulk.parameterSets)) throw new TypeError("RenderedBulk parameterSets must be an array.");
|
|
804
574
|
const parameterCount = statement.parameters.length;
|
|
@@ -866,6 +636,8 @@ function copyNativeTemplate(value, segments) {
|
|
|
866
636
|
});
|
|
867
637
|
return Object.freeze(cooked);
|
|
868
638
|
}
|
|
639
|
+
/** Validate and freeze one logical statement without creating a second mutable SQL/value source of truth. */
|
|
640
|
+
/** @throws {TypeError|SqlRenderError} For broken segment/parameter invariants or unsupported bind values. */
|
|
869
641
|
function createRenderedStatement(statement) {
|
|
870
642
|
if (typeof statement !== "object" || statement === null) throw new TypeError("RenderedStatement must be an object.");
|
|
871
643
|
if (knownRenderedStatements.has(statement)) return statement;
|
|
@@ -900,6 +672,10 @@ function createRenderedStatement(statement) {
|
|
|
900
672
|
knownRenderedStatements.add(rendered);
|
|
901
673
|
return rendered;
|
|
902
674
|
}
|
|
675
|
+
|
|
676
|
+
//#endregion
|
|
677
|
+
//#region src/binding.ts
|
|
678
|
+
/** Materialize placeholder text as a derived view; this helper does not own reuse or driver transport policy. */
|
|
903
679
|
function parameterizedSql(statement, placeholder) {
|
|
904
680
|
const parts = [statement.segments[0] ?? ""];
|
|
905
681
|
for (let index = 0; index < statement.parameters.length; index += 1) parts.push(placeholder(index + 1), statement.segments[index + 1] ?? "");
|
|
@@ -972,6 +748,7 @@ function literalized(statement, dialectId, formatLiteral, options) {
|
|
|
972
748
|
truncatedParameters
|
|
973
749
|
});
|
|
974
750
|
}
|
|
751
|
+
/** Build an immutable binding description before I/O, including adapter reuse policy and diagnostic literalization. */
|
|
975
752
|
function createStatementBindingDescription(statement, context, options) {
|
|
976
753
|
const logical = createRenderedStatement(statement);
|
|
977
754
|
const adapterId = options.adapterId;
|
|
@@ -1071,9 +848,8 @@ function createStatementBindingDescription(statement, context, options) {
|
|
|
1071
848
|
return Object.freeze(description);
|
|
1072
849
|
}
|
|
1073
850
|
/**
|
|
1074
|
-
* Build one binding description for a
|
|
1075
|
-
* metadata is shared by every parameter set; values and diagnostics are
|
|
1076
|
-
* addressed only when requested for a particular item.
|
|
851
|
+
* Build one binding description for a homogeneous bulk statement without cloning application-owned values.
|
|
852
|
+
* Statement metadata is shared by every parameter set; values and diagnostics are addressed by item index.
|
|
1077
853
|
*/
|
|
1078
854
|
function createBulkBindingDescription(bulk, context, options) {
|
|
1079
855
|
const logical = createRenderedBulk(bulk);
|
|
@@ -1116,45 +892,359 @@ function createBulkBindingDescription(bulk, context, options) {
|
|
|
1116
892
|
});
|
|
1117
893
|
return Object.freeze(description);
|
|
1118
894
|
}
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
895
|
+
|
|
896
|
+
//#endregion
|
|
897
|
+
//#region src/template-ir.ts
|
|
898
|
+
const SQL_FRAGMENT = Symbol.for("sqlbraid.fragment");
|
|
899
|
+
|
|
900
|
+
//#endregion
|
|
901
|
+
//#region src/authoring-modules.ts
|
|
902
|
+
const AUTHORING_MODULE_CATALOG = Object.freeze([
|
|
903
|
+
{
|
|
904
|
+
moduleSpecifier: "@sqlbraid/template",
|
|
905
|
+
helperFamily: "template"
|
|
906
|
+
},
|
|
907
|
+
{
|
|
908
|
+
moduleSpecifier: "@sqlbraid/postgres",
|
|
909
|
+
dialectId: "postgres",
|
|
910
|
+
helperFamily: "template"
|
|
911
|
+
},
|
|
912
|
+
{
|
|
913
|
+
moduleSpecifier: "@sqlbraid/mysql",
|
|
914
|
+
dialectId: "mysql",
|
|
915
|
+
helperFamily: "template"
|
|
916
|
+
},
|
|
917
|
+
{
|
|
918
|
+
moduleSpecifier: "@sqlbraid/mariadb",
|
|
919
|
+
dialectId: "mariadb",
|
|
920
|
+
helperFamily: "template"
|
|
921
|
+
},
|
|
922
|
+
{
|
|
923
|
+
moduleSpecifier: "@sqlbraid/sqlite",
|
|
924
|
+
dialectId: "sqlite",
|
|
925
|
+
helperFamily: "template"
|
|
926
|
+
},
|
|
927
|
+
{
|
|
928
|
+
moduleSpecifier: "@sqlbraid/oracle",
|
|
929
|
+
dialectId: "oracle",
|
|
930
|
+
helperFamily: "template"
|
|
931
|
+
},
|
|
932
|
+
{
|
|
933
|
+
moduleSpecifier: "@sqlbraid/mssql",
|
|
934
|
+
dialectId: "mssql",
|
|
935
|
+
helperFamily: "template"
|
|
936
|
+
},
|
|
937
|
+
{
|
|
938
|
+
moduleSpecifier: "sqlbraid/pg",
|
|
939
|
+
dialectId: "postgres",
|
|
940
|
+
helperFamily: "facade"
|
|
941
|
+
},
|
|
942
|
+
{
|
|
943
|
+
moduleSpecifier: "sqlbraid/mysql2",
|
|
944
|
+
dialectId: "mysql",
|
|
945
|
+
helperFamily: "facade"
|
|
946
|
+
},
|
|
947
|
+
{
|
|
948
|
+
moduleSpecifier: "sqlbraid/mariadb",
|
|
949
|
+
dialectId: "mariadb",
|
|
950
|
+
helperFamily: "facade"
|
|
951
|
+
},
|
|
952
|
+
{
|
|
953
|
+
moduleSpecifier: "sqlbraid/node-sqlite",
|
|
954
|
+
dialectId: "sqlite",
|
|
955
|
+
helperFamily: "facade"
|
|
956
|
+
},
|
|
957
|
+
{
|
|
958
|
+
moduleSpecifier: "sqlbraid/better-sqlite3",
|
|
959
|
+
dialectId: "sqlite",
|
|
960
|
+
helperFamily: "facade"
|
|
961
|
+
},
|
|
962
|
+
{
|
|
963
|
+
moduleSpecifier: "sqlbraid/libsql",
|
|
964
|
+
dialectId: "sqlite",
|
|
965
|
+
helperFamily: "facade"
|
|
966
|
+
},
|
|
967
|
+
{
|
|
968
|
+
moduleSpecifier: "sqlbraid/sqlite-wasm",
|
|
969
|
+
dialectId: "sqlite",
|
|
970
|
+
helperFamily: "facade"
|
|
971
|
+
},
|
|
972
|
+
{
|
|
973
|
+
moduleSpecifier: "sqlbraid/d1",
|
|
974
|
+
dialectId: "sqlite",
|
|
975
|
+
helperFamily: "facade"
|
|
976
|
+
},
|
|
977
|
+
{
|
|
978
|
+
moduleSpecifier: "sqlbraid/oracledb",
|
|
979
|
+
dialectId: "oracle",
|
|
980
|
+
helperFamily: "facade"
|
|
981
|
+
},
|
|
982
|
+
{
|
|
983
|
+
moduleSpecifier: "sqlbraid/tedious",
|
|
984
|
+
dialectId: "mssql",
|
|
985
|
+
helperFamily: "facade"
|
|
986
|
+
},
|
|
987
|
+
{
|
|
988
|
+
moduleSpecifier: "sqlbraid/postgres",
|
|
989
|
+
dialectId: "postgres",
|
|
990
|
+
helperFamily: "facade"
|
|
991
|
+
},
|
|
992
|
+
{
|
|
993
|
+
moduleSpecifier: "sqlbraid/mysql",
|
|
994
|
+
dialectId: "mysql",
|
|
995
|
+
helperFamily: "facade"
|
|
996
|
+
},
|
|
997
|
+
{
|
|
998
|
+
moduleSpecifier: "sqlbraid/sqlite",
|
|
999
|
+
dialectId: "sqlite",
|
|
1000
|
+
helperFamily: "facade"
|
|
1001
|
+
},
|
|
1002
|
+
{
|
|
1003
|
+
moduleSpecifier: "sqlbraid/oracle",
|
|
1004
|
+
dialectId: "oracle",
|
|
1005
|
+
helperFamily: "facade"
|
|
1006
|
+
},
|
|
1007
|
+
{
|
|
1008
|
+
moduleSpecifier: "sqlbraid/mssql",
|
|
1009
|
+
dialectId: "mssql",
|
|
1010
|
+
helperFamily: "facade"
|
|
1149
1011
|
}
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1012
|
+
].map((entry) => Object.freeze(entry)));
|
|
1013
|
+
|
|
1014
|
+
//#endregion
|
|
1015
|
+
//#region src/capabilities.ts
|
|
1016
|
+
const definitions = [
|
|
1017
|
+
{
|
|
1018
|
+
id: "sql.native-transparency",
|
|
1019
|
+
family: "support"
|
|
1020
|
+
},
|
|
1021
|
+
{
|
|
1022
|
+
id: "sql.generated-structure",
|
|
1023
|
+
family: "support"
|
|
1024
|
+
},
|
|
1025
|
+
{
|
|
1026
|
+
id: "result.rows",
|
|
1027
|
+
family: "support"
|
|
1028
|
+
},
|
|
1029
|
+
{
|
|
1030
|
+
id: "result.command",
|
|
1031
|
+
family: "support"
|
|
1032
|
+
},
|
|
1033
|
+
{
|
|
1034
|
+
id: "result.multiple-sets",
|
|
1035
|
+
family: "support"
|
|
1036
|
+
},
|
|
1037
|
+
{
|
|
1038
|
+
id: "result.standard-schema",
|
|
1039
|
+
family: "support"
|
|
1040
|
+
},
|
|
1041
|
+
{
|
|
1042
|
+
id: "numeric.exact-integer",
|
|
1043
|
+
family: "representation"
|
|
1044
|
+
},
|
|
1045
|
+
{
|
|
1046
|
+
id: "numeric.exact-decimal",
|
|
1047
|
+
family: "representation"
|
|
1048
|
+
},
|
|
1049
|
+
{
|
|
1050
|
+
id: "numeric.approximate-float",
|
|
1051
|
+
family: "representation"
|
|
1052
|
+
},
|
|
1053
|
+
{
|
|
1054
|
+
id: "numeric.approximate-special",
|
|
1055
|
+
family: "representation"
|
|
1056
|
+
},
|
|
1057
|
+
{
|
|
1058
|
+
id: "numeric.bind-exact",
|
|
1059
|
+
family: "representation"
|
|
1060
|
+
},
|
|
1061
|
+
{
|
|
1062
|
+
id: "numeric.aggregate",
|
|
1063
|
+
family: "representation"
|
|
1064
|
+
},
|
|
1065
|
+
{
|
|
1066
|
+
id: "numeric.command-metadata",
|
|
1067
|
+
family: "representation"
|
|
1068
|
+
},
|
|
1069
|
+
{
|
|
1070
|
+
id: "numeric.special-values",
|
|
1071
|
+
family: "representation"
|
|
1072
|
+
},
|
|
1073
|
+
{
|
|
1074
|
+
id: "numeric.scale-greater-than-precision",
|
|
1075
|
+
family: "representation"
|
|
1076
|
+
},
|
|
1077
|
+
{
|
|
1078
|
+
id: "numeric.negative-scale",
|
|
1079
|
+
family: "representation"
|
|
1080
|
+
},
|
|
1081
|
+
{
|
|
1082
|
+
id: "data.json-parsed",
|
|
1083
|
+
family: "representation"
|
|
1084
|
+
},
|
|
1085
|
+
{
|
|
1086
|
+
id: "data.json-lossless-text",
|
|
1087
|
+
family: "representation"
|
|
1088
|
+
},
|
|
1089
|
+
{
|
|
1090
|
+
id: "data.sql-variant",
|
|
1091
|
+
family: "representation"
|
|
1092
|
+
},
|
|
1093
|
+
{
|
|
1094
|
+
id: "data.oracle-object",
|
|
1095
|
+
family: "representation"
|
|
1096
|
+
},
|
|
1097
|
+
{
|
|
1098
|
+
id: "data.oracle-collection",
|
|
1099
|
+
family: "representation"
|
|
1100
|
+
},
|
|
1101
|
+
{
|
|
1102
|
+
id: "data.vector",
|
|
1103
|
+
family: "representation"
|
|
1104
|
+
},
|
|
1105
|
+
{
|
|
1106
|
+
id: "data.binary",
|
|
1107
|
+
family: "representation"
|
|
1108
|
+
},
|
|
1109
|
+
{
|
|
1110
|
+
id: "data.uuid",
|
|
1111
|
+
family: "representation"
|
|
1112
|
+
},
|
|
1113
|
+
{
|
|
1114
|
+
id: "data.temporal-native",
|
|
1115
|
+
family: "representation"
|
|
1116
|
+
},
|
|
1117
|
+
{
|
|
1118
|
+
id: "data.temporal-lossless",
|
|
1119
|
+
family: "representation"
|
|
1120
|
+
},
|
|
1121
|
+
{
|
|
1122
|
+
id: "data.timezone",
|
|
1123
|
+
family: "representation"
|
|
1124
|
+
},
|
|
1125
|
+
{
|
|
1126
|
+
id: "metadata.command-safe",
|
|
1127
|
+
family: "metadata"
|
|
1128
|
+
},
|
|
1129
|
+
{
|
|
1130
|
+
id: "dml.insert-returning",
|
|
1131
|
+
family: "support"
|
|
1132
|
+
},
|
|
1133
|
+
{
|
|
1134
|
+
id: "dml.update-returning",
|
|
1135
|
+
family: "support"
|
|
1136
|
+
},
|
|
1137
|
+
{
|
|
1138
|
+
id: "dml.delete-returning",
|
|
1139
|
+
family: "support"
|
|
1140
|
+
},
|
|
1141
|
+
{
|
|
1142
|
+
id: "dml.merge-returning",
|
|
1143
|
+
family: "support"
|
|
1144
|
+
},
|
|
1145
|
+
{
|
|
1146
|
+
id: "dml.upsert-returning",
|
|
1147
|
+
family: "support"
|
|
1148
|
+
},
|
|
1149
|
+
{
|
|
1150
|
+
id: "session.pinned",
|
|
1151
|
+
family: "support"
|
|
1152
|
+
},
|
|
1153
|
+
{
|
|
1154
|
+
id: "statement.prepare",
|
|
1155
|
+
family: "support"
|
|
1156
|
+
},
|
|
1157
|
+
{
|
|
1158
|
+
id: "statement.cancel",
|
|
1159
|
+
family: "support"
|
|
1160
|
+
},
|
|
1161
|
+
{
|
|
1162
|
+
id: "statement.stream",
|
|
1163
|
+
family: "support"
|
|
1164
|
+
},
|
|
1165
|
+
{
|
|
1166
|
+
id: "statement.bulk",
|
|
1167
|
+
family: "support"
|
|
1168
|
+
},
|
|
1169
|
+
{
|
|
1170
|
+
id: "execution.bulk-fidelity",
|
|
1171
|
+
family: "support"
|
|
1172
|
+
},
|
|
1173
|
+
{
|
|
1174
|
+
id: "transaction",
|
|
1175
|
+
family: "support"
|
|
1176
|
+
},
|
|
1177
|
+
{
|
|
1178
|
+
id: "transaction.savepoint",
|
|
1179
|
+
family: "support"
|
|
1180
|
+
},
|
|
1181
|
+
{
|
|
1182
|
+
id: "transaction.read-only",
|
|
1183
|
+
family: "support"
|
|
1184
|
+
},
|
|
1185
|
+
{
|
|
1186
|
+
id: "transaction.isolation.read-uncommitted",
|
|
1187
|
+
family: "support"
|
|
1188
|
+
},
|
|
1189
|
+
{
|
|
1190
|
+
id: "transaction.isolation.read-committed",
|
|
1191
|
+
family: "support"
|
|
1192
|
+
},
|
|
1193
|
+
{
|
|
1194
|
+
id: "transaction.isolation.repeatable-read",
|
|
1195
|
+
family: "support"
|
|
1196
|
+
},
|
|
1197
|
+
{
|
|
1198
|
+
id: "transaction.isolation.serializable",
|
|
1199
|
+
family: "support"
|
|
1200
|
+
},
|
|
1201
|
+
{
|
|
1202
|
+
id: "routine.call",
|
|
1203
|
+
family: "support"
|
|
1204
|
+
},
|
|
1205
|
+
{
|
|
1206
|
+
id: "routine.out",
|
|
1207
|
+
family: "support"
|
|
1208
|
+
},
|
|
1209
|
+
{
|
|
1210
|
+
id: "routine.inout",
|
|
1211
|
+
family: "support"
|
|
1212
|
+
},
|
|
1213
|
+
{
|
|
1214
|
+
id: "routine.result-sets",
|
|
1215
|
+
family: "support"
|
|
1216
|
+
},
|
|
1217
|
+
{
|
|
1218
|
+
id: "routine.out-cursor",
|
|
1219
|
+
family: "support"
|
|
1220
|
+
},
|
|
1221
|
+
{
|
|
1222
|
+
id: "routine.return-value",
|
|
1223
|
+
family: "support"
|
|
1224
|
+
},
|
|
1225
|
+
{
|
|
1226
|
+
id: "metadata.identity",
|
|
1227
|
+
family: "metadata"
|
|
1228
|
+
},
|
|
1229
|
+
{
|
|
1230
|
+
id: "metadata.generated",
|
|
1231
|
+
family: "metadata"
|
|
1232
|
+
},
|
|
1233
|
+
{
|
|
1234
|
+
id: "metadata.routines",
|
|
1235
|
+
family: "metadata"
|
|
1236
|
+
},
|
|
1237
|
+
{
|
|
1238
|
+
id: "metadata.types",
|
|
1239
|
+
family: "metadata"
|
|
1156
1240
|
}
|
|
1157
|
-
|
|
1241
|
+
];
|
|
1242
|
+
const WELL_KNOWN_CAPABILITIES = Object.freeze(definitions.map((entry) => Object.freeze(entry)));
|
|
1243
|
+
const WELL_KNOWN_CAPABILITY_IDS = Object.freeze(definitions.map(({ id }) => id));
|
|
1244
|
+
const wellKnownCapabilityIds = new Set(WELL_KNOWN_CAPABILITY_IDS);
|
|
1245
|
+
function isWellKnownCapabilityId(value) {
|
|
1246
|
+
return wellKnownCapabilityIds.has(value);
|
|
1247
|
+
}
|
|
1158
1248
|
|
|
1159
1249
|
//#endregion
|
|
1160
1250
|
export { AUTHORING_MODULE_CATALOG, AdapterError, PUBLIC_ERROR_DEFINITIONS, ResultExactnessError, RoutineMappingError, SQL_FRAGMENT, SqlRenderError, UnsupportedFeatureError, WELL_KNOWN_CAPABILITIES, WELL_KNOWN_CAPABILITY_IDS, createBoundParameter, createBulkBindingDescription, createParameterTypeHint, createRenderedBulk, createRenderedStatement, createRoutineInOutParameter, createRoutineOutParameter, createStatementBindingDescription, decodeExactDecimal, decodeExactInteger, isBoundParameter, isPublicUnsupportedFeatureError, isRoutineParameter, isWellKnownCapabilityId, normalizeExactInteger, parameterizedSql, safeDatabaseCount };
|