Skip to content
This repository was archived by the owner on Aug 19, 2025. It is now read-only.

Conversation

@rzane
Copy link
Contributor

@rzane rzane commented Mar 13, 2020

It's fairly common to select two columns that are assigned the same name. In those scenarios, you can't really rely on the dictionary version of the record, but you get the values by their index.

Previously, when two columns with the same name were selected, the PostgreSQL Record would return only the first column's value.

>>> query = "SELECT 1 AS id, 2 AS id"
>>> row = await database.fetch_one(query=query)
>>> list(row.values())
[1, 1]

This PR fixes that bug and returns the correct values.

@rzane rzane force-pushed the fix-incorrect-values branch from 22a8cc9 to ed66340 Compare March 13, 2020 17:39
@rzane rzane force-pushed the fix-incorrect-values branch from ed66340 to c9a8f82 Compare March 13, 2020 17:48
@lovelydinosaur
Copy link
Contributor

Fantastic, thanks!

@rzane Since this is your first approved PR, you're welcome to an invite to maintainers if you'd like it? That'd give you permissions to approve or merge PRs.

Thanks for your time on this. 😀

@lovelydinosaur lovelydinosaur merged commit 5cccb5c into encode:master Apr 29, 2020
@vmarkovtsev
Copy link
Contributor

@tomchristie did you mean myself or Ray?..

@lovelydinosaur
Copy link
Contributor

I meant Ray, yup. We're trying to move to an open doors policy of "invites to the maintainers team for anyone who gets a PR through"

@vmarkovtsev
Copy link
Contributor

All right 👍 I wonder if #199 counts in my case, too.

@lovelydinosaur
Copy link
Contributor

Yup absolutely, just not always succeeding in tracking it! 😬

@lovelydinosaur lovelydinosaur changed the title Make sure the correct values are returned from a PostgreSQL record Return correct values from PostgreSQL record when columns have identical name Apr 30, 2020
@lovelydinosaur lovelydinosaur mentioned this pull request Apr 30, 2020
@rzane rzane deleted the fix-incorrect-values branch May 6, 2020 15:15
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants