sqlalchemy: or_ and and_() should emit a warning / someday raise an error with no arguments
This is using SQLAlchemy-1.3.12.
I would expect or_() to produce kind of false, but it has truthy behaviour.
Note, false is neutral element for disjunction (and true for conjunction), so I would expect adding false() to it didnβt change result, thatβs why I would expect following statements producing the same result:
print(session.query(literal(42)).filter(or_()).first())
# (42,)
print(session.query(literal(42)).filter(or_(false())).first())
# None
Note, that for and_ everything works as expected:
print(session.query(literal(42)).filter(and_()).first())
# (42,)
print(session.query(literal(42)).filter(and_(true())).first())
# (42,)
There might some rationale behind current behaviour I am missing.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 19 (18 by maintainers)
Commits related to this issue
- fix: SADeprecationWarning * SADeprecationWarning: Invoking or_() without arguments is deprecated, and will be disallowed in a future release. For an empty or_() construct, use 'or_(false(), *ar... — committed to utnapischtim/invenio-banners by utnapischtim 2 years ago
- fix: SADeprecationWarning * SADeprecationWarning: Invoking or_() without arguments is deprecated, and will be disallowed in a future release. For an empty or_() construct, use 'or_(false(), *ar... — committed to utnapischtim/invenio-banners by utnapischtim 2 years ago
- fix: SADeprecationWarning * SADeprecationWarning: Invoking or_() without arguments is deprecated, and will be disallowed in a future release. For an empty or_() construct, use 'or_(false(), *ar... — committed to inveniosoftware/invenio-banners by utnapischtim 2 years ago
- installation: bump dependencies π invenio-accounts (5.1.4 -> 5.1.5 π) release: v5.1.5 model: make forward compatible to sqlalchemy >= 2 π invenio-admin (1.4.0 -> 1.4.1 π) π¦ releas... — committed to ptamarit/zenodo-rdm by ptamarit 2 years ago
- installation: bump dependencies π invenio-accounts (5.1.4 -> 5.1.5 π) release: v5.1.5 model: make forward compatible to sqlalchemy >= 2 π invenio-admin (1.4.0 -> 1.4.1 π) π¦ releas... — committed to ptamarit/zenodo-rdm by ptamarit 2 years ago
- installation: bump dependencies π invenio-accounts (5.1.4 -> 5.1.5 π) release: v5.1.5 model: make forward compatible to sqlalchemy >= 2 π invenio-admin (1.4.0 -> 1.4.1 π) π¦ releas... — committed to zenodo/zenodo-rdm by ptamarit 2 years ago
- Fix SQLAlchemy deprecation warning about empty or() https://github.com/sqlalchemy/sqlalchemy/issues/5054 — committed to ucam-department-of-psychiatry/camcops by martinburchell 2 years ago
- Fix SQLAlchemy deprecation warning about empty or() https://github.com/sqlalchemy/sqlalchemy/issues/5054 — committed to ucam-department-of-psychiatry/camcops by martinburchell 2 years ago
- fix: SADeprecationWarning * SADeprecationWarning: Invoking or_() without arguments is deprecated, and will be disallowed in a future release. For an empty or_() construct, use 'or_(false(), *ar... — committed to utnapischtim/invenio-vocabularies by utnapischtim 2 years ago
- fix: SADeprecationWarning * SADeprecationWarning: Invoking or_() without arguments is deprecated, and will be disallowed in a future release. For an empty or_() construct, use 'or_(false(), *ar... — committed to utnapischtim/invenio-rdm-records by utnapischtim 2 years ago
- fix: SADeprecationWarning * SADeprecationWarning: Invoking or_() without arguments is deprecated, and will be disallowed in a future release. For an empty or_() construct, use 'or_(false(), *ar... — committed to utnapischtim/invenio-pages by utnapischtim 2 years ago
- fix: SADeprecationWarning * SADeprecationWarning: Invoking or_() without arguments is deprecated, and will be disallowed in a future release. For an empty or_() construct, use 'or_(false(), *ar... — committed to utnapischtim/invenio-jobs by utnapischtim 2 years ago
- fix: SADeprecationWarning * SADeprecationWarning: Invoking or_() without arguments is deprecated, and will be disallowed in a future release. For an empty or_() construct, use 'or_(false(), *ar... — committed to utnapischtim/invenio-rdm-records by utnapischtim 2 years ago
- fix: SADeprecationWarning * SADeprecationWarning: Invoking or_() without arguments is deprecated, and will be disallowed in a future release. For an empty or_() construct, use 'or_(false(), *ar... — committed to utnapischtim/invenio-rdm-records by utnapischtim 2 years ago
- fix: SADeprecationWarning * SADeprecationWarning: Invoking or_() without arguments is deprecated, and will be disallowed in a future release. For an empty or_() construct, use 'or_(false(), *ar... — committed to utnapischtim/invenio-rdm-records by utnapischtim 2 years ago
- fix: SADeprecationWarning * SADeprecationWarning: Invoking or_() without arguments is deprecated, and will be disallowed in a future release. For an empty or_() construct, use 'or_(false(), *ar... — committed to utnapischtim/invenio-rdm-records by utnapischtim 2 years ago
- fix: SADeprecationWarning * SADeprecationWarning: Invoking or_() without arguments is deprecated, and will be disallowed in a future release. For an empty or_() construct, use 'or_(false(), *ar... — committed to utnapischtim/invenio-vocabularies by utnapischtim 2 years ago
- fix: SADeprecationWarning * SADeprecationWarning: Invoking or_() without arguments is deprecated, and will be disallowed in a future release. For an empty or_() construct, use 'or_(false(), *ar... — committed to inveniosoftware/invenio-rdm-records by utnapischtim 2 years ago
- fix: SADeprecationWarning * SADeprecationWarning: Invoking or_() without arguments is deprecated, and will be disallowed in a future release. For an empty or_() construct, use 'or_(false(), *ar... — committed to inveniosoftware/invenio-vocabularies by utnapischtim 2 years ago
Iβll update the warning and make the changes to the test.
Maybe this guidance should also be in the documentation for
and_andor_?