11 lines
257 B
TypeScript
11 lines
257 B
TypeScript
export function splitSqlStatements(sql: string): string[] {
|
|
const withoutComments = sql
|
|
.replace(/\/\*[\s\S]*?\*\//g, "")
|
|
.replace(/^\s*--.*$/gm, "");
|
|
|
|
return withoutComments
|
|
.split(";")
|
|
.map((statement) => statement.trim())
|
|
.filter(Boolean);
|
|
}
|