fix(db): normalise line endings when parsing queries
The generator embeds each query's SQL as a string literal, taking whatever line endings the checkout happened to have. On a CRLF checkout every regenerated query differed from the committed one by `\n` -> `\r\n`, so `wrnexus build` dirtied the working tree and that churn buried real changes in the same file -- which is how a hand-applied edit ends up preferable to running the generator. Line endings carry no meaning in SQL, so normalise on parse and let generated output be stable across platforms. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -29,8 +29,17 @@ export interface ModelRef {
|
||||
model: Model;
|
||||
}
|
||||
|
||||
/** Parse annotated queries from one `.sql` file's contents. */
|
||||
/**
|
||||
* Parse annotated queries from one `.sql` file's contents.
|
||||
*
|
||||
* Line endings are normalised to LF first. The generator embeds each query's
|
||||
* SQL as a string literal, so without this a CRLF checkout regenerated every
|
||||
* query with CRLF where the committed file had LF -- a build dirtied the
|
||||
* working tree, and that churn buried real changes in the same file. Line
|
||||
* endings carry no meaning in SQL.
|
||||
*/
|
||||
export function parseQueries(content: string): QueryDef[] {
|
||||
content = content.replace(/\r\n?/g, "\n");
|
||||
const out: QueryDef[] = [];
|
||||
const re = /--\s*name:\s*(\w+)\s*:(one|many|exec)\b[^\n]*\n([\s\S]*?)(?=--\s*name:|$)/gi;
|
||||
let m: RegExpExecArray | null;
|
||||
|
||||
Reference in New Issue
Block a user