Conversation
|
Ohh, nice this looks interesting! Thanks so much for your PR. This change makes a lot of sense... I had noticed a lot of repetition when doing joins with tables where I was using all the columns. My only hesitation is that the last time I was working on the code, I remember making a quick hack to make sub-queries work on postgres involving automatically giving names to sub-queries (https://github.com/Gopiandcode/petrol/blob/e83d3c833b98a3a915949651316a04469417d7f5/lib/types.ml#L276), which I think is the cause of some issues discussed in #3. I was thinking of making some kind of large change to allow representing table aliases (JOIN ... AS B) explicitly in the DSL. |
No problem :) it was a fun PR. I don't know that the subquery problem will exist because there isn't a subquery when using the table this way (it's just a join on a table, so the resulting query should work fine in postgres or not, at least that is my understanding). That's why I have this part: I think it should avoid the problem. Either way, thanks for the response :) |
Hi @kiranandcode, if you still remember, could you elaborate? I'd like to look into it, but I'm a bit clueless, how table aliases could be added to the DSL. |
|
@royneary I don't have a great recollection of how that would work, but if I had to guess we could potentially add a "Named" term to the DSL which is constructed by a helper function |
Hi!
First off, really enjoying petrol. Thanks for the library.
I was wondering if this would be a welcome addition to the library. I'm not necessarily 100% sold on using
TABLEas a new variant, but I wasn't sure how else to handle this easily (and also allows inserting tables into other locations in queries later, if needed).Usage looks now like this:
Printed:
Thanks