Skip to content

Support sub query expressions (ANY, SOME, ALL, EXISTS) in PostgreSQL and MySQL #618

@manhrev

Description

@manhrev

I can't find a way to express sub query expressions, for examples:

# ANY / SOME / ALL subquery
...
WHERE book_type = ANY (?)

# EXISTS subquery
...
WHERE EXISTS(
   SELECT 1 FROM ...
)

Currenty, I workaround this by using F() but I don't think this is the corect approach:

sm.Where(
   psql.F("EXISTS", existQuery),
)

I think we should add dedicated starters for those expressions, such as Exists(...Expression), Any(...Expression), etc. Both PostgreSQL and MySQL support those operator, while SQLite supports EXISTS only.
Actually, IN and NOT IN belong to the same category of operators and are already supported through operator chaining but other operators that I mention can't be implemented like that.

Bonus: I also can’t find a way to express the unary minus operator (-). Should this be added as a starter as well?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions