rawsql-ts
Version:
[beta]High-performance SQL parser and AST analyzer written in TypeScript. Provides fast parsing and advanced transformation capabilities.
61 lines • 2.36 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ValuesQuery = void 0;
const ParameterHelper_1 = require("../utils/ParameterHelper");
const QueryBuilder_1 = require("../transformers/QueryBuilder");
const SqlComponent_1 = require("./SqlComponent");
/**
* Represents a VALUES query in SQL.
*/
class ValuesQuery extends SqlComponent_1.SqlComponent {
constructor(tuples, columnAliases = null) {
super();
this.__selectQueryType = 'SelectQuery'; // Discriminator for type safety
this.headerComments = null; // Comments that appear before VALUES clause
this.tuples = tuples;
this.columnAliases = columnAliases;
}
toSimpleQuery() {
return QueryBuilder_1.QueryBuilder.buildSimpleQuery(this);
}
/**
* Converts this VALUES query into an INSERT statement definition.
* @remarks The conversion may reorder the generated SELECT clause to align with the requested column order.
*/
toInsertQuery(options) {
return this.toSimpleQuery().toInsertQuery(options);
}
/**
* Converts this VALUES query into an UPDATE statement definition.
* @remarks The conversion may reorder the generated SELECT clause to align with the requested column order.
*/
toUpdateQuery(options) {
return this.toSimpleQuery().toUpdateQuery(options);
}
/**
* Converts this VALUES query into a DELETE statement definition.
* @remarks The conversion may reorder the generated SELECT clause to align with the requested column order.
*/
toDeleteQuery(options) {
return this.toSimpleQuery().toDeleteQuery(options);
}
/**
* Converts this VALUES query into a MERGE statement definition.
* @remarks The conversion may reorder the generated SELECT clause to align with the requested column order.
*/
toMergeQuery(options) {
return this.toSimpleQuery().toMergeQuery(options);
}
/**
* Sets the value of a parameter by name in this query.
* @param name Parameter name
* @param value Value to set
*/
setParameter(name, value) {
ParameterHelper_1.ParameterHelper.set(this, name, value);
return this;
}
}
exports.ValuesQuery = ValuesQuery;
ValuesQuery.kind = Symbol("ValuesQuery");
//# sourceMappingURL=ValuesQuery.js.map