spine-framework 0.2.7 → 0.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -99,13 +99,10 @@ async function migrateCommand(options: MigrateOptions): Promise<void> {
|
|
|
99
99
|
// Dollar-quoted strings ($$ ... $$ or $tag$ ... $tag$) can contain semicolons
|
|
100
100
|
// that are NOT statement terminators.
|
|
101
101
|
function splitSqlStatements(sql: string): string[] {
|
|
102
|
-
// Simple approach: use regex to split, but protect dollar-quoted blocks first
|
|
103
|
-
// Replace dollar-quoted blocks with placeholders, split by semicolons, then restore
|
|
104
|
-
|
|
105
102
|
const dollarBlocks: string[] = []
|
|
106
103
|
let blockIndex = 0
|
|
107
104
|
|
|
108
|
-
//
|
|
105
|
+
// Step 1: Protect dollar-quoted blocks with placeholders (preserves internal semicolons)
|
|
109
106
|
const protectedSql = sql.replace(/\$[A-Za-z_]*\$[\s\S]*?\$[A-Za-z_]*\$/g, (match) => {
|
|
110
107
|
const placeholder = `__DOLLAR_BLOCK_${blockIndex}__`
|
|
111
108
|
dollarBlocks[blockIndex] = match
|
|
@@ -113,23 +110,23 @@ async function migrateCommand(options: MigrateOptions): Promise<void> {
|
|
|
113
110
|
return placeholder
|
|
114
111
|
})
|
|
115
112
|
|
|
116
|
-
//
|
|
117
|
-
|
|
113
|
+
// Step 2: Strip single-line comments (prevents semicolons inside -- comments
|
|
114
|
+
// from being treated as statement terminators)
|
|
115
|
+
const noComments = protectedSql.replace(/--[^\n]*/g, '')
|
|
118
116
|
|
|
119
|
-
//
|
|
120
|
-
|
|
117
|
+
// Step 3: Split by semicolons, restore dollar blocks, and filter empty statements
|
|
118
|
+
return noComments
|
|
119
|
+
.split(';')
|
|
121
120
|
.map(s => {
|
|
122
121
|
let restored = s.trim()
|
|
123
|
-
//
|
|
122
|
+
// Use function form of replace — prevents JS from interpreting $$ as $
|
|
124
123
|
dollarBlocks.forEach((block, idx) => {
|
|
125
|
-
restored = restored.replace(`__DOLLAR_BLOCK_${idx}__`, block)
|
|
124
|
+
restored = restored.replace(`__DOLLAR_BLOCK_${idx}__`, () => block)
|
|
126
125
|
})
|
|
127
126
|
return restored
|
|
128
127
|
})
|
|
129
|
-
.filter(s => s.length > 0
|
|
128
|
+
.filter(s => s.length > 0)
|
|
130
129
|
.map(s => s + ';')
|
|
131
|
-
|
|
132
|
-
return statements
|
|
133
130
|
}
|
|
134
131
|
|
|
135
132
|
const statements = splitSqlStatements(sql)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrate.d.ts","sourceRoot":"","sources":["../../../.framework/cli/commands/migrate.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;
|
|
1
|
+
{"version":3,"file":"migrate.d.ts","sourceRoot":"","sources":["../../../.framework/cli/commands/migrate.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AA8IxC,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,OAAO,QAevD"}
|