bitemyapp / esqueleto

New home of Esqueleto, please file issues so we can get things caught up!
BSD 3-Clause "New" or "Revised" License
370 stars 107 forks source link

Add support of PostgreSQL-specific `VALUES(..)` expression #284

Closed NikitaRazmakhnin closed 2 years ago

NikitaRazmakhnin commented 2 years ago

At my company we really wanted to use VALUES Postgres expression to use it inside of JOIN between large db data-set with some smaller user-input data-set without loading of data into app-memory. VALUES allows us to do that and even gives performance benefit to our app.

I think it is a relevant issue https://github.com/bitemyapp/esqueleto/issues/231 :)

This PR tries to bring an ability to use like:

SQL : SELECT * FROM (VALUES (a1), (a2) ...) as "vs"("v1") Haskell: select $ from $ values [val 1, val 2, val 3]

It also works for more than one columns as well (a bit doubting about aliases/refs assembling but works good so far). :)

I implemented it as part of From and thanks to latest refactoring from GADTs to type-classes it was not so difficult :)

Few appropriate semi-integrational tests with other sql capabilities as join, sinigle/multicolumn were added as well.

Please, let me know if I made something in a wrong way - I am ready to try to fix :)

Thanks!

Before submitting your PR, check that you've:

After submitting your PR:

parsonsmatt commented 2 years ago

Try merging master once #285 is pulled in