@sqlbraid/core 1.0.0 → 1.0.2
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 +730 -565
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +637 -592
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,661 +1,313 @@
|
|
|
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_CALL_UNSUPPORTED",
|
|
88
|
+
category: "adapter",
|
|
89
|
+
owner: "UnsupportedFeatureError",
|
|
90
|
+
features: ["routine.call"]
|
|
71
91
|
},
|
|
72
92
|
{
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
93
|
+
code: "BRAID_RESULT_SETS_UNSUPPORTED",
|
|
94
|
+
category: "adapter",
|
|
95
|
+
owner: "UnsupportedFeatureError",
|
|
96
|
+
features: ["routine.result-sets"]
|
|
76
97
|
},
|
|
77
98
|
{
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
99
|
+
code: "BRAID_STREAM_UNSUPPORTED",
|
|
100
|
+
category: "adapter",
|
|
101
|
+
owner: "UnsupportedFeatureError",
|
|
102
|
+
features: ["statement.stream"]
|
|
81
103
|
},
|
|
82
104
|
{
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
105
|
+
code: "BRAID_CANCEL_UNSUPPORTED",
|
|
106
|
+
category: "adapter",
|
|
107
|
+
owner: "UnsupportedFeatureError",
|
|
108
|
+
features: ["statement.cancel"]
|
|
86
109
|
},
|
|
87
110
|
{
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
111
|
+
code: "BRAID_SESSION_UNSUPPORTED",
|
|
112
|
+
category: "adapter",
|
|
113
|
+
owner: "UnsupportedFeatureError",
|
|
114
|
+
features: ["session.pinned"]
|
|
91
115
|
},
|
|
92
116
|
{
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
117
|
+
code: "BRAID_TX_UNSUPPORTED",
|
|
118
|
+
category: "adapter",
|
|
119
|
+
owner: "UnsupportedFeatureError",
|
|
120
|
+
features: ["transaction", "transaction.savepoint"]
|
|
96
121
|
},
|
|
97
122
|
{
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
123
|
+
code: "BRAID_TX_OPTIONS_INVALID",
|
|
124
|
+
category: "runtime",
|
|
125
|
+
owner: "TypeError with code"
|
|
101
126
|
},
|
|
102
127
|
{
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
128
|
+
code: "BRAID_TX_OPTION_UNSUPPORTED",
|
|
129
|
+
category: "adapter",
|
|
130
|
+
owner: "UnsupportedFeatureError",
|
|
131
|
+
features: [
|
|
132
|
+
"transaction.read-only",
|
|
133
|
+
"transaction.isolation.read-uncommitted",
|
|
134
|
+
"transaction.isolation.read-committed",
|
|
135
|
+
"transaction.isolation.repeatable-read",
|
|
136
|
+
"transaction.isolation.serializable"
|
|
137
|
+
]
|
|
106
138
|
},
|
|
107
139
|
{
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
].map((entry) => Object.freeze(entry)));
|
|
113
|
-
|
|
114
|
-
//#endregion
|
|
115
|
-
//#region src/capabilities.ts
|
|
116
|
-
const definitions = [
|
|
117
|
-
{
|
|
118
|
-
id: "sql.native-transparency",
|
|
119
|
-
family: "support"
|
|
140
|
+
code: "BRAID_CALL_RESULT_SETS",
|
|
141
|
+
category: "adapter",
|
|
142
|
+
owner: "UnsupportedFeatureError",
|
|
143
|
+
features: ["routine.result-sets"]
|
|
120
144
|
},
|
|
121
145
|
{
|
|
122
|
-
|
|
123
|
-
|
|
146
|
+
code: "BRAID_CALL_CURSOR_TX_REQUIRED",
|
|
147
|
+
category: "adapter",
|
|
148
|
+
owner: "UnsupportedFeatureError",
|
|
149
|
+
features: ["routine.out-cursor"]
|
|
124
150
|
},
|
|
125
151
|
{
|
|
126
|
-
|
|
127
|
-
|
|
152
|
+
code: "BRAID_CALL_OUT_UNSUPPORTED",
|
|
153
|
+
category: "adapter",
|
|
154
|
+
owner: "UnsupportedFeatureError",
|
|
155
|
+
features: ["routine.out", "routine.inout"]
|
|
128
156
|
},
|
|
129
157
|
{
|
|
130
|
-
|
|
131
|
-
|
|
158
|
+
code: "BRAID_CALL_RETURN_UNSUPPORTED",
|
|
159
|
+
category: "adapter",
|
|
160
|
+
owner: "UnsupportedFeatureError",
|
|
161
|
+
features: ["routine.return-value"]
|
|
132
162
|
},
|
|
133
163
|
{
|
|
134
|
-
|
|
135
|
-
|
|
164
|
+
code: "BRAID_CALL_PROCEDURE_INVALID",
|
|
165
|
+
category: "adapter",
|
|
166
|
+
owner: "AdapterError"
|
|
136
167
|
},
|
|
137
168
|
{
|
|
138
|
-
|
|
139
|
-
|
|
169
|
+
code: "BRAID_CALL_CURSOR_UNSUPPORTED",
|
|
170
|
+
category: "adapter",
|
|
171
|
+
owner: "UnsupportedFeatureError",
|
|
172
|
+
features: ["routine.out-cursor"]
|
|
140
173
|
},
|
|
141
174
|
{
|
|
142
|
-
|
|
143
|
-
|
|
175
|
+
code: "BRAID_RESOURCE_CLEANUP",
|
|
176
|
+
category: "adapter",
|
|
177
|
+
owner: "adapter cleanup error with code",
|
|
178
|
+
features: ["resource.cleanup", "resource.discard"]
|
|
144
179
|
},
|
|
145
180
|
{
|
|
146
|
-
|
|
147
|
-
|
|
181
|
+
code: "BRAID_BIND_HINT_UNSUPPORTED",
|
|
182
|
+
category: "adapter",
|
|
183
|
+
owner: "UnsupportedFeatureError",
|
|
184
|
+
features: ["statement.bind-hint"]
|
|
148
185
|
},
|
|
149
186
|
{
|
|
150
|
-
|
|
151
|
-
|
|
187
|
+
code: "BRAID_BIND_VALUE_UNSUPPORTED",
|
|
188
|
+
category: "adapter",
|
|
189
|
+
owner: "AdapterError"
|
|
152
190
|
},
|
|
153
191
|
{
|
|
154
|
-
|
|
155
|
-
|
|
192
|
+
code: "BRAID_INTEGER_MODE_UNSUPPORTED",
|
|
193
|
+
category: "adapter",
|
|
194
|
+
owner: "UnsupportedFeatureError",
|
|
195
|
+
features: ["result.exact-integer"]
|
|
156
196
|
},
|
|
157
197
|
{
|
|
158
|
-
|
|
159
|
-
|
|
198
|
+
code: "BRAID_CALL_LOB_UNSUPPORTED",
|
|
199
|
+
category: "adapter",
|
|
200
|
+
owner: "UnsupportedFeatureError",
|
|
201
|
+
features: ["routine.out"]
|
|
160
202
|
},
|
|
161
203
|
{
|
|
162
|
-
|
|
163
|
-
|
|
204
|
+
code: "BRAID_BULK_UNSUPPORTED",
|
|
205
|
+
category: "adapter",
|
|
206
|
+
owner: "UnsupportedFeatureError",
|
|
207
|
+
features: ["statement.bulk"]
|
|
164
208
|
},
|
|
165
209
|
{
|
|
166
|
-
|
|
167
|
-
|
|
210
|
+
code: "BRAID_PREPARE_UNSUPPORTED",
|
|
211
|
+
category: "adapter",
|
|
212
|
+
owner: "UnsupportedFeatureError",
|
|
213
|
+
features: ["statement.prepare"]
|
|
168
214
|
},
|
|
169
215
|
{
|
|
170
|
-
|
|
171
|
-
|
|
216
|
+
code: "BRAID_DIALECT_MISMATCH",
|
|
217
|
+
category: "adapter",
|
|
218
|
+
owner: "UnsupportedFeatureError",
|
|
219
|
+
features: ["dialect"]
|
|
172
220
|
},
|
|
173
221
|
{
|
|
174
|
-
|
|
175
|
-
|
|
222
|
+
code: "BRAID_RESULT_KIND_AMBIGUOUS",
|
|
223
|
+
category: "adapter",
|
|
224
|
+
owner: "UnsupportedFeatureError",
|
|
225
|
+
features: ["result.rows", "result.command"]
|
|
176
226
|
},
|
|
177
227
|
{
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
{
|
|
182
|
-
id: "data.json-parsed",
|
|
183
|
-
family: "representation"
|
|
184
|
-
},
|
|
185
|
-
{
|
|
186
|
-
id: "data.json-lossless-text",
|
|
187
|
-
family: "representation"
|
|
188
|
-
},
|
|
189
|
-
{
|
|
190
|
-
id: "data.sql-variant",
|
|
191
|
-
family: "representation"
|
|
192
|
-
},
|
|
193
|
-
{
|
|
194
|
-
id: "data.oracle-object",
|
|
195
|
-
family: "representation"
|
|
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"
|
|
312
|
-
},
|
|
313
|
-
{
|
|
314
|
-
id: "routine.result-sets",
|
|
315
|
-
family: "support"
|
|
316
|
-
},
|
|
317
|
-
{
|
|
318
|
-
id: "routine.out-cursor",
|
|
319
|
-
family: "support"
|
|
320
|
-
},
|
|
321
|
-
{
|
|
322
|
-
id: "routine.return-value",
|
|
323
|
-
family: "support"
|
|
228
|
+
code: "BRAID_PREPARED_NAME",
|
|
229
|
+
category: "runtime",
|
|
230
|
+
owner: "prepared query validation"
|
|
324
231
|
},
|
|
325
232
|
{
|
|
326
|
-
|
|
327
|
-
|
|
233
|
+
code: "BRAID_PREPARED_SHAPE",
|
|
234
|
+
category: "runtime",
|
|
235
|
+
owner: "prepared query validation"
|
|
328
236
|
},
|
|
329
237
|
{
|
|
330
|
-
|
|
331
|
-
|
|
238
|
+
code: "BRAID_BIND_TYPE_REQUIRED",
|
|
239
|
+
category: "adapter",
|
|
240
|
+
owner: "AdapterError"
|
|
332
241
|
},
|
|
333
242
|
{
|
|
334
|
-
|
|
335
|
-
|
|
243
|
+
code: "BRAID_EMPTY_LIST",
|
|
244
|
+
category: "runtime",
|
|
245
|
+
owner: "SqlRenderError"
|
|
336
246
|
},
|
|
337
247
|
{
|
|
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",
|
|
248
|
+
code: "BRAID_EMPTY_SET",
|
|
376
249
|
category: "runtime",
|
|
377
|
-
owner: "
|
|
250
|
+
owner: "SqlRenderError"
|
|
378
251
|
},
|
|
379
252
|
{
|
|
380
|
-
code: "
|
|
253
|
+
code: "BRAID_DIALECT",
|
|
381
254
|
category: "runtime",
|
|
382
|
-
owner: "
|
|
255
|
+
owner: "SqlRenderError"
|
|
383
256
|
},
|
|
384
257
|
{
|
|
385
|
-
code: "
|
|
386
|
-
category: "
|
|
387
|
-
owner: "
|
|
258
|
+
code: "BRAID_ASYNC_CONTEXT",
|
|
259
|
+
category: "compiler",
|
|
260
|
+
owner: "compiler diagnostic"
|
|
388
261
|
},
|
|
389
262
|
{
|
|
390
|
-
code: "
|
|
263
|
+
code: "BRAID_DIRECTIVE_UNTERMINATED",
|
|
391
264
|
category: "runtime",
|
|
392
|
-
owner: "
|
|
265
|
+
owner: "SqlRenderError"
|
|
393
266
|
},
|
|
394
267
|
{
|
|
395
|
-
code: "
|
|
268
|
+
code: "BRAID_DIRECTIVE",
|
|
396
269
|
category: "runtime",
|
|
397
|
-
owner: "
|
|
270
|
+
owner: "SqlRenderError"
|
|
398
271
|
},
|
|
399
272
|
{
|
|
400
|
-
code: "
|
|
273
|
+
code: "BRAID_CONDITION",
|
|
401
274
|
category: "runtime",
|
|
402
|
-
owner: "
|
|
275
|
+
owner: "SqlRenderError"
|
|
403
276
|
},
|
|
404
277
|
{
|
|
405
|
-
code: "
|
|
278
|
+
code: "BRAID_ATTRIBUTES",
|
|
406
279
|
category: "runtime",
|
|
407
|
-
owner: "
|
|
280
|
+
owner: "SqlRenderError"
|
|
408
281
|
},
|
|
409
282
|
{
|
|
410
|
-
code: "
|
|
283
|
+
code: "BRAID_STRUCTURE",
|
|
411
284
|
category: "runtime",
|
|
412
|
-
owner: "
|
|
285
|
+
owner: "SqlRenderError"
|
|
413
286
|
},
|
|
414
287
|
{
|
|
415
|
-
code: "
|
|
288
|
+
code: "BRAID_HOLE_CONTEXT",
|
|
416
289
|
category: "runtime",
|
|
417
|
-
owner: "
|
|
290
|
+
owner: "SqlRenderError"
|
|
418
291
|
},
|
|
419
292
|
{
|
|
420
|
-
code: "
|
|
293
|
+
code: "BRAID_SQL_LEX",
|
|
421
294
|
category: "runtime",
|
|
422
|
-
owner: "
|
|
295
|
+
owner: "SqlRenderError"
|
|
423
296
|
},
|
|
424
297
|
{
|
|
425
|
-
code: "
|
|
298
|
+
code: "BRAID_DEPTH",
|
|
426
299
|
category: "runtime",
|
|
427
|
-
owner: "
|
|
300
|
+
owner: "SqlRenderError"
|
|
428
301
|
},
|
|
429
302
|
{
|
|
430
|
-
code: "
|
|
303
|
+
code: "BRAID_STRUCTURE_LIMIT",
|
|
431
304
|
category: "runtime",
|
|
432
|
-
owner: "
|
|
305
|
+
owner: "SqlRenderError"
|
|
433
306
|
},
|
|
434
307
|
{
|
|
435
|
-
code: "
|
|
308
|
+
code: "BRAID_SQL_LIMIT",
|
|
436
309
|
category: "runtime",
|
|
437
|
-
owner: "
|
|
438
|
-
},
|
|
439
|
-
{
|
|
440
|
-
code: "BRAID_CALL_UNSUPPORTED",
|
|
441
|
-
category: "adapter",
|
|
442
|
-
owner: "UnsupportedFeatureError",
|
|
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"
|
|
310
|
+
owner: "SqlRenderError"
|
|
659
311
|
},
|
|
660
312
|
{
|
|
661
313
|
code: "BRAID_BIND_LIMIT",
|
|
@@ -663,9 +315,47 @@ const PUBLIC_ERROR_DEFINITIONS = Object.freeze([
|
|
|
663
315
|
owner: "SqlRenderError"
|
|
664
316
|
}
|
|
665
317
|
]);
|
|
318
|
+
/** Public adapter capability failure. Unsupported features reject explicitly rather than being buffered or simulated. */
|
|
319
|
+
var UnsupportedFeatureError = class extends Error {
|
|
320
|
+
constructor(feature, code, message, options) {
|
|
321
|
+
super(`${code}: ${message}`, options);
|
|
322
|
+
this.feature = feature;
|
|
323
|
+
this.code = code;
|
|
324
|
+
this.name = "UnsupportedFeatureError";
|
|
325
|
+
}
|
|
326
|
+
};
|
|
327
|
+
/** Return true only for a registered, semantically valid feature/code pair. */
|
|
328
|
+
function isPublicUnsupportedFeatureError(error) {
|
|
329
|
+
if (!(error instanceof UnsupportedFeatureError)) return false;
|
|
330
|
+
return PUBLIC_ERROR_DEFINITIONS.find((candidate) => candidate.owner === "UnsupportedFeatureError" && candidate.code === error.code)?.features?.includes(error.feature) === true;
|
|
331
|
+
}
|
|
332
|
+
/** An adapter-owned input/transport failure that retains TypeError semantics. */
|
|
333
|
+
var AdapterError = class extends TypeError {
|
|
334
|
+
constructor(code, message, options) {
|
|
335
|
+
super(`${code}: ${message}`, options);
|
|
336
|
+
this.code = code;
|
|
337
|
+
this.name = "AdapterError";
|
|
338
|
+
}
|
|
339
|
+
};
|
|
340
|
+
/** Rendering/authoring failure with a stable diagnostic code, raised before driver execution. */
|
|
341
|
+
var SqlRenderError = class extends Error {
|
|
342
|
+
constructor(code, message) {
|
|
343
|
+
super(message);
|
|
344
|
+
this.name = "SqlRenderError";
|
|
345
|
+
this.code = code;
|
|
346
|
+
}
|
|
347
|
+
};
|
|
348
|
+
|
|
349
|
+
//#endregion
|
|
350
|
+
//#region src/numeric.ts
|
|
666
351
|
function exactnessFailure(message) {
|
|
667
352
|
throw new ResultExactnessError(message);
|
|
668
353
|
}
|
|
354
|
+
/**
|
|
355
|
+
* Decode an exact integer from driver output, optionally enforcing bigint bounds.
|
|
356
|
+
*
|
|
357
|
+
* @throws {ResultExactnessError} When the value is not an exact integer or violates the requested range.
|
|
358
|
+
*/
|
|
669
359
|
function decodeExactInteger(value, range) {
|
|
670
360
|
let result;
|
|
671
361
|
if (typeof value === "bigint") result = value;
|
|
@@ -714,28 +404,41 @@ function safeDatabaseCount(value) {
|
|
|
714
404
|
} catch {}
|
|
715
405
|
return exactnessFailure("Database count is not a safe non-negative integer.");
|
|
716
406
|
}
|
|
407
|
+
/**
|
|
408
|
+
* Preserve an exact decimal as text; numeric JavaScript values are rejected because they may already be rounded.
|
|
409
|
+
*
|
|
410
|
+
* @throws {ResultExactnessError} When the value cannot prove exact decimal fidelity.
|
|
411
|
+
*/
|
|
717
412
|
function decodeExactDecimal(value, options) {
|
|
718
413
|
if (typeof value === "string") return value;
|
|
719
414
|
if (typeof value === "bigint" && options?.allowBigInt === true) return value.toString();
|
|
720
415
|
return exactnessFailure("Result value does not have an exact decimal representation.");
|
|
721
416
|
}
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
417
|
+
|
|
418
|
+
//#endregion
|
|
419
|
+
//#region src/parameter.ts
|
|
420
|
+
const SQL_BOUND_PARAMETER = Symbol.for("sqlbraid.bound-parameter");
|
|
421
|
+
const knownBoundParameters = /* @__PURE__ */ new WeakSet();
|
|
422
|
+
const SQL_ROUTINE_PARAMETER = Symbol.for("sqlbraid.routine-parameter");
|
|
423
|
+
const knownRoutineParameters = /* @__PURE__ */ new WeakSet();
|
|
424
|
+
function validHintNumber$1(value) {
|
|
425
|
+
return typeof value === "number" && Number.isFinite(value) && Number.isInteger(value) && value >= 0;
|
|
426
|
+
}
|
|
427
|
+
function validHintInteger(value) {
|
|
726
428
|
return typeof value === "number" && Number.isFinite(value) && Number.isInteger(value);
|
|
727
429
|
}
|
|
728
430
|
function isParameterTypeHint(value) {
|
|
729
431
|
if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
|
|
730
432
|
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));
|
|
433
|
+
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
434
|
}
|
|
435
|
+
/** Validate and freeze an explicit database parameter-type hint. */
|
|
733
436
|
function createParameterTypeHint(hint) {
|
|
734
437
|
if (!isParameterTypeHint(hint)) throw new TypeError("sql.bind hint must be an object with valid structural fields.");
|
|
735
438
|
const candidate = hint;
|
|
736
439
|
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.");
|
|
440
|
+
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\".");
|
|
441
|
+
if (candidate.precision !== void 0 && !validHintNumber$1(candidate.precision)) throw new TypeError("sql.bind hint precision must be a non-negative integer.");
|
|
739
442
|
if (candidate.scale !== void 0 && !validHintInteger(candidate.scale)) throw new TypeError("sql.bind hint scale must be an integer.");
|
|
740
443
|
const normalized = {
|
|
741
444
|
databaseType: candidate.databaseType,
|
|
@@ -745,6 +448,7 @@ function createParameterTypeHint(hint) {
|
|
|
745
448
|
};
|
|
746
449
|
return Object.freeze(normalized);
|
|
747
450
|
}
|
|
451
|
+
/** Create the value-only marker consumed by adapter binding for an explicitly typed input. */
|
|
748
452
|
function createBoundParameter(value, hint) {
|
|
749
453
|
const normalizedHint = createParameterTypeHint(hint);
|
|
750
454
|
const bound = Object.freeze({
|
|
@@ -755,6 +459,7 @@ function createBoundParameter(value, hint) {
|
|
|
755
459
|
knownBoundParameters.add(bound);
|
|
756
460
|
return bound;
|
|
757
461
|
}
|
|
462
|
+
/** Recognize only bound-parameter objects created by SQLBraid's own constructor. */
|
|
758
463
|
function isBoundParameter(value) {
|
|
759
464
|
if (typeof value !== "object" || value === null || !knownBoundParameters.has(value) || !Object.hasOwn(value, SQL_BOUND_PARAMETER)) return false;
|
|
760
465
|
const candidate = value;
|
|
@@ -764,6 +469,7 @@ function normalizeOutputName(name) {
|
|
|
764
469
|
if (typeof name !== "string" || !name.trim()) throw new TypeError("Routine outputName must be a non-empty string.");
|
|
765
470
|
return name;
|
|
766
471
|
}
|
|
472
|
+
/** Create a value-only OUT parameter descriptor; the adapter supplies the native carrier. */
|
|
767
473
|
function createRoutineOutParameter(name, hint) {
|
|
768
474
|
const normalizedHint = hint === void 0 ? void 0 : createParameterTypeHint(hint);
|
|
769
475
|
const parameter = Object.freeze({
|
|
@@ -776,6 +482,7 @@ function createRoutineOutParameter(name, hint) {
|
|
|
776
482
|
knownRoutineParameters.add(parameter);
|
|
777
483
|
return parameter;
|
|
778
484
|
}
|
|
485
|
+
/** Create a value-only INOUT parameter descriptor; input value and output channel stay distinct. */
|
|
779
486
|
function createRoutineInOutParameter(name, value, hint) {
|
|
780
487
|
const normalizedHint = hint === void 0 ? void 0 : createParameterTypeHint(hint);
|
|
781
488
|
const parameter = Object.freeze({
|
|
@@ -788,15 +495,33 @@ function createRoutineInOutParameter(name, value, hint) {
|
|
|
788
495
|
knownRoutineParameters.add(parameter);
|
|
789
496
|
return parameter;
|
|
790
497
|
}
|
|
498
|
+
/** Recognize only routine OUT/INOUT descriptors created by SQLBraid's own constructor. */
|
|
791
499
|
function isRoutineParameter(value) {
|
|
792
500
|
if (typeof value !== "object" || value === null || Array.isArray(value) || !knownRoutineParameters.has(value)) return false;
|
|
793
501
|
const candidate = value;
|
|
794
502
|
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
503
|
}
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
*/
|
|
504
|
+
|
|
505
|
+
//#endregion
|
|
506
|
+
//#region src/routine.ts
|
|
507
|
+
/** Identifies which routine channel or row failed during Standard Schema mapping. */
|
|
508
|
+
var RoutineMappingError = class RoutineMappingError extends Error {
|
|
509
|
+
static {
|
|
510
|
+
this.code = "BRAID_CALL_MAP";
|
|
511
|
+
}
|
|
512
|
+
constructor(message, location, options) {
|
|
513
|
+
super(message, options);
|
|
514
|
+
this.code = RoutineMappingError.code;
|
|
515
|
+
this.name = "RoutineMappingError";
|
|
516
|
+
this.location = Object.freeze(location);
|
|
517
|
+
}
|
|
518
|
+
};
|
|
519
|
+
|
|
520
|
+
//#endregion
|
|
521
|
+
//#region src/statement.ts
|
|
522
|
+
function validHintNumber(value) {
|
|
523
|
+
return typeof value === "number" && Number.isFinite(value) && Number.isInteger(value) && value >= 0;
|
|
524
|
+
}
|
|
800
525
|
function createRenderedBulk(bulk) {
|
|
801
526
|
if (bulk === null || typeof bulk !== "object" || Array.isArray(bulk)) throw new TypeError("RenderedBulk must be an object.");
|
|
802
527
|
const statement = createRenderedStatement(bulk.statement);
|
|
@@ -866,6 +591,8 @@ function copyNativeTemplate(value, segments) {
|
|
|
866
591
|
});
|
|
867
592
|
return Object.freeze(cooked);
|
|
868
593
|
}
|
|
594
|
+
/** Validate and freeze one logical statement without creating a second mutable SQL/value source of truth. */
|
|
595
|
+
/** @throws {TypeError|SqlRenderError} For broken segment/parameter invariants or unsupported bind values. */
|
|
869
596
|
function createRenderedStatement(statement) {
|
|
870
597
|
if (typeof statement !== "object" || statement === null) throw new TypeError("RenderedStatement must be an object.");
|
|
871
598
|
if (knownRenderedStatements.has(statement)) return statement;
|
|
@@ -900,6 +627,10 @@ function createRenderedStatement(statement) {
|
|
|
900
627
|
knownRenderedStatements.add(rendered);
|
|
901
628
|
return rendered;
|
|
902
629
|
}
|
|
630
|
+
|
|
631
|
+
//#endregion
|
|
632
|
+
//#region src/binding.ts
|
|
633
|
+
/** Materialize placeholder text as a derived view; this helper does not own reuse or driver transport policy. */
|
|
903
634
|
function parameterizedSql(statement, placeholder) {
|
|
904
635
|
const parts = [statement.segments[0] ?? ""];
|
|
905
636
|
for (let index = 0; index < statement.parameters.length; index += 1) parts.push(placeholder(index + 1), statement.segments[index + 1] ?? "");
|
|
@@ -972,6 +703,7 @@ function literalized(statement, dialectId, formatLiteral, options) {
|
|
|
972
703
|
truncatedParameters
|
|
973
704
|
});
|
|
974
705
|
}
|
|
706
|
+
/** Build an immutable binding description before I/O, including adapter reuse policy and diagnostic literalization. */
|
|
975
707
|
function createStatementBindingDescription(statement, context, options) {
|
|
976
708
|
const logical = createRenderedStatement(statement);
|
|
977
709
|
const adapterId = options.adapterId;
|
|
@@ -1071,9 +803,8 @@ function createStatementBindingDescription(statement, context, options) {
|
|
|
1071
803
|
return Object.freeze(description);
|
|
1072
804
|
}
|
|
1073
805
|
/**
|
|
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.
|
|
806
|
+
* Build one binding description for a homogeneous bulk statement without cloning application-owned values.
|
|
807
|
+
* Statement metadata is shared by every parameter set; values and diagnostics are addressed by item index.
|
|
1077
808
|
*/
|
|
1078
809
|
function createBulkBindingDescription(bulk, context, options) {
|
|
1079
810
|
const logical = createRenderedBulk(bulk);
|
|
@@ -1116,45 +847,359 @@ function createBulkBindingDescription(bulk, context, options) {
|
|
|
1116
847
|
});
|
|
1117
848
|
return Object.freeze(description);
|
|
1118
849
|
}
|
|
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
|
-
|
|
850
|
+
|
|
851
|
+
//#endregion
|
|
852
|
+
//#region src/template-ir.ts
|
|
853
|
+
const SQL_FRAGMENT = Symbol.for("sqlbraid.fragment");
|
|
854
|
+
|
|
855
|
+
//#endregion
|
|
856
|
+
//#region src/authoring-modules.ts
|
|
857
|
+
const AUTHORING_MODULE_CATALOG = Object.freeze([
|
|
858
|
+
{
|
|
859
|
+
moduleSpecifier: "@sqlbraid/template",
|
|
860
|
+
helperFamily: "template"
|
|
861
|
+
},
|
|
862
|
+
{
|
|
863
|
+
moduleSpecifier: "@sqlbraid/postgres",
|
|
864
|
+
dialectId: "postgres",
|
|
865
|
+
helperFamily: "template"
|
|
866
|
+
},
|
|
867
|
+
{
|
|
868
|
+
moduleSpecifier: "@sqlbraid/mysql",
|
|
869
|
+
dialectId: "mysql",
|
|
870
|
+
helperFamily: "template"
|
|
871
|
+
},
|
|
872
|
+
{
|
|
873
|
+
moduleSpecifier: "@sqlbraid/mariadb",
|
|
874
|
+
dialectId: "mariadb",
|
|
875
|
+
helperFamily: "template"
|
|
876
|
+
},
|
|
877
|
+
{
|
|
878
|
+
moduleSpecifier: "@sqlbraid/sqlite",
|
|
879
|
+
dialectId: "sqlite",
|
|
880
|
+
helperFamily: "template"
|
|
881
|
+
},
|
|
882
|
+
{
|
|
883
|
+
moduleSpecifier: "@sqlbraid/oracle",
|
|
884
|
+
dialectId: "oracle",
|
|
885
|
+
helperFamily: "template"
|
|
886
|
+
},
|
|
887
|
+
{
|
|
888
|
+
moduleSpecifier: "@sqlbraid/mssql",
|
|
889
|
+
dialectId: "mssql",
|
|
890
|
+
helperFamily: "template"
|
|
891
|
+
},
|
|
892
|
+
{
|
|
893
|
+
moduleSpecifier: "sqlbraid/pg",
|
|
894
|
+
dialectId: "postgres",
|
|
895
|
+
helperFamily: "facade"
|
|
896
|
+
},
|
|
897
|
+
{
|
|
898
|
+
moduleSpecifier: "sqlbraid/mysql2",
|
|
899
|
+
dialectId: "mysql",
|
|
900
|
+
helperFamily: "facade"
|
|
901
|
+
},
|
|
902
|
+
{
|
|
903
|
+
moduleSpecifier: "sqlbraid/mariadb",
|
|
904
|
+
dialectId: "mariadb",
|
|
905
|
+
helperFamily: "facade"
|
|
906
|
+
},
|
|
907
|
+
{
|
|
908
|
+
moduleSpecifier: "sqlbraid/node-sqlite",
|
|
909
|
+
dialectId: "sqlite",
|
|
910
|
+
helperFamily: "facade"
|
|
911
|
+
},
|
|
912
|
+
{
|
|
913
|
+
moduleSpecifier: "sqlbraid/better-sqlite3",
|
|
914
|
+
dialectId: "sqlite",
|
|
915
|
+
helperFamily: "facade"
|
|
916
|
+
},
|
|
917
|
+
{
|
|
918
|
+
moduleSpecifier: "sqlbraid/libsql",
|
|
919
|
+
dialectId: "sqlite",
|
|
920
|
+
helperFamily: "facade"
|
|
921
|
+
},
|
|
922
|
+
{
|
|
923
|
+
moduleSpecifier: "sqlbraid/sqlite-wasm",
|
|
924
|
+
dialectId: "sqlite",
|
|
925
|
+
helperFamily: "facade"
|
|
926
|
+
},
|
|
927
|
+
{
|
|
928
|
+
moduleSpecifier: "sqlbraid/d1",
|
|
929
|
+
dialectId: "sqlite",
|
|
930
|
+
helperFamily: "facade"
|
|
931
|
+
},
|
|
932
|
+
{
|
|
933
|
+
moduleSpecifier: "sqlbraid/oracledb",
|
|
934
|
+
dialectId: "oracle",
|
|
935
|
+
helperFamily: "facade"
|
|
936
|
+
},
|
|
937
|
+
{
|
|
938
|
+
moduleSpecifier: "sqlbraid/tedious",
|
|
939
|
+
dialectId: "mssql",
|
|
940
|
+
helperFamily: "facade"
|
|
941
|
+
},
|
|
942
|
+
{
|
|
943
|
+
moduleSpecifier: "sqlbraid/postgres",
|
|
944
|
+
dialectId: "postgres",
|
|
945
|
+
helperFamily: "facade"
|
|
946
|
+
},
|
|
947
|
+
{
|
|
948
|
+
moduleSpecifier: "sqlbraid/mysql",
|
|
949
|
+
dialectId: "mysql",
|
|
950
|
+
helperFamily: "facade"
|
|
951
|
+
},
|
|
952
|
+
{
|
|
953
|
+
moduleSpecifier: "sqlbraid/sqlite",
|
|
954
|
+
dialectId: "sqlite",
|
|
955
|
+
helperFamily: "facade"
|
|
956
|
+
},
|
|
957
|
+
{
|
|
958
|
+
moduleSpecifier: "sqlbraid/oracle",
|
|
959
|
+
dialectId: "oracle",
|
|
960
|
+
helperFamily: "facade"
|
|
961
|
+
},
|
|
962
|
+
{
|
|
963
|
+
moduleSpecifier: "sqlbraid/mssql",
|
|
964
|
+
dialectId: "mssql",
|
|
965
|
+
helperFamily: "facade"
|
|
1149
966
|
}
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
967
|
+
].map((entry) => Object.freeze(entry)));
|
|
968
|
+
|
|
969
|
+
//#endregion
|
|
970
|
+
//#region src/capabilities.ts
|
|
971
|
+
const definitions = [
|
|
972
|
+
{
|
|
973
|
+
id: "sql.native-transparency",
|
|
974
|
+
family: "support"
|
|
975
|
+
},
|
|
976
|
+
{
|
|
977
|
+
id: "sql.generated-structure",
|
|
978
|
+
family: "support"
|
|
979
|
+
},
|
|
980
|
+
{
|
|
981
|
+
id: "result.rows",
|
|
982
|
+
family: "support"
|
|
983
|
+
},
|
|
984
|
+
{
|
|
985
|
+
id: "result.command",
|
|
986
|
+
family: "support"
|
|
987
|
+
},
|
|
988
|
+
{
|
|
989
|
+
id: "result.multiple-sets",
|
|
990
|
+
family: "support"
|
|
991
|
+
},
|
|
992
|
+
{
|
|
993
|
+
id: "result.standard-schema",
|
|
994
|
+
family: "support"
|
|
995
|
+
},
|
|
996
|
+
{
|
|
997
|
+
id: "numeric.exact-integer",
|
|
998
|
+
family: "representation"
|
|
999
|
+
},
|
|
1000
|
+
{
|
|
1001
|
+
id: "numeric.exact-decimal",
|
|
1002
|
+
family: "representation"
|
|
1003
|
+
},
|
|
1004
|
+
{
|
|
1005
|
+
id: "numeric.approximate-float",
|
|
1006
|
+
family: "representation"
|
|
1007
|
+
},
|
|
1008
|
+
{
|
|
1009
|
+
id: "numeric.approximate-special",
|
|
1010
|
+
family: "representation"
|
|
1011
|
+
},
|
|
1012
|
+
{
|
|
1013
|
+
id: "numeric.bind-exact",
|
|
1014
|
+
family: "representation"
|
|
1015
|
+
},
|
|
1016
|
+
{
|
|
1017
|
+
id: "numeric.aggregate",
|
|
1018
|
+
family: "representation"
|
|
1019
|
+
},
|
|
1020
|
+
{
|
|
1021
|
+
id: "numeric.command-metadata",
|
|
1022
|
+
family: "representation"
|
|
1023
|
+
},
|
|
1024
|
+
{
|
|
1025
|
+
id: "numeric.special-values",
|
|
1026
|
+
family: "representation"
|
|
1027
|
+
},
|
|
1028
|
+
{
|
|
1029
|
+
id: "numeric.scale-greater-than-precision",
|
|
1030
|
+
family: "representation"
|
|
1031
|
+
},
|
|
1032
|
+
{
|
|
1033
|
+
id: "numeric.negative-scale",
|
|
1034
|
+
family: "representation"
|
|
1035
|
+
},
|
|
1036
|
+
{
|
|
1037
|
+
id: "data.json-parsed",
|
|
1038
|
+
family: "representation"
|
|
1039
|
+
},
|
|
1040
|
+
{
|
|
1041
|
+
id: "data.json-lossless-text",
|
|
1042
|
+
family: "representation"
|
|
1043
|
+
},
|
|
1044
|
+
{
|
|
1045
|
+
id: "data.sql-variant",
|
|
1046
|
+
family: "representation"
|
|
1047
|
+
},
|
|
1048
|
+
{
|
|
1049
|
+
id: "data.oracle-object",
|
|
1050
|
+
family: "representation"
|
|
1051
|
+
},
|
|
1052
|
+
{
|
|
1053
|
+
id: "data.oracle-collection",
|
|
1054
|
+
family: "representation"
|
|
1055
|
+
},
|
|
1056
|
+
{
|
|
1057
|
+
id: "data.vector",
|
|
1058
|
+
family: "representation"
|
|
1059
|
+
},
|
|
1060
|
+
{
|
|
1061
|
+
id: "data.binary",
|
|
1062
|
+
family: "representation"
|
|
1063
|
+
},
|
|
1064
|
+
{
|
|
1065
|
+
id: "data.uuid",
|
|
1066
|
+
family: "representation"
|
|
1067
|
+
},
|
|
1068
|
+
{
|
|
1069
|
+
id: "data.temporal-native",
|
|
1070
|
+
family: "representation"
|
|
1071
|
+
},
|
|
1072
|
+
{
|
|
1073
|
+
id: "data.temporal-lossless",
|
|
1074
|
+
family: "representation"
|
|
1075
|
+
},
|
|
1076
|
+
{
|
|
1077
|
+
id: "data.timezone",
|
|
1078
|
+
family: "representation"
|
|
1079
|
+
},
|
|
1080
|
+
{
|
|
1081
|
+
id: "metadata.command-safe",
|
|
1082
|
+
family: "metadata"
|
|
1083
|
+
},
|
|
1084
|
+
{
|
|
1085
|
+
id: "dml.insert-returning",
|
|
1086
|
+
family: "support"
|
|
1087
|
+
},
|
|
1088
|
+
{
|
|
1089
|
+
id: "dml.update-returning",
|
|
1090
|
+
family: "support"
|
|
1091
|
+
},
|
|
1092
|
+
{
|
|
1093
|
+
id: "dml.delete-returning",
|
|
1094
|
+
family: "support"
|
|
1095
|
+
},
|
|
1096
|
+
{
|
|
1097
|
+
id: "dml.merge-returning",
|
|
1098
|
+
family: "support"
|
|
1099
|
+
},
|
|
1100
|
+
{
|
|
1101
|
+
id: "dml.upsert-returning",
|
|
1102
|
+
family: "support"
|
|
1103
|
+
},
|
|
1104
|
+
{
|
|
1105
|
+
id: "session.pinned",
|
|
1106
|
+
family: "support"
|
|
1107
|
+
},
|
|
1108
|
+
{
|
|
1109
|
+
id: "statement.prepare",
|
|
1110
|
+
family: "support"
|
|
1111
|
+
},
|
|
1112
|
+
{
|
|
1113
|
+
id: "statement.cancel",
|
|
1114
|
+
family: "support"
|
|
1115
|
+
},
|
|
1116
|
+
{
|
|
1117
|
+
id: "statement.stream",
|
|
1118
|
+
family: "support"
|
|
1119
|
+
},
|
|
1120
|
+
{
|
|
1121
|
+
id: "statement.bulk",
|
|
1122
|
+
family: "support"
|
|
1123
|
+
},
|
|
1124
|
+
{
|
|
1125
|
+
id: "execution.bulk-fidelity",
|
|
1126
|
+
family: "support"
|
|
1127
|
+
},
|
|
1128
|
+
{
|
|
1129
|
+
id: "transaction",
|
|
1130
|
+
family: "support"
|
|
1131
|
+
},
|
|
1132
|
+
{
|
|
1133
|
+
id: "transaction.savepoint",
|
|
1134
|
+
family: "support"
|
|
1135
|
+
},
|
|
1136
|
+
{
|
|
1137
|
+
id: "transaction.read-only",
|
|
1138
|
+
family: "support"
|
|
1139
|
+
},
|
|
1140
|
+
{
|
|
1141
|
+
id: "transaction.isolation.read-uncommitted",
|
|
1142
|
+
family: "support"
|
|
1143
|
+
},
|
|
1144
|
+
{
|
|
1145
|
+
id: "transaction.isolation.read-committed",
|
|
1146
|
+
family: "support"
|
|
1147
|
+
},
|
|
1148
|
+
{
|
|
1149
|
+
id: "transaction.isolation.repeatable-read",
|
|
1150
|
+
family: "support"
|
|
1151
|
+
},
|
|
1152
|
+
{
|
|
1153
|
+
id: "transaction.isolation.serializable",
|
|
1154
|
+
family: "support"
|
|
1155
|
+
},
|
|
1156
|
+
{
|
|
1157
|
+
id: "routine.call",
|
|
1158
|
+
family: "support"
|
|
1159
|
+
},
|
|
1160
|
+
{
|
|
1161
|
+
id: "routine.out",
|
|
1162
|
+
family: "support"
|
|
1163
|
+
},
|
|
1164
|
+
{
|
|
1165
|
+
id: "routine.inout",
|
|
1166
|
+
family: "support"
|
|
1167
|
+
},
|
|
1168
|
+
{
|
|
1169
|
+
id: "routine.result-sets",
|
|
1170
|
+
family: "support"
|
|
1171
|
+
},
|
|
1172
|
+
{
|
|
1173
|
+
id: "routine.out-cursor",
|
|
1174
|
+
family: "support"
|
|
1175
|
+
},
|
|
1176
|
+
{
|
|
1177
|
+
id: "routine.return-value",
|
|
1178
|
+
family: "support"
|
|
1179
|
+
},
|
|
1180
|
+
{
|
|
1181
|
+
id: "metadata.identity",
|
|
1182
|
+
family: "metadata"
|
|
1183
|
+
},
|
|
1184
|
+
{
|
|
1185
|
+
id: "metadata.generated",
|
|
1186
|
+
family: "metadata"
|
|
1187
|
+
},
|
|
1188
|
+
{
|
|
1189
|
+
id: "metadata.routines",
|
|
1190
|
+
family: "metadata"
|
|
1191
|
+
},
|
|
1192
|
+
{
|
|
1193
|
+
id: "metadata.types",
|
|
1194
|
+
family: "metadata"
|
|
1156
1195
|
}
|
|
1157
|
-
|
|
1196
|
+
];
|
|
1197
|
+
const WELL_KNOWN_CAPABILITIES = Object.freeze(definitions.map((entry) => Object.freeze(entry)));
|
|
1198
|
+
const WELL_KNOWN_CAPABILITY_IDS = Object.freeze(definitions.map(({ id }) => id));
|
|
1199
|
+
const wellKnownCapabilityIds = new Set(WELL_KNOWN_CAPABILITY_IDS);
|
|
1200
|
+
function isWellKnownCapabilityId(value) {
|
|
1201
|
+
return wellKnownCapabilityIds.has(value);
|
|
1202
|
+
}
|
|
1158
1203
|
|
|
1159
1204
|
//#endregion
|
|
1160
1205
|
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 };
|