rhombic
Version:
SQL parsing, lineage extraction and manipulation
29 lines • 1.02 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getText = void 0;
/**
* Get a piece of text in a multine sql statement.
* @param sql intial sql
* @param input text to insert
* @param location
*/
const getText = (sql, location) => {
let output = "";
sql.split("\n").forEach((line, lineNumber) => {
if (lineNumber === location.startLine - 1 && location.startLine === location.endLine) {
output += line.slice(location.startColumn - 1, location.endColumn);
}
else if (location.startLine - 1 === lineNumber) {
output += line.slice(location.startColumn - 1) + "\n";
}
else if (location.endLine - 1 === lineNumber) {
output += line.slice(0, location.endColumn);
}
else if (lineNumber > location.startLine - 1 && lineNumber < location.endLine - 1) {
output += line + "\n";
}
});
return output;
};
exports.getText = getText;
//# sourceMappingURL=getText.js.map