Skip to content

Support "rank 2" catListTable (by "parsing" anonymous record)#243

Merged
shane-circuithub merged 1 commit intomasterfrom
nested-array-parse
Jun 18, 2023
Merged

Support "rank 2" catListTable (by "parsing" anonymous record)#243
shane-circuithub merged 1 commit intomasterfrom
nested-array-parse

Conversation

@shane-circuithub
Copy link
Copy Markdown
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
Copy Markdown
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.

@shane-circuithub shane-circuithub force-pushed the profunctor-fold-aggregator branch from 144366d to e28cc31 Compare June 18, 2023 19:57
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