-
Notifications
You must be signed in to change notification settings - Fork 690
Fix: include t.* columns in RECORDSET results (fixes #2070) #2153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like new code.
When/why are we using this?
| return res; | ||
| } | ||
|
|
||
| // ✅ Custom RECORDSET class |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove comments. Make the code speak.
| }, {}); | ||
|
|
||
| case 'RECORDSET': { | ||
| // ✅ FIX: include all keys from t.* + computed columns |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use ?? instead of ||
|
|
||
| query.defcols = this.compileDefCols(query, databaseid); | ||
|
|
||
| // 1. Compile FROM clause |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please keep comment
| query.modifier = this.modifier; | ||
|
|
||
| query.database = db; | ||
| // 0. Precompile whereexists |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please leave comment
| ); | ||
| } | ||
|
|
||
| // Compile SELECT statement |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please keep comment
| s += ' UNION ALL ' + (this.corresponding ? 'CORRESPONDING ' : '') + this.unionall.toString(); | ||
| } | ||
| if (this.except) { | ||
| if (this.unionall) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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: