@minnowdb/core 0.6.9 → 0.7.1
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/dist/block-format/block.js +254 -325
- package/dist/block-format/checksum.js +30 -52
- package/dist/block-format/codecs.js +112 -125
- package/dist/block-format/column.js +187 -205
- package/dist/block-format/index.js +5 -1
- package/dist/block-format/physical.js +371 -387
- package/dist/block-format/types.js +4 -1
- package/dist/block-format/unicode.js +30 -39
- package/dist/date-value.d.ts +5 -0
- package/dist/date-value.js +71 -41
- package/dist/engine/artifact-cache.js +106 -116
- package/dist/engine/batch.js +36 -44
- package/dist/engine/buffered-writer.js +156 -158
- package/dist/engine/byte-estimates.js +20 -22
- package/dist/engine/cache-limits.js +24 -25
- package/dist/engine/cancellation.js +5 -3
- package/dist/engine/catalog.js +64 -73
- package/dist/engine/client.js +715 -780
- package/dist/engine/database.js +15952 -18465
- package/dist/engine/defaults.js +104 -111
- package/dist/engine/errors.js +113 -128
- package/dist/engine/fts.js +233 -280
- package/dist/engine/group-index.js +287 -321
- package/dist/engine/index.js +23 -12
- package/dist/engine/join-index.js +177 -186
- package/dist/engine/keyed-live.js +168 -173
- package/dist/engine/live-api.js +0 -1
- package/dist/engine/live-equal.js +32 -37
- package/dist/engine/live.js +603 -647
- package/dist/engine/memory.js +109 -111
- package/dist/engine/optimizer.d.ts +19 -1
- package/dist/engine/optimizer.js +2642 -2515
- package/dist/engine/point-read.d.ts +4 -2
- package/dist/engine/point-read.js +121 -171
- package/dist/engine/query-api.js +12 -3
- package/dist/engine/query-cache.js +61 -69
- package/dist/engine/query.d.ts +45 -0
- package/dist/engine/query.js +8506 -9375
- package/dist/engine/result-wire.js +221 -252
- package/dist/engine/schema-wire.js +97 -112
- package/dist/engine/schema.js +1099 -1254
- package/dist/engine/sort-keys.js +315 -389
- package/dist/engine/sql-domains.d.ts +7 -1
- package/dist/engine/sql-domains.js +648 -734
- package/dist/engine/sql-driver.js +0 -1
- package/dist/engine/sql-functions.d.ts +11 -0
- package/dist/engine/sql-functions.js +1092 -0
- package/dist/engine/sql-json.js +199 -218
- package/dist/engine/sql-semantics.d.ts +25 -4
- package/dist/engine/sql-semantics.js +579 -513
- package/dist/engine/typed-live.js +271 -293
- package/dist/engine/vector.d.ts +7 -1
- package/dist/engine/vector.js +4513 -4580
- package/dist/engine/worker-host.d.ts +8 -63
- package/dist/engine/worker-host.js +28 -1130
- package/dist/engine/worker-indexeddb.d.ts +1 -0
- package/dist/engine/worker-indexeddb.js +3 -0
- package/dist/engine/worker-memory.d.ts +1 -0
- package/dist/engine/worker-memory.js +3 -0
- package/dist/engine/worker-opfs.d.ts +1 -0
- package/dist/engine/worker-opfs.js +3 -0
- package/dist/engine/worker-server.d.ts +93 -0
- package/dist/engine/worker-server.js +999 -0
- package/dist/engine/worker-store-indexeddb.d.ts +2 -0
- package/dist/engine/worker-store-indexeddb.js +11 -0
- package/dist/engine/worker-store-memory.d.ts +2 -0
- package/dist/engine/worker-store-memory.js +6 -0
- package/dist/engine/worker-store-opfs.d.ts +2 -0
- package/dist/engine/worker-store-opfs.js +9 -0
- package/dist/engine/worker.js +0 -12
- package/dist/engine/write-block-planner.js +93 -100
- package/dist/plan/index.js +15 -16
- package/dist/plan/model.d.ts +9 -1
- package/dist/plan/model.js +20 -27
- package/dist/storage/index.js +0 -12
- package/dist/storage/indexeddb.js +11776 -13171
- package/dist/storage/memory.js +1198 -1241
- package/dist/storage/opfs/files.js +238 -295
- package/dist/storage/opfs/index.js +9 -3
- package/dist/storage/opfs/leader.js +4386 -4856
- package/dist/storage/opfs/rpc.js +223 -259
- package/dist/storage/opfs/snapshot-ledger.js +219 -260
- package/dist/storage/opfs/store.js +884 -1003
- package/dist/storage/persistence.js +59 -74
- package/dist/storage/snapshot-stream.js +788 -826
- package/dist/storage/snapshot.js +36 -37
- package/dist/storage/toolkit/extents.js +444 -520
- package/dist/storage/toolkit/index.js +28 -29
- package/dist/storage/toolkit/record-core.js +5792 -6377
- package/dist/storage/toolkit/sync-file.js +34 -42
- package/dist/storage/toolkit/wal.js +92 -127
- package/dist/storage/toolkit/wire.js +232 -256
- package/dist/storage/types.js +2952 -3228
- package/dist/testing/block-store-conformance.js +1556 -1629
- package/dist/testing/index.js +310 -291
- package/dist/testing/opfs-shim.js +280 -312
- package/dist/testing/simulator.js +496 -534
- package/dist/testing/sqllogictest.js +425 -365
- package/dist/transactions/index.js +1464 -1712
- package/dist/worker-protocol/index.js +70 -69
- package/package.json +20 -2
- package/postgres-feature-profile.json +15 -5
- package/sql-feature-matrix.json +252 -2
package/dist/engine/sql-json.js
CHANGED
|
@@ -1,239 +1,220 @@
|
|
|
1
1
|
import { stringArgument } from "./sql-semantics.js";
|
|
2
2
|
import { externalSqlDomainValue, jsonDomainDocument } from "./sql-domains.js";
|
|
3
3
|
import { MAX_CACHEABLE_TEXT_CHARACTERS, MAX_SQL_SCALAR_RESULT_CHARACTERS } from "./cache-limits.js";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
4
|
+
function parseJsonPath(path, caller) {
|
|
5
|
+
const text = stringArgument(caller, path).trim();
|
|
6
|
+
if (text.length > MAX_CACHEABLE_TEXT_CHARACTERS) {
|
|
7
|
+
throw new RangeError(`${caller} path exceeds ${String(MAX_CACHEABLE_TEXT_CHARACTERS)} characters`);
|
|
8
|
+
}
|
|
9
|
+
if (!text.startsWith("$"))
|
|
10
|
+
throw new TypeError(`${caller} paths start at $`);
|
|
11
|
+
const steps = [];
|
|
12
|
+
let cursor = 1;
|
|
13
|
+
while (cursor < text.length) {
|
|
14
|
+
if (text[cursor] === ".") {
|
|
15
|
+
cursor += 1;
|
|
16
|
+
const start = cursor;
|
|
17
|
+
while (cursor < text.length && /[A-Za-z0-9_]/.test(text[cursor] ?? ""))
|
|
18
|
+
cursor += 1;
|
|
19
|
+
if (cursor === start)
|
|
20
|
+
throw new TypeError(`${caller} path expects a member name after .`);
|
|
21
|
+
steps.push({ kind: "member", name: text.slice(start, cursor), index: 0 });
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
if (text[cursor] === "[") {
|
|
25
|
+
const close = text.indexOf("]", cursor);
|
|
26
|
+
if (close === -1)
|
|
27
|
+
throw new TypeError(`${caller} path has an unclosed subscript`);
|
|
28
|
+
const inner = text.slice(cursor + 1, close).trim();
|
|
29
|
+
cursor = close + 1;
|
|
30
|
+
if (/^\d+$/.test(inner)) {
|
|
31
|
+
steps.push({ kind: "index", name: "", index: Number(inner) });
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
const quoted = /^'(.*)'$/.exec(inner) ?? /^"(.*)"$/.exec(inner);
|
|
35
|
+
if (quoted?.[1] !== void 0) {
|
|
36
|
+
steps.push({ kind: "member", name: quoted[1], index: 0 });
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
throw new TypeError(`${caller} paths take array indexes and member names, not: ${inner}`);
|
|
40
|
+
}
|
|
41
|
+
throw new TypeError(`${caller} path is not understood: ${text}`);
|
|
42
|
+
}
|
|
43
|
+
return steps;
|
|
44
44
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
45
|
+
function jsonAtPath(document, path, caller) {
|
|
46
|
+
const steps = parseJsonPath(path, caller);
|
|
47
|
+
let current;
|
|
48
|
+
const source = boundedJsonDocument(document, caller);
|
|
49
|
+
try {
|
|
50
|
+
current = JSON.parse(source);
|
|
51
|
+
} catch {
|
|
52
|
+
return { found: false };
|
|
53
|
+
}
|
|
54
|
+
for (const step of steps) {
|
|
55
|
+
if (current === null || current === void 0)
|
|
56
|
+
return { found: false };
|
|
57
|
+
if (step.kind === "index") {
|
|
58
|
+
if (!Array.isArray(current))
|
|
56
59
|
return { found: false };
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
return { found: false };
|
|
71
|
-
const members = current;
|
|
72
|
-
if (!Object.hasOwn(members, step.name))
|
|
73
|
-
return { found: false };
|
|
74
|
-
current = members[step.name];
|
|
75
|
-
}
|
|
76
|
-
return { found: true, value: current };
|
|
60
|
+
if (step.index >= current.length)
|
|
61
|
+
return { found: false };
|
|
62
|
+
current = current[step.index];
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
if (typeof current !== "object" || Array.isArray(current))
|
|
66
|
+
return { found: false };
|
|
67
|
+
const members = current;
|
|
68
|
+
if (!Object.hasOwn(members, step.name))
|
|
69
|
+
return { found: false };
|
|
70
|
+
current = members[step.name];
|
|
71
|
+
}
|
|
72
|
+
return { found: true, value: current };
|
|
77
73
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
|
|
109
|
-
return { found: false };
|
|
110
|
-
}
|
|
111
|
-
const members = parsed;
|
|
112
|
-
if (!Object.hasOwn(members, step))
|
|
113
|
-
return { found: false };
|
|
114
|
-
return { found: true, value: members[step] };
|
|
115
|
-
}
|
|
116
|
-
throw new TypeError(`${caller} keys are member names or array positions`);
|
|
74
|
+
function jsonArrowStep(document, key, caller) {
|
|
75
|
+
const source = boundedJsonDocument(document, caller);
|
|
76
|
+
let parsed;
|
|
77
|
+
try {
|
|
78
|
+
parsed = JSON.parse(source);
|
|
79
|
+
} catch {
|
|
80
|
+
throw new TypeError(`${caller} requires a JSON document`);
|
|
81
|
+
}
|
|
82
|
+
const step = externalSqlDomainValue(key);
|
|
83
|
+
if (typeof step === "number") {
|
|
84
|
+
if (!Number.isInteger(step)) {
|
|
85
|
+
throw new TypeError(`${caller} array positions are integers`);
|
|
86
|
+
}
|
|
87
|
+
if (!Array.isArray(parsed))
|
|
88
|
+
return { found: false };
|
|
89
|
+
const index = step < 0 ? parsed.length + step : step;
|
|
90
|
+
if (index < 0 || index >= parsed.length)
|
|
91
|
+
return { found: false };
|
|
92
|
+
return { found: true, value: parsed[index] };
|
|
93
|
+
}
|
|
94
|
+
if (typeof step === "string") {
|
|
95
|
+
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
|
|
96
|
+
return { found: false };
|
|
97
|
+
}
|
|
98
|
+
const members = parsed;
|
|
99
|
+
if (!Object.hasOwn(members, step))
|
|
100
|
+
return { found: false };
|
|
101
|
+
return { found: true, value: members[step] };
|
|
102
|
+
}
|
|
103
|
+
throw new TypeError(`${caller} keys are member names or array positions`);
|
|
117
104
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
return true;
|
|
143
|
-
}
|
|
105
|
+
function jsonIsValid(document, kind) {
|
|
106
|
+
document = externalSqlDomainValue(document);
|
|
107
|
+
if (typeof document !== "string")
|
|
108
|
+
return false;
|
|
109
|
+
if (document.length > MAX_SQL_SCALAR_RESULT_CHARACTERS) {
|
|
110
|
+
throw new RangeError(`JSON document exceeds ${String(MAX_SQL_SCALAR_RESULT_CHARACTERS)} characters`);
|
|
111
|
+
}
|
|
112
|
+
let parsed;
|
|
113
|
+
try {
|
|
114
|
+
parsed = JSON.parse(document);
|
|
115
|
+
} catch {
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
const isObject = typeof parsed === "object" && parsed !== null && !Array.isArray(parsed);
|
|
119
|
+
switch (kind) {
|
|
120
|
+
case "object":
|
|
121
|
+
return isObject;
|
|
122
|
+
case "array":
|
|
123
|
+
return Array.isArray(parsed);
|
|
124
|
+
case "scalar":
|
|
125
|
+
return !isObject && !Array.isArray(parsed);
|
|
126
|
+
default:
|
|
127
|
+
return true;
|
|
128
|
+
}
|
|
144
129
|
}
|
|
145
|
-
/** A SQL value as its JSON counterpart: datetimes serialize as ISO text, like every cast. */
|
|
146
130
|
function jsonValueOf(value) {
|
|
147
|
-
|
|
148
|
-
|
|
131
|
+
const external = externalSqlDomainValue(value);
|
|
132
|
+
return external instanceof Date ? dateIsoString(external) : external;
|
|
149
133
|
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
// Build JSON text directly. WITHOUT UNIQUE KEYS is the default, so duplicate names must be
|
|
177
|
-
// preserved; assigning through a JavaScript object would collapse them and mishandle
|
|
178
|
-
// special names such as "__proto__".
|
|
179
|
-
// Keys are always JSON strings. In particular, a JSON-domain expression used as a key is
|
|
180
|
-
// its document text, not a raw object member token as JSON-domain values are below.
|
|
181
|
-
const encodedKey = boundedJsonString(key, "JSON_OBJECT key");
|
|
182
|
-
const encodedValue = boundedJsonValue(member ?? null, "JSON_OBJECT value");
|
|
183
|
-
members.push(`${encodedKey}:${encodedValue}`);
|
|
184
|
-
}
|
|
185
|
-
return joinBoundedJson("{", members, "}", "JSON_OBJECT result");
|
|
134
|
+
function jsonConstructor(name, values) {
|
|
135
|
+
if (name === "JSON_ARRAY") {
|
|
136
|
+
const members2 = values.map((value) => boundedJsonValue(value ?? null, "JSON_ARRAY value"));
|
|
137
|
+
return joinBoundedJson("[", members2, "]", "JSON_ARRAY result");
|
|
138
|
+
}
|
|
139
|
+
const members = [];
|
|
140
|
+
for (let index = 0; index + 1 < values.length; index += 2) {
|
|
141
|
+
const rawKey = externalSqlDomainValue(values[index]);
|
|
142
|
+
if (rawKey === null || rawKey === void 0) {
|
|
143
|
+
throw new TypeError("JSON_OBJECT keys cannot be NULL");
|
|
144
|
+
}
|
|
145
|
+
let key;
|
|
146
|
+
if (rawKey instanceof Date)
|
|
147
|
+
key = dateIsoString(rawKey);
|
|
148
|
+
else if (typeof rawKey === "string")
|
|
149
|
+
key = rawKey;
|
|
150
|
+
else if (typeof rawKey === "number" || typeof rawKey === "boolean")
|
|
151
|
+
key = String(rawKey);
|
|
152
|
+
else
|
|
153
|
+
throw new TypeError("JSON_OBJECT keys must be scalar values");
|
|
154
|
+
const member = values[index + 1];
|
|
155
|
+
const encodedKey = boundedJsonString(key, "JSON_OBJECT key");
|
|
156
|
+
const encodedValue = boundedJsonValue(member ?? null, "JSON_OBJECT value");
|
|
157
|
+
members.push(`${encodedKey}:${encodedValue}`);
|
|
158
|
+
}
|
|
159
|
+
return joinBoundedJson("{", members, "}", "JSON_OBJECT result");
|
|
186
160
|
}
|
|
187
161
|
function boundedJsonString(value, label) {
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
162
|
+
if (value.length > MAX_SQL_SCALAR_RESULT_CHARACTERS) {
|
|
163
|
+
throw new RangeError(`${label} exceeds ${String(MAX_SQL_SCALAR_RESULT_CHARACTERS)} characters`);
|
|
164
|
+
}
|
|
165
|
+
const encoded = JSON.stringify(value);
|
|
166
|
+
if (encoded.length > MAX_SQL_SCALAR_RESULT_CHARACTERS) {
|
|
167
|
+
throw new RangeError(`${label} exceeds ${String(MAX_SQL_SCALAR_RESULT_CHARACTERS)} characters`);
|
|
168
|
+
}
|
|
169
|
+
return encoded;
|
|
196
170
|
}
|
|
197
171
|
function boundedJsonDocument(value, caller) {
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
172
|
+
const document = stringArgument(caller, externalSqlDomainValue(value));
|
|
173
|
+
if (document.length > MAX_SQL_SCALAR_RESULT_CHARACTERS) {
|
|
174
|
+
throw new RangeError(`${caller} document exceeds ${String(MAX_SQL_SCALAR_RESULT_CHARACTERS)} characters`);
|
|
175
|
+
}
|
|
176
|
+
return document;
|
|
203
177
|
}
|
|
204
178
|
function boundedJsonValue(value, label) {
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
179
|
+
const domainDocument = jsonDomainDocument(value);
|
|
180
|
+
if (domainDocument !== void 0) {
|
|
181
|
+
if (domainDocument.length > MAX_SQL_SCALAR_RESULT_CHARACTERS) {
|
|
182
|
+
throw new RangeError(`${label} exceeds ${String(MAX_SQL_SCALAR_RESULT_CHARACTERS)} characters`);
|
|
183
|
+
}
|
|
184
|
+
return domainDocument;
|
|
185
|
+
}
|
|
186
|
+
const normalized = jsonValueOf(value);
|
|
187
|
+
if (typeof normalized === "string" && normalized.length > MAX_SQL_SCALAR_RESULT_CHARACTERS) {
|
|
188
|
+
throw new RangeError(`${label} exceeds ${String(MAX_SQL_SCALAR_RESULT_CHARACTERS)} characters`);
|
|
189
|
+
}
|
|
190
|
+
const encoded = JSON.stringify(normalized);
|
|
191
|
+
if (typeof encoded !== "string")
|
|
192
|
+
throw new TypeError(`${label} is not JSON serializable`);
|
|
193
|
+
if (encoded.length > MAX_SQL_SCALAR_RESULT_CHARACTERS) {
|
|
194
|
+
throw new RangeError(`${label} exceeds ${String(MAX_SQL_SCALAR_RESULT_CHARACTERS)} characters`);
|
|
195
|
+
}
|
|
196
|
+
return encoded;
|
|
223
197
|
}
|
|
224
198
|
function joinBoundedJson(prefix, members, suffix, label) {
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
if (!Number.isSafeInteger(length) || length > MAX_SQL_SCALAR_RESULT_CHARACTERS) {
|
|
229
|
-
throw new RangeError(`${label} exceeds ${String(MAX_SQL_SCALAR_RESULT_CHARACTERS)} characters`);
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
if (members.length > 1)
|
|
233
|
-
length += members.length - 1;
|
|
199
|
+
let length = prefix.length + suffix.length;
|
|
200
|
+
for (const member of members) {
|
|
201
|
+
length += member.length;
|
|
234
202
|
if (!Number.isSafeInteger(length) || length > MAX_SQL_SCALAR_RESULT_CHARACTERS) {
|
|
235
|
-
|
|
236
|
-
}
|
|
237
|
-
|
|
203
|
+
throw new RangeError(`${label} exceeds ${String(MAX_SQL_SCALAR_RESULT_CHARACTERS)} characters`);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
if (members.length > 1)
|
|
207
|
+
length += members.length - 1;
|
|
208
|
+
if (!Number.isSafeInteger(length) || length > MAX_SQL_SCALAR_RESULT_CHARACTERS) {
|
|
209
|
+
throw new RangeError(`${label} exceeds ${String(MAX_SQL_SCALAR_RESULT_CHARACTERS)} characters`);
|
|
210
|
+
}
|
|
211
|
+
return `${prefix}${members.join(",")}${suffix}`;
|
|
238
212
|
}
|
|
239
213
|
import { dateIsoString } from "../date-value.js";
|
|
214
|
+
export {
|
|
215
|
+
jsonArrowStep,
|
|
216
|
+
jsonAtPath,
|
|
217
|
+
jsonConstructor,
|
|
218
|
+
jsonIsValid,
|
|
219
|
+
parseJsonPath
|
|
220
|
+
};
|
|
@@ -1,9 +1,23 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* optimization cannot silently change query results.
|
|
2
|
+
* The standard's datetime text — `2026-01-02`, `2026-01-02 03:04:05`, `2026-01-02T03:04:05.250Z`,
|
|
3
|
+
* an optional zone offset — read as an instant. A zoneless spelling is UTC, the reading every
|
|
4
|
+
* datetime in a Minnow database has; `undefined` for text in any other shape.
|
|
6
5
|
*/
|
|
6
|
+
export declare function parseSqlTimestampText(text: string): Date | undefined;
|
|
7
|
+
/**
|
|
8
|
+
* PostgreSQL reads an untyped string constant beside a typed value in that value's type:
|
|
9
|
+
* `joined >= '2026-01-01'`, `id = '5'`, `active = 't'`. Catalog-backed plans coerce such literals
|
|
10
|
+
* before execution; this runtime reading covers the schema-less row executor and anything the
|
|
11
|
+
* plan rewrite could not see. Text that does not parse in the other side's type keeps the
|
|
12
|
+
* comparable-types error below, so a genuine mismatch still fails.
|
|
13
|
+
*/
|
|
14
|
+
export declare function coercedComparable(text: string, other: unknown): unknown;
|
|
15
|
+
/**
|
|
16
|
+
* Applies the untyped-literal reading to a comparison's two operands: a plain string beside a
|
|
17
|
+
* typed value (datetime, DATE, number, boolean) is read in that value's type when it parses.
|
|
18
|
+
* Both executors call this before their own comparisons, so the reading is one decision.
|
|
19
|
+
*/
|
|
20
|
+
export declare function coerceComparisonOperands(left: unknown, right: unknown): [unknown, unknown];
|
|
7
21
|
/**
|
|
8
22
|
* Deterministic SQL ordering. Strings use Unicode codepoint order rather than host locale data,
|
|
9
23
|
* and signed zero compares equal because SQL numeric equality does not distinguish it.
|
|
@@ -24,6 +38,13 @@ interface SqlPatternMatcher {
|
|
|
24
38
|
}
|
|
25
39
|
/** Compiles SQL LIKE without exposing input to the host regular-expression engine. */
|
|
26
40
|
export declare function compileLikePattern(pattern: string, caseInsensitive?: boolean, escape?: string): SqlPatternMatcher;
|
|
41
|
+
/**
|
|
42
|
+
* PostgreSQL's ~ / ~* / !~ / !~* operators and REGEXP_REPLACE, compiled as JavaScript regular
|
|
43
|
+
* expressions. Advanced regular expressions and JavaScript agree on the everyday syntax; the
|
|
44
|
+
* `n` flag makes `.` and anchors newline-sensitive, `i` is case-insensitive, and `g` replaces
|
|
45
|
+
* every match. Patterns are bounded like every other SQL pattern.
|
|
46
|
+
*/
|
|
47
|
+
export declare function compileRegexPattern(pattern: string, flags?: string): RegExp;
|
|
27
48
|
/** PostgreSQL SIMILAR TO compiled to a Thompson NFA with bounded deterministic work. */
|
|
28
49
|
export declare function compileSimilarPattern(pattern: string, escape?: string): SqlPatternMatcher;
|
|
29
50
|
/** Defines an own enumerable result-column property, including the special name `__proto__`. */
|