1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 | Object.defineProperty(exports, "__esModule", { value: true });
|
11 | exports.SqliteDialect = void 0;
|
12 | class SqliteDialect {
|
13 | constructor(client) {
|
14 | Object.defineProperty(this, "client", {
|
15 | enumerable: true,
|
16 | configurable: true,
|
17 | writable: true,
|
18 | value: client
|
19 | });
|
20 | Object.defineProperty(this, "name", {
|
21 | enumerable: true,
|
22 | configurable: true,
|
23 | writable: true,
|
24 | value: 'sqlite3'
|
25 | });
|
26 | Object.defineProperty(this, "supportsAdvisoryLocks", {
|
27 | enumerable: true,
|
28 | configurable: true,
|
29 | writable: true,
|
30 | value: false
|
31 | });
|
32 | |
33 |
|
34 |
|
35 |
|
36 | Object.defineProperty(this, "version", {
|
37 | enumerable: true,
|
38 | configurable: true,
|
39 | writable: true,
|
40 | value: this.client.getReadClient()['context']['client'].version
|
41 | });
|
42 | |
43 |
|
44 |
|
45 |
|
46 | Object.defineProperty(this, "dateTimeFormat", {
|
47 | enumerable: true,
|
48 | configurable: true,
|
49 | writable: true,
|
50 | value: 'yyyy-MM-dd HH:mm:ss'
|
51 | });
|
52 | }
|
53 | |
54 |
|
55 |
|
56 | async getAllTables() {
|
57 | const tables = await this.client
|
58 | .query()
|
59 | .from('sqlite_master')
|
60 | .select('name as table_name')
|
61 | .where('type', 'table')
|
62 | .whereNot('name', 'like', 'sqlite_%')
|
63 | .orderBy('name', 'asc');
|
64 | return tables.map(({ table_name }) => table_name);
|
65 | }
|
66 | |
67 |
|
68 |
|
69 | async truncate(table, _) {
|
70 | return this.client.knexQuery().table(table).truncate();
|
71 | }
|
72 | |
73 |
|
74 |
|
75 | async dropAllTables() {
|
76 | await this.client.rawQuery('PRAGMA writable_schema = 1;');
|
77 | await this.client.rawQuery(`delete from sqlite_master where type in ('table', 'index', 'trigger');`);
|
78 | await this.client.rawQuery('PRAGMA writable_schema = 0;');
|
79 | await this.client.rawQuery('VACUUM;');
|
80 | }
|
81 | |
82 |
|
83 |
|
84 |
|
85 | getAdvisoryLock() {
|
86 | throw new Error("Sqlite doesn't support advisory locks");
|
87 | }
|
88 | |
89 |
|
90 |
|
91 | releaseAdvisoryLock() {
|
92 | throw new Error("Sqlite doesn't support advisory locks");
|
93 | }
|
94 | }
|
95 | exports.SqliteDialect = SqliteDialect;
|