Fix docs
This commit is contained in:
@@ -59,7 +59,7 @@ LocaleType
|
||||
IPAddressType
|
||||
^^^^^^^^^^^^^
|
||||
|
||||
.. module:: sqlalchemy_utils.types.ip_addresss
|
||||
.. module:: sqlalchemy_utils.types.ip_address
|
||||
|
||||
.. autoclass:: IPAddressType
|
||||
|
||||
|
@@ -4,7 +4,10 @@ Utility classes
|
||||
QueryChain
|
||||
----------
|
||||
|
||||
.. module:: sqlalchemy_utils.query_chain
|
||||
.. automodule:: sqlalchemy_utils.query_chain
|
||||
|
||||
API
|
||||
^^^
|
||||
|
||||
.. autoclass:: QueryChain
|
||||
:members:
|
||||
|
@@ -1,26 +1,33 @@
|
||||
from copy import copy
|
||||
"""
|
||||
QueryChain is a wrapper for sequence of queries.
|
||||
|
||||
|
||||
class QueryChain(object):
|
||||
"""
|
||||
QueryChain can be used as a wrapper for sequence of queries.
|
||||
|
||||
Features:
|
||||
Features:
|
||||
|
||||
* Easy iteration for sequence of queries
|
||||
* Limit and offset which are smartly applied to all queries
|
||||
* Limit and offset which are applied to all queries in the chain
|
||||
* Smart __getitem__ support
|
||||
|
||||
:param queries: A sequence of SQLAlchemy Query objects
|
||||
:param limit: Similar to normal query limit this parameter can be used for
|
||||
limiting the number of results for the whole query chain.
|
||||
:param offset: Similar to normal query offset this parameter can be used
|
||||
for offsetting the query chain as a whole.
|
||||
|
||||
Initialization
|
||||
^^^^^^^^^^^^^^
|
||||
|
||||
QueryChain takes iterable of queries as first argument. Additionally limit and
|
||||
offset parameters can be given
|
||||
|
||||
::
|
||||
|
||||
chain = QueryChain([session.query(User), session.query(Article)])
|
||||
|
||||
chain = QueryChain(
|
||||
[session.query(User), session.query(Article)],
|
||||
limit=4
|
||||
)
|
||||
|
||||
|
||||
Simple iteration
|
||||
^^^^^^^^^^^^^^^^
|
||||
::
|
||||
Simple iteration
|
||||
^^^^^^^^^^^^^^^^
|
||||
::
|
||||
|
||||
chain = QueryChain([session.query(User), session.query(Article)])
|
||||
|
||||
@@ -28,13 +35,13 @@ class QueryChain(object):
|
||||
print obj
|
||||
|
||||
|
||||
Limit and offset
|
||||
^^^^^^^^^^^^^^^^
|
||||
Limit and offset
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
||||
Lets say you have 5 blog posts, 5 articles and 5 news items in your
|
||||
database.
|
||||
Lets say you have 5 blog posts, 5 articles and 5 news items in your
|
||||
database.
|
||||
|
||||
::
|
||||
::
|
||||
|
||||
chain = QueryChain(
|
||||
[
|
||||
@@ -52,10 +59,10 @@ class QueryChain(object):
|
||||
list(chain) # last blog post, and first four articles
|
||||
|
||||
|
||||
Chain slicing
|
||||
^^^^^^^^^^^^^
|
||||
Chain slicing
|
||||
^^^^^^^^^^^^^
|
||||
|
||||
::
|
||||
::
|
||||
|
||||
chain = QueryChain(
|
||||
[
|
||||
@@ -66,8 +73,19 @@ class QueryChain(object):
|
||||
)
|
||||
|
||||
chain[3:6] # New QueryChain with offset=3 and limit=6
|
||||
"""
|
||||
from copy import copy
|
||||
|
||||
|
||||
class QueryChain(object):
|
||||
"""
|
||||
QueryChain can be used as a wrapper for sequence of queries.
|
||||
|
||||
:param queries: A sequence of SQLAlchemy Query objects
|
||||
:param limit: Similar to normal query limit this parameter can be used for
|
||||
limiting the number of results for the whole query chain.
|
||||
:param offset: Similar to normal query offset this parameter can be used
|
||||
for offsetting the query chain as a whole.
|
||||
|
||||
.. versionadded: 0.26.0
|
||||
"""
|
||||
|
Reference in New Issue
Block a user