jsql-neo 6.8.26 → 6.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -4
- package/index.d.ts +23 -5
- package/index.js +1 -1
- package/lib/columnar_fast.js +13 -2
- package/lib/database.js +306 -47
- package/lib/errors.js +2 -0
- package/lib/migrate.js +30 -3
- package/lib/mongo_server.js +42 -9
- package/lib/multiserver.js +4 -1
- package/lib/mysql_server.js +13 -1
- package/lib/pg_server.js +8 -2
- package/lib/redis_server.js +4 -1
- package/lib/sql.js +140 -23
- package/lib/table.js +42 -5
- package/package.json +2 -2
- package/test/columnar-vector.test.js +2 -1
- package/test/issue-259-264.test.js +5 -1
- package/test/issue-329-346.test.js +22 -5
- package/test/issue-445-449.test.js +271 -0
- package/test/issue-450-454.test.js +202 -0
- package/test/issue-455-459.test.js +348 -0
- package/test/issue-460-464.test.js +195 -0
- package/test/issue-465-469.test.js +201 -0
- package/test/issue-471.test.js +150 -0
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
> **One engine to rule them all** — a Rust-powered embedded database that speaks your language:
|
|
4
4
|
> MySQL, PostgreSQL, MongoDB, Redis, SQL, TypeScript, **and the browser**.
|
|
5
5
|
|
|
6
|
-
> **v6.
|
|
6
|
+
> **v6.9.0** — stable release · [github.com/vexify-org/JSQL-neo](https://github.com/vexify-org/JSQL-neo) · [jsql.vexify.top](https://jsql.vexify.top)
|
|
7
7
|
|
|
8
8
|

|
|
9
9
|

|
|
@@ -172,9 +172,12 @@ await db.start();
|
|
|
172
172
|
File mode (`new Database('./data/db.json')`) is **not** an in-memory store that only
|
|
173
173
|
writes on exit. Every `insert` / `insertMany` / `update` / `updateById` / `remove` /
|
|
174
174
|
`removeById` / `softDelete` / `truncate` appends one JSONL record to `<file>.wal` and
|
|
175
|
-
|
|
176
|
-
`
|
|
177
|
-
|
|
175
|
+
writes it to the kernel before returning, so a `kill -9` loses nothing that already
|
|
176
|
+
committed. `fsync` is coalesced into a short window (`walSyncInterval`, default 20 ms)
|
|
177
|
+
so bulk single-row writes no longer pay one disk flush per row — set it to `0` for the
|
|
178
|
+
strictest per-write `fsync` behaviour (roughly an order of magnitude slower).
|
|
179
|
+
`save()` / `close()` / `stop()` checkpoint the WAL (write a full snapshot, `fsync`, then
|
|
180
|
+
truncate) and always flush any pending window first.
|
|
178
181
|
WAL is on by default for file mode — pass `wal: false` for the old semantics, or tune
|
|
179
182
|
auto-checkpointing with `walCheckpointOps` (default 1000, `0` disables). Directory
|
|
180
183
|
(`mode: 'disk' | 'hybrid'`) and encrypted (`encryptKey`) databases keep it off unless
|
package/index.d.ts
CHANGED
|
@@ -295,6 +295,7 @@ declare namespace JSQLNeo {
|
|
|
295
295
|
allowComments?: boolean;
|
|
296
296
|
safety?: boolean;
|
|
297
297
|
maxStatements?: number;
|
|
298
|
+
allowStacked?: boolean;
|
|
298
299
|
session?: Record<string, unknown>;
|
|
299
300
|
/** 5.5.0+:原生 `?` 占位符绑定值(与 applyParams 的数组入参二选一) */
|
|
300
301
|
params?: unknown[];
|
|
@@ -334,13 +335,30 @@ declare namespace JSQLNeo {
|
|
|
334
335
|
export function transform(ast: unknown, fn: (node: unknown) => unknown): unknown;
|
|
335
336
|
|
|
336
337
|
export interface DatabaseOptions {
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
338
|
+
mode?: 'memory' | 'hybrid' | 'disk';
|
|
339
|
+
autoSave?: boolean;
|
|
340
|
+
autoSaveInterval?: number;
|
|
341
|
+
memReserveMB?: number;
|
|
342
|
+
flushInterval?: number;
|
|
343
|
+
evictInterval?: number;
|
|
344
|
+
encryptKey?: string;
|
|
345
|
+
versioning?: boolean;
|
|
346
|
+
wal?: boolean;
|
|
347
|
+
walCheckpointOps?: number;
|
|
348
|
+
walSyncInterval?: number;
|
|
349
|
+
isolationLevel?: 'READ_COMMITTED' | 'REPEATABLE_READ';
|
|
350
|
+
slowQueryThreshold?: number;
|
|
351
|
+
fileLock?: boolean;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
export interface DatastoreOptions {
|
|
355
|
+
filename?: string;
|
|
356
|
+
database?: unknown;
|
|
357
|
+
engine?: unknown;
|
|
340
358
|
}
|
|
341
359
|
|
|
342
360
|
export class Database {
|
|
343
|
-
constructor(options?: DatabaseOptions);
|
|
361
|
+
constructor(filePath?: string, options?: DatabaseOptions);
|
|
344
362
|
createTable(name: string, schema: Schema): Promise<unknown>;
|
|
345
363
|
insert(table: string, data: Record<string, unknown>): Promise<unknown>;
|
|
346
364
|
find(table: string, filter?: Record<string, unknown>): Promise<Row[]>;
|
|
@@ -424,7 +442,7 @@ declare namespace JSQLNeo {
|
|
|
424
442
|
}
|
|
425
443
|
|
|
426
444
|
export class Datastore {
|
|
427
|
-
constructor(options?:
|
|
445
|
+
constructor(options?: DatastoreOptions);
|
|
428
446
|
insert(docs: unknown): Promise<unknown>;
|
|
429
447
|
find(query?: unknown): Promise<unknown[]>;
|
|
430
448
|
update(query: unknown, update: unknown): Promise<number>;
|
package/index.js
CHANGED
package/lib/columnar_fast.js
CHANGED
|
@@ -14,6 +14,17 @@ function colNameOf(node) {
|
|
|
14
14
|
return node.type === 'column' ? node.name : null;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
+
/**
|
|
18
|
+
* #469:聚合输出列名,与行存命名规则一致 —— 保留实参 / `*`:
|
|
19
|
+
* COUNT(v)、COUNT(*)、MIN(s),不得退化为 COUNT()。
|
|
20
|
+
*/
|
|
21
|
+
function aggLabel(fn, col) {
|
|
22
|
+
let arg;
|
|
23
|
+
if (col == null || col.type === 'star' || col.type === '*') arg = '*';
|
|
24
|
+
else arg = colNameOf(col) || '*';
|
|
25
|
+
return fn + '(' + arg + ')';
|
|
26
|
+
}
|
|
27
|
+
|
|
17
28
|
/**
|
|
18
29
|
* 把 WHERE 编译成「命中行下标数组」。
|
|
19
30
|
* 只支持 `列 OP 字面量` 以及它们的 AND 组合;其它(OR / LIKE / 函数 / 子查询 /
|
|
@@ -196,7 +207,7 @@ function aggregate(statement, data) {
|
|
|
196
207
|
default: return null;
|
|
197
208
|
}
|
|
198
209
|
outRow.push(v);
|
|
199
|
-
outCols.push(c.alias || (fn
|
|
210
|
+
outCols.push(c.alias || aggLabel(fn, argNode));
|
|
200
211
|
}
|
|
201
212
|
return { type: 'select', columns: outCols, rows: [outRow] };
|
|
202
213
|
}
|
|
@@ -339,7 +350,7 @@ function groupBy(statement, data) {
|
|
|
339
350
|
outRows.push(row);
|
|
340
351
|
}
|
|
341
352
|
const outCols = cols.map(c => c.alias || (c.aggregate
|
|
342
|
-
? String(c.aggregate).toUpperCase()
|
|
353
|
+
? aggLabel(String(c.aggregate).toUpperCase(), c.column)
|
|
343
354
|
: colNameOf(c.scalar || c.expr)));
|
|
344
355
|
|
|
345
356
|
// ORDER BY:在分组结果上排序 —— 组数通常远小于行数,代价很低。
|