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 "rank 2" catListTable (by "parsing" anonymous record) #243

Merged
merged 1 commit into from
Jun 18, 2023

Conversation

shane-circuithub
Copy link
Contributor

This is another possible "fix" to #168 (as opposed to #242). It doesn't really fix the problem, but it allows us to use two levels of catListTable instead of only one. Instead of trying to use Postgres's broken .f1 syntax, we cast the anonymous record to text, remove the parentheses and quotes and unescape any escaped quotes or backslashes, and then cast the resulting text back to the appropriate type. The reason this only works one level deep is that if the type we cast the text back to is itself an anonymous record, then PostgreSQL doesn't know how to parse the text.

It's kind of ugly and hacky but it does work and otherwise maintains the status quo. Comparison operators on nested lists continue to work as before and we don't need to burden DBType with parsing nonsense.

@shane-circuithub
Copy link
Contributor Author

@ocharles I'm tempted just to merge this now and revisit #242 if someone ever comes along wanting to do triple-nested catListTable, and just hope that Postgres gets better support for anonymous records (or nested 1D arrays!) in the mean time.

Base automatically changed from profunctor-fold-aggregator to master June 18, 2023 20:05
This is another possible "fix" to #168 (as opposed to #242). It doesn't really fix the problem, but it allows us to use two levels of `catListTable` instead of only one. Instead of trying to use Postgres's broken `.f1` syntax, we cast the anonymous record to text, remove the parentheses and quotes and unescape any escaped quotes or backslashes, and then cast the resulting text back to the appropriate type. The reason this only works one level deep is that if the type we cast the text back to is itself an anonymous record, then PostgreSQL doesn't know how to parse the text.

It's kind of ugly and hacky but it does work and otherwise maintains the status quo. Comparison operators on nested lists continue to work as before and we don't need to burden `DBType` with parsing nonsense.
@shane-circuithub shane-circuithub merged commit 2230452 into master Jun 18, 2023
@shane-circuithub shane-circuithub deleted the nested-array-parse branch June 18, 2023 20:57
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

Successfully merging this pull request may close these issues.

1 participant