2019-06-04 00:37:17 +02:00
|
|
|
const ColumnCompiler = require('../../../schema/columncompiler');
|
2015-05-09 13:58:18 -04:00
|
|
|
|
|
|
|
// Column Compiler
|
|
|
|
// -------
|
|
|
|
|
2021-01-01 20:35:54 +02:00
|
|
|
class ColumnCompiler_SQLite3 extends ColumnCompiler {
|
|
|
|
constructor() {
|
|
|
|
super(...arguments);
|
|
|
|
this.modifiers = ['nullable', 'defaultTo'];
|
2022-01-06 14:44:16 +01:00
|
|
|
this._addCheckModifiers();
|
2021-01-01 20:35:54 +02:00
|
|
|
}
|
2015-05-09 13:58:18 -04:00
|
|
|
|
2021-01-01 20:35:54 +02:00
|
|
|
// Types
|
|
|
|
// -------
|
2015-05-09 13:58:18 -04:00
|
|
|
|
2021-01-01 20:35:54 +02:00
|
|
|
enu(allowed) {
|
|
|
|
return `text check (${this.formatter.wrap(
|
|
|
|
this.args[0]
|
|
|
|
)} in ('${allowed.join("', '")}'))`;
|
|
|
|
}
|
2022-01-06 14:44:16 +01:00
|
|
|
|
|
|
|
_pushAlterCheckQuery(checkPredicate, constraintName) {
|
|
|
|
throw new Error(
|
|
|
|
`Alter table with to add constraints is not permitted in SQLite`
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
checkRegex(regexes, constraintName) {
|
|
|
|
return this._check(
|
|
|
|
`${this.formatter.wrap(
|
|
|
|
this.getColumnName()
|
|
|
|
)} REGEXP ${this.client._escapeBinding(regexes)}`,
|
|
|
|
constraintName
|
|
|
|
);
|
|
|
|
}
|
2021-01-01 20:35:54 +02:00
|
|
|
}
|
2015-05-09 13:58:18 -04:00
|
|
|
|
2018-09-26 08:15:31 +02:00
|
|
|
ColumnCompiler_SQLite3.prototype.json = 'json';
|
2020-12-30 21:16:09 +01:00
|
|
|
ColumnCompiler_SQLite3.prototype.jsonb = 'json';
|
2021-10-10 01:33:20 +03:00
|
|
|
ColumnCompiler_SQLite3.prototype.double =
|
|
|
|
ColumnCompiler_SQLite3.prototype.decimal =
|
|
|
|
ColumnCompiler_SQLite3.prototype.floating =
|
|
|
|
'float';
|
2021-01-01 20:35:54 +02:00
|
|
|
ColumnCompiler_SQLite3.prototype.timestamp = 'datetime';
|
2022-01-03 20:55:24 +01:00
|
|
|
// autoincrement without primary key is a syntax error in SQLite, so it's necessary
|
|
|
|
ColumnCompiler_SQLite3.prototype.increments =
|
|
|
|
ColumnCompiler_SQLite3.prototype.bigincrements =
|
|
|
|
'integer not null primary key autoincrement';
|
2018-09-26 08:15:31 +02:00
|
|
|
|
2019-06-04 00:37:17 +02:00
|
|
|
module.exports = ColumnCompiler_SQLite3;
|