Bug
Column names containing periods (e.g. Sp. Atk, Sp. Def) are silently dropped from results when using qualified star expansion (p.*) or unqualified star (*) in JOIN queries.
Reproduction
const { collect, executeSql } = require('squirreling')
const pokemon = [
{ '#': 1, Name: 'Bulbasaur', 'Sp. Atk': 65, 'Sp. Def': 65 },
]
const rowgroups = [{ numbers: 1 }]
// Qualified star — drops Sp. Atk and Sp. Def
const r1 = await collect(executeSql({
tables: { pokemon, rowgroups },
query: 'SELECT p.*, r.numbers FROM pokemon p JOIN rowgroups r ON p."#" = r.numbers',
}))
console.log(Object.keys(r1[0]))
// => ['#', 'Name', 'numbers'] — missing 'Sp. Atk' and 'Sp. Def'
// Unqualified star — mangles names
const r2 = await collect(executeSql({
tables: { pokemon, rowgroups },
query: 'SELECT * FROM pokemon p JOIN rowgroups r ON p."#" = r.numbers',
}))
console.log(Object.keys(r2[0]))
// => ['#', 'Name', ' Atk', ' Def', 'numbers'] — mangled to ' Atk' and ' Def'
// Explicit columns work fine
const r3 = await collect(executeSql({
tables: { pokemon, rowgroups },
query: 'SELECT p."#", p."Name", p."Sp. Atk", p."Sp. Def", r.numbers FROM pokemon p JOIN rowgroups r ON p."#" = r.numbers',
}))
console.log(Object.keys(r3[0]))
// => ['#', 'Name', 'Sp. Atk', 'Sp. Def', 'numbers'] — correct
Cause
mergeRows and prefixColumns in src/execute/join.js use key.includes('.') to detect "already-prefixed" columns (from previous joins). Column names like Sp. Atk contain a literal dot and get misidentified as already-prefixed, so the table.column alias is never created.
Then in executeProject (src/execute/execute.js), qualified star expansion (p.*) checks key.startsWith(prefix) which never matches these columns since they were never prefixed.
Workaround
Use explicit column names instead of p.* when columns contain dots.
Bug
Column names containing periods (e.g.
Sp. Atk,Sp. Def) are silently dropped from results when using qualified star expansion (p.*) or unqualified star (*) in JOIN queries.Reproduction
Cause
mergeRowsandprefixColumnsinsrc/execute/join.jsusekey.includes('.')to detect "already-prefixed" columns (from previous joins). Column names likeSp. Atkcontain a literal dot and get misidentified as already-prefixed, so thetable.columnalias is never created.Then in
executeProject(src/execute/execute.js), qualified star expansion (p.*) checkskey.startsWith(prefix)which never matches these columns since they were never prefixed.Workaround
Use explicit column names instead of
p.*when columns contain dots.