nedb-engine 6.0.0 → 7.2.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 CHANGED
@@ -31,28 +31,123 @@ One Rust core → ships to **PyPI** and **npm** from a single source.
31
31
 
32
32
  ---
33
33
 
34
- ## What's next — [neSQL](https://github.com/Eth-Interchained/neSQL)
34
+ ## [neSQL](https://github.com/Eth-Interchained/neSQL) — the language this engine speaks
35
35
 
36
- Nobody should have to learn a query language to use a database. NEDB's PostgreSQL
37
- endpoint already answers `psql`, SQLAlchemy Core **and** ORM, asyncpg and
38
- node-postgres against a live store — but it gets there by *translating* SQL into
36
+ Nobody should have to learn a query language to use a database. That sentence cost
37
+ us one.
38
+
39
+ NEDB's PostgreSQL endpoint answers `psql`, SQLAlchemy Core **and** ORM, asyncpg and
40
+ node-postgres against a live store. It used to get there by *translating* SQL into
39
41
  NQL, and a translation can only reach as far as the target language's shape.
40
42
 
41
- **[neSQL](https://github.com/Eth-Interchained/neSQL)** removes the translation.
42
- PostgreSQL's real grammar (`gram.y`, 19,513 lines, 492 keywords, vendored from
43
- 17.4 at [`vendor/postgresql/`](vendor/postgresql/) with its licence intact),
44
- extended with NEDB's temporal and causal clauses. **Two front-ends, one plan.
45
- NQL folded in, not deleted.**
43
+ **neSQL is the name for what replaced that.** PostgreSQL's real grammar (`gram.y`,
44
+ 19,513 lines, 492 keywords, vendored from 17.4 at
45
+ [`vendor/postgresql/`](vendor/postgresql/) with its licence intact), extended with
46
+ NEDB's temporal and causal clauses. **Two front-ends, one plan. NQL folded in, not
47
+ deleted.**
48
+
49
+ **neQL** is the name for the pair — NQL *and* PostgreSQL SQL, one language with two
50
+ halves. Which half a statement is read as is decided **structurally**, not guessed:
51
+ NQL statements begin `FROM`, and PostgreSQL has no statement form that begins with
52
+ `FROM`, so the leading keyword partitions the two vocabularies rather than hinting
53
+ at them. A first word in neither is refused *naming both*.
54
+
55
+ This section is not a roadmap. Everything below ships in this release — the
56
+ evaluator with no flag to set, the `nesql` CLI likewise.
46
57
 
47
58
  [![neSQL on PyPI](https://img.shields.io/pypi/v/nesql?label=nesql%20·%20PyPI&color=a855f7)](https://pypi.org/project/nesql/)
48
59
  [![neSQL on crates.io](https://img.shields.io/crates/v/nesql?label=nesql%20·%20crates.io&color=a855f7)](https://crates.io/crates/nesql)
49
60
  [![neSQL on npm](https://img.shields.io/npm/v/nesql-engine?label=nesql-engine%20·%20npm&color=a855f7)](https://www.npmjs.com/package/nesql-engine)
50
61
 
51
- ### Available now, opt-in: `NEDBD_SQL_ENGINE=1`
62
+ Those three badges read **0.0.1** next to an engine at 6.1.0, and that is
63
+ deliberate rather than neglected. They are **reserved names**: each package loads,
64
+ reports the vendored PostgreSQL release, and answers `is_release() == false`,
65
+ because a package that imports cleanly and then lies is worse than one that is not
66
+ published. The engine you actually install is `nedb-engine`. The
67
+ [neSQL repository](https://github.com/Eth-Interchained/neSQL) holds the language —
68
+ both halves of the grammar and the CLI's source, side by side.
69
+
70
+ ### `nesql` — the CLI, and it speaks neQL
71
+
72
+ Ships in this release, no flag. `nesql` opens a store directly — no daemon, no
73
+ port — and answers both halves of the language through **one** `query` command:
74
+
75
+ ```console
76
+ $ nesql --db ./store query "SELECT who, total FROM orders ORDER BY total DESC"
77
+ {"who":"globex","total":250,...}
78
+ {"who":"acme","total":100,...}
79
+ (2 rows)
80
+
81
+ $ nesql --db ./store query "FROM orders WHERE total > 150"
82
+ {"who":"globex","total":250,...}
83
+ (1 rows, 1 scanned)
84
+ ```
85
+
86
+ Same command, two dialects, routed on the leading keyword. `--nql` / `--sql`
87
+ force one when you want *that dialect's* error rather than a routing error —
88
+ `query --nql "SELECT 1"` tells you `expected keyword FROM`, which is the useful
89
+ answer when you are debugging why something was rejected.
90
+
91
+ It is built for scripts as much as for people. `--json` emits exactly one JSON
92
+ object on stdout — engine diagnostics go to stderr, so a pipe stays clean — and
93
+ the exit code carries the verdict:
94
+
95
+ | | |
96
+ | --- | --- |
97
+ | `0` | success — the thing was done, or the check ran and passed |
98
+ | `1` | failure — the operation ran and did not succeed |
99
+ | `2` | usage — the command line was not understood, or was ambiguous |
100
+ | `3` | **could not determine** — the check could not run (history pruned) |
101
+ | `4` | not found |
102
+ | `5` | unsupported — a version or format this build does not know |
103
+
104
+ **`3` is the one that matters.** A pruned history is not a corrupt one, and an
105
+ operator who cannot tell those apart will either ignore a real alarm or panic at
106
+ a routine one. `root verify` reports the stored record and the recomputation as
107
+ two independent facts and never collapses them:
108
+
109
+ ```console
110
+ $ nesql --db ./store root verify
111
+ at_seq 2
112
+ root_record valid
113
+ recomputation matches
114
+ exit 0
115
+ ```
116
+
117
+ `root_record valid` / `recomputation unavailable` with exit 3 is a pruned store
118
+ answering honestly. Only `recomputation DIFFERS` means something is wrong.
119
+
120
+ The rest of the surface: `status`, `log`, `inspect` (a collection, a document, a
121
+ sequence, or a persisted root — named by kind, because a bare `42` could be
122
+ `seq:42` or `root:42` and the CLI refuses to pick), `diff`, immutable `tag`,
123
+ `branch`, `merge` with first-class conflicts, and `grammar` / `constitution`,
124
+ which publish the command surface and the engine's guarantees with digests you
125
+ can compare across builds.
126
+
127
+ ```console
128
+ $ nesql constitution
129
+ engine 6.1.0
130
+ nesql 6.1.0
131
+ verdict compatible with gaps
132
+ nql grammar ef0f1696... (agrees — same grammar this build compiled against)
133
+ ```
52
134
 
53
- The SQL engine is in this release and it is **off by default**. Turn it on and a
54
- user collection is answered by a real SQL evaluator instead of a translation —
55
- every one of these works, and every one is refused *by name* without it:
135
+ ### One evaluator, no flag
136
+
137
+ The SQL evaluator answers **every `SELECT` it can parse** user collections
138
+ included, with nothing to turn on. `NEDBD_SQL_ENGINE` is gone; a deployment
139
+ still exporting it is told the variable is inert rather than left believing it
140
+ holds a switch.
141
+
142
+ It used to be opt-in, and the honest reason it is not any more is that the two
143
+ sides were never two correct answers. `SELECT who FROM orders` returned
144
+ `who, total, _id, _hash, _seq, _coll` on the translator, because NQL has no
145
+ projection to translate a column list into. A flag whose positions give
146
+ different answers to the same correct SQL is not a parity switch.
147
+
148
+ What did not change is the fallthrough, which was never the flag: a statement
149
+ the evaluator cannot **parse** still goes to the translator, and that is how
150
+ every write is served.
56
151
 
57
152
  ```sql
58
153
  SELECT o._id, d.name FROM orders o JOIN drivers d ON o.driver = d._id;
@@ -91,11 +186,10 @@ the other. `AS OF SYSTEM TIME`, `VALID AS OF` and `SEARCH` are **unreserved
91
186
  keywords**: a collection aliased `search`, or a column named `valid`, keeps
92
187
  working exactly as before.
93
188
 
94
- **Why it is opt-in rather than the default**, stated plainly because the reason
95
- is the interesting part. A parity harness runs the same corpus through both
96
- engines and asserts identical answers — 44 checks, in CI, and it is what earns
97
- the flag being flipped rather than a benchmark. It already found two real
98
- divergences: `SELECT *` returned its columns in a different order on each
189
+ **What earned the flag's removal**, stated plainly because the reason is the
190
+ interesting part. A parity harness runs the same corpus through both paths and
191
+ asserts identical answers — 44 checks, in CI and it is that, rather than a
192
+ benchmark, that earned it. It found two real divergences: `SELECT *` returned its columns in a different order on each
99
193
  engine, and the SQL evaluator built its column list from the **first row alone**,
100
194
  so a field only later documents carried silently did not appear at all.
101
195
 
@@ -260,7 +354,7 @@ all the work in this sentence. Every refusal below traces to the same cause:
260
354
  NQL is the engine's native language, so SQL has to be rewritten into it, and a
261
355
  rewrite can only ever reach as far as the target language's shape.
262
356
 
263
- | Supported on the default path | Refused there, with the reason | `NEDBD_SQL_ENGINE=1` |
357
+ | Expressible in NQL | Not expressible there, and why | the evaluator |
264
358
  | --- | --- | --- |
265
359
  | `*`, a column list, `COUNT(*)`, `SUM`/`AVG`/`MIN`/`MAX(col)` | `JOIN` — NQL is single-collection | ✅ **works** (nested-loop + hash) |
266
360
  | `WHERE` — the whole NQL predicate surface | subqueries, `UNION`, window functions | ✅ **subqueries, `EXISTS`, `UNION`/`INTERSECT`/`EXCEPT` work**; window functions arrive with the grammar |
@@ -286,7 +380,7 @@ to them. Those answers do not change.
286
380
  > nested-loop and hash joins, subqueries, `EXISTS`, quantified comparisons, set
287
381
  > operations, `array_agg(x ORDER BY y)` and derived tables for some time — they
288
382
  > were simply unreachable *through a translator*, because the translator's
289
- > target was NQL. Set `NEDBD_SQL_ENGINE=1` and they are reachable.
383
+ > target was NQL. They are reachable now, with nothing to set.
290
384
  >
291
385
  > neSQL vendors PostgreSQL's **real grammar** — `gram.y`, 19,513 lines and 492
292
386
  > keywords, from 17.4, licence intact — and extends it with the clauses NEDB
@@ -929,9 +1023,38 @@ curl -X POST :7070/v1/databases -d '{
929
1023
  "links": [["users:u1","buys","orders:o1"]]
930
1024
  }}'
931
1025
 
932
- # Query (full NQL including time-travel and bi-temporal)
1026
+ # Query the endpoint speaks neQL: SQL *or* NQL, routed on the first keyword
1027
+ curl -X POST :7070/v1/databases/shop/query \
1028
+ -d '{"nql":"SELECT name FROM users WHERE status = '"'"'active'"'"' ORDER BY name"}'
1029
+ # → {"rows":[{"name":"Alice"}],"count":1,"dialect":"sql", ...}
1030
+
933
1031
  curl -X POST :7070/v1/databases/shop/query \
934
1032
  -d '{"nql":"FROM users WHERE status = \"active\" ORDER BY name ASC"}'
1033
+ # → {"rows":[...],"count":1,"dialect":"nql", ...}
1034
+
1035
+
1036
+ **The field is still called `nql`, and its contents no longer have to be.** This
1037
+ endpoint accepts **neQL** — NQL *or* PostgreSQL SQL — and answers with the
1038
+ `dialect` it chose. The name is unchanged because every existing HTTP client
1039
+ sends it; renaming would break them to gain nothing. Old NQL clients are
1040
+ unaffected.
1041
+
1042
+ Routing is **structural, not guessed**. NQL statements begin `FROM`; PostgreSQL
1043
+ has no statement form that begins with `FROM`, so the leading keyword partitions
1044
+ the two vocabularies rather than hinting at them. A first word in neither is
1045
+ refused *naming both* — never handed to whichever parser seems likelier.
1046
+
1047
+ ```bash
1048
+ curl -X POST :7070/v1/databases/shop/query -d '{"nql":"GRANT ALL ON users"}'
1049
+ # → 400 "GRANT" does not begin a statement in either half of neQL
1050
+ # NQL statements begin with: FROM
1051
+ # SQL statements begin with: SELECT, INSERT, UPDATE, ...
1052
+ ```
1053
+
1054
+ It is the **same router** `nesql query` uses — `nedb_engine::neql::route`, which
1055
+ the CLI re-exports rather than copies. Two implementations of that decision
1056
+ would let the daemon and the CLI disagree about what a statement *means*, which
1057
+ is worse than disagreeing about a result: nothing looks broken when it happens.
935
1058
 
936
1059
  # Verify the hash chain
937
1060
  curl :7070/v1/databases/shop/verify
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nedb-engine",
3
- "version": "6.0.0",
3
+ "version": "7.2.0",
4
4
  "description": "NEDB \u2014 hash-chained, time-traveling, bi-temporal embedded database with Rust native core. SQL, Redis, MongoDB adapters. Causal Write Provenance. RESP2 wire protocol.",
5
5
  "main": "index.js",
6
6
  "exports": {