diff options
author | mike bayer <mike_mp@zzzcomputing.com> | 2020-06-29 19:05:53 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@bbpush.zzzcomputing.com> | 2020-06-29 19:05:53 +0000 |
commit | 8a3b29ed238240ee725a9f338d256fdc3dc79d4e (patch) | |
tree | 8277a7a2afd5c89b3e451fd2955d6ffc2e60df34 | |
parent | 0139afccaad036e60f0b9ee5db5b96ec7d15159f (diff) | |
parent | 90a97ad9b63d5aa80439a20e7a9db450026d58de (diff) | |
download | sqlalchemy-8a3b29ed238240ee725a9f338d256fdc3dc79d4e.tar.gz |
Merge "Provide example for exists"
-rw-r--r-- | lib/sqlalchemy/sql/selectable.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/sqlalchemy/sql/selectable.py b/lib/sqlalchemy/sql/selectable.py index bf6f20436..59c292a07 100644 --- a/lib/sqlalchemy/sql/selectable.py +++ b/lib/sqlalchemy/sql/selectable.py @@ -4929,7 +4929,15 @@ class Exists(UnaryExpression): # use on an existing select() s = select([table.c.col1]).where(table.c.col2==5) - s = exists(s) + s_e = exists(s) + + # an exists is usually used in a where of another select + # to produce a WHERE EXISTS (SELECT ... ) + select([table.c.col1]).where(s_e) + + # but can also be used in a select to produce a + # SELECT EXISTS (SELECT ... ) query + select([s_e]) # construct a select() at once exists(['*'], **select_arguments).where(criterion) |