[Sqlalchemy-tickets] Issue #4093: .all_ condition doesn't act as expected, documentation is unclear
Brought to you by:
zzzeek
From: Lars W. <iss...@bi...> - 2017-09-27 10:27:22
|
New issue 4093: .all_ condition doesn't act as expected, documentation is unclear https://bitbucket.org/zzzeek/sqlalchemy/issues/4093/all_-condition-doesnt-act-as-expected Lars Wikman: Unclear if this causes issues on other engines. Test case and my issue is postgres. It does not match up with what I'd expect from PostgreSQL ALL: https://www.postgresql.org/docs/9.1/static/functions-subquery.html#FUNCTIONS-SUBQUERY-ALL The code below throws a TypeError: Traceback (most recent call last): File "all_repro.py", line 32, in <module> posts = session.query(Post).filter(Post.title.all_(['test', 'test2'])).all() TypeError: all_() takes exactly 1 argument (2 given) I would expect it work similarly to .in_ where you can add a subquery and it will AND them rather than OR them. This part of the docs does show that it doesn't take any arguments, which fits with the error: http://docs.sqlalchemy.org/en/latest/core/sqlelement.html#sqlalchemy.sql.operators.ColumnOperators.all_ but it links to a part of the docs where it takes an argument though I think they should be the same? http://docs.sqlalchemy.org/en/latest/core/sqlelement.html#sqlalchemy.sql.expression.all_ ``` #!python # Issue against: SQLAlchemy==1.2.0b2 # Using psycopg2: psycopg2==2.7.3.1 # It does not match up with what I'd expect from PostgreSQL ALL: # https://www.postgresql.org/docs/9.1/static/functions-subquery.html#FUNCTIONS-SUBQUERY-ALL from sqlalchemy import create_engine from sqlalchemy.orm import sessionmaker import sys from sqlalchemy.ext.declarative import declarative_base from sqlalchemy import Column from sqlalchemy import String from sqlalchemy.orm import relationship Base = declarative_base() connection_string = sys.argv[1] # Just add it as an argument class Post(Base): __tablename__ = 'post' uuid = Column(String(72), primary_key=True) title = Column(String(200), nullable=True) engine = create_engine(connection_string) Base.metadata.create_all(engine) SessionClass = sessionmaker(bind=engine) session = SessionClass() posts = session.query(Post).filter(Post.title.all_(['test', 'test2'])).all() # Throws a TyperError: """ Traceback (most recent call last): File "all_repro.py", line 32, in <module> posts = session.query(Post).filter(Post.title.all_(['test', 'test2'])).all() TypeError: all_() takes exactly 1 argument (2 given) """ # I would expect it work similarly to .in_ where you can add a subquery # This part of the docs does show that it doesn't take any arguments: # http://docs.sqlalchemy.org/en/latest/core/sqlelement.html#sqlalchemy.sql.operators.ColumnOperators.all_ # but it links to a part of the docs where it takes and argument though I think they should be the same? # http://docs.sqlalchemy.org/en/latest/core/sqlelement.html#sqlalchemy.sql.expression.all_ ``` I hope this fits with the information you need. I couldn't find the issue previously reported. |