diff --git a/docs/model_helpers.rst b/docs/model_helpers.rst index 8942f9b..9fbf30d 100644 --- a/docs/model_helpers.rst +++ b/docs/model_helpers.rst @@ -16,6 +16,12 @@ escape_like .. autofunction:: escape_like +query_entities +^^^^^^^^^^^^^^ + +.. autofunction:: query_entities + + has_changes ^^^^^^^^^^^ diff --git a/sqlalchemy_utils/functions/orm.py b/sqlalchemy_utils/functions/orm.py index 2135fb3..9b925ba 100644 --- a/sqlalchemy_utils/functions/orm.py +++ b/sqlalchemy_utils/functions/orm.py @@ -127,9 +127,10 @@ def query_labels(query): def query_entities(query): """ - Return all entities for given SQLAlchemy query object. + Return a generator that iterates through all entities for given SQLAlchemy + query object. - Example:: + Examples:: query = session.query(Category) @@ -142,6 +143,14 @@ def query_entities(query): query_entities(query) # + This function also supports queries with joins: + + + query = session.query(Category).join(Article) + + query_entities(query) # (,
) + + :param query: SQLAlchemy Query object """ for entity in query._entities: