Skip to content
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

Allow introspection of Rows by making PostgresRow.lookupTable readable #132

Open
winsmith opened this issue Nov 21, 2020 · 3 comments
Open
Assignees
Labels
enhancement New feature or request

Comments

@winsmith
Copy link

winsmith commented Nov 21, 2020

Is your feature request related to a problem? Please describe.
For a variety of complicated tasks, I want to use hand-crafted queries (instead of relying on Fluent's ORM). I run these queries and would like to convert them into an array to return them to my client.

To do this, however, I seem to need to know in advance how the row fields are named, since I can only access a row field by name. This is frustrating since I would like to use different row field names in different queries and still use the same code to convert them into a dictionary.

Describe the solution you'd like
I almost got my solution from PostgresRow.description, which loops through self.lookupTable.rowDescription.fields to get the field names.

I tried to write an extension to PostgresRow that would give me the field names, but 'lookupTable' is inaccessible due to 'internal' protection level. So my request is to make the lookupTable property readable.

Describe alternatives you've considered
The alternative I'm going with for now is to build a query and staple to it the list of expected field names and types. This seems a bit unwieldy, especially since the data is right there 😅

Thanks and stay awesome <3

@winsmith winsmith added the enhancement New feature or request label Nov 21, 2020
@jonny7
Copy link
Member

jonny7 commented Nov 21, 2020

Can you not achieve this with raw sql kit queries or the sql builder? Or are you saying it should be built into fluent?

@winsmith
Copy link
Author

I'm saying if I build a raw SQL query, and get the result back, I don't know any easy solution to find out the column titles in the result. I mean, I kinda know because I wrote the query and defined the column titles there, but it would be helpful to read these out of the PostgresRow instance somehow.

@0xTim
Copy link
Member

0xTim commented Dec 12, 2020

I see no reason not to make it public - it seems like a reasonable use case. @gwynne Any objections?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants