~ubuntu-branches/debian/sid/sqlalchemy/sid

« back to all changes in this revision

Viewing changes to doc/build/orm/tutorial.rst

  • Committer: Package Import Robot
  • Author(s): Piotr Ożarowski
  • Date: 2014-06-27 20:17:13 UTC
  • mfrom: (1.4.28)
  • Revision ID: package-import@ubuntu.com-20140627201713-g6p1kq8q1qenztrv
Tags: 0.9.6-1
* New upstream release
* Remove Python 3.X build tag files, thanks to Matthias Urlichs for the
  patch (closes: #747852)
* python-fdb isn't in the Debian archive yet so default dialect for firebird://
  URLs is changed to obsolete kinterbasdb, thanks to Russell Stuart for the
  patch (closes: #752145)

Show diffs side-by-side

added added

removed removed

Lines of Context:
744
744
Here's a rundown of some of the most common operators used in
745
745
:func:`~sqlalchemy.orm.query.Query.filter`:
746
746
 
747
 
* equals::
 
747
* :meth:`equals <.ColumnOperators.__eq__>`::
748
748
 
749
749
    query.filter(User.name == 'ed')
750
750
 
751
 
* not equals::
 
751
* :meth:`not equals <.ColumnOperators.__ne__>`::
752
752
 
753
753
    query.filter(User.name != 'ed')
754
754
 
755
 
* LIKE::
 
755
* :meth:`LIKE <.ColumnOperators.like>`::
756
756
 
757
757
    query.filter(User.name.like('%ed%'))
758
758
 
759
 
* IN::
 
759
* :meth:`IN <.ColumnOperators.in_>`::
760
760
 
761
761
    query.filter(User.name.in_(['ed', 'wendy', 'jack']))
762
762
 
765
765
            session.query(User.name).filter(User.name.like('%ed%'))
766
766
    ))
767
767
 
768
 
* NOT IN::
 
768
* :meth:`NOT IN <.ColumnOperators.notin_>`::
769
769
 
770
770
    query.filter(~User.name.in_(['ed', 'wendy', 'jack']))
771
771
 
772
 
* IS NULL::
 
772
* :meth:`IS NULL <.ColumnOperators.is_>`::
773
773
 
774
774
    query.filter(User.name == None)
775
775
 
776
776
    # alternatively, if pep8/linters are a concern
777
777
    query.filter(User.name.is_(None))
778
778
 
779
 
* IS NOT NULL::
 
779
* :meth:`IS NOT NULL <.ColumnOperators.isnot>`::
780
780
 
781
781
    query.filter(User.name != None)
782
782
 
783
783
    # alternatively, if pep8/linters are a concern
784
784
    query.filter(User.name.isnot(None))
785
785
 
786
 
* AND::
 
786
* :func:`AND <.sql.expression.and_>`::
787
787
 
788
788
    # use and_()
789
789
    from sqlalchemy import and_
795
795
    # or chain multiple filter()/filter_by() calls
796
796
    query.filter(User.name == 'ed').filter(User.fullname == 'Ed Jones')
797
797
 
798
 
* OR::
 
798
* :func:`OR <.sql.expression.or_>`::
799
799
 
800
800
    from sqlalchemy import or_
801
801
    query.filter(or_(User.name == 'ed', User.name == 'wendy'))
802
802
 
803
 
* match::
 
803
* :meth:`MATCH <.ColumnOperators.match>`::
804
804
 
805
805
    query.filter(User.name.match('wendy'))
806
806
 
807
 
 The contents of the match parameter are database backend specific.
 
807
 .. note::
 
808
 
 
809
    :meth:`~.ColumnOperators.match` uses a database-specific ``MATCH``
 
810
    or ``CONTAINS`` function; its behavior will vary by backend and is not
 
811
    available on some backends such as SQLite.
808
812
 
809
813
Returning Lists and Scalars
810
814
---------------------------