morphismtech / squeal

Squeal, a deep embedding of SQL in Haskell
350 stars 32 forks source link

polymorphic lateral context #251

Closed echatav closed 4 years ago

echatav commented 4 years ago

This change makes it possible to have polymorphic lateral context! When looking up a column heretofore, the relevant typeclasses would search through Join lat from. This is the "correct" ordering as far as the structure from left to right in the query, making lat consistently ordered as one goes through nested lateral joins or nested subquery expressions. However, it doesn't really matter how the lookup orders the columns. And if the lookup searches through Join from lat instead then thanks to good old Haskell lazy list appending, if a query only references columns in from then it will work no matter the lat. With a small proviso; if you leave lat polymorphic, then you must qualify all columns since there could be more than one table even if from has only one table in it.