knex/lib/dialects/cockroachdb/crdb-querycompiler.js

28 lines
676 B
JavaScript
Raw Normal View History

const QueryCompiler_PG = require('../postgres/query/pg-querycompiler');
class QueryCompiler_CRDB extends QueryCompiler_PG {
truncate() {
return `truncate ${this.tableName}`;
}
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;
}
}
module.exports = QueryCompiler_CRDB;