diff --git a/CHANGES.rst b/CHANGES.rst index 458f0ea..d6b56df 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -4,6 +4,12 @@ Changelog Here you can see the full list of changes between each SQLAlchemy-Utils release. +0.30.17 (2015-08-16) +^^^^^^^^^^^^^^^^^^^^ + +- Added correlate parameter to select_correlated_expression function + + 0.30.16 (2015-08-04) ^^^^^^^^^^^^^^^^^^^^ diff --git a/sqlalchemy_utils/__init__.py b/sqlalchemy_utils/__init__.py index bbc175c..e2b894f 100644 --- a/sqlalchemy_utils/__init__.py +++ b/sqlalchemy_utils/__init__.py @@ -92,4 +92,4 @@ from .types import ( # noqa WeekDaysType ) -__version__ = '0.30.16' +__version__ = '0.30.17' diff --git a/sqlalchemy_utils/relationships/__init__.py b/sqlalchemy_utils/relationships/__init__.py index 1bbb85d..5249b75 100644 --- a/sqlalchemy_utils/relationships/__init__.py +++ b/sqlalchemy_utils/relationships/__init__.py @@ -89,7 +89,8 @@ def select_correlated_expression( path, leaf_model, from_obj=None, - order_by=None + order_by=None, + correlate=True ): relationships = list(reversed(path_to_relationships(path, root_model))) @@ -112,6 +113,8 @@ def select_correlated_expression( query = query.select_from(join_expr.selectable) - return query.correlate( - from_obj if from_obj is not None else root_model - ).where(condition) + if correlate: + query = query.correlate( + from_obj if from_obj is not None else root_model + ) + return query.where(condition)