Skip to content

Allow exists to be used within expressions #301

@gkaracha

Description

@gkaracha

Hello! Is there a way to encode in Rel8 the following idiom?

SELECT ...
FROM table_name 
WHERE
  (condition1
  OR EXISTS (<some query here>)   -- this
  OR ...) 

More specifically, is there a way to use EXISTS in an Expr context? Currently exists seems to only work within Query, which makes it impossible to use it within a where_ clause

exists :: Query a -> Query (Expr Bool)

Is there a workaround for this at the moment? If not, are there any plans to implement this feature in the future?

For a little bit of context: in the project I'm currently working on we are trying to migrate from Hasql to Rel8 and a part of that is the conversion of filtering. The frontend sends potentially complex filters to the backend, which are then converted to an SQL expression that becomes part of a where_ clause. Hence the need to use exists within the Expr context.

Thanks for all the work you've put into this wonderful library!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions