@saltcorn/data 0.8.6-beta.8 → 0.8.6
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/dist/base-plugin/actions.js +14 -14
- package/dist/base-plugin/actions.js.map +1 -1
- package/dist/base-plugin/fieldviews.js +5 -5
- package/dist/base-plugin/fieldviews.js.map +1 -1
- package/dist/base-plugin/fileviews.js +18 -9
- package/dist/base-plugin/fileviews.js.map +1 -1
- package/dist/base-plugin/index.d.ts +330 -322
- package/dist/base-plugin/index.d.ts.map +1 -1
- package/dist/base-plugin/types.d.ts +35 -28
- package/dist/base-plugin/types.d.ts.map +1 -1
- package/dist/base-plugin/types.js +40 -24
- package/dist/base-plugin/types.js.map +1 -1
- package/dist/base-plugin/viewtemplates/edit.d.ts +3 -1
- package/dist/base-plugin/viewtemplates/edit.d.ts.map +1 -1
- package/dist/base-plugin/viewtemplates/edit.js +61 -43
- package/dist/base-plugin/viewtemplates/edit.js.map +1 -1
- package/dist/base-plugin/viewtemplates/feed.d.ts.map +1 -1
- package/dist/base-plugin/viewtemplates/feed.js +9 -8
- package/dist/base-plugin/viewtemplates/feed.js.map +1 -1
- package/dist/base-plugin/viewtemplates/filter.js +9 -9
- package/dist/base-plugin/viewtemplates/filter.js.map +1 -1
- package/dist/base-plugin/viewtemplates/list.js +20 -16
- package/dist/base-plugin/viewtemplates/list.js.map +1 -1
- package/dist/base-plugin/viewtemplates/listshowlist.js +4 -4
- package/dist/base-plugin/viewtemplates/listshowlist.js.map +1 -1
- package/dist/base-plugin/viewtemplates/room.js +6 -6
- package/dist/base-plugin/viewtemplates/room.js.map +1 -1
- package/dist/base-plugin/viewtemplates/show.d.ts.map +1 -1
- package/dist/base-plugin/viewtemplates/show.js +49 -18
- package/dist/base-plugin/viewtemplates/show.js.map +1 -1
- package/dist/base-plugin/viewtemplates/viewable_fields.d.ts.map +1 -1
- package/dist/base-plugin/viewtemplates/viewable_fields.js +4 -4
- package/dist/base-plugin/viewtemplates/viewable_fields.js.map +1 -1
- package/dist/db/state.d.ts +3 -2
- package/dist/db/state.d.ts.map +1 -1
- package/dist/db/state.js +5 -2
- package/dist/db/state.js.map +1 -1
- package/dist/models/config.d.ts.map +1 -1
- package/dist/models/config.js +13 -17
- package/dist/models/config.js.map +1 -1
- package/dist/models/field.d.ts.map +1 -1
- package/dist/models/field.js +12 -6
- package/dist/models/field.js.map +1 -1
- package/dist/models/file.d.ts.map +1 -1
- package/dist/models/file.js +4 -3
- package/dist/models/file.js.map +1 -1
- package/dist/models/form.d.ts.map +1 -1
- package/dist/models/form.js +2 -0
- package/dist/models/form.js.map +1 -1
- package/dist/models/index.d.ts +3 -3
- package/dist/models/layout.d.ts +1 -1
- package/dist/models/layout.d.ts.map +1 -1
- package/dist/models/layout.js +4 -1
- package/dist/models/layout.js.map +1 -1
- package/dist/models/page.d.ts.map +1 -1
- package/dist/models/page.js +28 -7
- package/dist/models/page.js.map +1 -1
- package/dist/models/random.js +3 -3
- package/dist/models/random.js.map +1 -1
- package/dist/models/table.d.ts +3 -2
- package/dist/models/table.d.ts.map +1 -1
- package/dist/models/table.js +37 -27
- package/dist/models/table.js.map +1 -1
- package/dist/models/table_constraints.d.ts +1 -1
- package/dist/models/table_constraints.d.ts.map +1 -1
- package/dist/models/table_constraints.js +2 -2
- package/dist/models/table_constraints.js.map +1 -1
- package/dist/models/trigger.js +2 -2
- package/dist/models/trigger.js.map +1 -1
- package/dist/models/user.d.ts.map +1 -1
- package/dist/models/user.js +1 -1
- package/dist/models/user.js.map +1 -1
- package/dist/models/view.d.ts.map +1 -1
- package/dist/models/view.js +9 -5
- package/dist/models/view.js.map +1 -1
- package/dist/plugin-helper.d.ts.map +1 -1
- package/dist/plugin-helper.js +17 -13
- package/dist/plugin-helper.js.map +1 -1
- package/dist/plugin-testing.js +1 -1
- package/dist/plugin-testing.js.map +1 -1
- package/dist/tests/actions.test.js +10 -10
- package/dist/tests/actions.test.js.map +1 -1
- package/dist/tests/auxtest.test.js +8 -8
- package/dist/tests/auxtest.test.js.map +1 -1
- package/dist/tests/calc.test.js +2 -2
- package/dist/tests/calc.test.js.map +1 -1
- package/dist/tests/email.test.js +1 -1
- package/dist/tests/email.test.js.map +1 -1
- package/dist/tests/exact_views.test.js +1 -1
- package/dist/tests/exact_views.test.js.map +1 -1
- package/dist/tests/field.test.js +13 -9
- package/dist/tests/field.test.js.map +1 -1
- package/dist/tests/models.test.js +2 -2
- package/dist/tests/models.test.js.map +1 -1
- package/dist/tests/table.test.js +92 -92
- package/dist/tests/table.test.js.map +1 -1
- package/dist/tests/user.test.js +1 -1
- package/dist/tests/user.test.js.map +1 -1
- package/dist/tests/view.test.js +8 -8
- package/dist/tests/view.test.js.map +1 -1
- package/dist/utils.d.ts +1 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +8 -0
- package/dist/utils.js.map +1 -1
- package/package.json +7 -7
- package/dist/base-plugin/base.test.d.ts +0 -2
- package/dist/base-plugin/base.test.d.ts.map +0 -1
- package/dist/base-plugin/base.test.js +0 -15
- package/dist/base-plugin/base.test.js.map +0 -1
package/dist/tests/table.test.js
CHANGED
|
@@ -45,7 +45,7 @@ jest.setTimeout(30000);
|
|
|
45
45
|
(0, globals_1.describe)("Table create basic tests", () => {
|
|
46
46
|
(0, globals_1.it)("should create", async () => {
|
|
47
47
|
const tc = await table_1.default.create("mytable1");
|
|
48
|
-
const tf =
|
|
48
|
+
const tf = table_1.default.findOne({ id: tc.id });
|
|
49
49
|
(0, assertions_1.assertIsSet)(tf);
|
|
50
50
|
(0, globals_1.expect)(tf.external).toBe(false);
|
|
51
51
|
(0, globals_1.expect)(tc.external).toBe(false);
|
|
@@ -67,7 +67,7 @@ jest.setTimeout(30000);
|
|
|
67
67
|
(0, globals_1.expect)(row.group).toBe(false);
|
|
68
68
|
});
|
|
69
69
|
(0, globals_1.it)("should create required field in empty table without default", async () => {
|
|
70
|
-
const mytable1 =
|
|
70
|
+
const mytable1 = table_1.default.findOne({ name: "mytable1" });
|
|
71
71
|
(0, globals_1.expect)(!!mytable1).toBe(true);
|
|
72
72
|
await field_1.default.create({
|
|
73
73
|
table: mytable1,
|
|
@@ -78,7 +78,7 @@ jest.setTimeout(30000);
|
|
|
78
78
|
});
|
|
79
79
|
});
|
|
80
80
|
(0, globals_1.it)("should insert", async () => {
|
|
81
|
-
const mytable1 =
|
|
81
|
+
const mytable1 = table_1.default.findOne({ name: "mytable1" });
|
|
82
82
|
(0, assertions_1.assertIsSet)(mytable1);
|
|
83
83
|
(0, globals_1.expect)(mytable1.name).toBe("mytable1");
|
|
84
84
|
const id = await db_1.default.insert(mytable1.name, { height1: 6 });
|
|
@@ -100,13 +100,13 @@ jest.setTimeout(30000);
|
|
|
100
100
|
await (0, globals_1.expect)((async () => await db_1.default.selectOne("mytable1", { id: 789 }))()).rejects.toThrow();
|
|
101
101
|
});
|
|
102
102
|
(0, globals_1.it)("should get distinct values", async () => {
|
|
103
|
-
const table =
|
|
103
|
+
const table = table_1.default.findOne({ name: "mytable1" });
|
|
104
104
|
(0, assertions_1.assertIsSet)(table);
|
|
105
105
|
const vs = await table.distinctValues("height1");
|
|
106
106
|
(0, globals_1.expect)(vs).toEqual([7]);
|
|
107
107
|
});
|
|
108
108
|
(0, globals_1.it)("should delete", async () => {
|
|
109
|
-
const table =
|
|
109
|
+
const table = table_1.default.findOne({ name: "mytable1" });
|
|
110
110
|
(0, assertions_1.assertIsSet)(table);
|
|
111
111
|
await table.delete();
|
|
112
112
|
const table1 = await table_1.default.find({ name: "mytable1" });
|
|
@@ -115,27 +115,27 @@ jest.setTimeout(30000);
|
|
|
115
115
|
});
|
|
116
116
|
(0, globals_1.describe)("Table get data", () => {
|
|
117
117
|
(0, globals_1.it)("should get rows", async () => {
|
|
118
|
-
const patients =
|
|
118
|
+
const patients = table_1.default.findOne({ name: "patients" });
|
|
119
119
|
(0, assertions_1.assertIsSet)(patients);
|
|
120
120
|
const all = await patients.getRows();
|
|
121
121
|
(0, globals_1.expect)(all.length).toStrictEqual(2);
|
|
122
122
|
});
|
|
123
123
|
(0, globals_1.it)("should get rows where name is Michael", async () => {
|
|
124
|
-
const patients =
|
|
124
|
+
const patients = table_1.default.findOne({ name: "patients" });
|
|
125
125
|
(0, assertions_1.assertIsSet)(patients);
|
|
126
126
|
const michaels = await patients.getRows({ name: "Michael Douglas" });
|
|
127
127
|
(0, assertions_1.assertIsSet)(michaels);
|
|
128
128
|
(0, globals_1.expect)(michaels.length).toStrictEqual(1);
|
|
129
129
|
});
|
|
130
130
|
(0, globals_1.it)("should get limited rows", async () => {
|
|
131
|
-
const patients =
|
|
131
|
+
const patients = table_1.default.findOne({ name: "patients" });
|
|
132
132
|
(0, assertions_1.assertIsSet)(patients);
|
|
133
133
|
const michaels = await patients.getRows({ name: { ilike: "Douglas" } }, { limit: 1, orderBy: "id", offset: 1 });
|
|
134
134
|
(0, globals_1.expect)(michaels.length).toStrictEqual(1);
|
|
135
135
|
(0, globals_1.expect)(michaels[0].name).toStrictEqual("Michael Douglas");
|
|
136
136
|
});
|
|
137
137
|
(0, globals_1.it)("should get rows by slug", async () => {
|
|
138
|
-
const books =
|
|
138
|
+
const books = table_1.default.findOne({ name: "books" });
|
|
139
139
|
(0, assertions_1.assertIsSet)(books);
|
|
140
140
|
const all = await books.getRows({
|
|
141
141
|
author: { slugify: "herman-melville" },
|
|
@@ -144,7 +144,7 @@ jest.setTimeout(30000);
|
|
|
144
144
|
(0, globals_1.expect)(all[0].pages).toStrictEqual(967);
|
|
145
145
|
});
|
|
146
146
|
(0, globals_1.it)("should get joined rows where name is Michael", async () => {
|
|
147
|
-
const patients =
|
|
147
|
+
const patients = table_1.default.findOne({ name: "patients" });
|
|
148
148
|
(0, assertions_1.assertIsSet)(patients);
|
|
149
149
|
const michaels = await patients.getJoinedRows({
|
|
150
150
|
where: { name: "Michael Douglas" },
|
|
@@ -153,7 +153,7 @@ jest.setTimeout(30000);
|
|
|
153
153
|
(0, globals_1.expect)(michaels[0].favbook).toBe(2);
|
|
154
154
|
});
|
|
155
155
|
(0, globals_1.it)("should get joined rows where name is not null", async () => {
|
|
156
|
-
const patients =
|
|
156
|
+
const patients = table_1.default.findOne({ name: "patients" });
|
|
157
157
|
(0, assertions_1.assertIsSet)(patients);
|
|
158
158
|
const nameds = await patients.getJoinedRows({
|
|
159
159
|
where: { not: { name: null } },
|
|
@@ -161,13 +161,13 @@ jest.setTimeout(30000);
|
|
|
161
161
|
(0, globals_1.expect)(nameds.length).toStrictEqual(2);
|
|
162
162
|
});
|
|
163
163
|
(0, globals_1.it)("should get rows in id range", async () => {
|
|
164
|
-
const patients =
|
|
164
|
+
const patients = table_1.default.findOne({ name: "patients" });
|
|
165
165
|
(0, assertions_1.assertIsSet)(patients);
|
|
166
166
|
const rows = await patients.getRows({ id: [{ gt: 0 }, { lt: 10 }] });
|
|
167
167
|
(0, globals_1.expect)(rows.length).toStrictEqual(2);
|
|
168
168
|
});
|
|
169
169
|
(0, globals_1.it)("should get rows by subselect", async () => {
|
|
170
|
-
const books =
|
|
170
|
+
const books = table_1.default.findOne({ name: "books" });
|
|
171
171
|
(0, assertions_1.assertIsSet)(books);
|
|
172
172
|
const nrows = await books.countRows({
|
|
173
173
|
id: {
|
|
@@ -181,7 +181,7 @@ jest.setTimeout(30000);
|
|
|
181
181
|
(0, globals_1.expect)(nrows).toStrictEqual(1);
|
|
182
182
|
});
|
|
183
183
|
(0, globals_1.it)("should get joined rows with limit and order", async () => {
|
|
184
|
-
const patients =
|
|
184
|
+
const patients = table_1.default.findOne({ name: "patients" });
|
|
185
185
|
(0, assertions_1.assertIsSet)(patients);
|
|
186
186
|
const all = await patients.getJoinedRows({
|
|
187
187
|
limit: 2,
|
|
@@ -191,7 +191,7 @@ jest.setTimeout(30000);
|
|
|
191
191
|
(0, globals_1.expect)(all[1].favbook).toBe(2);
|
|
192
192
|
});
|
|
193
193
|
(0, globals_1.it)("should get joined rows with limit and desc order", async () => {
|
|
194
|
-
const patients =
|
|
194
|
+
const patients = table_1.default.findOne({ name: "patients" });
|
|
195
195
|
(0, assertions_1.assertIsSet)(patients);
|
|
196
196
|
const all = await patients.getJoinedRows({
|
|
197
197
|
limit: 2,
|
|
@@ -202,7 +202,7 @@ jest.setTimeout(30000);
|
|
|
202
202
|
(0, globals_1.expect)(all[0].favbook).toBe(2);
|
|
203
203
|
});
|
|
204
204
|
(0, globals_1.it)("should get joined rows with aggregations", async () => {
|
|
205
|
-
const patients =
|
|
205
|
+
const patients = table_1.default.findOne({ name: "patients" });
|
|
206
206
|
(0, assertions_1.assertIsSet)(patients);
|
|
207
207
|
const michaels = await patients.getJoinedRows({
|
|
208
208
|
orderBy: "id",
|
|
@@ -219,7 +219,7 @@ jest.setTimeout(30000);
|
|
|
219
219
|
(0, globals_1.expect)(Math.round(michaels[0].avg_temp)).toBe(38);
|
|
220
220
|
});
|
|
221
221
|
(0, globals_1.it)("should get fkey aggregations", async () => {
|
|
222
|
-
const books =
|
|
222
|
+
const books = table_1.default.findOne({ name: "books" });
|
|
223
223
|
(0, assertions_1.assertIsSet)(books);
|
|
224
224
|
if (!db_1.default.isSQLite) {
|
|
225
225
|
const rows = await books.getJoinedRows({
|
|
@@ -239,7 +239,7 @@ jest.setTimeout(30000);
|
|
|
239
239
|
});
|
|
240
240
|
(0, globals_1.it)("should get join-aggregations", async () => {
|
|
241
241
|
//how many books has my publisher published
|
|
242
|
-
const books =
|
|
242
|
+
const books = table_1.default.findOne({ name: "books" });
|
|
243
243
|
(0, assertions_1.assertIsSet)(books);
|
|
244
244
|
if (!db_1.default.isSQLite) {
|
|
245
245
|
const rows = await books.getJoinedRows({
|
|
@@ -259,7 +259,7 @@ jest.setTimeout(30000);
|
|
|
259
259
|
}
|
|
260
260
|
});
|
|
261
261
|
(0, globals_1.it)("should get joined rows with latest aggregations", async () => {
|
|
262
|
-
const patients =
|
|
262
|
+
const patients = table_1.default.findOne({ name: "patients" });
|
|
263
263
|
(0, assertions_1.assertIsSet)(patients);
|
|
264
264
|
const michaels = await patients.getJoinedRows({
|
|
265
265
|
orderBy: "id",
|
|
@@ -276,7 +276,7 @@ jest.setTimeout(30000);
|
|
|
276
276
|
(0, globals_1.expect)(Math.round(michaels[0].last_temp)).toBe(37);
|
|
277
277
|
});
|
|
278
278
|
(0, globals_1.it)("should get joined rows with earliest aggregations", async () => {
|
|
279
|
-
const patients =
|
|
279
|
+
const patients = table_1.default.findOne({ name: "patients" });
|
|
280
280
|
(0, assertions_1.assertIsSet)(patients);
|
|
281
281
|
const michaels = await patients.getJoinedRows({
|
|
282
282
|
orderBy: "id",
|
|
@@ -293,7 +293,7 @@ jest.setTimeout(30000);
|
|
|
293
293
|
(0, globals_1.expect)(Math.round(michaels[0].last_temp)).toBe(37);
|
|
294
294
|
});
|
|
295
295
|
(0, globals_1.it)("should get double joined rows", async () => {
|
|
296
|
-
const readings =
|
|
296
|
+
const readings = table_1.default.findOne({ name: "readings" });
|
|
297
297
|
(0, assertions_1.assertIsSet)(readings);
|
|
298
298
|
const reads = await readings.getJoinedRows({
|
|
299
299
|
orderBy: "id",
|
|
@@ -305,7 +305,7 @@ jest.setTimeout(30000);
|
|
|
305
305
|
(0, globals_1.expect)(reads[0].author).toBe("Herman Melville");
|
|
306
306
|
});
|
|
307
307
|
(0, globals_1.it)("should get triple joined rows", async () => {
|
|
308
|
-
const readings =
|
|
308
|
+
const readings = table_1.default.findOne({ name: "readings" });
|
|
309
309
|
(0, assertions_1.assertIsSet)(readings);
|
|
310
310
|
const reads = await readings.getJoinedRows({
|
|
311
311
|
orderBy: "id",
|
|
@@ -322,7 +322,7 @@ jest.setTimeout(30000);
|
|
|
322
322
|
(0, globals_1.expect)(reads[2].publisher).toBe("AK Press");
|
|
323
323
|
});
|
|
324
324
|
(0, globals_1.it)("should rename joined rows signly", async () => {
|
|
325
|
-
const patients =
|
|
325
|
+
const patients = table_1.default.findOne({ name: "patients" });
|
|
326
326
|
(0, assertions_1.assertIsSet)(patients);
|
|
327
327
|
const pats = await patients.getJoinedRows({
|
|
328
328
|
orderBy: "id",
|
|
@@ -339,7 +339,7 @@ jest.setTimeout(30000);
|
|
|
339
339
|
(0, globals_1.expect)(pats[0].favbook.id).toBe(1);
|
|
340
340
|
});
|
|
341
341
|
(0, globals_1.it)("should rename joined rows doubly", async () => {
|
|
342
|
-
const readings =
|
|
342
|
+
const readings = table_1.default.findOne({ name: "readings" });
|
|
343
343
|
(0, assertions_1.assertIsSet)(readings);
|
|
344
344
|
const reads = await readings.getJoinedRows({
|
|
345
345
|
orderBy: "id",
|
|
@@ -356,7 +356,7 @@ jest.setTimeout(30000);
|
|
|
356
356
|
(0, globals_1.expect)(reads[0].patient_id.favbook.author).toBe("Herman Melville");
|
|
357
357
|
});
|
|
358
358
|
(0, globals_1.it)("should get joined rows with aggregations and joins", async () => {
|
|
359
|
-
const patients =
|
|
359
|
+
const patients = table_1.default.findOne({ name: "patients" });
|
|
360
360
|
(0, assertions_1.assertIsSet)(patients);
|
|
361
361
|
const michaels = await patients.getJoinedRows({
|
|
362
362
|
orderBy: "id",
|
|
@@ -378,22 +378,22 @@ jest.setTimeout(30000);
|
|
|
378
378
|
(0, globals_1.expect)(michaels[1].author).toBe("Leo Tolstoy");
|
|
379
379
|
});
|
|
380
380
|
(0, globals_1.it)("should support full text search", async () => {
|
|
381
|
-
const table =
|
|
381
|
+
const table = table_1.default.findOne({ name: "patients" });
|
|
382
382
|
(0, assertions_1.assertIsSet)(table);
|
|
383
|
-
const fields =
|
|
383
|
+
const fields = table.getFields();
|
|
384
384
|
const rows = await db_1.default.select("patients", {
|
|
385
385
|
_fts: { fields, searchTerm: "Douglas" },
|
|
386
386
|
});
|
|
387
387
|
(0, globals_1.expect)(rows.length).toBe(2);
|
|
388
388
|
});
|
|
389
389
|
(0, globals_1.it)("should enable versioning", async () => {
|
|
390
|
-
const table =
|
|
390
|
+
const table = table_1.default.findOne({ name: "patients" });
|
|
391
391
|
(0, assertions_1.assertIsSet)(table);
|
|
392
392
|
table.versioned = true;
|
|
393
393
|
await table.update(table);
|
|
394
394
|
});
|
|
395
395
|
(0, globals_1.it)("should save version on insert", async () => {
|
|
396
|
-
const table =
|
|
396
|
+
const table = table_1.default.findOne({ name: "patients" });
|
|
397
397
|
(0, assertions_1.assertIsSet)(table);
|
|
398
398
|
await table.insertRow({ name: "Bunny foo-foo", favbook: 1 });
|
|
399
399
|
const bunnyFooFoo = await table.getRow({ name: "Bunny foo-foo" });
|
|
@@ -405,7 +405,7 @@ jest.setTimeout(30000);
|
|
|
405
405
|
(0, globals_1.expect)(history1[0].name).toBe("Bunny foo-foo");
|
|
406
406
|
});
|
|
407
407
|
(0, globals_1.it)("should save version on update", async () => {
|
|
408
|
-
const table =
|
|
408
|
+
const table = table_1.default.findOne({ name: "patients" });
|
|
409
409
|
(0, assertions_1.assertIsSet)(table);
|
|
410
410
|
const bunnyFooFoo = await table.getRow({ name: "Bunny foo-foo" });
|
|
411
411
|
(0, assertions_1.assertIsSet)(bunnyFooFoo);
|
|
@@ -426,7 +426,7 @@ jest.setTimeout(30000);
|
|
|
426
426
|
(0, globals_1.expect)(goon.favbook).toBe(1);
|
|
427
427
|
});
|
|
428
428
|
(0, globals_1.it)("create field on version table", async () => {
|
|
429
|
-
const table =
|
|
429
|
+
const table = table_1.default.findOne({ name: "patients" });
|
|
430
430
|
const fc = await field_1.default.create({
|
|
431
431
|
table: table,
|
|
432
432
|
name: "Height19",
|
|
@@ -438,9 +438,9 @@ jest.setTimeout(30000);
|
|
|
438
438
|
await fc.delete();
|
|
439
439
|
});
|
|
440
440
|
(0, globals_1.it)("should disable versioning", async () => {
|
|
441
|
-
const table =
|
|
441
|
+
const table = table_1.default.findOne({ name: "patients" });
|
|
442
442
|
(0, assertions_1.assertIsSet)(table);
|
|
443
|
-
|
|
443
|
+
table.getFields();
|
|
444
444
|
await table.update({ versioned: false });
|
|
445
445
|
});
|
|
446
446
|
(0, globals_1.it)("should rename", async () => {
|
|
@@ -472,12 +472,12 @@ jest.setTimeout(30000);
|
|
|
472
472
|
(0, globals_1.expect)(!!rows[0].reftall).toBe(false); //for sqlite
|
|
473
473
|
if (!db_1.default.isSQLite) {
|
|
474
474
|
await table.rename("isthisbetter");
|
|
475
|
-
const table3 =
|
|
475
|
+
const table3 = table_1.default.findOne({ name: "refsunsure" });
|
|
476
476
|
(0, assertions_1.assertIsSet)(table3);
|
|
477
477
|
const rows1 = await table3.getJoinedRows({ joinFields });
|
|
478
478
|
(0, globals_1.expect)(rows1[0].theref).toBe(id);
|
|
479
479
|
(0, globals_1.expect)(rows1[0].reftall).toBe(false);
|
|
480
|
-
const table2 =
|
|
480
|
+
const table2 = table_1.default.findOne({ name: "isthisbetter" });
|
|
481
481
|
(0, assertions_1.assertIsSet)(table2);
|
|
482
482
|
(0, globals_1.expect)(!!table2).toBe(true);
|
|
483
483
|
table2.versioned = true;
|
|
@@ -486,7 +486,7 @@ jest.setTimeout(30000);
|
|
|
486
486
|
}
|
|
487
487
|
});
|
|
488
488
|
(0, globals_1.it)("should get joined rows with arbitrary fieldnames", async () => {
|
|
489
|
-
const patients =
|
|
489
|
+
const patients = table_1.default.findOne({ name: "patients" });
|
|
490
490
|
(0, assertions_1.assertIsSet)(patients);
|
|
491
491
|
const michaels = await patients.getJoinedRows({
|
|
492
492
|
where: { name: "Michael Douglas" },
|
|
@@ -516,7 +516,7 @@ jest.setTimeout(30000);
|
|
|
516
516
|
table: ratings,
|
|
517
517
|
});
|
|
518
518
|
await ratings.insertRow({ book: 1, rating: 7 });
|
|
519
|
-
const books =
|
|
519
|
+
const books = table_1.default.findOne({ name: "books" });
|
|
520
520
|
(0, assertions_1.assertIsSet)(books);
|
|
521
521
|
//db.set_sql_logging();
|
|
522
522
|
const reads = await books.getJoinedRows({
|
|
@@ -534,14 +534,14 @@ jest.setTimeout(30000);
|
|
|
534
534
|
});
|
|
535
535
|
(0, globals_1.describe)("relations", () => {
|
|
536
536
|
(0, globals_1.it)("get parent relations", async () => {
|
|
537
|
-
const table =
|
|
537
|
+
const table = table_1.default.findOne({ name: "patients" });
|
|
538
538
|
(0, assertions_1.assertIsSet)(table);
|
|
539
539
|
const rels = await table.get_parent_relations();
|
|
540
540
|
(0, globals_1.expect)(rels.parent_field_list).toContain("favbook.author");
|
|
541
541
|
(0, globals_1.expect)(rels.parent_relations.length).toBe(2);
|
|
542
542
|
});
|
|
543
543
|
(0, globals_1.it)("get parent relations with one-to-one", async () => {
|
|
544
|
-
const table =
|
|
544
|
+
const table = table_1.default.findOne({ name: "books" });
|
|
545
545
|
(0, assertions_1.assertIsSet)(table);
|
|
546
546
|
const rels = await table.get_parent_relations();
|
|
547
547
|
(0, globals_1.expect)(rels.parent_field_list).toEqual([
|
|
@@ -553,7 +553,7 @@ jest.setTimeout(30000);
|
|
|
553
553
|
]);
|
|
554
554
|
});
|
|
555
555
|
(0, globals_1.it)("get child relations", async () => {
|
|
556
|
-
const table =
|
|
556
|
+
const table = table_1.default.findOne({ name: "books" });
|
|
557
557
|
(0, assertions_1.assertIsSet)(table);
|
|
558
558
|
const rels = await table.get_child_relations();
|
|
559
559
|
(0, globals_1.expect)(rels.child_field_list).toEqual([
|
|
@@ -564,7 +564,7 @@ jest.setTimeout(30000);
|
|
|
564
564
|
(0, globals_1.expect)(rels.child_relations.length).toBe(3);
|
|
565
565
|
});
|
|
566
566
|
(0, globals_1.it)("get child relations with join", async () => {
|
|
567
|
-
const table =
|
|
567
|
+
const table = table_1.default.findOne({ name: "books" });
|
|
568
568
|
(0, assertions_1.assertIsSet)(table);
|
|
569
569
|
const rels = await table.get_child_relations(true);
|
|
570
570
|
(0, globals_1.expect)(rels.child_field_list).toEqual([
|
|
@@ -576,7 +576,7 @@ jest.setTimeout(30000);
|
|
|
576
576
|
(0, globals_1.expect)(rels.child_relations.length).toBe(4);
|
|
577
577
|
});
|
|
578
578
|
(0, globals_1.it)("get grandparent relations", async () => {
|
|
579
|
-
const table =
|
|
579
|
+
const table = table_1.default.findOne({ name: "readings" });
|
|
580
580
|
(0, assertions_1.assertIsSet)(table);
|
|
581
581
|
const rels = await table.get_parent_relations(true);
|
|
582
582
|
(0, globals_1.expect)(rels.parent_field_list).toEqual([
|
|
@@ -596,7 +596,7 @@ jest.setTimeout(30000);
|
|
|
596
596
|
(0, globals_1.expect)(rels.parent_relations.length).toBe(3);
|
|
597
597
|
});
|
|
598
598
|
(0, globals_1.it)("get triple relations", async () => {
|
|
599
|
-
const table =
|
|
599
|
+
const table = table_1.default.findOne({ name: "readings" });
|
|
600
600
|
(0, assertions_1.assertIsSet)(table);
|
|
601
601
|
const rels = await table.get_parent_relations(true, true);
|
|
602
602
|
(0, globals_1.expect)(rels.parent_field_list).toEqual([
|
|
@@ -633,7 +633,7 @@ Joe Celko, 856
|
|
|
633
633
|
Gordon Kane, 217`;
|
|
634
634
|
const fnm = "/tmp/test1ok.csv";
|
|
635
635
|
await (0, promises_1.writeFile)(fnm, csv);
|
|
636
|
-
const table =
|
|
636
|
+
const table = table_1.default.findOne({ name: "books" });
|
|
637
637
|
(0, assertions_1.assertIsSet)(table);
|
|
638
638
|
(0, globals_1.expect)(!!table).toBe(true);
|
|
639
639
|
const impres = await table.import_csv_file(fnm);
|
|
@@ -648,7 +648,7 @@ William H Press, 852,7,100
|
|
|
648
648
|
Peter Rossi, 212,9,200`;
|
|
649
649
|
const fnm = "/tmp/test1ok.csv";
|
|
650
650
|
await (0, promises_1.writeFile)(fnm, csv);
|
|
651
|
-
const table =
|
|
651
|
+
const table = table_1.default.findOne({ name: "books" });
|
|
652
652
|
(0, assertions_1.assertIsSet)(table);
|
|
653
653
|
(0, globals_1.expect)(!!table).toBe(true);
|
|
654
654
|
const impres = await table.import_csv_file(fnm);
|
|
@@ -663,7 +663,7 @@ Peter Rossi, 212,9,200`;
|
|
|
663
663
|
17, David Harvey, 612`;
|
|
664
664
|
const fnm = "/tmp/testreplaceid.csv";
|
|
665
665
|
await (0, promises_1.writeFile)(fnm, csv);
|
|
666
|
-
const table =
|
|
666
|
+
const table = table_1.default.findOne({ name: "books" });
|
|
667
667
|
(0, assertions_1.assertIsSet)(table);
|
|
668
668
|
(0, globals_1.expect)(!!table).toBe(true);
|
|
669
669
|
const rowsBefore = await table.countRows();
|
|
@@ -681,7 +681,7 @@ Joe Celko, 856
|
|
|
681
681
|
Gordon Kane, 217`;
|
|
682
682
|
const fnm = "/tmp/test1f.csv";
|
|
683
683
|
await (0, promises_1.writeFile)(fnm, csv);
|
|
684
|
-
const table =
|
|
684
|
+
const table = table_1.default.findOne({ name: "books" });
|
|
685
685
|
(0, assertions_1.assertIsSet)(table);
|
|
686
686
|
(0, globals_1.expect)(!!table).toBe(true);
|
|
687
687
|
const impres = await table.import_csv_file(fnm);
|
|
@@ -776,7 +776,7 @@ Pencil, 0.5,2, t`;
|
|
|
776
776
|
(0, assertions_1.assertsIsSuccessMessage)(result);
|
|
777
777
|
const { table } = result;
|
|
778
778
|
(0, assertions_1.assertIsSet)(table);
|
|
779
|
-
const fields =
|
|
779
|
+
const fields = table.getFields();
|
|
780
780
|
const vatField = fields.find((f) => f.name === "vatable");
|
|
781
781
|
(0, assertions_1.assertIsSet)(vatField);
|
|
782
782
|
(0, assertions_1.assertIsType)(vatField.type);
|
|
@@ -805,7 +805,7 @@ Pencil, 0.5,2, t`;
|
|
|
805
805
|
(0, globals_1.expect)(res).toEqual({
|
|
806
806
|
error: "Invalid column name ! - Use A-Z, a-z, 0-9, _ only",
|
|
807
807
|
});
|
|
808
|
-
const table =
|
|
808
|
+
const table = table_1.default.findOne({ name: "Invoice1" });
|
|
809
809
|
(0, globals_1.expect)(table).toBe(null);
|
|
810
810
|
});
|
|
811
811
|
(0, globals_1.it)("ignores a col on duplicate col nm", async () => {
|
|
@@ -828,7 +828,7 @@ Pencil, 0.5,2, t`;
|
|
|
828
828
|
(0, globals_1.expect)(res).toEqual({
|
|
829
829
|
error: `Columns named "id" must have only integers`,
|
|
830
830
|
});
|
|
831
|
-
const table =
|
|
831
|
+
const table = table_1.default.findOne({ name: "Invoice2" });
|
|
832
832
|
(0, globals_1.expect)(table).toBe(null);
|
|
833
833
|
});
|
|
834
834
|
(0, globals_1.it)("should fail missing id", async () => {
|
|
@@ -841,7 +841,7 @@ Pencil, 0.5,2, t`;
|
|
|
841
841
|
(0, globals_1.expect)(res).toEqual({
|
|
842
842
|
error: `Columns named "id" must not have missing values`,
|
|
843
843
|
});
|
|
844
|
-
const table =
|
|
844
|
+
const table = table_1.default.findOne({ name: "Invoice3" });
|
|
845
845
|
(0, globals_1.expect)(table).toBe(null);
|
|
846
846
|
});
|
|
847
847
|
(0, globals_1.it)("should succeed on good id", async () => {
|
|
@@ -853,7 +853,7 @@ Pencil, 0.5,2, t`;
|
|
|
853
853
|
const res = await table_1.default.create_from_csv("Invoice3", fnm);
|
|
854
854
|
(0, assertions_1.assertsIsSuccessMessage)(res);
|
|
855
855
|
(0, globals_1.expect)(res.table.fields.length).toEqual(4); // incl id
|
|
856
|
-
const table =
|
|
856
|
+
const table = table_1.default.findOne({ name: "Invoice3" });
|
|
857
857
|
(0, assertions_1.assertIsSet)(table);
|
|
858
858
|
const rows = await table.getRows();
|
|
859
859
|
(0, globals_1.expect)(rows.length).toBe(2);
|
|
@@ -870,7 +870,7 @@ Pencil, 0.5,2, t`;
|
|
|
870
870
|
const res = await table_1.default.create_from_csv("Invoice4", fnm);
|
|
871
871
|
(0, assertions_1.assertIsErrorMsg)(res);
|
|
872
872
|
(0, globals_1.expect)(res.error).toContain("Error");
|
|
873
|
-
const table =
|
|
873
|
+
const table = table_1.default.findOne({ name: "Invoice4" });
|
|
874
874
|
(0, globals_1.expect)(table).toBe(null);
|
|
875
875
|
});
|
|
876
876
|
(0, globals_1.it)("should import with missing", async () => {
|
|
@@ -884,7 +884,7 @@ Pencil, 0.5,, t`;
|
|
|
884
884
|
const { table } = result;
|
|
885
885
|
(0, assertions_1.assertIsSet)(table);
|
|
886
886
|
(0, globals_1.expect)(!!table).toBe(true);
|
|
887
|
-
const fields =
|
|
887
|
+
const fields = table.getFields();
|
|
888
888
|
const countField = fields.find((f) => f.name === "count");
|
|
889
889
|
(0, assertions_1.assertIsSet)(countField);
|
|
890
890
|
(0, assertions_1.assertIsType)(countField.type);
|
|
@@ -906,7 +906,7 @@ Pencil, 0.5,2, t`;
|
|
|
906
906
|
const result = await table_1.default.create_from_csv("Invoice5", fnm);
|
|
907
907
|
(0, assertions_1.assertsIsSuccessMessage)(result);
|
|
908
908
|
const { table } = result;
|
|
909
|
-
const fields =
|
|
909
|
+
const fields = table.getFields();
|
|
910
910
|
const nameField = fields.find((f) => f.name === "item_name");
|
|
911
911
|
(0, globals_1.expect)(nameField.type.name).toBe("String");
|
|
912
912
|
(0, globals_1.expect)(nameField.label).toBe("Item Name");
|
|
@@ -923,7 +923,7 @@ Pencil, 0.5,2, t`;
|
|
|
923
923
|
const result = await table_1.default.create_from_csv("Invoice6", fnm);
|
|
924
924
|
(0, assertions_1.assertsIsSuccessMessage)(result);
|
|
925
925
|
const { table } = result;
|
|
926
|
-
const fields =
|
|
926
|
+
const fields = table.getFields();
|
|
927
927
|
(0, globals_1.expect)(fields.map((f) => f.name)).toContain("item_name");
|
|
928
928
|
const nameField = fields.find((f) => f.name === "item_name");
|
|
929
929
|
(0, globals_1.expect)(nameField.type.name).toBe("String");
|
|
@@ -943,7 +943,7 @@ Pencil, 0.5,2, t`;
|
|
|
943
943
|
(0, assertions_1.assertsIsSuccessMessage)(result);
|
|
944
944
|
const { table } = result;
|
|
945
945
|
(0, assertions_1.assertIsSet)(table);
|
|
946
|
-
const fields =
|
|
946
|
+
const fields = table.getFields();
|
|
947
947
|
const rows1 = await table.getJoinedRows({
|
|
948
948
|
where: { item: { ilike: "East" } },
|
|
949
949
|
});
|
|
@@ -1026,7 +1026,7 @@ Pencil, 0.5,2, t`;
|
|
|
1026
1026
|
}
|
|
1027
1027
|
});
|
|
1028
1028
|
(0, globals_1.it)("should query null", async () => {
|
|
1029
|
-
const table =
|
|
1029
|
+
const table = table_1.default.findOne({ name: "TableWithNotNulls" });
|
|
1030
1030
|
(0, assertions_1.assertIsSet)(table);
|
|
1031
1031
|
await table.insertRow({ name: "Ageless", age: null });
|
|
1032
1032
|
const rows = await table.getRows({ age: null });
|
|
@@ -1096,7 +1096,7 @@ Pencil, 0.5,2, t`;
|
|
|
1096
1096
|
await v.delete();
|
|
1097
1097
|
});
|
|
1098
1098
|
(0, globals_1.it)("should delete table after view delete", async () => {
|
|
1099
|
-
const tc =
|
|
1099
|
+
const tc = table_1.default.findOne({ name: "mytable19" });
|
|
1100
1100
|
if (tc)
|
|
1101
1101
|
await tc.delete();
|
|
1102
1102
|
});
|
|
@@ -1140,7 +1140,7 @@ Pencil, 0.5,2, t`;
|
|
|
1140
1140
|
await cars.insertRow({ name: "Mustang", owner: sally });
|
|
1141
1141
|
});
|
|
1142
1142
|
(0, globals_1.it)("should query", async () => {
|
|
1143
|
-
const cars =
|
|
1143
|
+
const cars = table_1.default.findOne({ name: "TableClashCar" });
|
|
1144
1144
|
(0, assertions_1.assertIsSet)(cars);
|
|
1145
1145
|
const rows = await cars.getJoinedRows({
|
|
1146
1146
|
joinFields: {
|
|
@@ -1155,7 +1155,7 @@ Pencil, 0.5,2, t`;
|
|
|
1155
1155
|
});
|
|
1156
1156
|
});
|
|
1157
1157
|
(0, globals_1.it)("should show list view", async () => {
|
|
1158
|
-
const cars =
|
|
1158
|
+
const cars = table_1.default.findOne({ name: "TableClashCar" });
|
|
1159
1159
|
(0, assertions_1.assertIsSet)(cars);
|
|
1160
1160
|
const v = await view_1.default.create({
|
|
1161
1161
|
table_id: cars.id,
|
|
@@ -1174,7 +1174,7 @@ Pencil, 0.5,2, t`;
|
|
|
1174
1174
|
(0, globals_1.expect)(res).toContain("Sally");
|
|
1175
1175
|
});
|
|
1176
1176
|
(0, globals_1.it)("should show show view", async () => {
|
|
1177
|
-
const cars =
|
|
1177
|
+
const cars = table_1.default.findOne({ name: "TableClashCar" });
|
|
1178
1178
|
(0, assertions_1.assertIsSet)(cars);
|
|
1179
1179
|
const v = await view_1.default.create({
|
|
1180
1180
|
table_id: cars.id,
|
|
@@ -1201,7 +1201,7 @@ Pencil, 0.5,2, t`;
|
|
|
1201
1201
|
});
|
|
1202
1202
|
(0, globals_1.describe)("Table joint unique constraint", () => {
|
|
1203
1203
|
(0, globals_1.it)("should create table", async () => {
|
|
1204
|
-
const table =
|
|
1204
|
+
const table = table_1.default.findOne({ name: "books" });
|
|
1205
1205
|
(0, assertions_1.assertIsSet)(table);
|
|
1206
1206
|
(0, assertions_1.assertIsSet)(table.id);
|
|
1207
1207
|
const rows = await table.getRows();
|
|
@@ -1222,7 +1222,7 @@ Pencil, 0.5,2, t`;
|
|
|
1222
1222
|
});
|
|
1223
1223
|
(0, globals_1.describe)("Table formula constraint", () => {
|
|
1224
1224
|
(0, globals_1.it)("should create table", async () => {
|
|
1225
|
-
const table =
|
|
1225
|
+
const table = table_1.default.findOne({ name: "books" });
|
|
1226
1226
|
(0, assertions_1.assertIsSet)(table);
|
|
1227
1227
|
(0, assertions_1.assertIsSet)(table.id);
|
|
1228
1228
|
const row0 = {
|
|
@@ -1234,7 +1234,7 @@ Pencil, 0.5,2, t`;
|
|
|
1234
1234
|
type: "Formula",
|
|
1235
1235
|
configuration: { formula: "pages>500", errormsg: "Too short" },
|
|
1236
1236
|
});
|
|
1237
|
-
const table1 =
|
|
1237
|
+
const table1 = table_1.default.findOne({ name: "books" });
|
|
1238
1238
|
(0, assertions_1.assertIsSet)(table1);
|
|
1239
1239
|
const res = await table1.tryInsertRow(row0);
|
|
1240
1240
|
(0, assertions_1.assertIsErrorMsg)(res);
|
|
@@ -1244,7 +1244,7 @@ Pencil, 0.5,2, t`;
|
|
|
1244
1244
|
const uprow = await table1.getRow({ id: 1 });
|
|
1245
1245
|
(0, globals_1.expect)(uprow?.pages).toBeGreaterThan(400);
|
|
1246
1246
|
await tc.delete();
|
|
1247
|
-
const table2 =
|
|
1247
|
+
const table2 = table_1.default.findOne({ name: "books" });
|
|
1248
1248
|
(0, assertions_1.assertIsSet)(table2);
|
|
1249
1249
|
const res1 = await table2.tryInsertRow(row0);
|
|
1250
1250
|
(0, assertions_1.assertIsErrorMsg)(res1);
|
|
@@ -1262,11 +1262,11 @@ Pencil, 0.5,2, t`;
|
|
|
1262
1262
|
(0, globals_1.it)("should create and insert stuff in table", async () => {
|
|
1263
1263
|
getState().registerPlugin("mock_plugin", plugin_with_routes());
|
|
1264
1264
|
const table = await table_1.default.create("TableUUID");
|
|
1265
|
-
const [pk] =
|
|
1265
|
+
const [pk] = table.getFields();
|
|
1266
1266
|
await pk.update({ type: "UUID" });
|
|
1267
1267
|
// @ts-ignore
|
|
1268
1268
|
(0, globals_1.expect)(pk.type.name).toBe("UUID");
|
|
1269
|
-
const table1 =
|
|
1269
|
+
const table1 = table_1.default.findOne({ name: "TableUUID" });
|
|
1270
1270
|
(0, assertions_1.assertIsSet)(table1);
|
|
1271
1271
|
const flds1 = await table1.getFields();
|
|
1272
1272
|
// @ts-ignore
|
|
@@ -1299,10 +1299,10 @@ Pencil, 0.5,2, t`;
|
|
|
1299
1299
|
const fnm = "/tmp/test1.json";
|
|
1300
1300
|
await (0, promises_1.writeFile)(fnm, JSON.stringify(json));
|
|
1301
1301
|
await getState().refresh_tables();
|
|
1302
|
-
const table =
|
|
1302
|
+
const table = table_1.default.findOne({ name: "TableUUID" });
|
|
1303
1303
|
(0, assertions_1.assertIsSet)(table);
|
|
1304
1304
|
(0, globals_1.expect)(!!table).toBe(true);
|
|
1305
|
-
const flds =
|
|
1305
|
+
const flds = table.getFields();
|
|
1306
1306
|
// @ts-ignore
|
|
1307
1307
|
(0, globals_1.expect)(flds[0].type.name).toBe("UUID");
|
|
1308
1308
|
const impres = await table.import_json_file(fnm);
|
|
@@ -1313,7 +1313,7 @@ Pencil, 0.5,2, t`;
|
|
|
1313
1313
|
(0, globals_1.expect)(rows.length).toBe(2);
|
|
1314
1314
|
});
|
|
1315
1315
|
(0, globals_1.it)("should be joinable to", async () => {
|
|
1316
|
-
const uuidtable1 =
|
|
1316
|
+
const uuidtable1 = table_1.default.findOne({ name: "TableUUID" });
|
|
1317
1317
|
(0, assertions_1.assertIsSet)(uuidtable1);
|
|
1318
1318
|
const table = await table_1.default.create("JoinUUID");
|
|
1319
1319
|
await field_1.default.create({
|
|
@@ -1349,14 +1349,14 @@ Pencil, 0.5,2, t`;
|
|
|
1349
1349
|
(0, globals_1.it)("should create and delete table", async () => {
|
|
1350
1350
|
getState().registerPlugin("mock_plugin", plugin_with_routes());
|
|
1351
1351
|
const table = await table_1.default.create("TableUUID1");
|
|
1352
|
-
const [pk] =
|
|
1352
|
+
const [pk] = table.getFields();
|
|
1353
1353
|
await pk.update({ type: "UUID" });
|
|
1354
1354
|
const table1 = table_1.default.findOne({ name: table.name });
|
|
1355
1355
|
(0, assertions_1.assertIsSet)(table1);
|
|
1356
1356
|
const [pk1] = await table1.getFields();
|
|
1357
1357
|
// @ts-ignore
|
|
1358
1358
|
(0, globals_1.expect)(pk1.type?.name).toBe("UUID");
|
|
1359
|
-
//const [pk1] =
|
|
1359
|
+
//const [pk1] = table.getFields();
|
|
1360
1360
|
await pk.update({ type: "Integer" });
|
|
1361
1361
|
await table.delete();
|
|
1362
1362
|
});
|
|
@@ -1367,9 +1367,9 @@ Pencil, 0.5,2, t`;
|
|
|
1367
1367
|
getState().registerPlugin("mock_plugin", plugin_with_routes());
|
|
1368
1368
|
});
|
|
1369
1369
|
(0, globals_1.it)("should find table", async () => {
|
|
1370
|
-
const table =
|
|
1370
|
+
const table = table_1.default.findOne({ name: "exttab" });
|
|
1371
1371
|
(0, globals_1.expect)(!!table).toBe(true);
|
|
1372
|
-
const notable =
|
|
1372
|
+
const notable = table_1.default.findOne({ name: "exttnosuchab" });
|
|
1373
1373
|
(0, globals_1.expect)(!!notable).toBe(false);
|
|
1374
1374
|
const tables = await table_1.default.find_with_external();
|
|
1375
1375
|
(0, globals_1.expect)(tables.map((t) => t.name)).toContain("exttab");
|
|
@@ -1405,7 +1405,7 @@ Pencil, 0.5,2, t`;
|
|
|
1405
1405
|
});
|
|
1406
1406
|
});
|
|
1407
1407
|
(0, globals_1.it)("should query", async () => {
|
|
1408
|
-
const table =
|
|
1408
|
+
const table = table_1.default.findOne({ name: "JoeTable" });
|
|
1409
1409
|
(0, assertions_1.assertIsSet)(table);
|
|
1410
1410
|
const rows = await table.getRows({});
|
|
1411
1411
|
(0, globals_1.expect)(rows.length === 1);
|
|
@@ -1413,12 +1413,12 @@ Pencil, 0.5,2, t`;
|
|
|
1413
1413
|
(0, globals_1.expect)(rows[0].age).toBe(36);
|
|
1414
1414
|
});
|
|
1415
1415
|
(0, globals_1.it)("should change role", async () => {
|
|
1416
|
-
const table =
|
|
1416
|
+
const table = table_1.default.findOne({ name: "JoeTable" });
|
|
1417
1417
|
(0, assertions_1.assertIsSet)(table);
|
|
1418
1418
|
await table.update({ min_role_read: 40 });
|
|
1419
1419
|
});
|
|
1420
1420
|
(0, globals_1.it)("should get role", async () => {
|
|
1421
|
-
const table =
|
|
1421
|
+
const table = table_1.default.findOne({ name: "JoeTable" });
|
|
1422
1422
|
(0, assertions_1.assertIsSet)(table);
|
|
1423
1423
|
(0, globals_1.expect)(table.min_role_read).toBe(40);
|
|
1424
1424
|
});
|
|
@@ -1447,13 +1447,13 @@ Pencil, 0.5,2, t`;
|
|
|
1447
1447
|
});
|
|
1448
1448
|
});
|
|
1449
1449
|
(0, globals_1.it)("should enable versioning", async () => {
|
|
1450
|
-
const table =
|
|
1450
|
+
const table = table_1.default.findOne({ name: "unihistory" });
|
|
1451
1451
|
(0, assertions_1.assertIsSet)(table);
|
|
1452
1452
|
table.versioned = true;
|
|
1453
1453
|
await table.update(table);
|
|
1454
1454
|
});
|
|
1455
1455
|
(0, globals_1.it)("should not error on history with unique", async () => {
|
|
1456
|
-
const table =
|
|
1456
|
+
const table = table_1.default.findOne({ name: "unihistory" });
|
|
1457
1457
|
(0, assertions_1.assertIsSet)(table);
|
|
1458
1458
|
await table.insertRow({ name: "Bartimaeus", age: 2500 });
|
|
1459
1459
|
const row = await table.getRow({ name: "Bartimaeus" });
|
|
@@ -1526,7 +1526,7 @@ Pencil, 0.5,2, t`;
|
|
|
1526
1526
|
await tc.insertRow({ name: "George", lat: 20, long: 20 });
|
|
1527
1527
|
});
|
|
1528
1528
|
(0, globals_1.it)("should query", async () => {
|
|
1529
|
-
const table =
|
|
1529
|
+
const table = table_1.default.findOne({ name: "geotable1" });
|
|
1530
1530
|
(0, assertions_1.assertIsSet)(table);
|
|
1531
1531
|
const fred_rows = await table.getRows({}, {
|
|
1532
1532
|
orderBy: {
|
|
@@ -1546,35 +1546,35 @@ Pencil, 0.5,2, t`;
|
|
|
1546
1546
|
});
|
|
1547
1547
|
(0, globals_1.describe)("getField", () => {
|
|
1548
1548
|
(0, globals_1.it)("should find own field", async () => {
|
|
1549
|
-
const table =
|
|
1549
|
+
const table = table_1.default.findOne({ name: "patients" });
|
|
1550
1550
|
(0, assertions_1.assertIsSet)(table);
|
|
1551
1551
|
const field = await table.getField("name");
|
|
1552
1552
|
(0, globals_1.expect)(field?.name).toBe("name");
|
|
1553
1553
|
(0, globals_1.expect)(field?.id).toBe(7);
|
|
1554
1554
|
});
|
|
1555
1555
|
(0, globals_1.it)("should find single join field", async () => {
|
|
1556
|
-
const table =
|
|
1556
|
+
const table = table_1.default.findOne({ name: "patients" });
|
|
1557
1557
|
(0, assertions_1.assertIsSet)(table);
|
|
1558
1558
|
const field = await table.getField("favbook.pages");
|
|
1559
1559
|
(0, globals_1.expect)(field?.name).toBe("pages");
|
|
1560
1560
|
(0, globals_1.expect)(field?.id).toBe(5);
|
|
1561
1561
|
});
|
|
1562
1562
|
(0, globals_1.it)("should find double join field", async () => {
|
|
1563
|
-
const table =
|
|
1563
|
+
const table = table_1.default.findOne({ name: "patients" });
|
|
1564
1564
|
(0, assertions_1.assertIsSet)(table);
|
|
1565
1565
|
const field = await table.getField("favbook.publisher.name");
|
|
1566
1566
|
(0, globals_1.expect)(field?.name).toBe("name");
|
|
1567
1567
|
(0, globals_1.expect)(field?.id).toBe(19);
|
|
1568
1568
|
});
|
|
1569
1569
|
(0, globals_1.it)("should find triple join field", async () => {
|
|
1570
|
-
const table =
|
|
1570
|
+
const table = table_1.default.findOne({ name: "readings" });
|
|
1571
1571
|
(0, assertions_1.assertIsSet)(table);
|
|
1572
1572
|
const field = await table.getField("patient_id.favbook.publisher.name");
|
|
1573
1573
|
(0, globals_1.expect)(field?.name).toBe("name");
|
|
1574
1574
|
(0, globals_1.expect)(field?.id).toBe(19);
|
|
1575
1575
|
});
|
|
1576
1576
|
(0, globals_1.it)("should find own key field", async () => {
|
|
1577
|
-
const table =
|
|
1577
|
+
const table = table_1.default.findOne({ name: "patients" });
|
|
1578
1578
|
(0, assertions_1.assertIsSet)(table);
|
|
1579
1579
|
const field = await table.getField("favbook");
|
|
1580
1580
|
(0, globals_1.expect)(field?.name).toBe("favbook");
|
|
@@ -1582,7 +1582,7 @@ Pencil, 0.5,2, t`;
|
|
|
1582
1582
|
(0, globals_1.expect)(field?.id).toBe(8);
|
|
1583
1583
|
});
|
|
1584
1584
|
(0, globals_1.it)("should find single join key field", async () => {
|
|
1585
|
-
const table =
|
|
1585
|
+
const table = table_1.default.findOne({ name: "patients" });
|
|
1586
1586
|
(0, assertions_1.assertIsSet)(table);
|
|
1587
1587
|
const field = await table.getField("favbook.publisher");
|
|
1588
1588
|
(0, globals_1.expect)(field?.name).toBe("publisher");
|
|
@@ -1592,12 +1592,12 @@ Pencil, 0.5,2, t`;
|
|
|
1592
1592
|
});
|
|
1593
1593
|
(0, globals_1.describe)("field_options", () => {
|
|
1594
1594
|
(0, globals_1.it)("should find own fields", async () => {
|
|
1595
|
-
const table =
|
|
1595
|
+
const table = table_1.default.findOne({ name: "patients" });
|
|
1596
1596
|
const opts = await table?.field_options();
|
|
1597
1597
|
(0, globals_1.expect)(opts).toStrictEqual(["favbook", "id", "name", "parent"]);
|
|
1598
1598
|
});
|
|
1599
1599
|
(0, globals_1.it)("should find one-level join fields", async () => {
|
|
1600
|
-
const table =
|
|
1600
|
+
const table = table_1.default.findOne({ name: "patients" });
|
|
1601
1601
|
const opts = await table?.field_options(1);
|
|
1602
1602
|
(0, globals_1.expect)(opts).toStrictEqual([
|
|
1603
1603
|
"favbook",
|
|
@@ -1615,16 +1615,16 @@ Pencil, 0.5,2, t`;
|
|
|
1615
1615
|
]);
|
|
1616
1616
|
});
|
|
1617
1617
|
(0, globals_1.it)("should find string fields", async () => {
|
|
1618
|
-
const table =
|
|
1618
|
+
const table = table_1.default.findOne({ name: "patients" });
|
|
1619
1619
|
const opts = await table?.field_options(1, (f) => f.type_name === "String");
|
|
1620
1620
|
(0, globals_1.expect)(opts).toStrictEqual(["name", "favbook.author", "parent.name"]);
|
|
1621
1621
|
});
|
|
1622
1622
|
});
|
|
1623
1623
|
(0, globals_1.describe)("grandparent join", () => {
|
|
1624
1624
|
(0, globals_1.it)("should define rows", async () => {
|
|
1625
|
-
const table =
|
|
1625
|
+
const table = table_1.default.findOne({ name: "patients" });
|
|
1626
1626
|
(0, assertions_1.assertIsSet)(table);
|
|
1627
|
-
const fields =
|
|
1627
|
+
const fields = table.getFields();
|
|
1628
1628
|
const greatgranny = await table.insertRow({ name: "Greatgranny" });
|
|
1629
1629
|
const granny = await table.insertRow({
|
|
1630
1630
|
name: "Granny",
|