@eltjs/elt-sqlite 0.1.3 → 0.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 +2 -1
- package/dist/computed-dataset.js +16 -3
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -197,7 +197,8 @@ At each refresh, the computed dataset compares the inputs with the output rows.
|
|
|
197
197
|
## When something fails
|
|
198
198
|
|
|
199
199
|
- **A rule failure** gives an output row with the status `failed` and the reason in `error`. The run continues, and the refresh after the next pass tries the input again.
|
|
200
|
-
- **A dataset failure**, for example a query that SQLite refuses, rejects the run, or it stops the watch.
|
|
200
|
+
- **A dataset failure**, for example a query that SQLite refuses, rejects the run, or it stops the watch, with a `DerivedDatasetError` that names the dataset.
|
|
201
|
+
- **A table that is gone**, for example one that a person dropped by hand, is no failure. A computed dataset that reads it waits and keeps its output rows. When the copy loads the table again, the dataset asks the rule only for inputs that changed.
|
|
201
202
|
- **A copy that failed** keeps its last committed rows. The derived datasets read those rows.
|
|
202
203
|
|
|
203
204
|
## Recipes
|
package/dist/computed-dataset.js
CHANGED
|
@@ -78,6 +78,8 @@ export class ComputedDataset extends DerivedDataset {
|
|
|
78
78
|
}
|
|
79
79
|
async refresh({ connections, signal, trigger, }) {
|
|
80
80
|
const inputs = this.#inputs(connections);
|
|
81
|
+
if (inputs === null)
|
|
82
|
+
return;
|
|
81
83
|
using database = openDestination(this.#into.path);
|
|
82
84
|
const key = this.#rule.key.name;
|
|
83
85
|
const stored = transaction(database, () => {
|
|
@@ -188,6 +190,10 @@ export class ComputedDataset extends DerivedDataset {
|
|
|
188
190
|
// Each input by key, from the rows of each relation of from that exists
|
|
189
191
|
// yet: what the copies loaded, or what a view before this dataset gives. A
|
|
190
192
|
// key read twice keeps its first input.
|
|
193
|
+
// null while a relation reads a table that is gone, such as one a person
|
|
194
|
+
// dropped by hand: its copy loads it again, and the dataset waits with what it
|
|
195
|
+
// made, as a view waits. Read as no rows, it would delete every output, and the
|
|
196
|
+
// reload would pay the rule for each again.
|
|
191
197
|
#inputs(connections) {
|
|
192
198
|
const inputs = new Map();
|
|
193
199
|
for (const target of this.#from) {
|
|
@@ -204,9 +210,16 @@ export class ComputedDataset extends DerivedDataset {
|
|
|
204
210
|
.prepare('SELECT 1 FROM sqlite_schema WHERE lower("name") = lower(?)')
|
|
205
211
|
.get(relation) === undefined)
|
|
206
212
|
continue;
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
.all()
|
|
213
|
+
let rows;
|
|
214
|
+
try {
|
|
215
|
+
rows = database.prepare(`SELECT * FROM ${quote(relation)}`).all();
|
|
216
|
+
}
|
|
217
|
+
catch (error) {
|
|
218
|
+
if (Error.isError(error) && error.message.startsWith('no such table: '))
|
|
219
|
+
return null;
|
|
220
|
+
throw error;
|
|
221
|
+
}
|
|
222
|
+
for (const row of rows) {
|
|
210
223
|
const read = this.#rule.read(row);
|
|
211
224
|
if (read !== null && !inputs.has(read.key))
|
|
212
225
|
inputs.set(read.key, read.input);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eltjs/elt-sqlite",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "The SQLite destination of elt: each stream is a raw table in one SQLite file, with a reader view over it and a catalog of each table, view and column.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"node": ">=24"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@eltjs/elt": "^0.
|
|
42
|
+
"@eltjs/elt": "^0.2.0",
|
|
43
43
|
"@zukhruf/mutex": "^0.8.10",
|
|
44
44
|
"@zukhruf/sqlite-drift": "^0.8.10",
|
|
45
45
|
"@zukhruf/sqlite-open": "^0.8.10",
|