circuithub / rel8

Hey! Hey! Can u rel8?
https://rel8.readthedocs.io
Other
154 stars 39 forks source link

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

Closed shane-circuithub closed 1 year ago

shane-circuithub commented 1 year ago

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 commented 1 year ago

@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.