knex 0.21.20 → 0.21.21
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 +6 -0
- package/CONTRIBUTING.md +184 -184
- package/LICENSE +22 -22
- package/README.md +95 -95
- package/bin/cli.js +414 -414
- package/bin/utils/cli-config-utils.js +151 -151
- package/bin/utils/constants.js +7 -7
- package/bin/utils/migrationsLister.js +37 -37
- package/knex.js +8 -8
- package/lib/client.js +413 -413
- package/lib/config-resolver.js +61 -61
- package/lib/constants.js +44 -44
- package/lib/dialects/mssql/index.js +390 -390
- package/lib/dialects/mssql/query/compiler.js +444 -444
- package/lib/dialects/mssql/schema/columncompiler.js +103 -103
- package/lib/dialects/mssql/schema/compiler.js +59 -59
- package/lib/dialects/mssql/schema/tablecompiler.js +245 -245
- package/lib/dialects/mssql/transaction.js +97 -97
- package/lib/dialects/mysql/index.js +191 -191
- package/lib/dialects/mysql/query/compiler.js +142 -142
- package/lib/dialects/mysql/schema/columncompiler.js +171 -171
- package/lib/dialects/mysql/schema/compiler.js +60 -60
- package/lib/dialects/mysql/schema/tablecompiler.js +262 -262
- package/lib/dialects/mysql/transaction.js +48 -48
- package/lib/dialects/mysql2/index.js +35 -35
- package/lib/dialects/mysql2/transaction.js +46 -46
- package/lib/dialects/oracle/DEAD_CODE.md +5 -5
- package/lib/dialects/oracle/formatter.js +20 -20
- package/lib/dialects/oracle/index.js +79 -79
- package/lib/dialects/oracle/query/compiler.js +327 -327
- package/lib/dialects/oracle/schema/columnbuilder.js +18 -18
- package/lib/dialects/oracle/schema/columncompiler.js +139 -139
- package/lib/dialects/oracle/schema/compiler.js +81 -81
- package/lib/dialects/oracle/schema/tablecompiler.js +165 -165
- package/lib/dialects/oracle/schema/trigger.js +126 -126
- package/lib/dialects/oracle/utils.js +86 -86
- package/lib/dialects/oracledb/index.js +489 -489
- package/lib/dialects/oracledb/query/compiler.js +363 -363
- package/lib/dialects/oracledb/schema/columncompiler.js +35 -35
- package/lib/dialects/oracledb/transaction.js +76 -76
- package/lib/dialects/oracledb/utils.js +14 -14
- package/lib/dialects/postgres/index.js +319 -319
- package/lib/dialects/postgres/query/compiler.js +206 -206
- package/lib/dialects/postgres/schema/columncompiler.js +125 -125
- package/lib/dialects/postgres/schema/compiler.js +109 -109
- package/lib/dialects/postgres/schema/tablecompiler.js +183 -183
- package/lib/dialects/redshift/index.js +73 -73
- package/lib/dialects/redshift/query/compiler.js +119 -119
- package/lib/dialects/redshift/schema/columnbuilder.js +20 -20
- package/lib/dialects/redshift/schema/columncompiler.js +60 -60
- package/lib/dialects/redshift/schema/compiler.js +14 -14
- package/lib/dialects/redshift/schema/tablecompiler.js +123 -123
- package/lib/dialects/redshift/transaction.js +18 -18
- package/lib/dialects/sqlite3/formatter.js +21 -21
- package/lib/dialects/sqlite3/index.js +169 -169
- package/lib/dialects/sqlite3/query/compiler.js +222 -222
- package/lib/dialects/sqlite3/schema/columncompiler.js +27 -27
- package/lib/dialects/sqlite3/schema/compiler.js +49 -49
- package/lib/dialects/sqlite3/schema/ddl.js +525 -525
- package/lib/dialects/sqlite3/schema/tablecompiler.js +238 -238
- package/lib/formatter.js +295 -295
- package/lib/functionhelper.js +14 -14
- package/lib/helpers.js +92 -92
- package/lib/index.js +3 -3
- package/lib/interface.js +115 -115
- package/lib/knex.js +42 -42
- package/lib/logger.js +76 -76
- package/lib/migrate/MigrationGenerator.js +82 -82
- package/lib/migrate/Migrator.js +611 -611
- package/lib/migrate/configuration-merger.js +60 -60
- package/lib/migrate/migrate-stub.js +17 -17
- package/lib/migrate/migration-list-resolver.js +36 -36
- package/lib/migrate/sources/fs-migrations.js +99 -99
- package/lib/migrate/stub/cjs.stub +15 -15
- package/lib/migrate/stub/coffee.stub +13 -13
- package/lib/migrate/stub/eg.stub +14 -14
- package/lib/migrate/stub/js.stub +15 -15
- package/lib/migrate/stub/knexfile-coffee.stub +34 -34
- package/lib/migrate/stub/knexfile-eg.stub +43 -43
- package/lib/migrate/stub/knexfile-js.stub +44 -44
- package/lib/migrate/stub/knexfile-ls.stub +35 -35
- package/lib/migrate/stub/knexfile-ts.stub +44 -44
- package/lib/migrate/stub/ls.stub +14 -14
- package/lib/migrate/stub/ts.stub +21 -21
- package/lib/migrate/table-creator.js +67 -67
- package/lib/migrate/table-resolver.js +27 -27
- package/lib/query/builder.js +1372 -1372
- package/lib/query/compiler.js +889 -889
- package/lib/query/constants.js +13 -13
- package/lib/query/joinclause.js +263 -263
- package/lib/query/methods.js +92 -92
- package/lib/query/string.js +190 -190
- package/lib/raw.js +188 -188
- package/lib/ref.js +39 -39
- package/lib/runner.js +285 -285
- package/lib/schema/builder.js +82 -82
- package/lib/schema/columnbuilder.js +117 -117
- package/lib/schema/columncompiler.js +177 -177
- package/lib/schema/compiler.js +101 -101
- package/lib/schema/helpers.js +51 -51
- package/lib/schema/tablebuilder.js +288 -288
- package/lib/schema/tablecompiler.js +296 -296
- package/lib/seed/Seeder.js +203 -203
- package/lib/seed/seed-stub.js +13 -13
- package/lib/seed/stub/coffee.stub +9 -9
- package/lib/seed/stub/eg.stub +11 -11
- package/lib/seed/stub/js.stub +13 -13
- package/lib/seed/stub/ls.stub +11 -11
- package/lib/seed/stub/ts.stub +13 -13
- package/lib/transaction.js +363 -363
- package/lib/util/batchInsert.js +59 -59
- package/lib/util/delay.js +6 -6
- package/lib/util/fake-client.js +9 -9
- package/lib/util/finally-mixin.js +13 -13
- package/lib/util/fs.js +76 -76
- package/lib/util/import-file.js +13 -13
- package/lib/util/is-module-type.js +14 -14
- package/lib/util/is.js +32 -32
- package/lib/util/make-knex.js +338 -338
- package/lib/util/nanoid.js +29 -29
- package/lib/util/noop.js +1 -1
- package/lib/util/parse-connection.js +66 -66
- package/lib/util/save-async-stack.js +14 -14
- package/lib/util/template.js +52 -52
- package/lib/util/timeout.js +29 -29
- package/lib/util/timestamp.js +16 -16
- package/package.json +1 -1
- package/scripts/build.js +125 -125
- package/scripts/docker-compose.yml +111 -111
- package/scripts/next-release-howto.md +24 -24
- package/scripts/release.sh +34 -34
- package/scripts/runkit-example.js +34 -34
- package/scripts/stress-test/README.txt +18 -18
- package/scripts/stress-test/docker-compose.yml +47 -47
- package/scripts/stress-test/knex-stress-test.js +196 -196
- package/scripts/stress-test/mysql2-random-hanging-every-now-and-then.js +145 -145
- package/scripts/stress-test/mysql2-sudden-exit-without-error.js +100 -100
- package/scripts/stress-test/reconnect-test-mysql-based-drivers.js +184 -184
- package/types/index.d.ts +2249 -2249
- package/types/result.d.ts +27 -27
- package/types/tables.d.ts +4 -4
|
@@ -1,73 +1,73 @@
|
|
|
1
|
-
// Redshift
|
|
2
|
-
// -------
|
|
3
|
-
const { inherits } = require('util');
|
|
4
|
-
const Client_PG = require('../postgres');
|
|
5
|
-
const map = require('lodash/map');
|
|
6
|
-
|
|
7
|
-
const Transaction = require('./transaction');
|
|
8
|
-
const QueryCompiler = require('./query/compiler');
|
|
9
|
-
const ColumnBuilder = require('./schema/columnbuilder');
|
|
10
|
-
const ColumnCompiler = require('./schema/columncompiler');
|
|
11
|
-
const TableCompiler = require('./schema/tablecompiler');
|
|
12
|
-
const SchemaCompiler = require('./schema/compiler');
|
|
13
|
-
|
|
14
|
-
function Client_Redshift(config) {
|
|
15
|
-
Client_PG.apply(this, arguments);
|
|
16
|
-
}
|
|
17
|
-
inherits(Client_Redshift, Client_PG);
|
|
18
|
-
|
|
19
|
-
Object.assign(Client_Redshift.prototype, {
|
|
20
|
-
transaction() {
|
|
21
|
-
return new Transaction(this, ...arguments);
|
|
22
|
-
},
|
|
23
|
-
|
|
24
|
-
queryCompiler() {
|
|
25
|
-
return new QueryCompiler(this, ...arguments);
|
|
26
|
-
},
|
|
27
|
-
|
|
28
|
-
columnBuilder() {
|
|
29
|
-
return new ColumnBuilder(this, ...arguments);
|
|
30
|
-
},
|
|
31
|
-
|
|
32
|
-
columnCompiler() {
|
|
33
|
-
return new ColumnCompiler(this, ...arguments);
|
|
34
|
-
},
|
|
35
|
-
|
|
36
|
-
tableCompiler() {
|
|
37
|
-
return new TableCompiler(this, ...arguments);
|
|
38
|
-
},
|
|
39
|
-
|
|
40
|
-
schemaCompiler() {
|
|
41
|
-
return new SchemaCompiler(this, ...arguments);
|
|
42
|
-
},
|
|
43
|
-
|
|
44
|
-
dialect: 'redshift',
|
|
45
|
-
|
|
46
|
-
driverName: 'pg-redshift',
|
|
47
|
-
|
|
48
|
-
_driver() {
|
|
49
|
-
return require('pg');
|
|
50
|
-
},
|
|
51
|
-
|
|
52
|
-
// Ensures the response is returned in the same format as other clients.
|
|
53
|
-
processResponse(obj, runner) {
|
|
54
|
-
const resp = obj.response;
|
|
55
|
-
if (obj.output) return obj.output.call(runner, resp);
|
|
56
|
-
if (obj.method === 'raw') return resp;
|
|
57
|
-
if (resp.command === 'SELECT') {
|
|
58
|
-
if (obj.method === 'first') return resp.rows[0];
|
|
59
|
-
if (obj.method === 'pluck') return map(resp.rows, obj.pluck);
|
|
60
|
-
return resp.rows;
|
|
61
|
-
}
|
|
62
|
-
if (
|
|
63
|
-
resp.command === 'INSERT' ||
|
|
64
|
-
resp.command === 'UPDATE' ||
|
|
65
|
-
resp.command === 'DELETE'
|
|
66
|
-
) {
|
|
67
|
-
return resp.rowCount;
|
|
68
|
-
}
|
|
69
|
-
return resp;
|
|
70
|
-
},
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
module.exports = Client_Redshift;
|
|
1
|
+
// Redshift
|
|
2
|
+
// -------
|
|
3
|
+
const { inherits } = require('util');
|
|
4
|
+
const Client_PG = require('../postgres');
|
|
5
|
+
const map = require('lodash/map');
|
|
6
|
+
|
|
7
|
+
const Transaction = require('./transaction');
|
|
8
|
+
const QueryCompiler = require('./query/compiler');
|
|
9
|
+
const ColumnBuilder = require('./schema/columnbuilder');
|
|
10
|
+
const ColumnCompiler = require('./schema/columncompiler');
|
|
11
|
+
const TableCompiler = require('./schema/tablecompiler');
|
|
12
|
+
const SchemaCompiler = require('./schema/compiler');
|
|
13
|
+
|
|
14
|
+
function Client_Redshift(config) {
|
|
15
|
+
Client_PG.apply(this, arguments);
|
|
16
|
+
}
|
|
17
|
+
inherits(Client_Redshift, Client_PG);
|
|
18
|
+
|
|
19
|
+
Object.assign(Client_Redshift.prototype, {
|
|
20
|
+
transaction() {
|
|
21
|
+
return new Transaction(this, ...arguments);
|
|
22
|
+
},
|
|
23
|
+
|
|
24
|
+
queryCompiler() {
|
|
25
|
+
return new QueryCompiler(this, ...arguments);
|
|
26
|
+
},
|
|
27
|
+
|
|
28
|
+
columnBuilder() {
|
|
29
|
+
return new ColumnBuilder(this, ...arguments);
|
|
30
|
+
},
|
|
31
|
+
|
|
32
|
+
columnCompiler() {
|
|
33
|
+
return new ColumnCompiler(this, ...arguments);
|
|
34
|
+
},
|
|
35
|
+
|
|
36
|
+
tableCompiler() {
|
|
37
|
+
return new TableCompiler(this, ...arguments);
|
|
38
|
+
},
|
|
39
|
+
|
|
40
|
+
schemaCompiler() {
|
|
41
|
+
return new SchemaCompiler(this, ...arguments);
|
|
42
|
+
},
|
|
43
|
+
|
|
44
|
+
dialect: 'redshift',
|
|
45
|
+
|
|
46
|
+
driverName: 'pg-redshift',
|
|
47
|
+
|
|
48
|
+
_driver() {
|
|
49
|
+
return require('pg');
|
|
50
|
+
},
|
|
51
|
+
|
|
52
|
+
// Ensures the response is returned in the same format as other clients.
|
|
53
|
+
processResponse(obj, runner) {
|
|
54
|
+
const resp = obj.response;
|
|
55
|
+
if (obj.output) return obj.output.call(runner, resp);
|
|
56
|
+
if (obj.method === 'raw') return resp;
|
|
57
|
+
if (resp.command === 'SELECT') {
|
|
58
|
+
if (obj.method === 'first') return resp.rows[0];
|
|
59
|
+
if (obj.method === 'pluck') return map(resp.rows, obj.pluck);
|
|
60
|
+
return resp.rows;
|
|
61
|
+
}
|
|
62
|
+
if (
|
|
63
|
+
resp.command === 'INSERT' ||
|
|
64
|
+
resp.command === 'UPDATE' ||
|
|
65
|
+
resp.command === 'DELETE'
|
|
66
|
+
) {
|
|
67
|
+
return resp.rowCount;
|
|
68
|
+
}
|
|
69
|
+
return resp;
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
module.exports = Client_Redshift;
|
|
@@ -1,119 +1,119 @@
|
|
|
1
|
-
// Redshift Query Builder & Compiler
|
|
2
|
-
// ------
|
|
3
|
-
const QueryCompiler = require('../../../query/compiler');
|
|
4
|
-
const QueryCompiler_PG = require('../../postgres/query/compiler');
|
|
5
|
-
|
|
6
|
-
const identity = require('lodash/identity');
|
|
7
|
-
const reduce = require('lodash/reduce');
|
|
8
|
-
|
|
9
|
-
class QueryCompiler_Redshift extends QueryCompiler_PG {
|
|
10
|
-
constructor(client, builder) {
|
|
11
|
-
super(client, builder);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
truncate() {
|
|
15
|
-
return `truncate ${this.tableName.toLowerCase()}`;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
// Compiles an `insert` query, allowing for multiple
|
|
19
|
-
// inserts using a single query statement.
|
|
20
|
-
insert() {
|
|
21
|
-
const sql = QueryCompiler.prototype.insert.apply(this, arguments);
|
|
22
|
-
if (sql === '') return sql;
|
|
23
|
-
this._slightReturn();
|
|
24
|
-
return {
|
|
25
|
-
sql,
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
// Compiles an `update` query, warning on unsupported returning
|
|
30
|
-
update() {
|
|
31
|
-
const sql = QueryCompiler.prototype.update.apply(this, arguments);
|
|
32
|
-
this._slightReturn();
|
|
33
|
-
return {
|
|
34
|
-
sql,
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// Compiles an `delete` query, warning on unsupported returning
|
|
39
|
-
del() {
|
|
40
|
-
const sql = QueryCompiler.prototype.del.apply(this, arguments);
|
|
41
|
-
this._slightReturn();
|
|
42
|
-
return {
|
|
43
|
-
sql,
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// simple: if trying to return, warn
|
|
48
|
-
_slightReturn() {
|
|
49
|
-
if (this.single.isReturning) {
|
|
50
|
-
this.client.logger.warn(
|
|
51
|
-
'insert/update/delete returning is not supported by redshift dialect'
|
|
52
|
-
);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
forUpdate() {
|
|
57
|
-
this.client.logger.warn('table lock is not supported by redshift dialect');
|
|
58
|
-
return '';
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
forShare() {
|
|
62
|
-
this.client.logger.warn(
|
|
63
|
-
'lock for share is not supported by redshift dialect'
|
|
64
|
-
);
|
|
65
|
-
return '';
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
// Compiles a columnInfo query
|
|
69
|
-
columnInfo() {
|
|
70
|
-
const column = this.single.columnInfo;
|
|
71
|
-
let schema = this.single.schema;
|
|
72
|
-
|
|
73
|
-
// The user may have specified a custom wrapIdentifier function in the config. We
|
|
74
|
-
// need to run the identifiers through that function, but not format them as
|
|
75
|
-
// identifiers otherwise.
|
|
76
|
-
const table = this.client.customWrapIdentifier(this.single.table, identity);
|
|
77
|
-
|
|
78
|
-
if (schema) {
|
|
79
|
-
schema = this.client.customWrapIdentifier(schema, identity);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
let sql =
|
|
83
|
-
'select * from information_schema.columns where table_name = ? and table_catalog = ?';
|
|
84
|
-
const bindings = [
|
|
85
|
-
table.toLowerCase(),
|
|
86
|
-
this.client.database().toLowerCase(),
|
|
87
|
-
];
|
|
88
|
-
|
|
89
|
-
if (schema) {
|
|
90
|
-
sql += ' and table_schema = ?';
|
|
91
|
-
bindings.push(schema);
|
|
92
|
-
} else {
|
|
93
|
-
sql += ' and table_schema = current_schema()';
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
return {
|
|
97
|
-
sql,
|
|
98
|
-
bindings,
|
|
99
|
-
output(resp) {
|
|
100
|
-
const out = reduce(
|
|
101
|
-
resp.rows,
|
|
102
|
-
function (columns, val) {
|
|
103
|
-
columns[val.column_name] = {
|
|
104
|
-
type: val.data_type,
|
|
105
|
-
maxLength: val.character_maximum_length,
|
|
106
|
-
nullable: val.is_nullable === 'YES',
|
|
107
|
-
defaultValue: val.column_default,
|
|
108
|
-
};
|
|
109
|
-
return columns;
|
|
110
|
-
},
|
|
111
|
-
{}
|
|
112
|
-
);
|
|
113
|
-
return (column && out[column]) || out;
|
|
114
|
-
},
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
module.exports = QueryCompiler_Redshift;
|
|
1
|
+
// Redshift Query Builder & Compiler
|
|
2
|
+
// ------
|
|
3
|
+
const QueryCompiler = require('../../../query/compiler');
|
|
4
|
+
const QueryCompiler_PG = require('../../postgres/query/compiler');
|
|
5
|
+
|
|
6
|
+
const identity = require('lodash/identity');
|
|
7
|
+
const reduce = require('lodash/reduce');
|
|
8
|
+
|
|
9
|
+
class QueryCompiler_Redshift extends QueryCompiler_PG {
|
|
10
|
+
constructor(client, builder) {
|
|
11
|
+
super(client, builder);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
truncate() {
|
|
15
|
+
return `truncate ${this.tableName.toLowerCase()}`;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// Compiles an `insert` query, allowing for multiple
|
|
19
|
+
// inserts using a single query statement.
|
|
20
|
+
insert() {
|
|
21
|
+
const sql = QueryCompiler.prototype.insert.apply(this, arguments);
|
|
22
|
+
if (sql === '') return sql;
|
|
23
|
+
this._slightReturn();
|
|
24
|
+
return {
|
|
25
|
+
sql,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Compiles an `update` query, warning on unsupported returning
|
|
30
|
+
update() {
|
|
31
|
+
const sql = QueryCompiler.prototype.update.apply(this, arguments);
|
|
32
|
+
this._slightReturn();
|
|
33
|
+
return {
|
|
34
|
+
sql,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Compiles an `delete` query, warning on unsupported returning
|
|
39
|
+
del() {
|
|
40
|
+
const sql = QueryCompiler.prototype.del.apply(this, arguments);
|
|
41
|
+
this._slightReturn();
|
|
42
|
+
return {
|
|
43
|
+
sql,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// simple: if trying to return, warn
|
|
48
|
+
_slightReturn() {
|
|
49
|
+
if (this.single.isReturning) {
|
|
50
|
+
this.client.logger.warn(
|
|
51
|
+
'insert/update/delete returning is not supported by redshift dialect'
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
forUpdate() {
|
|
57
|
+
this.client.logger.warn('table lock is not supported by redshift dialect');
|
|
58
|
+
return '';
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
forShare() {
|
|
62
|
+
this.client.logger.warn(
|
|
63
|
+
'lock for share is not supported by redshift dialect'
|
|
64
|
+
);
|
|
65
|
+
return '';
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Compiles a columnInfo query
|
|
69
|
+
columnInfo() {
|
|
70
|
+
const column = this.single.columnInfo;
|
|
71
|
+
let schema = this.single.schema;
|
|
72
|
+
|
|
73
|
+
// The user may have specified a custom wrapIdentifier function in the config. We
|
|
74
|
+
// need to run the identifiers through that function, but not format them as
|
|
75
|
+
// identifiers otherwise.
|
|
76
|
+
const table = this.client.customWrapIdentifier(this.single.table, identity);
|
|
77
|
+
|
|
78
|
+
if (schema) {
|
|
79
|
+
schema = this.client.customWrapIdentifier(schema, identity);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
let sql =
|
|
83
|
+
'select * from information_schema.columns where table_name = ? and table_catalog = ?';
|
|
84
|
+
const bindings = [
|
|
85
|
+
table.toLowerCase(),
|
|
86
|
+
this.client.database().toLowerCase(),
|
|
87
|
+
];
|
|
88
|
+
|
|
89
|
+
if (schema) {
|
|
90
|
+
sql += ' and table_schema = ?';
|
|
91
|
+
bindings.push(schema);
|
|
92
|
+
} else {
|
|
93
|
+
sql += ' and table_schema = current_schema()';
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return {
|
|
97
|
+
sql,
|
|
98
|
+
bindings,
|
|
99
|
+
output(resp) {
|
|
100
|
+
const out = reduce(
|
|
101
|
+
resp.rows,
|
|
102
|
+
function (columns, val) {
|
|
103
|
+
columns[val.column_name] = {
|
|
104
|
+
type: val.data_type,
|
|
105
|
+
maxLength: val.character_maximum_length,
|
|
106
|
+
nullable: val.is_nullable === 'YES',
|
|
107
|
+
defaultValue: val.column_default,
|
|
108
|
+
};
|
|
109
|
+
return columns;
|
|
110
|
+
},
|
|
111
|
+
{}
|
|
112
|
+
);
|
|
113
|
+
return (column && out[column]) || out;
|
|
114
|
+
},
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
module.exports = QueryCompiler_Redshift;
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
const { inherits } = require('util');
|
|
2
|
-
const ColumnBuilder = require('../../../schema/columnbuilder');
|
|
3
|
-
|
|
4
|
-
function ColumnBuilder_Redshift() {
|
|
5
|
-
ColumnBuilder.apply(this, arguments);
|
|
6
|
-
}
|
|
7
|
-
inherits(ColumnBuilder_Redshift, ColumnBuilder);
|
|
8
|
-
|
|
9
|
-
// primary needs to set not null on non-preexisting columns, or fail
|
|
10
|
-
ColumnBuilder_Redshift.prototype.primary = function () {
|
|
11
|
-
this.notNullable();
|
|
12
|
-
return ColumnBuilder.prototype.primary.apply(this, arguments);
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
ColumnBuilder_Redshift.prototype.index = function () {
|
|
16
|
-
this.client.logger.warn('Redshift does not support the creation of indexes.');
|
|
17
|
-
return this;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
module.exports = ColumnBuilder_Redshift;
|
|
1
|
+
const { inherits } = require('util');
|
|
2
|
+
const ColumnBuilder = require('../../../schema/columnbuilder');
|
|
3
|
+
|
|
4
|
+
function ColumnBuilder_Redshift() {
|
|
5
|
+
ColumnBuilder.apply(this, arguments);
|
|
6
|
+
}
|
|
7
|
+
inherits(ColumnBuilder_Redshift, ColumnBuilder);
|
|
8
|
+
|
|
9
|
+
// primary needs to set not null on non-preexisting columns, or fail
|
|
10
|
+
ColumnBuilder_Redshift.prototype.primary = function () {
|
|
11
|
+
this.notNullable();
|
|
12
|
+
return ColumnBuilder.prototype.primary.apply(this, arguments);
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
ColumnBuilder_Redshift.prototype.index = function () {
|
|
16
|
+
this.client.logger.warn('Redshift does not support the creation of indexes.');
|
|
17
|
+
return this;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
module.exports = ColumnBuilder_Redshift;
|
|
@@ -1,60 +1,60 @@
|
|
|
1
|
-
// Redshift Column Compiler
|
|
2
|
-
// -------
|
|
3
|
-
|
|
4
|
-
const { inherits } = require('util');
|
|
5
|
-
const ColumnCompiler_PG = require('../../postgres/schema/columncompiler');
|
|
6
|
-
|
|
7
|
-
function ColumnCompiler_Redshift() {
|
|
8
|
-
ColumnCompiler_PG.apply(this, arguments);
|
|
9
|
-
}
|
|
10
|
-
inherits(ColumnCompiler_Redshift, ColumnCompiler_PG);
|
|
11
|
-
|
|
12
|
-
Object.assign(ColumnCompiler_Redshift.prototype, {
|
|
13
|
-
// Types:
|
|
14
|
-
// ------
|
|
15
|
-
bigincrements: 'bigint identity(1,1) primary key not null',
|
|
16
|
-
binary: 'varchar(max)',
|
|
17
|
-
bit(column) {
|
|
18
|
-
return column.length !== false ? `char(${column.length})` : 'char(1)';
|
|
19
|
-
},
|
|
20
|
-
blob: 'varchar(max)',
|
|
21
|
-
enu: 'varchar(255)',
|
|
22
|
-
enum: 'varchar(255)',
|
|
23
|
-
increments: 'integer identity(1,1) primary key not null',
|
|
24
|
-
json: 'varchar(max)',
|
|
25
|
-
jsonb: 'varchar(max)',
|
|
26
|
-
longblob: 'varchar(max)',
|
|
27
|
-
mediumblob: 'varchar(16777218)',
|
|
28
|
-
set: 'text',
|
|
29
|
-
text: 'varchar(max)',
|
|
30
|
-
datetime(without) {
|
|
31
|
-
return without ? 'timestamp' : 'timestamptz';
|
|
32
|
-
},
|
|
33
|
-
timestamp(without) {
|
|
34
|
-
return without ? 'timestamp' : 'timestamptz';
|
|
35
|
-
},
|
|
36
|
-
tinyblob: 'varchar(256)',
|
|
37
|
-
uuid: 'char(36)',
|
|
38
|
-
varbinary: 'varchar(max)',
|
|
39
|
-
bigint: 'bigint',
|
|
40
|
-
bool: 'boolean',
|
|
41
|
-
double: 'double precision',
|
|
42
|
-
floating: 'real',
|
|
43
|
-
smallint: 'smallint',
|
|
44
|
-
tinyint: 'smallint',
|
|
45
|
-
|
|
46
|
-
// Modifiers:
|
|
47
|
-
// ------
|
|
48
|
-
comment(comment) {
|
|
49
|
-
this.pushAdditional(function () {
|
|
50
|
-
this.pushQuery(
|
|
51
|
-
`comment on column ${this.tableCompiler.tableName()}.` +
|
|
52
|
-
this.formatter.wrap(this.args[0]) +
|
|
53
|
-
' is ' +
|
|
54
|
-
(comment ? `'${comment}'` : 'NULL')
|
|
55
|
-
);
|
|
56
|
-
}, comment);
|
|
57
|
-
},
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
module.exports = ColumnCompiler_Redshift;
|
|
1
|
+
// Redshift Column Compiler
|
|
2
|
+
// -------
|
|
3
|
+
|
|
4
|
+
const { inherits } = require('util');
|
|
5
|
+
const ColumnCompiler_PG = require('../../postgres/schema/columncompiler');
|
|
6
|
+
|
|
7
|
+
function ColumnCompiler_Redshift() {
|
|
8
|
+
ColumnCompiler_PG.apply(this, arguments);
|
|
9
|
+
}
|
|
10
|
+
inherits(ColumnCompiler_Redshift, ColumnCompiler_PG);
|
|
11
|
+
|
|
12
|
+
Object.assign(ColumnCompiler_Redshift.prototype, {
|
|
13
|
+
// Types:
|
|
14
|
+
// ------
|
|
15
|
+
bigincrements: 'bigint identity(1,1) primary key not null',
|
|
16
|
+
binary: 'varchar(max)',
|
|
17
|
+
bit(column) {
|
|
18
|
+
return column.length !== false ? `char(${column.length})` : 'char(1)';
|
|
19
|
+
},
|
|
20
|
+
blob: 'varchar(max)',
|
|
21
|
+
enu: 'varchar(255)',
|
|
22
|
+
enum: 'varchar(255)',
|
|
23
|
+
increments: 'integer identity(1,1) primary key not null',
|
|
24
|
+
json: 'varchar(max)',
|
|
25
|
+
jsonb: 'varchar(max)',
|
|
26
|
+
longblob: 'varchar(max)',
|
|
27
|
+
mediumblob: 'varchar(16777218)',
|
|
28
|
+
set: 'text',
|
|
29
|
+
text: 'varchar(max)',
|
|
30
|
+
datetime(without) {
|
|
31
|
+
return without ? 'timestamp' : 'timestamptz';
|
|
32
|
+
},
|
|
33
|
+
timestamp(without) {
|
|
34
|
+
return without ? 'timestamp' : 'timestamptz';
|
|
35
|
+
},
|
|
36
|
+
tinyblob: 'varchar(256)',
|
|
37
|
+
uuid: 'char(36)',
|
|
38
|
+
varbinary: 'varchar(max)',
|
|
39
|
+
bigint: 'bigint',
|
|
40
|
+
bool: 'boolean',
|
|
41
|
+
double: 'double precision',
|
|
42
|
+
floating: 'real',
|
|
43
|
+
smallint: 'smallint',
|
|
44
|
+
tinyint: 'smallint',
|
|
45
|
+
|
|
46
|
+
// Modifiers:
|
|
47
|
+
// ------
|
|
48
|
+
comment(comment) {
|
|
49
|
+
this.pushAdditional(function () {
|
|
50
|
+
this.pushQuery(
|
|
51
|
+
`comment on column ${this.tableCompiler.tableName()}.` +
|
|
52
|
+
this.formatter.wrap(this.args[0]) +
|
|
53
|
+
' is ' +
|
|
54
|
+
(comment ? `'${comment}'` : 'NULL')
|
|
55
|
+
);
|
|
56
|
+
}, comment);
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
module.exports = ColumnCompiler_Redshift;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
/* eslint max-len: 0 */
|
|
2
|
-
|
|
3
|
-
// Redshift Table Builder & Compiler
|
|
4
|
-
// -------
|
|
5
|
-
|
|
6
|
-
const { inherits } = require('util');
|
|
7
|
-
const SchemaCompiler_PG = require('../../postgres/schema/compiler');
|
|
8
|
-
|
|
9
|
-
function SchemaCompiler_Redshift() {
|
|
10
|
-
SchemaCompiler_PG.apply(this, arguments);
|
|
11
|
-
}
|
|
12
|
-
inherits(SchemaCompiler_Redshift, SchemaCompiler_PG);
|
|
13
|
-
|
|
14
|
-
module.exports = SchemaCompiler_Redshift;
|
|
1
|
+
/* eslint max-len: 0 */
|
|
2
|
+
|
|
3
|
+
// Redshift Table Builder & Compiler
|
|
4
|
+
// -------
|
|
5
|
+
|
|
6
|
+
const { inherits } = require('util');
|
|
7
|
+
const SchemaCompiler_PG = require('../../postgres/schema/compiler');
|
|
8
|
+
|
|
9
|
+
function SchemaCompiler_Redshift() {
|
|
10
|
+
SchemaCompiler_PG.apply(this, arguments);
|
|
11
|
+
}
|
|
12
|
+
inherits(SchemaCompiler_Redshift, SchemaCompiler_PG);
|
|
13
|
+
|
|
14
|
+
module.exports = SchemaCompiler_Redshift;
|