fix(lastleg): route all relabel pickups directly to outbound and verify final schemas
This commit is contained in:
@@ -49,12 +49,15 @@ function splitValues(value) {
|
||||
}
|
||||
|
||||
export function seedRows(sql, name) {
|
||||
const pattern = new RegExp(`^INSERT INTO ${name} \\(([^\\n]+?)\\) VALUES \\(([^\\n]+)\\);$`, 'gm')
|
||||
return [...sql.matchAll(pattern)].map(match => {
|
||||
const pattern = new RegExp(`^INSERT INTO ${name} \\(([^\\n]+?)\\) VALUES\\s*([\\s\\S]*?);$`, 'gm')
|
||||
return [...sql.replaceAll('\r\n', '\n').matchAll(pattern)].flatMap(match => {
|
||||
const keys = match[1].split(',').map(key => key.trim())
|
||||
const values = splitValues(match[2])
|
||||
if (keys.length !== values.length) throw new Error(`Invalid seed columns: ${name}`)
|
||||
return Object.fromEntries(keys.map((key, i) => [key, values[i]]))
|
||||
return splitValues(match[2]).map(row => {
|
||||
if (!row.startsWith('(') || !row.endsWith(')')) throw new Error(`Invalid seed row: ${name}`)
|
||||
const values = splitValues(row.slice(1, -1))
|
||||
if (keys.length !== values.length) throw new Error(`Invalid seed columns: ${name}`)
|
||||
return Object.fromEntries(keys.map((key, i) => [key, values[i]]))
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user