rawsql-ts
Version:
[beta]High-performance SQL parser and AST analyzer written in TypeScript. Provides fast parsing and advanced transformation capabilities.
153 lines • 6.96 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DropConstraintStatement = exports.AlterTableStatement = exports.AlterTableDropColumn = exports.AlterTableDropConstraint = exports.AlterTableAddConstraint = exports.CreateIndexStatement = exports.IndexColumnDefinition = exports.DropIndexStatement = exports.DropTableStatement = void 0;
const SqlComponent_1 = require("./SqlComponent");
const ValueComponent_1 = require("./ValueComponent");
/**
* DROP TABLE statement representation.
*/
class DropTableStatement extends SqlComponent_1.SqlComponent {
constructor(params) {
var _a, _b;
super();
this.tables = params.tables.map(table => new ValueComponent_1.QualifiedName(table.namespaces, table.name));
this.ifExists = (_a = params.ifExists) !== null && _a !== void 0 ? _a : false;
this.behavior = (_b = params.behavior) !== null && _b !== void 0 ? _b : null;
}
}
exports.DropTableStatement = DropTableStatement;
DropTableStatement.kind = Symbol("DropTableStatement");
/**
* DROP INDEX statement representation.
*/
class DropIndexStatement extends SqlComponent_1.SqlComponent {
constructor(params) {
var _a, _b, _c;
super();
this.indexNames = params.indexNames.map(index => new ValueComponent_1.QualifiedName(index.namespaces, index.name));
this.ifExists = (_a = params.ifExists) !== null && _a !== void 0 ? _a : false;
this.concurrently = (_b = params.concurrently) !== null && _b !== void 0 ? _b : false;
this.behavior = (_c = params.behavior) !== null && _c !== void 0 ? _c : null;
}
}
exports.DropIndexStatement = DropIndexStatement;
DropIndexStatement.kind = Symbol("DropIndexStatement");
/**
* Column definition within CREATE INDEX clause.
*/
class IndexColumnDefinition extends SqlComponent_1.SqlComponent {
constructor(params) {
var _a, _b, _c, _d;
super();
this.expression = params.expression;
this.sortOrder = (_a = params.sortOrder) !== null && _a !== void 0 ? _a : null;
this.nullsOrder = (_b = params.nullsOrder) !== null && _b !== void 0 ? _b : null;
this.collation = (_c = params.collation) !== null && _c !== void 0 ? _c : null;
this.operatorClass = (_d = params.operatorClass) !== null && _d !== void 0 ? _d : null;
}
}
exports.IndexColumnDefinition = IndexColumnDefinition;
IndexColumnDefinition.kind = Symbol("IndexColumnDefinition");
/**
* CREATE INDEX statement representation.
*/
class CreateIndexStatement extends SqlComponent_1.SqlComponent {
constructor(params) {
var _a, _b, _c, _d, _e, _f;
super();
this.unique = (_a = params.unique) !== null && _a !== void 0 ? _a : false;
this.concurrently = (_b = params.concurrently) !== null && _b !== void 0 ? _b : false;
this.ifNotExists = (_c = params.ifNotExists) !== null && _c !== void 0 ? _c : false;
this.indexName = new ValueComponent_1.QualifiedName(params.indexName.namespaces, params.indexName.name);
this.tableName = new ValueComponent_1.QualifiedName(params.tableName.namespaces, params.tableName.name);
this.usingMethod = (_d = params.usingMethod) !== null && _d !== void 0 ? _d : null;
this.columns = params.columns.map(col => {
var _a, _b;
return new IndexColumnDefinition({
expression: col.expression,
sortOrder: col.sortOrder,
nullsOrder: col.nullsOrder,
collation: (_a = col.collation) !== null && _a !== void 0 ? _a : null,
operatorClass: (_b = col.operatorClass) !== null && _b !== void 0 ? _b : null
});
});
this.include = params.include ? [...params.include] : null;
this.where = params.where;
this.withOptions = (_e = params.withOptions) !== null && _e !== void 0 ? _e : null;
this.tablespace = (_f = params.tablespace) !== null && _f !== void 0 ? _f : null;
}
}
exports.CreateIndexStatement = CreateIndexStatement;
CreateIndexStatement.kind = Symbol("CreateIndexStatement");
/**
* ALTER TABLE ... ADD CONSTRAINT action.
*/
class AlterTableAddConstraint extends SqlComponent_1.SqlComponent {
constructor(params) {
var _a, _b;
super();
this.constraint = params.constraint;
this.ifNotExists = (_a = params.ifNotExists) !== null && _a !== void 0 ? _a : false;
this.notValid = (_b = params.notValid) !== null && _b !== void 0 ? _b : false;
}
}
exports.AlterTableAddConstraint = AlterTableAddConstraint;
AlterTableAddConstraint.kind = Symbol("AlterTableAddConstraint");
/**
* ALTER TABLE ... DROP CONSTRAINT action.
*/
class AlterTableDropConstraint extends SqlComponent_1.SqlComponent {
constructor(params) {
var _a, _b;
super();
this.constraintName = params.constraintName;
this.ifExists = (_a = params.ifExists) !== null && _a !== void 0 ? _a : false;
this.behavior = (_b = params.behavior) !== null && _b !== void 0 ? _b : null;
}
}
exports.AlterTableDropConstraint = AlterTableDropConstraint;
AlterTableDropConstraint.kind = Symbol("AlterTableDropConstraint");
/**
* ALTER TABLE ... DROP COLUMN action.
*/
class AlterTableDropColumn extends SqlComponent_1.SqlComponent {
constructor(params) {
var _a, _b;
super();
this.columnName = params.columnName;
this.ifExists = (_a = params.ifExists) !== null && _a !== void 0 ? _a : false;
this.behavior = (_b = params.behavior) !== null && _b !== void 0 ? _b : null;
}
}
exports.AlterTableDropColumn = AlterTableDropColumn;
AlterTableDropColumn.kind = Symbol("AlterTableDropColumn");
/**
* ALTER TABLE statement representation with constraint-centric actions.
*/
class AlterTableStatement extends SqlComponent_1.SqlComponent {
constructor(params) {
var _a, _b;
super();
this.table = new ValueComponent_1.QualifiedName(params.table.namespaces, params.table.name);
this.only = (_a = params.only) !== null && _a !== void 0 ? _a : false;
this.ifExists = (_b = params.ifExists) !== null && _b !== void 0 ? _b : false;
this.actions = params.actions.map(action => action);
}
}
exports.AlterTableStatement = AlterTableStatement;
AlterTableStatement.kind = Symbol("AlterTableStatement");
/**
* Standalone DROP CONSTRAINT statement representation.
*/
class DropConstraintStatement extends SqlComponent_1.SqlComponent {
constructor(params) {
var _a, _b;
super();
this.constraintName = params.constraintName;
this.ifExists = (_a = params.ifExists) !== null && _a !== void 0 ? _a : false;
this.behavior = (_b = params.behavior) !== null && _b !== void 0 ? _b : null;
}
}
exports.DropConstraintStatement = DropConstraintStatement;
DropConstraintStatement.kind = Symbol("DropConstraintStatement");
//# sourceMappingURL=DDLStatements.js.map