diff --git a/CHANGES.rst b/CHANGES.rst index 912241b..31c1d2a 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.16.16 (2013-09-18) +^^^^^^^^^^^^^^^^^^^^ + +- Fixed fatal bug in batch fetch join table inheritance handling (not handling one-to-many relations properly) + + 0.16.15 (2013-09-17) ^^^^^^^^^^^^^^^^^^^^ diff --git a/setup.py b/setup.py index 04ba542..7cef0c9 100644 --- a/setup.py +++ b/setup.py @@ -56,7 +56,7 @@ for name, requirements in extras_require.items(): setup( name='SQLAlchemy-Utils', - version='0.16.15', + version='0.16.16', url='https://github.com/kvesteri/sqlalchemy-utils', license='BSD', author='Konsta Vesterinen, Ryan Leckey, Janne Vanhala, Vesa Uimonen', diff --git a/sqlalchemy_utils/__init__.py b/sqlalchemy_utils/__init__.py index a7e707e..387306b 100644 --- a/sqlalchemy_utils/__init__.py +++ b/sqlalchemy_utils/__init__.py @@ -38,7 +38,7 @@ from .types import ( ) -__version__ = '0.16.15' +__version__ = '0.16.16' __all__ = ( diff --git a/sqlalchemy_utils/functions/batch_fetch.py b/sqlalchemy_utils/functions/batch_fetch.py index ad4cfa2..a76a796 100644 --- a/sqlalchemy_utils/functions/batch_fetch.py +++ b/sqlalchemy_utils/functions/batch_fetch.py @@ -8,6 +8,10 @@ from sqlalchemy.orm.attributes import ( from sqlalchemy.orm.session import object_session +class PathException(Exception): + pass + + class with_backrefs(object): """ Marks given attribute path so that whenever its fetched with batch_fetch @@ -27,7 +31,7 @@ class Path(object): self.entities = entities self.populate_backrefs = populate_backrefs if not isinstance(self.property, RelationshipProperty): - raise Exception( + raise PathException( 'Given attribute is not a relationship property.' ) self.fetcher = self.fetcher_class(self) @@ -65,7 +69,7 @@ class Path(object): elif isinstance(path, InstrumentedAttribute): attr = path else: - raise Exception('Unknown path type.') + raise PathException('Unknown path type.') return Path(entities, attr.property, populate_backrefs) @@ -181,7 +185,7 @@ class CompositeFetcher(object): fetchers[0].path.model == fetcher.path.model for fetcher in fetchers ): - raise Exception( + raise PathException( 'Each relationship property must have the same class when ' 'using CompositeFetcher.' ) @@ -321,7 +325,7 @@ class Fetcher(object): ) return sa.or_(*conditions) else: - raise Exception( + raise PathException( 'Could not obtain remote column names.' ) @@ -354,7 +358,7 @@ class ManyToManyFetcher(Fetcher): for local, remote in self.prop.local_remote_pairs: for fk in remote.foreign_keys: if fk.column.table in self.prop.parent.tables: - names.append(fk.parent.name) + names.append(remote.name) return names @property