ulule/loukoum

How to Select Exists ?

ferhatelmas opened this issue · 2 comments

How to write following query ?

SELECT EXISTS (SELECT 1)

One try:

lk.Select(lk.Exists(lk.Select("1"))).String()

It fails like this:

panic: loukoum: cannot use stmt.Exists as column

I checked tests and it was only tested as a condition. Missing anything ?

novln commented

Hello,

Loukoum support only a subset of PostgreSQL (at the moment).
Select currently expect columns and that's why it panic.

Until we fix that, you could use this workaround:

lk.Select("EXISTS (SELECT 1)")

Thank you for submitting this issue.

Cheers,

novln commented

@ferhatelmas I've added support of few expressions for select, hope that helps 🙂

https://github.com/ulule/loukoum/blob/dev/builder/select_test.go#L60