ddl-manager
Version:
store postgres procedures and triggers in files
46 lines • 1.31 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.TableID = void 0;
const defaults_1 = require("../../parser/defaults");
const constants_1 = require("../postgres/constants");
const keywords = [
"order",
"where",
"from",
"join",
"on",
"select"
];
class TableID {
constructor(schema, name) {
this.schema = schema.replace(/"/g, "");
this.name = name.replace(/"/g, "").slice(0, constants_1.MAX_NAME_LENGTH);
}
static fromString(schemaTable) {
const [schema, table] = schemaTable.split(".");
if (!table) {
return new TableID(defaults_1.DEFAULT_SCHEMA, schema);
}
return new TableID(schema, table);
}
equal(otherTable) {
return (this.schema === otherTable.schema &&
this.name === otherTable.name);
}
toString() {
return `${this.schema}.${this.name}`;
}
// TODO: use it as default toString
toStringWithoutPublic() {
const nameIsKeyWord = keywords.includes(this.name);
if (!nameIsKeyWord && this.schema === "public") {
return this.name;
}
else {
return `${this.schema}.${this.name}`;
;
}
}
}
exports.TableID = TableID;
//# sourceMappingURL=TableID.js.map