2021-01-01 17:46:10 +02:00
|
|
|
const ColumnCompiler_Oracle = require('../../oracle/schema/oracle-columncompiler');
|
2020-10-05 21:29:39 +03:00
|
|
|
const { isObject } = require('../../../util/is');
|
2016-06-20 17:03:52 +02:00
|
|
|
|
2021-01-01 20:35:54 +02:00
|
|
|
class ColumnCompiler_Oracledb extends ColumnCompiler_Oracle {
|
|
|
|
constructor() {
|
|
|
|
super(...arguments);
|
2022-01-06 14:44:16 +01:00
|
|
|
this.modifiers = ['defaultTo', 'nullable', 'comment'];
|
|
|
|
this._addCheckModifiers();
|
2021-01-01 20:35:54 +02:00
|
|
|
}
|
2016-06-20 17:03:52 +02:00
|
|
|
|
2021-01-01 20:35:54 +02:00
|
|
|
datetime(withoutTz) {
|
2019-05-19 17:40:59 +05:30
|
|
|
let useTz;
|
|
|
|
if (isObject(withoutTz)) {
|
|
|
|
({ useTz } = withoutTz);
|
|
|
|
} else {
|
|
|
|
useTz = !withoutTz;
|
|
|
|
}
|
|
|
|
return useTz ? 'timestamp with local time zone' : 'timestamp';
|
2021-01-01 20:35:54 +02:00
|
|
|
}
|
2016-06-20 17:03:52 +02:00
|
|
|
|
2021-01-01 20:35:54 +02:00
|
|
|
timestamp(withoutTz) {
|
2019-05-19 17:40:59 +05:30
|
|
|
let useTz;
|
|
|
|
if (isObject(withoutTz)) {
|
|
|
|
({ useTz } = withoutTz);
|
|
|
|
} else {
|
|
|
|
useTz = !withoutTz;
|
|
|
|
}
|
|
|
|
return useTz ? 'timestamp with local time zone' : 'timestamp';
|
2021-01-01 20:35:54 +02:00
|
|
|
}
|
2021-12-22 10:47:16 +01:00
|
|
|
|
2022-01-06 14:44:16 +01:00
|
|
|
checkRegex(regex, constraintName) {
|
|
|
|
return this._check(
|
|
|
|
`REGEXP_LIKE(${this.formatter.wrap(
|
|
|
|
this.getColumnName()
|
|
|
|
)},${this.client._escapeBinding(regex)})`,
|
|
|
|
constraintName
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-12-22 10:47:16 +01:00
|
|
|
json() {
|
|
|
|
return `varchar2(4000) check (${this.formatter.columnize(
|
|
|
|
this.getColumnName()
|
|
|
|
)} is json)`;
|
|
|
|
}
|
|
|
|
|
|
|
|
jsonb() {
|
|
|
|
return this.json();
|
|
|
|
}
|
2021-01-01 20:35:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
ColumnCompiler_Oracledb.prototype.time = 'timestamp with local time zone';
|
2021-12-15 07:57:23 -05:00
|
|
|
ColumnCompiler_Oracledb.prototype.uuid = ({ useBinaryUuid = false } = {}) =>
|
|
|
|
useBinaryUuid ? 'raw(16)' : 'char(36)';
|
2016-06-20 17:03:52 +02:00
|
|
|
|
|
|
|
module.exports = ColumnCompiler_Oracledb;
|