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

Support for fetching results in the text format #281

Open
17dec opened this issue Dec 23, 2023 · 0 comments
Open

Support for fetching results in the text format #281

17dec opened this issue Dec 23, 2023 · 0 comments

Comments

@17dec
Copy link

17dec commented Dec 23, 2023

I'm using crystal-pg to build a web-based query UI, which means I don't control the queries that are being executed nor which types are being used. Postgres does a much better job at formatting every possible type as text than we could ever hope to achieve, so I'd like to make use of that. My current approach involves running a COPY command (using #279) and parsing its output. While that has the benefit of letting me use the same format for caching query results, the downside is that dealing with TSV everywhere adds some extra overhead of its own, so I'm wondering if it isn't a better idea to grab the results the traditional way, but in the text format.

I'd be happy to write a PR for this, but I'm stuck on how to best expose this functionality through the API. Adjusting PG::Statement::perform_query to request the text format and ResultSet to handle this case and always offer a direct String read seems like an obvious approach, but how do we tell perform_query to switch to text? Add a flag to PG::Connection?

Is this a use case you're interested in supporting?

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

No branches or pull requests

1 participant