sea-query icon indicating copy to clipboard operation
sea-query copied to clipboard

Support `EXISTS (subquery)` operator

Open MuhannadAlrusayni opened this issue 4 years ago • 5 comments

Hi, I'm trying to do simple query and use EXISTS (subquery) operator, but it looks it's not supported yet in sea-query.

.e.g:

select exists(select 1 from accounts where email = $1 limit 1) as "exists!"

MuhannadAlrusayni avatar Aug 31 '21 14:08 MuhannadAlrusayni

I think it can be done like

Query::select().expr(Expr::cust("COUNT(*) AS count")).from_subquery(...);

tyt2y3 avatar Sep 13 '21 15:09 tyt2y3

Yeah that's work too, but I'm not sure about the query performance count() vs `exists(). I'm no expert in query performance things.

And I think we should have exists() sooner or later.

MuhannadAlrusayni avatar Sep 13 '21 15:09 MuhannadAlrusayni

+1 on having exists()

penso avatar Jul 01 '22 18:07 penso

I will look at the issue

ikrivosheev avatar Jul 01 '22 18:07 ikrivosheev

Hello! I create PR: https://github.com/SeaQL/sea-query/issues/118.

ikrivosheev avatar Jul 04 '22 17:07 ikrivosheev