quiverdb 0.9.9 → 0.9.10

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.
Binary file
Binary file
Binary file
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "quiverdb",
3
- "version": "0.9.9",
3
+ "version": "0.9.10",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
package/src/lua-api.ts CHANGED
@@ -42,8 +42,8 @@ Lua values map to Quiver column values as follows:
42
42
 
43
43
  | Lua value | Quiver value | Notes |
44
44
  | ------------------ | ------------ | ---------------------------------------------- |
45
- | integer | INTEGER | Lua integers map to int64. |
46
- | number (float) | REAL | REAL columns reject bare integers: write 75.0, not 75. |
45
+ | integer | INTEGER | Also accepted for REAL columns (coerced to real). |
46
+ | number (float) | REAL | A float is rejected for an INTEGER column. |
47
47
  | string | TEXT | Also used for \`date_time\` columns (ISO 8601). |
48
48
  | \`nil\` | NULL | In query params, file paths, and ts rows. |
49
49
  | table (1-indexed) | array | Used for vectors/sets and column-oriented data.|
@@ -60,8 +60,9 @@ datetime surface — there are no DateTime wrapper helpers, unlike Julia/Dart/Py
60
60
 
61
61
  ## Critical rules
62
62
 
63
- - **STRICT typing.** A REAL column rejects integer literals — write \`75.0\`, not \`75\`; an INTEGER
64
- column rejects floats. A mismatch raises a validation error and rolls the whole script back.
63
+ - **Type coercion.** An integer is accepted for a REAL column (coerced to real on insert); a float
64
+ is rejected for an INTEGER column. Other type mismatches raise a validation error and roll the
65
+ whole script back.
65
66
  - **Errors abort the script.** Any error thrown by a \`db:\` call stops the script and surfaces as
66
67
  \`Failed to run Lua script: <message>\`. Validation failures roll back whatever the current
67
68
  transaction covered.
@@ -78,6 +79,10 @@ datetime surface — there are no DateTime wrapper helpers, unlike Julia/Dart/Py
78
79
  see (it is captured). Arrays are 1-indexed (iterate with \`ipairs\`); reading a NULL yields \`nil\`,
79
80
  writing \`nil\` stores NULL where NULL is accepted (query params, ts rows, file columns — but NOT
80
81
  element scalar attributes; see CRUD).
82
+ - **Embedding harness may restrict further.** The library itself allows transactions and the
83
+ (sandboxed) CSV/file operations below. A host that runs your script (e.g. a hosted \`run_lua\`
84
+ tool) may disable some of them and report \`disabled in the run_lua sandbox\` — that limit comes
85
+ from the harness, not from quiverdb.
81
86
 
82
87
  ---
83
88
 
@@ -152,11 +157,16 @@ db:update_element("Collection", id, { some_integer = 999 })
152
157
  \`\`\`
153
158
 
154
159
  Notes:
160
+ - **\`update_element\` / \`delete_element\` require an existing id.** Targeting an id that does not
161
+ exist throws \`Element not found: <id> in collection '<collection>'\` (no silent no-op). Use
162
+ \`read_element_ids\` to get valid ids.
155
163
  - **Empty arrays are skipped.** An attribute whose value is \`{}\` writes no vector/set (the element
156
164
  type can't be inferred from an empty array), so it is silently dropped.
157
- - **No \`nil\` scalar attributes.** Passing \`nil\` for a scalar attribute **throws** (unsupported
158
- type). To leave a column unset, omit the key — you cannot set a scalar to NULL via the element
159
- table. (\`nil\` → NULL is only accepted by \`add_time_series_row\` and \`update_time_series_files\`.)
165
+ - **No \`nil\` scalar attributes.** In Lua a key set to \`nil\` is dropped from the table, so
166
+ \`{ x = nil }\` is identical to \`{}\`; an update/create table that ends up with no attributes
167
+ **throws** (\`element must have at least one attribute\`). To leave a column unchanged, omit the
168
+ key — you cannot set a scalar to NULL via the element table. (\`nil\` → NULL is only accepted by
169
+ \`add_time_series_row\` and \`update_time_series_files\`.)
160
170
 
161
171
  ---
162
172
 
@@ -367,7 +377,9 @@ entirely.
367
377
  ## Query (parameterized SQL)
368
378
 
369
379
  Positional \`?\` placeholders; \`params\` is an optional 1-indexed array. Each returns the first
370
- column of the first row as the requested type, or \`nil\` if there is no result.
380
+ column of the first row as the requested type, or \`nil\` if there is no result. The number of
381
+ \`params\` must match the number of \`?\` placeholders exactly — a mismatch (too few or too many)
382
+ throws rather than binding NULL or ignoring extras.
371
383
 
372
384
  \`\`\`lua
373
385
  db:query_string(sql, params) -- string or nil
@@ -477,7 +489,9 @@ db:csv_to_bin(path)
477
489
 
478
490
  local e = (quiver.expression(r) + 10.0) * 2.0 -- files auto-wrap; scalars either side
479
491
  e = quiver.abs(e); e = quiver.sqrt(e) -- also quiver.log / quiver.exp
480
- e = quiver.ifelse(cond_e, then_e, else_e)
492
+ local cond_e = quiver.gt(e, 3.0) -- gt/lt/gte/lte/eq/neq -> 1.0/0.0 (NaN -> NaN)
493
+ cond_e = cond_e & ~quiver.lt(e, 1.0) -- boolean logic via & | ~ operators (and/or/not are keywords)
494
+ e = quiver.ifelse(cond_e, then_e, else_e) -- build cond_e with comparison + logical operators
481
495
  e = e:aggregate("stage", "sum") -- sum/mean/min/max/percentile
482
496
  e = e:aggregate("stage", "percentile", 0.9) -- percentile needs the fraction
483
497
  e = e:aggregate_agents("mean") -- collapse the label axis