rawsql-ts
Version:
High-performance SQL parser and AST analyzer written in TypeScript. Provides fast parsing and advanced transformation capabilities.
41 lines • 1.22 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.HintClause = void 0;
const SqlComponent_1 = require("./SqlComponent");
/**
* Represents a SQL hint clause
*/
class HintClause extends SqlComponent_1.SqlComponent {
constructor(hintContent) {
super();
this.hintContent = hintContent;
}
/**
* Returns the full hint clause with delimiters
*/
getFullHint() {
return '/*+ ' + this.hintContent + ' */';
}
/**
* Checks if a string is a hint clause
*/
static isHintClause(value) {
const trimmed = value.trim();
return trimmed.length >= 5 &&
trimmed.substring(0, 3) === '/*+' &&
trimmed.substring(trimmed.length - 2) === '*/';
}
/**
* Extracts hint content from a hint clause string
*/
static extractHintContent(hintClause) {
const trimmed = hintClause.trim();
if (!this.isHintClause(trimmed)) {
throw new Error('Not a valid hint clause: ' + hintClause);
}
return trimmed.slice(3, -2).trim();
}
}
exports.HintClause = HintClause;
HintClause.kind = Symbol('HintClause');
//# sourceMappingURL=HintClause.js.map