@saltcorn/data 1.6.0-rc.1 → 1.6.0-rc.2
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.d.ts.map +1 -1
- package/dist/base-plugin/actions.js +8 -11
- package/dist/base-plugin/actions.js.map +1 -1
- package/dist/base-plugin/index.d.ts.map +1 -1
- package/dist/models/table.d.ts +1 -0
- package/dist/models/table.d.ts.map +1 -1
- package/dist/models/table.js +4 -0
- package/dist/models/table.js.map +1 -1
- package/dist/models/workflow_step.js +1 -1
- package/dist/models/workflow_step.js.map +1 -1
- package/dist/setup-test-schema.d.ts +2 -0
- package/dist/setup-test-schema.d.ts.map +1 -0
- package/dist/setup-test-schema.js +34 -0
- package/dist/setup-test-schema.js.map +1 -0
- package/dist/tests/actions.test.d.ts +2 -0
- package/dist/tests/actions.test.d.ts.map +1 -0
- package/dist/tests/actions.test.js +1104 -0
- package/dist/tests/actions.test.js.map +1 -0
- package/dist/tests/auth.test.d.ts +2 -0
- package/dist/tests/auth.test.d.ts.map +1 -0
- package/dist/tests/auth.test.js +927 -0
- package/dist/tests/auth.test.js.map +1 -0
- package/dist/tests/auxtest.test.d.ts +2 -0
- package/dist/tests/auxtest.test.d.ts.map +1 -0
- package/dist/tests/auxtest.test.js +631 -0
- package/dist/tests/auxtest.test.js.map +1 -0
- package/dist/tests/base.test.d.ts +2 -0
- package/dist/tests/base.test.d.ts.map +1 -0
- package/dist/tests/base.test.js +27 -0
- package/dist/tests/base.test.js.map +1 -0
- package/dist/tests/calc.test.d.ts +2 -0
- package/dist/tests/calc.test.d.ts.map +1 -0
- package/dist/tests/calc.test.js +1465 -0
- package/dist/tests/calc.test.js.map +1 -0
- package/dist/tests/composite_pk.test.d.ts +2 -0
- package/dist/tests/composite_pk.test.d.ts.map +1 -0
- package/dist/tests/composite_pk.test.js +98 -0
- package/dist/tests/composite_pk.test.js.map +1 -0
- package/dist/tests/config.test.d.ts +2 -0
- package/dist/tests/config.test.d.ts.map +1 -0
- package/dist/tests/config.test.js +86 -0
- package/dist/tests/config.test.js.map +1 -0
- package/dist/tests/db.test.d.ts +2 -0
- package/dist/tests/db.test.d.ts.map +1 -0
- package/dist/tests/db.test.js +179 -0
- package/dist/tests/db.test.js.map +1 -0
- package/dist/tests/discover.test.d.ts +2 -0
- package/dist/tests/discover.test.d.ts.map +1 -0
- package/dist/tests/discover.test.js +330 -0
- package/dist/tests/discover.test.js.map +1 -0
- package/dist/tests/edit.test.d.ts +2 -0
- package/dist/tests/edit.test.d.ts.map +1 -0
- package/dist/tests/edit.test.js +1186 -0
- package/dist/tests/edit.test.js.map +1 -0
- package/dist/tests/email.test.d.ts +2 -0
- package/dist/tests/email.test.d.ts.map +1 -0
- package/dist/tests/email.test.js +255 -0
- package/dist/tests/email.test.js.map +1 -0
- package/dist/tests/exact_views.test.d.ts +2 -0
- package/dist/tests/exact_views.test.d.ts.map +1 -0
- package/dist/tests/exact_views.test.js +1363 -0
- package/dist/tests/exact_views.test.js.map +1 -0
- package/dist/tests/field.test.d.ts +2 -0
- package/dist/tests/field.test.d.ts.map +1 -0
- package/dist/tests/field.test.js +589 -0
- package/dist/tests/field.test.js.map +1 -0
- package/dist/tests/fieldviews.test.d.ts +2 -0
- package/dist/tests/fieldviews.test.d.ts.map +1 -0
- package/dist/tests/fieldviews.test.js +74 -0
- package/dist/tests/fieldviews.test.js.map +1 -0
- package/dist/tests/file.test.d.ts +2 -0
- package/dist/tests/file.test.d.ts.map +1 -0
- package/dist/tests/file.test.js +165 -0
- package/dist/tests/file.test.js.map +1 -0
- package/dist/tests/filter.test.d.ts +2 -0
- package/dist/tests/filter.test.d.ts.map +1 -0
- package/dist/tests/filter.test.js +499 -0
- package/dist/tests/filter.test.js.map +1 -0
- package/dist/tests/form.test.d.ts +2 -0
- package/dist/tests/form.test.d.ts.map +1 -0
- package/dist/tests/form.test.js +343 -0
- package/dist/tests/form.test.js.map +1 -0
- package/dist/tests/list.test.d.ts +2 -0
- package/dist/tests/list.test.d.ts.map +1 -0
- package/dist/tests/list.test.js +1236 -0
- package/dist/tests/list.test.js.map +1 -0
- package/dist/tests/mail_queue.test.d.ts +2 -0
- package/dist/tests/mail_queue.test.d.ts.map +1 -0
- package/dist/tests/mail_queue.test.js +122 -0
- package/dist/tests/mail_queue.test.js.map +1 -0
- package/dist/tests/models.test.d.ts +2 -0
- package/dist/tests/models.test.d.ts.map +1 -0
- package/dist/tests/models.test.js +417 -0
- package/dist/tests/models.test.js.map +1 -0
- package/dist/tests/page.test.d.ts +2 -0
- package/dist/tests/page.test.d.ts.map +1 -0
- package/dist/tests/page.test.js +91 -0
- package/dist/tests/page.test.js.map +1 -0
- package/dist/tests/page_group.test.d.ts +2 -0
- package/dist/tests/page_group.test.d.ts.map +1 -0
- package/dist/tests/page_group.test.js +52 -0
- package/dist/tests/page_group.test.js.map +1 -0
- package/dist/tests/plugin.test.d.ts +2 -0
- package/dist/tests/plugin.test.d.ts.map +1 -0
- package/dist/tests/plugin.test.js +66 -0
- package/dist/tests/plugin.test.js.map +1 -0
- package/dist/tests/show.test.d.ts +2 -0
- package/dist/tests/show.test.d.ts.map +1 -0
- package/dist/tests/show.test.js +613 -0
- package/dist/tests/show.test.js.map +1 -0
- package/dist/tests/state.test.d.ts +2 -0
- package/dist/tests/state.test.d.ts.map +1 -0
- package/dist/tests/state.test.js +82 -0
- package/dist/tests/state.test.js.map +1 -0
- package/dist/tests/table.test.d.ts +2 -0
- package/dist/tests/table.test.d.ts.map +1 -0
- package/dist/tests/table.test.js +3211 -0
- package/dist/tests/table.test.js.map +1 -0
- package/dist/tests/table_history.test.d.ts +2 -0
- package/dist/tests/table_history.test.d.ts.map +1 -0
- package/dist/tests/table_history.test.js +415 -0
- package/dist/tests/table_history.test.js.map +1 -0
- package/dist/tests/table_sync_info.test.d.ts +2 -0
- package/dist/tests/table_sync_info.test.d.ts.map +1 -0
- package/dist/tests/table_sync_info.test.js +62 -0
- package/dist/tests/table_sync_info.test.js.map +1 -0
- package/dist/tests/tag.test.d.ts +2 -0
- package/dist/tests/tag.test.d.ts.map +1 -0
- package/dist/tests/tag.test.js +97 -0
- package/dist/tests/tag.test.js.map +1 -0
- package/dist/tests/user.test.d.ts +2 -0
- package/dist/tests/user.test.d.ts.map +1 -0
- package/dist/tests/user.test.js +467 -0
- package/dist/tests/user.test.js.map +1 -0
- package/dist/tests/view.test.d.ts +2 -0
- package/dist/tests/view.test.d.ts.map +1 -0
- package/dist/tests/view.test.js +703 -0
- package/dist/tests/view.test.js.map +1 -0
- package/dist/tests/workflow.test.d.ts +2 -0
- package/dist/tests/workflow.test.d.ts.map +1 -0
- package/dist/tests/workflow.test.js +303 -0
- package/dist/tests/workflow.test.js.map +1 -0
- package/dist/tests/workflow_run.test.d.ts +2 -0
- package/dist/tests/workflow_run.test.d.ts.map +1 -0
- package/dist/tests/workflow_run.test.js +922 -0
- package/dist/tests/workflow_run.test.js.map +1 -0
- package/dist/viewable_fields.d.ts.map +1 -1
- package/dist/viewable_fields.js +1 -0
- package/dist/viewable_fields.js.map +1 -1
- package/package.json +8 -8
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
/**
|
|
7
|
+
* Tests for discovery.ts
|
|
8
|
+
*/
|
|
9
|
+
const discovery_1 = __importDefault(require("../models/discovery"));
|
|
10
|
+
const { discoverable_tables, discover_tables, implement_discovery, reconcile_table, } = discovery_1.default;
|
|
11
|
+
const { getState } = require("../db/state");
|
|
12
|
+
const db_1 = __importDefault(require("../db"));
|
|
13
|
+
const table_1 = __importDefault(require("../models/table"));
|
|
14
|
+
const field_1 = __importDefault(require("../models/field"));
|
|
15
|
+
const test_expect_1 = require("@saltcorn/db-common/test_expect");
|
|
16
|
+
const assertions_1 = require("./assertions");
|
|
17
|
+
getState().registerPlugin("base", require("../base-plugin"));
|
|
18
|
+
// todo do we need to delete tables after tests?
|
|
19
|
+
(0, test_expect_1.afterAll)(db_1.default.close);
|
|
20
|
+
(0, test_expect_1.beforeAll)(async () => {
|
|
21
|
+
await require("../db/reset_schema")();
|
|
22
|
+
await require("../db/fixtures")();
|
|
23
|
+
});
|
|
24
|
+
test_expect_1.jest.setTimeout(30000);
|
|
25
|
+
// todo tests with forgotten tables
|
|
26
|
+
// todo more sql types
|
|
27
|
+
// [+done] more complex relationships between tables
|
|
28
|
+
// [+done] tests with names with spaces
|
|
29
|
+
// [+done] test cases about table with history
|
|
30
|
+
// todo partly discovering (not all tables in one discovery)
|
|
31
|
+
(0, test_expect_1.describe)("Table Discovery", () => {
|
|
32
|
+
if (!db_1.default.isSQLite) {
|
|
33
|
+
(0, test_expect_1.it)("should create tables", async () => {
|
|
34
|
+
// this is simple ref table
|
|
35
|
+
await db_1.default.query(`create table "disc breed"(id serial primary key, name text, rating smallint, population bigint );`);
|
|
36
|
+
// this table has FK to users!
|
|
37
|
+
await db_1.default.query(`create table discperson(
|
|
38
|
+
id serial primary key,
|
|
39
|
+
name text,
|
|
40
|
+
age integer not null,
|
|
41
|
+
"user" int references users(id)
|
|
42
|
+
);`);
|
|
43
|
+
// this table has 2 FK and column with space in name
|
|
44
|
+
await db_1.default.query(`create table discdog(
|
|
45
|
+
id serial primary key,
|
|
46
|
+
name text,
|
|
47
|
+
"birth date" date,
|
|
48
|
+
owner int references discperson(id),
|
|
49
|
+
breed int references "disc breed"(id));`);
|
|
50
|
+
// this table added to check that *_history tables are not discovered
|
|
51
|
+
const table = await table_1.default.create("table_with_history");
|
|
52
|
+
await table.update({ versioned: true });
|
|
53
|
+
});
|
|
54
|
+
(0, test_expect_1.it)("should list tables", async () => {
|
|
55
|
+
const tbls = await discoverable_tables();
|
|
56
|
+
(0, test_expect_1.expect)(tbls.map((t) => t.table_name).sort()).toStrictEqual([
|
|
57
|
+
"disc breed",
|
|
58
|
+
"discdog",
|
|
59
|
+
"discperson",
|
|
60
|
+
]);
|
|
61
|
+
});
|
|
62
|
+
(0, test_expect_1.it)("should make simple pack", async () => {
|
|
63
|
+
const pack = await discover_tables(["discperson"]);
|
|
64
|
+
(0, test_expect_1.expect)(pack).toStrictEqual({
|
|
65
|
+
tables: [
|
|
66
|
+
{
|
|
67
|
+
fields: [
|
|
68
|
+
{
|
|
69
|
+
label: "id",
|
|
70
|
+
name: "id",
|
|
71
|
+
required: true,
|
|
72
|
+
type: "Integer",
|
|
73
|
+
primary_key: true,
|
|
74
|
+
is_unique: true,
|
|
75
|
+
},
|
|
76
|
+
{ label: "name", name: "name", required: false, type: "String" },
|
|
77
|
+
{ label: "age", name: "age", required: true, type: "Integer" },
|
|
78
|
+
{
|
|
79
|
+
label: "user",
|
|
80
|
+
name: "user",
|
|
81
|
+
refname: "id",
|
|
82
|
+
reftable_name: "users",
|
|
83
|
+
reftype: "Integer",
|
|
84
|
+
required: false,
|
|
85
|
+
type: "Key",
|
|
86
|
+
},
|
|
87
|
+
],
|
|
88
|
+
name: "discperson",
|
|
89
|
+
min_role_read: 1,
|
|
90
|
+
min_role_write: 1,
|
|
91
|
+
},
|
|
92
|
+
],
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
(0, test_expect_1.it)("should make and implement pack with fkey", async () => {
|
|
96
|
+
const pack = await discover_tables([
|
|
97
|
+
"disc breed",
|
|
98
|
+
"discperson",
|
|
99
|
+
"discdog",
|
|
100
|
+
]);
|
|
101
|
+
(0, test_expect_1.expect)(pack).toStrictEqual({
|
|
102
|
+
tables: [
|
|
103
|
+
// disc breed
|
|
104
|
+
{
|
|
105
|
+
fields: [
|
|
106
|
+
{
|
|
107
|
+
label: "id",
|
|
108
|
+
name: "id",
|
|
109
|
+
required: true,
|
|
110
|
+
type: "Integer",
|
|
111
|
+
primary_key: true,
|
|
112
|
+
is_unique: true,
|
|
113
|
+
},
|
|
114
|
+
{ label: "name", name: "name", required: false, type: "String" },
|
|
115
|
+
{
|
|
116
|
+
label: "rating",
|
|
117
|
+
name: "rating",
|
|
118
|
+
required: false,
|
|
119
|
+
type: "Integer",
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
label: "population",
|
|
123
|
+
name: "population",
|
|
124
|
+
required: false,
|
|
125
|
+
type: "Integer",
|
|
126
|
+
},
|
|
127
|
+
],
|
|
128
|
+
name: "disc breed",
|
|
129
|
+
min_role_read: 1,
|
|
130
|
+
min_role_write: 1,
|
|
131
|
+
},
|
|
132
|
+
// discperson
|
|
133
|
+
{
|
|
134
|
+
fields: [
|
|
135
|
+
{
|
|
136
|
+
label: "id",
|
|
137
|
+
name: "id",
|
|
138
|
+
required: true,
|
|
139
|
+
type: "Integer",
|
|
140
|
+
primary_key: true,
|
|
141
|
+
is_unique: true,
|
|
142
|
+
},
|
|
143
|
+
{ label: "name", name: "name", required: false, type: "String" },
|
|
144
|
+
{ label: "age", name: "age", required: true, type: "Integer" },
|
|
145
|
+
{
|
|
146
|
+
label: "user",
|
|
147
|
+
name: "user",
|
|
148
|
+
refname: "id",
|
|
149
|
+
reftable_name: "users",
|
|
150
|
+
reftype: "Integer",
|
|
151
|
+
required: false,
|
|
152
|
+
type: "Key",
|
|
153
|
+
},
|
|
154
|
+
],
|
|
155
|
+
name: "discperson",
|
|
156
|
+
min_role_read: 1,
|
|
157
|
+
min_role_write: 1,
|
|
158
|
+
},
|
|
159
|
+
// discdog
|
|
160
|
+
{
|
|
161
|
+
fields: [
|
|
162
|
+
{
|
|
163
|
+
label: "id",
|
|
164
|
+
name: "id",
|
|
165
|
+
required: true,
|
|
166
|
+
type: "Integer",
|
|
167
|
+
primary_key: true,
|
|
168
|
+
is_unique: true,
|
|
169
|
+
},
|
|
170
|
+
{ label: "name", name: "name", required: false, type: "String" },
|
|
171
|
+
{
|
|
172
|
+
label: "birth date",
|
|
173
|
+
name: "birth date",
|
|
174
|
+
required: false,
|
|
175
|
+
type: "Date",
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
label: "owner",
|
|
179
|
+
name: "owner",
|
|
180
|
+
required: false,
|
|
181
|
+
refname: "id",
|
|
182
|
+
reftable_name: "discperson",
|
|
183
|
+
reftype: "Integer",
|
|
184
|
+
type: "Key",
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
label: "breed",
|
|
188
|
+
name: "breed",
|
|
189
|
+
required: false,
|
|
190
|
+
refname: "id",
|
|
191
|
+
reftable_name: "disc breed",
|
|
192
|
+
reftype: "Integer",
|
|
193
|
+
type: "Key",
|
|
194
|
+
},
|
|
195
|
+
],
|
|
196
|
+
name: "discdog",
|
|
197
|
+
min_role_read: 1,
|
|
198
|
+
min_role_write: 1,
|
|
199
|
+
},
|
|
200
|
+
],
|
|
201
|
+
});
|
|
202
|
+
await implement_discovery(pack);
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
else {
|
|
206
|
+
(0, test_expect_1.it)("doesnt run on sqlite", async () => {
|
|
207
|
+
(0, test_expect_1.expect)(2 + 2).toBe(4);
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
(0, test_expect_1.describe)("Repair primary key", () => {
|
|
212
|
+
if (!db_1.default.isSQLite) {
|
|
213
|
+
(0, test_expect_1.it)("creates table", async () => {
|
|
214
|
+
await db_1.default.query(`create table twoprimkeys(
|
|
215
|
+
the_x integer,
|
|
216
|
+
the_y integer,
|
|
217
|
+
primary key(the_x,the_y)
|
|
218
|
+
);`);
|
|
219
|
+
});
|
|
220
|
+
(0, test_expect_1.it)("should list tables", async () => {
|
|
221
|
+
const tbls = await discoverable_tables();
|
|
222
|
+
(0, test_expect_1.expect)(tbls.map((t) => t.table_name)).toContain("twoprimkeys");
|
|
223
|
+
});
|
|
224
|
+
(0, test_expect_1.it)("should discover", async () => {
|
|
225
|
+
const pack = await discover_tables(["twoprimkeys"]);
|
|
226
|
+
await implement_discovery(pack);
|
|
227
|
+
});
|
|
228
|
+
(0, test_expect_1.it)("should repair", async () => {
|
|
229
|
+
const table = table_1.default.findOne("twoprimkeys");
|
|
230
|
+
(0, assertions_1.assertIsSet)(table);
|
|
231
|
+
await table.repairCompositePrimary();
|
|
232
|
+
});
|
|
233
|
+
(0, test_expect_1.it)("should have an int primary key", async () => {
|
|
234
|
+
const table = table_1.default.findOne("twoprimkeys");
|
|
235
|
+
(0, assertions_1.assertIsSet)(table);
|
|
236
|
+
(0, test_expect_1.expect)(table.fields.length).toBe(3);
|
|
237
|
+
(0, test_expect_1.expect)(table.pk_name).toBe("id");
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
else {
|
|
241
|
+
(0, test_expect_1.it)("doesnt run on sqlite", async () => {
|
|
242
|
+
(0, test_expect_1.expect)(2 + 2).toBe(4);
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
});
|
|
246
|
+
(0, test_expect_1.describe)("reconcile_table", () => {
|
|
247
|
+
if (!db_1.default.isSQLite) {
|
|
248
|
+
(0, test_expect_1.it)("should report all matches for a healthy table", async () => {
|
|
249
|
+
const books = table_1.default.findOne("books");
|
|
250
|
+
(0, assertions_1.assertIsSet)(books);
|
|
251
|
+
const result = await reconcile_table(books);
|
|
252
|
+
(0, test_expect_1.expect)(result.ghost_count).toBe(0);
|
|
253
|
+
(0, test_expect_1.expect)(result.orphan_count).toBe(0);
|
|
254
|
+
(0, test_expect_1.expect)(result.match_count).toBeGreaterThan(0);
|
|
255
|
+
// All fields should be match
|
|
256
|
+
for (const f of result.fields) {
|
|
257
|
+
(0, test_expect_1.expect)(f.status).toBe("match");
|
|
258
|
+
}
|
|
259
|
+
});
|
|
260
|
+
(0, test_expect_1.it)("should detect ghost fields", async () => {
|
|
261
|
+
// Create a table with Saltcorn
|
|
262
|
+
const table = await table_1.default.create("reconcile_test");
|
|
263
|
+
await field_1.default.create({
|
|
264
|
+
table,
|
|
265
|
+
name: "mycol",
|
|
266
|
+
label: "My Column",
|
|
267
|
+
type: "String",
|
|
268
|
+
});
|
|
269
|
+
await field_1.default.create({
|
|
270
|
+
table,
|
|
271
|
+
name: "mycol2",
|
|
272
|
+
label: "My Column 2",
|
|
273
|
+
type: "Integer",
|
|
274
|
+
});
|
|
275
|
+
// Drop the column directly from DB
|
|
276
|
+
await db_1.default.query(`ALTER TABLE "reconcile_test" DROP COLUMN "mycol"`);
|
|
277
|
+
// Refresh table in-memory fields
|
|
278
|
+
const freshTable = table_1.default.findOne("reconcile_test");
|
|
279
|
+
(0, assertions_1.assertIsSet)(freshTable);
|
|
280
|
+
const result = await reconcile_table(freshTable);
|
|
281
|
+
(0, test_expect_1.expect)(result.ghost_count).toBe(1);
|
|
282
|
+
const ghost = result.fields.find((f) => f.status === "ghost");
|
|
283
|
+
(0, test_expect_1.expect)(ghost).toBeDefined();
|
|
284
|
+
(0, test_expect_1.expect)(ghost.name).toBe("mycol");
|
|
285
|
+
// mycol2 should still match
|
|
286
|
+
const match = result.fields.find((f) => f.name === "mycol2");
|
|
287
|
+
(0, test_expect_1.expect)(match).toBeDefined();
|
|
288
|
+
(0, test_expect_1.expect)(match.status).toBe("match");
|
|
289
|
+
});
|
|
290
|
+
(0, test_expect_1.it)("should detect orphan columns", async () => {
|
|
291
|
+
// Add a column directly to DB
|
|
292
|
+
await db_1.default.query(`ALTER TABLE "reconcile_test" ADD COLUMN "orphan_col" text`);
|
|
293
|
+
const freshTable = table_1.default.findOne("reconcile_test");
|
|
294
|
+
(0, assertions_1.assertIsSet)(freshTable);
|
|
295
|
+
const result = await reconcile_table(freshTable);
|
|
296
|
+
(0, test_expect_1.expect)(result.orphan_count).toBeGreaterThanOrEqual(1);
|
|
297
|
+
const orphan = result.fields.find((f) => f.status === "orphan");
|
|
298
|
+
(0, test_expect_1.expect)(orphan).toBeDefined();
|
|
299
|
+
(0, test_expect_1.expect)(orphan.name).toBe("orphan_col");
|
|
300
|
+
});
|
|
301
|
+
(0, test_expect_1.it)("should not report transient calculated fields as ghosts", async () => {
|
|
302
|
+
const table = table_1.default.findOne("reconcile_test");
|
|
303
|
+
(0, assertions_1.assertIsSet)(table);
|
|
304
|
+
// Add a transient calculated field (calculated=true, stored=false)
|
|
305
|
+
await field_1.default.create({
|
|
306
|
+
table,
|
|
307
|
+
name: "calc_transient",
|
|
308
|
+
label: "Calc Transient",
|
|
309
|
+
type: "String",
|
|
310
|
+
calculated: true,
|
|
311
|
+
stored: false,
|
|
312
|
+
expression: "'hello'",
|
|
313
|
+
});
|
|
314
|
+
// Refresh and reconcile
|
|
315
|
+
const freshTable = table_1.default.findOne("reconcile_test");
|
|
316
|
+
(0, assertions_1.assertIsSet)(freshTable);
|
|
317
|
+
const result = await reconcile_table(freshTable);
|
|
318
|
+
// The transient field should be a match, not a ghost
|
|
319
|
+
const transient = result.fields.find((f) => f.name === "calc_transient");
|
|
320
|
+
(0, test_expect_1.expect)(transient).toBeDefined();
|
|
321
|
+
(0, test_expect_1.expect)(transient.status).toBe("match");
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
else {
|
|
325
|
+
(0, test_expect_1.it)("doesnt run on sqlite", async () => {
|
|
326
|
+
(0, test_expect_1.expect)(2 + 2).toBe(4);
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
});
|
|
330
|
+
//# sourceMappingURL=discover.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discover.test.js","sourceRoot":"","sources":["../../tests/discover.test.ts"],"names":[],"mappings":";;;;;AAAA;;GAEG;AACH,oEAA4C;AAC5C,MAAM,EACJ,mBAAmB,EACnB,eAAe,EACf,mBAAmB,EACnB,eAAe,GAChB,GAAG,mBAAS,CAAC;AACd,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;AAC5C,+CAAuB;AACvB,4DAAoC;AACpC,4DAAoC;AACpC,iEAAkG;AAElG,6CAA2C;AAE3C,QAAQ,EAAE,CAAC,cAAc,CAAC,MAAM,EAAE,OAAO,CAAC,gBAAg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