rawsql-ts
Version:
[beta]High-performance SQL parser and AST analyzer written in TypeScript. Provides fast parsing and advanced transformation capabilities.
34 lines • 1.17 kB
JavaScript
import { SqlFormatter } from './SqlFormatter';
/**
* @deprecated The Formatter class is deprecated. Use SqlFormatter instead.
*/
export class Formatter {
constructor() {
this.sqlFormatter = new SqlFormatter({
identifierEscape: { start: '"', end: '"' },
parameterSymbol: ':',
parameterStyle: 'named' // Default to 'named' for backward compatibility
});
}
format(arg, config = null) {
// Use the sqlFormatter instance to format the SQL component
if (config) {
this.sqlFormatter = new SqlFormatter(config);
}
const result = this.sqlFormatter.format(arg);
return result.formattedSql;
}
formatWithParameters(arg, config = null) {
// Use the sqlFormatter instance to format the SQL component with parameters
if (config) {
this.sqlFormatter = new SqlFormatter(config);
}
const result = this.sqlFormatter.format(arg);
return { sql: result.formattedSql, params: result.params };
}
visit(arg) {
return this.format(arg);
}
}
export { SqlFormatter };
//# sourceMappingURL=Formatter.js.map