@proteinjs/db 1.0.27 → 1.0.29
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/CHANGELOG.md +23 -0
- package/dist/src/Columns.js +1 -1
- package/dist/src/Columns.js.map +1 -1
- package/dist/test/ColumnTypesTests.js +1 -1
- package/dist/test/ColumnTypesTests.js.map +1 -1
- package/dist/test/CrudTests.d.ts +21 -2
- package/dist/test/CrudTests.d.ts.map +1 -1
- package/dist/test/CrudTests.js +248 -26
- package/dist/test/CrudTests.js.map +1 -1
- package/dist/test/TableManagerTests.js +16 -16
- package/dist/test/TableManagerTests.js.map +1 -1
- package/package.json +3 -3
- package/src/Columns.ts +2 -2
- package/test/ColumnTypesTests.ts +1 -1
- package/test/CrudTests.ts +163 -17
- package/test/TableManagerTests.ts +13 -13
package/test/CrudTests.ts
CHANGED
|
@@ -13,7 +13,7 @@ export interface Employee extends Record {
|
|
|
13
13
|
object?: string;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
export class
|
|
16
|
+
export class EmployeeTestTable extends Table<Employee> {
|
|
17
17
|
name = 'db_test_employee';
|
|
18
18
|
columns = withRecordColumns<Employee>({
|
|
19
19
|
name: new StringColumn('name'),
|
|
@@ -25,13 +25,35 @@ export class EmployeeTable extends Table<Employee> {
|
|
|
25
25
|
});
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
export interface ReservedWordTest extends Record {
|
|
29
|
+
name: string;
|
|
30
|
+
order?: string;
|
|
31
|
+
select?: string;
|
|
32
|
+
join?: string;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export class ReservedWordTestTable extends Table<ReservedWordTest> {
|
|
36
|
+
name = 'db_test_reserved_word';
|
|
37
|
+
columns = withRecordColumns<ReservedWordTest>({
|
|
38
|
+
name: new StringColumn('name'),
|
|
39
|
+
order: new StringColumn('order'),
|
|
40
|
+
select: new StringColumn('select'),
|
|
41
|
+
join: new StringColumn('join'),
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
28
45
|
/**
|
|
29
46
|
* Used for testing purposes only.
|
|
30
47
|
* */
|
|
31
48
|
export const getTestTable = (tableName: string) => {
|
|
32
|
-
const employeeTable = new
|
|
49
|
+
const employeeTable = new EmployeeTestTable();
|
|
33
50
|
if (employeeTable.name == tableName) {
|
|
34
|
-
return new
|
|
51
|
+
return new EmployeeTestTable();
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const reservedWordTestTable = new ReservedWordTestTable();
|
|
55
|
+
if (reservedWordTestTable.name == tableName) {
|
|
56
|
+
return new ReservedWordTestTable();
|
|
35
57
|
}
|
|
36
58
|
|
|
37
59
|
throw new Error(`Cannot find test table: ${tableName}`);
|
|
@@ -46,11 +68,13 @@ export const crudTests = (driver: DbDriver, dropTable: (table: Table<any>) => Pr
|
|
|
46
68
|
await driver.start();
|
|
47
69
|
}
|
|
48
70
|
|
|
49
|
-
await driver.getTableManager().loadTable(new
|
|
71
|
+
await driver.getTableManager().loadTable(new EmployeeTestTable());
|
|
72
|
+
await driver.getTableManager().loadTable(new ReservedWordTestTable());
|
|
50
73
|
});
|
|
51
74
|
|
|
52
75
|
afterAll(async () => {
|
|
53
|
-
await dropTable(new
|
|
76
|
+
await dropTable(new EmployeeTestTable());
|
|
77
|
+
await dropTable(new ReservedWordTestTable());
|
|
54
78
|
|
|
55
79
|
if (driver.stop) {
|
|
56
80
|
await driver.stop();
|
|
@@ -59,7 +83,7 @@ export const crudTests = (driver: DbDriver, dropTable: (table: Table<any>) => Pr
|
|
|
59
83
|
|
|
60
84
|
test('Insert', async () => {
|
|
61
85
|
const testEmployee: Omit<Employee, keyof Record> = { name: 'Veronica' };
|
|
62
|
-
const emplyeeTable: Table<Employee> = new
|
|
86
|
+
const emplyeeTable: Table<Employee> = new EmployeeTestTable();
|
|
63
87
|
const insertedEmployee = await db.insert(emplyeeTable, testEmployee);
|
|
64
88
|
const fetchedEmployee = await db.get(emplyeeTable, { id: insertedEmployee.id });
|
|
65
89
|
expect(fetchedEmployee).toBeTruthy();
|
|
@@ -68,7 +92,7 @@ export const crudTests = (driver: DbDriver, dropTable: (table: Table<any>) => Pr
|
|
|
68
92
|
|
|
69
93
|
test('Update', async () => {
|
|
70
94
|
const testEmployee: Omit<Employee, keyof Record> = { name: 'Veronica' };
|
|
71
|
-
const emplyeeTable: Table<Employee> = new
|
|
95
|
+
const emplyeeTable: Table<Employee> = new EmployeeTestTable();
|
|
72
96
|
const insertedEmployee = await db.insert(emplyeeTable, testEmployee);
|
|
73
97
|
const updateCount = await db.update(
|
|
74
98
|
emplyeeTable,
|
|
@@ -89,7 +113,7 @@ export const crudTests = (driver: DbDriver, dropTable: (table: Table<any>) => Pr
|
|
|
89
113
|
|
|
90
114
|
test('Delete', async () => {
|
|
91
115
|
const testEmployee: Omit<Employee, keyof Record> = { name: 'Veronica' };
|
|
92
|
-
const emplyeeTable: Table<Employee> = new
|
|
116
|
+
const emplyeeTable: Table<Employee> = new EmployeeTestTable();
|
|
93
117
|
const insertedEmployee = await db.insert(emplyeeTable, testEmployee);
|
|
94
118
|
let fetchedEmployee = await db.get(emplyeeTable, { id: insertedEmployee.id });
|
|
95
119
|
expect(fetchedEmployee).toBeTruthy();
|
|
@@ -103,7 +127,7 @@ export const crudTests = (driver: DbDriver, dropTable: (table: Table<any>) => Pr
|
|
|
103
127
|
const testEmployee1: Omit<Employee, keyof Record> = { name: 'Veronica', department: 'Cake Factory' };
|
|
104
128
|
const testEmployee2: Omit<Employee, keyof Record> = { name: 'Brent', department: 'Cake Factory' };
|
|
105
129
|
const testEmployee3: Omit<Employee, keyof Record> = { name: 'Sean', department: 'Pug Playhouse' };
|
|
106
|
-
const emplyeeTable: Table<Employee> = new
|
|
130
|
+
const emplyeeTable: Table<Employee> = new EmployeeTestTable();
|
|
107
131
|
const fetchedEmployee1 = await db.insert(emplyeeTable, testEmployee1);
|
|
108
132
|
const fetchedEmployee2 = await db.insert(emplyeeTable, testEmployee2);
|
|
109
133
|
const fetchedEmployee3 = await db.insert(emplyeeTable, testEmployee3);
|
|
@@ -123,7 +147,7 @@ export const crudTests = (driver: DbDriver, dropTable: (table: Table<any>) => Pr
|
|
|
123
147
|
const testEmployee1: Omit<Employee, keyof Record> = { name: 'Veronica', department: 'Cake Factory' };
|
|
124
148
|
const testEmployee2: Omit<Employee, keyof Record> = { name: 'Brent', department: 'Cake Factory' };
|
|
125
149
|
const testEmployee3: Omit<Employee, keyof Record> = { name: 'Sean', department: 'Pug Playhouse' };
|
|
126
|
-
const emplyeeTable: Table<Employee> = new
|
|
150
|
+
const emplyeeTable: Table<Employee> = new EmployeeTestTable();
|
|
127
151
|
const fetchedEmployee1 = await db.insert(emplyeeTable, testEmployee1);
|
|
128
152
|
const fetchedEmployee2 = await db.insert(emplyeeTable, testEmployee2);
|
|
129
153
|
const fetchedEmployee3 = await db.insert(emplyeeTable, testEmployee3);
|
|
@@ -144,7 +168,7 @@ export const crudTests = (driver: DbDriver, dropTable: (table: Table<any>) => Pr
|
|
|
144
168
|
jobTitle: null,
|
|
145
169
|
isRemote: false,
|
|
146
170
|
};
|
|
147
|
-
const emplyeeTable: Table<Employee> = new
|
|
171
|
+
const emplyeeTable: Table<Employee> = new EmployeeTestTable();
|
|
148
172
|
const insertedEmployee = await db.insert(emplyeeTable, testEmployee);
|
|
149
173
|
const fetchedEmployee = await db.get(emplyeeTable, { id: insertedEmployee.id });
|
|
150
174
|
|
|
@@ -160,7 +184,7 @@ export const crudTests = (driver: DbDriver, dropTable: (table: Table<any>) => Pr
|
|
|
160
184
|
jobTitle: 'Cowboy',
|
|
161
185
|
isRemote: false,
|
|
162
186
|
};
|
|
163
|
-
const emplyeeTable: Table<Employee> = new
|
|
187
|
+
const emplyeeTable: Table<Employee> = new EmployeeTestTable();
|
|
164
188
|
const insertedEmployee = await db.insert(emplyeeTable, testEmployee);
|
|
165
189
|
const fetchedEmployee = await db.get(emplyeeTable, { id: insertedEmployee.id });
|
|
166
190
|
expect(fetchedEmployee).toBeTruthy();
|
|
@@ -176,7 +200,7 @@ export const crudTests = (driver: DbDriver, dropTable: (table: Table<any>) => Pr
|
|
|
176
200
|
jobTitle: null,
|
|
177
201
|
isRemote: false,
|
|
178
202
|
};
|
|
179
|
-
const emplyeeTable: Table<Employee> = new
|
|
203
|
+
const emplyeeTable: Table<Employee> = new EmployeeTestTable();
|
|
180
204
|
const insertedEmployee = await db.insert(emplyeeTable, testEmployee);
|
|
181
205
|
|
|
182
206
|
const qb = new QueryBuilder<Employee>(emplyeeTable.name)
|
|
@@ -194,7 +218,7 @@ export const crudTests = (driver: DbDriver, dropTable: (table: Table<any>) => Pr
|
|
|
194
218
|
const testEmployee1: Omit<Employee, keyof Record> = { name: 'Veronica', jobTitle: 'Engineer' };
|
|
195
219
|
const testEmployee2: Omit<Employee, keyof Record> = { name: 'Zenyatta', jobTitle: null };
|
|
196
220
|
const testEmployee3: Omit<Employee, keyof Record> = { name: 'Cassidy', jobTitle: 'Cowboy' };
|
|
197
|
-
const emplyeeTable: Table<Employee> = new
|
|
221
|
+
const emplyeeTable: Table<Employee> = new EmployeeTestTable();
|
|
198
222
|
const insertedEmployee1 = await db.insert(emplyeeTable, testEmployee1);
|
|
199
223
|
const insertedEmployee2 = await db.insert(emplyeeTable, testEmployee2);
|
|
200
224
|
const insertedEmployee3 = await db.insert(emplyeeTable, testEmployee3);
|
|
@@ -241,7 +265,7 @@ export const crudTests = (driver: DbDriver, dropTable: (table: Table<any>) => Pr
|
|
|
241
265
|
jobTitle: 'Cowboy',
|
|
242
266
|
startDate: new Date('2016-05-24T00:00:00Z'),
|
|
243
267
|
};
|
|
244
|
-
const employeeTable: Table<Employee> = new
|
|
268
|
+
const employeeTable: Table<Employee> = new EmployeeTestTable();
|
|
245
269
|
|
|
246
270
|
const insertedEmployee1 = await db.insert(employeeTable, testEmployee1);
|
|
247
271
|
const insertedEmployee2 = await db.insert(employeeTable, testEmployee2);
|
|
@@ -279,7 +303,7 @@ export const crudTests = (driver: DbDriver, dropTable: (table: Table<any>) => Pr
|
|
|
279
303
|
name: 'Cassidy',
|
|
280
304
|
jobTitle: 'Cowboy',
|
|
281
305
|
};
|
|
282
|
-
const emplyeeTable: Table<Employee> = new
|
|
306
|
+
const emplyeeTable: Table<Employee> = new EmployeeTestTable();
|
|
283
307
|
|
|
284
308
|
const insertedEmployee1 = await db.insert(emplyeeTable, testEmployee1);
|
|
285
309
|
const insertedEmployee2 = await db.insert(emplyeeTable, testEmployee2);
|
|
@@ -308,7 +332,7 @@ export const crudTests = (driver: DbDriver, dropTable: (table: Table<any>) => Pr
|
|
|
308
332
|
test('CRUD operations with undefined values', async () => {
|
|
309
333
|
const testEmployee1: Omit<Employee, keyof Record> = { name: 'Veronica', jobTitle: 'Software Engineer' };
|
|
310
334
|
const testEmployee2: Omit<Employee, keyof Record> = { name: 'Brent', jobTitle: undefined };
|
|
311
|
-
const emplyeeTable: Table<Employee> = new
|
|
335
|
+
const emplyeeTable: Table<Employee> = new EmployeeTestTable();
|
|
312
336
|
|
|
313
337
|
// Insert operation with undefined values
|
|
314
338
|
await expect(db.insert(emplyeeTable, testEmployee2)).rejects.toThrow();
|
|
@@ -338,5 +362,127 @@ export const crudTests = (driver: DbDriver, dropTable: (table: Table<any>) => Pr
|
|
|
338
362
|
});
|
|
339
363
|
await db.delete(emplyeeTable, deleteValidQuery);
|
|
340
364
|
});
|
|
365
|
+
|
|
366
|
+
test('Insert with reserved words', async () => {
|
|
367
|
+
const testRecord: Omit<ReservedWordTest, keyof Record> = { name: 'Test Name', order: '1', select: 'Option 1' };
|
|
368
|
+
const table: Table<ReservedWordTest> = new ReservedWordTestTable();
|
|
369
|
+
const insertedRecord = await db.insert(table, testRecord);
|
|
370
|
+
const fetchedRecord = await db.get(table, { id: insertedRecord.id });
|
|
371
|
+
expect(fetchedRecord).toBeTruthy();
|
|
372
|
+
await db.delete(table, { id: fetchedRecord.id });
|
|
373
|
+
});
|
|
374
|
+
|
|
375
|
+
test('Update with reserved words', async () => {
|
|
376
|
+
const testRecord: Omit<ReservedWordTest, keyof Record> = { name: 'Test Name', order: '1', select: 'Option 1' };
|
|
377
|
+
const table: Table<ReservedWordTest> = new ReservedWordTestTable();
|
|
378
|
+
const insertedRecord = await db.insert(table, testRecord);
|
|
379
|
+
const updateCount = await db.update(
|
|
380
|
+
table,
|
|
381
|
+
{
|
|
382
|
+
name: 'Updated Name',
|
|
383
|
+
order: '2',
|
|
384
|
+
join: 'Join Option',
|
|
385
|
+
},
|
|
386
|
+
{ id: insertedRecord.id }
|
|
387
|
+
);
|
|
388
|
+
expect(updateCount).toBe(1);
|
|
389
|
+
const fetchedRecord = await db.get(table, { id: insertedRecord.id });
|
|
390
|
+
expect(fetchedRecord.name).toBe('Updated Name');
|
|
391
|
+
expect(fetchedRecord.order).toBe('2');
|
|
392
|
+
expect(fetchedRecord.join).toBe('Join Option');
|
|
393
|
+
await db.delete(table, { id: fetchedRecord.id });
|
|
394
|
+
});
|
|
395
|
+
|
|
396
|
+
test('Delete with reserved words', async () => {
|
|
397
|
+
const testRecord: Omit<ReservedWordTest, keyof Record> = { name: 'Test Name', order: '1', select: 'Option 1' };
|
|
398
|
+
const table: Table<ReservedWordTest> = new ReservedWordTestTable();
|
|
399
|
+
const insertedRecord = await db.insert(table, testRecord);
|
|
400
|
+
let fetchedRecord = await db.get(table, { id: insertedRecord.id });
|
|
401
|
+
expect(fetchedRecord).toBeTruthy();
|
|
402
|
+
const deleteCount = await db.delete(table, { id: fetchedRecord.id });
|
|
403
|
+
expect(deleteCount).toBe(1);
|
|
404
|
+
fetchedRecord = await db.get(table, { id: insertedRecord.id });
|
|
405
|
+
expect(fetchedRecord).toBeFalsy();
|
|
406
|
+
});
|
|
407
|
+
|
|
408
|
+
test('Query with reserved words', async () => {
|
|
409
|
+
const testRecord1: Omit<ReservedWordTest, keyof Record> = { name: 'Test Name 1', order: '1', select: 'Option 1' };
|
|
410
|
+
const testRecord2: Omit<ReservedWordTest, keyof Record> = { name: 'Test Name 2', order: '1', select: 'Option 1' };
|
|
411
|
+
const testRecord3: Omit<ReservedWordTest, keyof Record> = { name: 'Test Name 3', order: '2', select: 'Option 2' };
|
|
412
|
+
const table: Table<ReservedWordTest> = new ReservedWordTestTable();
|
|
413
|
+
const insertedRecord1 = await db.insert(table, testRecord1);
|
|
414
|
+
const insertedRecord2 = await db.insert(table, testRecord2);
|
|
415
|
+
const insertedRecord3 = await db.insert(table, testRecord3);
|
|
416
|
+
const fetchedRecords = await db.query(table, { order: '1', select: 'Option 1' });
|
|
417
|
+
expect(fetchedRecords.length).toBe(2);
|
|
418
|
+
expect(fetchedRecords[0].name).toBe('Test Name 1');
|
|
419
|
+
expect(fetchedRecords[1].name).toBe('Test Name 2');
|
|
420
|
+
const qb = new QueryBuilder<ReservedWordTest>(table.name).condition({
|
|
421
|
+
field: 'id',
|
|
422
|
+
operator: 'IN',
|
|
423
|
+
value: [insertedRecord1.id, insertedRecord2.id, insertedRecord3.id],
|
|
424
|
+
});
|
|
425
|
+
await db.delete(table, qb);
|
|
426
|
+
});
|
|
427
|
+
|
|
428
|
+
test('Query with sort and reserved words', async () => {
|
|
429
|
+
const testRecord1: Omit<ReservedWordTest, keyof Record> = { name: 'Test Name 1', order: '1', select: 'Option 1' };
|
|
430
|
+
const testRecord2: Omit<ReservedWordTest, keyof Record> = { name: 'Test Name 2', order: '2', select: 'Option 2' };
|
|
431
|
+
const testRecord3: Omit<ReservedWordTest, keyof Record> = { name: 'Test Name 3', order: '3', select: 'Option 3' };
|
|
432
|
+
const table: Table<ReservedWordTest> = new ReservedWordTestTable();
|
|
433
|
+
|
|
434
|
+
const insertedRecord1 = await db.insert(table, testRecord1);
|
|
435
|
+
const insertedRecord2 = await db.insert(table, testRecord2);
|
|
436
|
+
const insertedRecord3 = await db.insert(table, testRecord3);
|
|
437
|
+
|
|
438
|
+
const sortQuery = new QueryBuilder<ReservedWordTest>(table.name).sort([
|
|
439
|
+
{ field: 'order', byValues: ['1', '2', '3'] },
|
|
440
|
+
]);
|
|
441
|
+
const sortResults = await db.query(table, sortQuery);
|
|
442
|
+
|
|
443
|
+
// Assertions
|
|
444
|
+
expect(sortResults.length).toBe(3);
|
|
445
|
+
expect(sortResults[0].order).toBe('1');
|
|
446
|
+
expect(sortResults[1].order).toBe('2');
|
|
447
|
+
expect(sortResults[2].order).toBe('3');
|
|
448
|
+
|
|
449
|
+
// Clean up
|
|
450
|
+
const qb = new QueryBuilder<ReservedWordTest>(table.name).condition({
|
|
451
|
+
field: 'id',
|
|
452
|
+
operator: 'IN',
|
|
453
|
+
value: [insertedRecord1.id, insertedRecord2.id, insertedRecord3.id],
|
|
454
|
+
});
|
|
455
|
+
await db.delete(table, qb);
|
|
456
|
+
});
|
|
457
|
+
|
|
458
|
+
test('Query with reserved words and subquery', async () => {
|
|
459
|
+
const testRecord1: Omit<ReservedWordTest, keyof Record> = { name: 'Test Name 1', order: '1', select: 'Option 1' };
|
|
460
|
+
const testRecord2: Omit<ReservedWordTest, keyof Record> = { name: 'Test Name 2', order: '2', select: 'Option 2' };
|
|
461
|
+
const table: Table<ReservedWordTest> = new ReservedWordTestTable();
|
|
462
|
+
|
|
463
|
+
const insertedRecord1 = await db.insert(table, testRecord1);
|
|
464
|
+
const insertedRecord2 = await db.insert(table, testRecord2);
|
|
465
|
+
|
|
466
|
+
const subQb = new QueryBuilder<ReservedWordTest>(table.name).select({ fields: ['id'] }).condition({
|
|
467
|
+
field: 'select',
|
|
468
|
+
operator: '=',
|
|
469
|
+
value: 'Option 1',
|
|
470
|
+
});
|
|
471
|
+
|
|
472
|
+
const qb = new QueryBuilder<ReservedWordTest>(table.name).condition({
|
|
473
|
+
field: 'id',
|
|
474
|
+
operator: 'IN',
|
|
475
|
+
value: subQb,
|
|
476
|
+
});
|
|
477
|
+
|
|
478
|
+
// Execute the query
|
|
479
|
+
const results = await db.query(table, qb);
|
|
480
|
+
expect(results.length).toBe(1);
|
|
481
|
+
expect(results[0].name).toBe('Test Name 1');
|
|
482
|
+
|
|
483
|
+
// Clean up
|
|
484
|
+
await db.delete(table, { id: insertedRecord1.id });
|
|
485
|
+
await db.delete(table, { id: insertedRecord2.id });
|
|
486
|
+
}, 10000);
|
|
341
487
|
};
|
|
342
488
|
};
|
|
@@ -20,7 +20,7 @@ interface User extends Record {
|
|
|
20
20
|
active: boolean;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
class
|
|
23
|
+
class UserTestTable extends Table<User> {
|
|
24
24
|
name = 'db_test_user';
|
|
25
25
|
columns = withRecordColumns<User>({
|
|
26
26
|
name: new StringColumn('name'),
|
|
@@ -87,7 +87,7 @@ export const tableManagerTests = (
|
|
|
87
87
|
|
|
88
88
|
afterEach(async () => {
|
|
89
89
|
await dropTable(new ColumnTypesTable());
|
|
90
|
-
await dropTable(new
|
|
90
|
+
await dropTable(new UserTestTable());
|
|
91
91
|
});
|
|
92
92
|
|
|
93
93
|
afterAll(async () => {
|
|
@@ -97,7 +97,7 @@ export const tableManagerTests = (
|
|
|
97
97
|
});
|
|
98
98
|
|
|
99
99
|
test('create primary key', async () => {
|
|
100
|
-
const userTable = new
|
|
100
|
+
const userTable = new UserTestTable();
|
|
101
101
|
await tableManager.loadTable(userTable);
|
|
102
102
|
expect(await tableManager.tableExists(userTable)).toBeTruthy();
|
|
103
103
|
const primaryKey = await tableManager.schemaMetadata.getPrimaryKey(userTable);
|
|
@@ -106,7 +106,7 @@ export const tableManagerTests = (
|
|
|
106
106
|
});
|
|
107
107
|
|
|
108
108
|
test('create columns', async () => {
|
|
109
|
-
const userTable = new
|
|
109
|
+
const userTable = new UserTestTable();
|
|
110
110
|
await tableManager.loadTable(userTable);
|
|
111
111
|
expect(await tableManager.tableExists(userTable)).toBeTruthy();
|
|
112
112
|
expect(await tableManager.schemaMetadata.columnExists(userTable.columns.name.name, userTable)).toBeTruthy();
|
|
@@ -115,7 +115,7 @@ export const tableManagerTests = (
|
|
|
115
115
|
});
|
|
116
116
|
|
|
117
117
|
test('add column via alter', async () => {
|
|
118
|
-
const userTable = new
|
|
118
|
+
const userTable = new UserTestTable();
|
|
119
119
|
const dataColumn = new ObjectColumn('data');
|
|
120
120
|
await tableManager.loadTable(userTable);
|
|
121
121
|
expect(await tableManager.tableExists(userTable)).toBeTruthy();
|
|
@@ -133,7 +133,7 @@ export const tableManagerTests = (
|
|
|
133
133
|
});
|
|
134
134
|
|
|
135
135
|
test('columns created with correct types', async () => {
|
|
136
|
-
const userTable = new
|
|
136
|
+
const userTable = new UserTestTable();
|
|
137
137
|
const columnTypesTable = new ColumnTypesTable();
|
|
138
138
|
await tableManager.loadTable(userTable);
|
|
139
139
|
await tableManager.loadTable(columnTypesTable);
|
|
@@ -178,7 +178,7 @@ export const tableManagerTests = (
|
|
|
178
178
|
});
|
|
179
179
|
|
|
180
180
|
test('columns created with correct options', async () => {
|
|
181
|
-
const userTable = new
|
|
181
|
+
const userTable = new UserTestTable();
|
|
182
182
|
const columnTypesTable = new ColumnTypesTable();
|
|
183
183
|
await tableManager.loadTable(userTable);
|
|
184
184
|
await tableManager.loadTable(columnTypesTable);
|
|
@@ -203,7 +203,7 @@ export const tableManagerTests = (
|
|
|
203
203
|
return;
|
|
204
204
|
}
|
|
205
205
|
|
|
206
|
-
const userTable = new
|
|
206
|
+
const userTable = new UserTestTable();
|
|
207
207
|
await tableManager.loadTable(userTable);
|
|
208
208
|
expect(await tableManager.tableExists(userTable)).toBeTruthy();
|
|
209
209
|
expect(await tableManager.schemaMetadata.columnExists(userTable.columns.name.name, userTable)).toBeTruthy();
|
|
@@ -219,7 +219,7 @@ export const tableManagerTests = (
|
|
|
219
219
|
return;
|
|
220
220
|
}
|
|
221
221
|
|
|
222
|
-
const userTable = new
|
|
222
|
+
const userTable = new UserTestTable();
|
|
223
223
|
const columnTypesTable = new ColumnTypesTable();
|
|
224
224
|
await tableManager.loadTable(userTable);
|
|
225
225
|
await tableManager.loadTable(columnTypesTable);
|
|
@@ -287,7 +287,7 @@ export const tableManagerTests = (
|
|
|
287
287
|
});
|
|
288
288
|
|
|
289
289
|
test('alter unique constraint', async () => {
|
|
290
|
-
const userTable = new
|
|
290
|
+
const userTable = new UserTestTable();
|
|
291
291
|
const columnTypesTable = new ColumnTypesTable();
|
|
292
292
|
await tableManager.loadTable(userTable);
|
|
293
293
|
columnTypesTable.columns.text.options = { defaultValue: async () => 'asdf' };
|
|
@@ -409,7 +409,7 @@ export const tableManagerTests = (
|
|
|
409
409
|
return;
|
|
410
410
|
}
|
|
411
411
|
|
|
412
|
-
const userTable = new
|
|
412
|
+
const userTable = new UserTestTable();
|
|
413
413
|
const columnTypesTable = new ColumnTypesTable();
|
|
414
414
|
await tableManager.loadTable(userTable);
|
|
415
415
|
columnTypesTable.columns.text.options = { defaultValue: async () => 'asdf' };
|
|
@@ -528,7 +528,7 @@ export const tableManagerTests = (
|
|
|
528
528
|
});
|
|
529
529
|
|
|
530
530
|
test('create index', async () => {
|
|
531
|
-
const userTable = new
|
|
531
|
+
const userTable = new UserTestTable();
|
|
532
532
|
await tableManager.loadTable(userTable);
|
|
533
533
|
expect(await tableManager.tableExists(userTable)).toBeTruthy();
|
|
534
534
|
const indexes = await tableManager.schemaMetadata.getIndexes(userTable);
|
|
@@ -537,7 +537,7 @@ export const tableManagerTests = (
|
|
|
537
537
|
});
|
|
538
538
|
|
|
539
539
|
test('alter index', async () => {
|
|
540
|
-
const userTable = new
|
|
540
|
+
const userTable = new UserTestTable();
|
|
541
541
|
await tableManager.loadTable(userTable);
|
|
542
542
|
expect(await tableManager.tableExists(userTable)).toBeTruthy();
|
|
543
543
|
let indexes = await tableManager.schemaMetadata.getIndexes(userTable);
|