ddl-manager
Version:
store postgres procedures and triggers in files
56 lines • 1.72 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.TableReference = void 0;
const TableID_1 = require("./TableID");
class TableReference {
constructor(table, alias) {
this.table = table;
this.alias = alias;
}
static identifier2filter(identifier) {
if (identifier.includes(".")) {
return {
schema: identifier.split(".")[0],
aliasOrTableName: identifier.split(".")[1]
};
}
else {
return {
aliasOrTableName: identifier
};
}
}
getIdentifier() {
return this.alias || this.table.toString();
}
matched(filter) {
if (filter.schema) {
return (!this.alias &&
this.table.schema === filter.schema &&
this.table.name === filter.aliasOrTableName);
}
if (this.alias) {
return this.alias === filter.aliasOrTableName;
}
return this.table.name === filter.aliasOrTableName;
}
equal(otherTable) {
if (otherTable instanceof TableReference) {
return (otherTable.alias === this.alias &&
otherTable.table.equal(this.table));
}
return this.table.equal(otherTable);
}
clone() {
return new TableReference(new TableID_1.TableID(this.table.schema, this.table.name), this.alias);
}
toString() {
const tableSQL = this.table.toStringWithoutPublic();
if (this.alias) {
return `${tableSQL} as ${this.alias}`;
}
return tableSQL;
}
}
exports.TableReference = TableReference;
//# sourceMappingURL=TableReference.js.map