From 1d06f07077723fd3ca1fb6dcc2c5688868d9dadd Mon Sep 17 00:00:00 2001 From: Konsta Vesterinen Date: Tue, 5 May 2015 14:13:12 +0300 Subject: [PATCH] Make foreign key helpers SA 1.0 compliant --- CHANGES.rst | 2 ++ setup.py | 2 +- sqlalchemy_utils/functions/foreign_keys.py | 2 +- tests/functions/test_make_order_by_deterministic.py | 2 +- tests/functions/test_non_indexed_foreign_keys.py | 2 +- 5 files changed, 6 insertions(+), 4 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 2b2239e..c82abbd 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -9,7 +9,9 @@ Here you can see the full list of changes between each SQLAlchemy-Utils release. - Drop undocumented batch fetch feature. Let's wait until the inner workings of SQLAlchemy loading API is well-documented. - Fixed GenericRelationshipProperty comparator to work with SA 1.0.x (#139) +- Make all foreign key helpers SA 1.0 compliant - Make translation_hybrid expression work the same way as SQLAlchemy-i18n translation expressions +- Update SQLAlchemy dependency to 1.0 0.30.0 (2015-04-15) diff --git a/setup.py b/setup.py index 02d8a52..50b012b 100644 --- a/setup.py +++ b/setup.py @@ -83,7 +83,7 @@ setup( ], install_requires=[ 'six', - 'SQLAlchemy>=0.9.9', + 'SQLAlchemy>=1.0', 'total_ordering>=0.1' if sys.version_info[0] == 2 and sys.version_info[1] < 7 else '', 'ordereddict>=1.1' diff --git a/sqlalchemy_utils/functions/foreign_keys.py b/sqlalchemy_utils/functions/foreign_keys.py index c9a0ef2..e1da428 100644 --- a/sqlalchemy_utils/functions/foreign_keys.py +++ b/sqlalchemy_utils/functions/foreign_keys.py @@ -14,7 +14,7 @@ from .orm import get_column_key, get_mapper, get_tables def get_foreign_key_values(fk, obj): return dict( ( - fk.constraint.columns[index].key, + fk.constraint.columns.values()[index].key, getattr(obj, element.column.key) ) for diff --git a/tests/functions/test_make_order_by_deterministic.py b/tests/functions/test_make_order_by_deterministic.py index 70d9aa8..632b1ca 100644 --- a/tests/functions/test_make_order_by_deterministic.py +++ b/tests/functions/test_make_order_by_deterministic.py @@ -64,7 +64,7 @@ class TestMakeOrderByDeterministic(TestCase): def test_string_order_by(self): query = self.session.query(self.User).order_by('name') query = make_order_by_deterministic(query) - assert_contains('ORDER BY name, "user".id ASC', query) + assert_contains('ORDER BY "user".name, "user".id ASC', query) def test_annotated_label(self): query = self.session.query(self.User).order_by(self.User.article_count) diff --git a/tests/functions/test_non_indexed_foreign_keys.py b/tests/functions/test_non_indexed_foreign_keys.py index 46a9d51..4f8a30e 100644 --- a/tests/functions/test_non_indexed_foreign_keys.py +++ b/tests/functions/test_non_indexed_foreign_keys.py @@ -44,7 +44,7 @@ class TestFindNonIndexedForeignKeys(TestCase): fks ) column_names = [ - column_name for column_name in fks['article'][0].columns + column_name for column_name in fks['article'][0].columns.keys() ] assert 'category_id' in column_names assert 'author_id' not in column_names