lines-db 0.18.0 → 0.19.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/CHANGELOG.md +21 -0
- package/README.md +2 -0
- package/bin/cli.mjs +320 -139
- package/dist/index.d.mts +26 -29
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +185 -63
- package/dist/index.mjs.map +1 -1
- package/dist/internal.d.mts +1 -3
- package/dist/internal.d.mts.map +1 -1
- package/dist/internal.mjs +1 -1
- package/dist/{jsonl-reader-CoYEJ9pg.d.mts → jsonl-reader-aQqE1pe5.d.mts} +10 -7
- package/dist/jsonl-reader-aQqE1pe5.d.mts.map +1 -0
- package/dist/{replace-file-AWLIm7aN.mjs → replace-file-fStWc0ej.mjs} +4 -7
- package/dist/{replace-file-AWLIm7aN.mjs.map → replace-file-fStWc0ej.mjs.map} +1 -1
- package/package.json +9 -9
- package/dist/jsonl-reader-CoYEJ9pg.d.mts.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# @toiroakr/lines-db
|
|
2
2
|
|
|
3
|
+
## 0.19.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 376a141: A JSON column now gives back a string, a boolean and a number as the value that was inserted. A string such as `"123"`, `"true"`, `"null"` or `'{"a":1}'` used to come back as a number, a boolean, null or an object, and `false` and `true` came back as `0` and `1`. Every value of a JSON column is now stored as JSON text with a string quoted, for `insert`, `batchInsert`, `update` (including `resetToDefault`) and the conditions of `find`, `update` and `delete` alike. Objects and arrays are stored as before, and the JSONL file still holds plain values.
|
|
8
|
+
|
|
9
|
+
Breaking for raw SQL: a string in a JSON column is now stored and read back through `query()` in its quoted form, so `WHERE data = 'abc'` becomes `WHERE data = '"abc"'`. `lines-db` also no longer warns "Failed to parse JSON column" for a plain string it wrote itself.
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 8deddc8: A table with a validation schema (a schema file, or `validationSchema` passed in code) no longer refuses a row that leaves out a field every existing row holds, when the schema takes that row. Before, the field was inferred as NOT NULL from the rows on disk, so inserting `{"id":3,"name":"c"}` into a table whose rows all had `nick` failed with `NOT NULL constraint failed: users.nick`, in `insert()` and in the studio's save, although the schema accepted the row. A field the schema fills in, or whose omission the schema rejects, stays as it was.
|
|
14
|
+
- aa9725e: `lines-db studio` now lists a table whose JSONL file has no rows, and a table with a primary key can have its first row added in the studio. The studio reads the columns of such a table from the types of its schema file, so the table is listed when the schema declares its input type through `~standard.types` (zod and valibot do; a hand-written Standard Schema has to declare `types`). Without types, the table stays out of the list as before. `DatabaseConfig` has a new `schemaOfEmptyTable` option to give the columns of a table with no rows. `lines-db validate` no longer says a table has "validation errors" when it only skips the foreign keys that point at an empty table; it says the table has no rows to read its columns from.
|
|
15
|
+
- 8deddc8: A boolean, object or array written into a field that no row holds a value in yet is now written back to the JSONL file as it was given. Before, saving `true` into a field that was `null` in every row wrote `1`, and an object wrote JSON text such as `"{\"a\":1}"`, which a schema that takes a boolean or an object then refuses on the next load. A string written first settles the field as text, so a later object is stored as text too, and a write that failed, matched no row or was rolled back leaves the field untyped.
|
|
16
|
+
- 8deddc8: Saving one row no longer rewrites the other rows of the file when the write-back writes only the primary key (`writeFilledValues: 'primaryKey'`, the studio's default). Before, a row nothing was written to had every field its line holds replaced by the value the schema computes: with a schema that computes `full` from `a` and `b`, saving row 1 changed `"full":"edited by hand"` in row 3 to `"full":"m-n"`. Such a row is now written as the file holds it. A field named in `writeBackFields`, and a foreign-key column that an `ON DELETE` / `ON UPDATE` `CASCADE` or `SET NULL` action can change, is still written from the database for every row.
|
|
17
|
+
|
|
18
|
+
## 0.18.1
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- e06facb: `lines-db validate` now prints a warning on stderr when every table it loaded has zero records (for example when all `.jsonl` files are empty placeholders), so a run that checked nothing no longer looks like a plain success. The exit code stays 0.
|
|
23
|
+
|
|
3
24
|
## 0.18.0
|
|
4
25
|
|
|
5
26
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -386,6 +386,8 @@ const order = unwrap(db.findOne('orders', { id: 1 }));
|
|
|
386
386
|
console.log(order.items[0].name); // "Laptop"
|
|
387
387
|
```
|
|
388
388
|
|
|
389
|
+
A JSON column keeps any value as it was inserted. Every value is stored as JSON text, a string quoted, so the string `"123"` is returned as `"123"`, and the number `123` as `123`. In SQL, a string is therefore compared in its quoted form: `WHERE data = '"abc"'`.
|
|
390
|
+
|
|
389
391
|
### Schema transformations
|
|
390
392
|
|
|
391
393
|
If a schema converts date strings to `Date` objects on load, define a `backward` transformation to convert them to strings when saving. JSONL stores the strings; the application works with `Date` objects.
|