2021-10-10 01:33:20 +03:00
|
|
|
const QueryCompiler_PG = require('../postgres/query/pg-querycompiler');
|
|
|
|
|
|
|
|
|
|
class QueryCompiler_CRDB extends QueryCompiler_PG {
|
|
|
|
|
truncate() {
|
|
|
|
|
return `truncate ${this.tableName}`;
|
|
|
|
|
}
|
2021-10-24 16:27:08 +03:00
|
|
|
|
|
|
|
|
upsert() {
|
|
|
|
|
let sql = this._upsert();
|
|
|
|
|
if (sql === '') return sql;
|
|
|
|
|
const { returning } = this.single;
|
|
|
|
|
if (returning) sql += this._returning(returning);
|
|
|
|
|
return {
|
|
|
|
|
sql: sql,
|
|
|
|
|
returning,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_upsert() {
|
|
|
|
|
const upsertValues = this.single.upsert || [];
|
2021-11-09 09:34:19 +01:00
|
|
|
const sql = this.with() + `upsert into ${this.tableName} `;
|
|
|
|
|
const body = this._insertBody(upsertValues);
|
|
|
|
|
return body === '' ? '' : sql + body;
|
2021-10-24 16:27:08 +03:00
|
|
|
}
|
2021-10-10 01:33:20 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
module.exports = QueryCompiler_CRDB;
|