UNPKG

ddl-manager

Version:

store postgres procedures and triggers in files

57 lines 1.95 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ColumnReference = void 0; const AbstractExpressionElement_1 = require("./AbstractExpressionElement"); class ColumnReference extends AbstractExpressionElement_1.AbstractExpressionElement { constructor(tableReference, name) { super(); this.tableReference = tableReference; this.name = name; } replaceTable(replaceTable, toTable) { if (this.tableReference.equal(replaceTable)) { return new ColumnReference(toTable, this.name); } return this.clone(); } replaceColumn(replaceColumn, toSql) { if (this.equal(replaceColumn)) { return toSql; } return this.clone(); } equal(otherColumnRef) { return (this.name === otherColumnRef.name && this.tableReference.equal(otherColumnRef.tableReference)); } getColumnReferences() { return [this]; } clone() { return new ColumnReference(this.tableReference.clone(), this.name); } isRefTo(cache, triggerTable, excludeRef = cache.for) { return (this.tableReference.table.equal(triggerTable) && (!excludeRef || !this.tableReference.equal(excludeRef))); } isFrom(table) { return this.tableReference.equal(table); } isFromTable(table) { return this.tableReference.table.equal(table); } template(spaces) { if (this.tableReference.alias) { return [`${this.tableReference.alias}.${this.name}`]; } if (this.tableReference.table.toStringWithoutPublic() === ".") { return [this.name]; } return [`${this.tableReference.table.toStringWithoutPublic()}.${this.name}`]; } getId() { return `${this.tableReference.table}.${this.name}`; } } exports.ColumnReference = ColumnReference; //# sourceMappingURL=ColumnReference.js.map