rawsql-ts
Version:
High-performance SQL parser and AST analyzer written in TypeScript. Provides fast parsing and advanced transformation capabilities.
58 lines • 2.2 kB
JavaScript
import { ParameterHelper } from "../utils/ParameterHelper";
import { QueryBuilder } from "../transformers/QueryBuilder";
import { SqlComponent } from "./SqlComponent";
/**
* Represents a VALUES query in SQL.
*/
export class ValuesQuery extends SqlComponent {
constructor(tuples, columnAliases = null) {
super();
this.__selectQueryType = 'SelectQuery'; // Discriminator for type safety
this.headerComments = null; // Comments that appear before VALUES clause
this.withClause = null;
this.tuples = tuples;
this.columnAliases = columnAliases;
}
toSimpleQuery() {
return 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.set(this, name, value);
return this;
}
}
ValuesQuery.kind = Symbol("ValuesQuery");
//# sourceMappingURL=ValuesQuery.js.map