Fix: include t.* columns in RECORDSET results (fixes #2070)#2153
Fix: include t.* columns in RECORDSET results (fixes #2070)#2153shhreya13 wants to merge 7 commits intoAlaSQL:developfrom
Conversation
mathiasrw
left a comment
There was a problem hiding this comment.
Way too many things changed in this PR. But lets lets work with it now that you have created it.
You shuold run yarn test locally to confirm things are working. 4 tests are broken.
The PR also needs to add new test file named test2070 that verifies that the problem in #2070 is not accidentally reintroduced in the future.
| } | ||
|
|
||
| // ✅ Custom RECORDSET class | ||
| yy.Recordset = class Recordset extends yy.Select { |
There was a problem hiding this comment.
Looks like new code.
When/why are we using this?
| return res; | ||
| } | ||
|
|
||
| // ✅ Custom RECORDSET class |
There was a problem hiding this comment.
Please remove comments. Make the code speak.
| }, {}); | ||
|
|
||
| case 'RECORDSET': { | ||
| // ✅ FIX: include all keys from t.* + computed columns |
There was a problem hiding this comment.
Please remove coments. Let. the code. speak.
| const keyIndex = columns?.[0]?.columnid || Object.keys(res[0])[0]; | ||
| const valIndex = columns?.[1]?.columnid || Object.keys(res[0])[1]; | ||
| return res.reduce((acc, row) => { | ||
| acc[row[keyIndex]] = row[valIndex]; |
There was a problem hiding this comment.
An improvement. Nice.
But not really related to the PR. In the future please make a seperate PR with things not related to the PR. Lets just keep it for now.
|
|
||
| return ar; | ||
| const key = columns?.[0]?.columnid || Object.keys(res[0])[0]; | ||
| return res.map(r => r[key]); |
There was a problem hiding this comment.
Nice with an improvement. But not really related to the PR. In the future please make a seperate PR with things not related to the PR. Lets just keep it for now.
src/40select.js
Outdated
|
|
||
| query.defcols = this.compileDefCols(query, databaseid); | ||
|
|
||
| // 1. Compile FROM clause |
src/40select.js
Outdated
| query.modifier = this.modifier; | ||
|
|
||
| query.database = db; | ||
| // 0. Precompile whereexists |
src/40select.js
Outdated
| ); | ||
| } | ||
|
|
||
| // Compile SELECT statement |
| s += ' UNION ALL ' + (this.corresponding ? 'CORRESPONDING ' : '') + this.unionall.toString(); | ||
| } | ||
| if (this.except) { | ||
| if (this.unionall) |
There was a problem hiding this comment.
Please avoid multi line if statement without brackets (even if there is only one statement)
| .map(jn => { | ||
| let ss = ' '; | ||
| if (jn.joinmode) ss += jn.joinmode + ' '; | ||
| if (jn.table) ss += 'JOIN ' + jn.table.toString(); |
There was a problem hiding this comment.
Please always use {...} when involving an else
|
Please run |
This PR fixes issue #2070, where
RECORDSET OF SELECT t.*, computed_column FROM ? treturned only the computed column (
rn) in thecolumnsmetadata, omitting those fromt.*.🧠 Summary of Fix
t.*are correctly included in thecolumnsarraywhen additional computed columns are present.
src/40select.jsto merge both sets of columns.🧪 Test
Verified manually using: