sqlite-hub 0.9.13 → 0.10.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/frontend/js/api.js +7 -0
- package/frontend/js/app.js +20 -4
- package/frontend/js/components/modal.js +98 -1
- package/frontend/js/components/queryEditor.js +1 -8
- package/frontend/js/store.js +176 -10
- package/frontend/js/views/data.js +39 -1
- package/frontend/js/views/editor.js +1 -3
- package/frontend/js/views/structure.js +43 -5
- package/frontend/styles/tailwind.generated.css +1 -1
- package/frontend/styles/views.css +4 -0
- package/package.json +1 -1
- package/server/routes/data.js +14 -0
- package/server/services/sqlite/dataBrowserService.js +124 -44
- package/tests/sql-identifier-safety.test.js +48 -8
|
@@ -8,6 +8,7 @@ test("data browser mutations preserve quoted dynamic identifiers", () => {
|
|
|
8
8
|
const db = new Database(":memory:");
|
|
9
9
|
const tableName = 'items" archived';
|
|
10
10
|
const valueColumn = 'display"name';
|
|
11
|
+
const noteColumn = 'review"note';
|
|
11
12
|
|
|
12
13
|
try {
|
|
13
14
|
db.exec(
|
|
@@ -16,7 +17,9 @@ test("data browser mutations preserve quoted dynamic identifiers", () => {
|
|
|
16
17
|
quoteIdentifier(tableName),
|
|
17
18
|
"(",
|
|
18
19
|
quoteIdentifier(valueColumn),
|
|
19
|
-
"TEXT, status INTEGER",
|
|
20
|
+
"TEXT, status INTEGER,",
|
|
21
|
+
quoteIdentifier(noteColumn),
|
|
22
|
+
"TEXT",
|
|
20
23
|
")",
|
|
21
24
|
].join(" ")
|
|
22
25
|
);
|
|
@@ -24,10 +27,10 @@ test("data browser mutations preserve quoted dynamic identifiers", () => {
|
|
|
24
27
|
[
|
|
25
28
|
"INSERT INTO",
|
|
26
29
|
quoteIdentifier(tableName),
|
|
27
|
-
"(" + quoteIdentifier(valueColumn) + ", status)",
|
|
28
|
-
"VALUES (?, ?)",
|
|
30
|
+
"(" + quoteIdentifier(valueColumn) + ", status, " + quoteIdentifier(noteColumn) + ")",
|
|
31
|
+
"VALUES (?, ?, ?)",
|
|
29
32
|
].join(" ")
|
|
30
|
-
).run("before", 0);
|
|
33
|
+
).run("before", 0, null);
|
|
31
34
|
|
|
32
35
|
const service = new DataBrowserService({
|
|
33
36
|
connectionManager: {
|
|
@@ -37,19 +40,56 @@ test("data browser mutations preserve quoted dynamic identifiers", () => {
|
|
|
37
40
|
});
|
|
38
41
|
const tableData = service.getTableData(tableName, { limit: 10, offset: 0 });
|
|
39
42
|
const identity = tableData.rows[0].__identity;
|
|
43
|
+
const preview = service.previewTableRowUpdate(tableName, {
|
|
44
|
+
identity,
|
|
45
|
+
values: {
|
|
46
|
+
[valueColumn]: "after",
|
|
47
|
+
status: 0,
|
|
48
|
+
[noteColumn]: "",
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
assert.equal(
|
|
53
|
+
preview.sql,
|
|
54
|
+
[
|
|
55
|
+
"UPDATE",
|
|
56
|
+
quoteIdentifier(tableName),
|
|
57
|
+
"SET",
|
|
58
|
+
quoteIdentifier(valueColumn) + " = ?",
|
|
59
|
+
"WHERE",
|
|
60
|
+
"rowid IS ?",
|
|
61
|
+
].join(" ")
|
|
62
|
+
);
|
|
63
|
+
assert.deepEqual(preview.changes, [
|
|
64
|
+
{
|
|
65
|
+
column: valueColumn,
|
|
66
|
+
oldValue: "before",
|
|
67
|
+
newValue: "after",
|
|
68
|
+
},
|
|
69
|
+
]);
|
|
40
70
|
|
|
41
71
|
const updated = service.updateTableRow(tableName, {
|
|
42
72
|
identity,
|
|
43
73
|
values: {
|
|
44
74
|
[valueColumn]: "after",
|
|
75
|
+
[noteColumn]: "",
|
|
45
76
|
},
|
|
46
77
|
});
|
|
47
78
|
|
|
48
79
|
assert.equal(updated.row[valueColumn], "after");
|
|
49
|
-
assert.equal(
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
80
|
+
assert.equal(updated.row[noteColumn], null);
|
|
81
|
+
const persistedRow = db.prepare(
|
|
82
|
+
[
|
|
83
|
+
"SELECT",
|
|
84
|
+
quoteIdentifier(valueColumn) + ",",
|
|
85
|
+
quoteIdentifier(noteColumn),
|
|
86
|
+
"FROM",
|
|
87
|
+
quoteIdentifier(tableName),
|
|
88
|
+
].join(" ")
|
|
89
|
+
).get();
|
|
90
|
+
|
|
91
|
+
assert.equal(persistedRow[valueColumn], "after");
|
|
92
|
+
assert.equal(persistedRow[noteColumn], null);
|
|
53
93
|
|
|
54
94
|
const deleted = service.deleteTableRow(tableName, {
|
|
55
95
|
identity: updated.row.__identity,
|