Repository navigation
Conversation
… keys Duplicate column names in a rowset (e.g. SELECT * over a join) were renamed starting from the first occurrence, so row.id returned the last id column instead of the first. columnsNames also returned the raw metadata names, which did not match the keys used in each row. - keep the first occurrence of a name and suffix later duplicates with _1, _2, skipping suffixes already used by another column - columnsNames now returns the same unique names used as row keys - add originalColumnsNames with the names exactly as returned by the query Fixes #282
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #285 +/- ##
==========================================
+ Coverage 85.23% 85.45% +0.21%
==========================================
Files 11 11
Lines 1131 1141 +10
Branches 374 375 +1
==========================================
+ Hits 964 975 +11
+ Misses 167 154 -13
- Partials 0 12 +12 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #282
Problem
When a query returns several columns with the same name (e.g.
SELECT *over a join),SQLiteCloudRowsetrenames them so eachSQLiteCloudRowcan hold them as object keys. Two bugs:idbecameid_0, the secondid_0_1, and only the last keptid.row.idreturned the value of the lastidcolumn instead of the first.columnsNamesdidn't match the row keys. The constructor renamed a local copy, but the getter rebuilt names frommetadata.columnson every call. Code that readrow[name]for each name incolumnsNamessilently got the last duplicate's value in every duplicate column.Fix
getUniqueColumnsNames):column_N(unchanged)_1,_2, …id, id, id_1→id, id_2, id_1)columnsNamesreturns those same names (as a copy), socolumnsNames+row[name]is consistent withgetData().originalColumnsNamesgetter returns the names exactly as the query returned them, duplicates included.slice()/filter()rebuild from metadata, so they get the same names.{ id_0: 7, id: 42 }, now{ id: 7, id_1: 42 }.columnsNamesnow returns deduplicated names (andcolumn_Nfor empty names) instead of the raw metadata names. If you need the raw names, useoriginalColumnsNames.Queries without duplicate or empty column names are not affected. This should go in the release notes.
Tests
test/rowset.test.ts:columnsNamesmatching row keys, suffix collisions, missing names,columnsNamesreturning a copy, andslice/filterAlbumId/TitlecolumnsRun locally:
rowset,row,database,connection-tls,connection-wssuites all pass.tscis clean.