From 0d2efa1015bce232055579f95cc1fc3e11fdd122 Mon Sep 17 00:00:00 2001 From: Konsta Vesterinen Date: Thu, 13 Nov 2014 14:11:00 +0200 Subject: [PATCH] Remove deprecated has_any_changes function --- CHANGES.rst | 1 + sqlalchemy_utils/__init__.py | 4 +--- sqlalchemy_utils/functions/__init__.py | 2 -- sqlalchemy_utils/functions/orm.py | 31 ------------------------- tests/functions/test_has_any_changes.py | 24 ------------------- 5 files changed, 2 insertions(+), 60 deletions(-) delete mode 100644 tests/functions/test_has_any_changes.py diff --git a/CHANGES.rst b/CHANGES.rst index 395dc24..759392d 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -8,6 +8,7 @@ Here you can see the full list of changes between each SQLAlchemy-Utils release. ^^^^^^^^^^^^^^^^^^^ - Added is_loaded utility function +- Removed deprecated has_any_changes 0.27.7 (2014-11-03) diff --git a/sqlalchemy_utils/__init__.py b/sqlalchemy_utils/__init__.py index f23471a..7e75563 100644 --- a/sqlalchemy_utils/__init__.py +++ b/sqlalchemy_utils/__init__.py @@ -24,7 +24,6 @@ from .functions import ( get_referencing_foreign_keys, get_tables, group_foreign_keys, - has_any_changes, has_changes, has_index, has_unique_index, @@ -80,7 +79,7 @@ from .types import ( from .models import Timestamp -__version__ = '0.27.7' +__version__ = '0.27.8' __all__ = ( @@ -114,7 +113,6 @@ __all__ = ( get_referencing_foreign_keys, get_tables, group_foreign_keys, - has_any_changes, has_changes, has_index, identity, diff --git a/sqlalchemy_utils/functions/__init__.py b/sqlalchemy_utils/functions/__init__.py index 766d7b6..df5b12a 100644 --- a/sqlalchemy_utils/functions/__init__.py +++ b/sqlalchemy_utils/functions/__init__.py @@ -35,7 +35,6 @@ from .orm import ( get_query_entities, get_tables, getdotattr, - has_any_changes, has_changes, identity, is_loaded, @@ -63,7 +62,6 @@ __all__ = ( 'get_tables', 'getdotattr', 'group_foreign_keys', - 'has_any_changes', 'has_changes', 'identity', 'is_loaded', diff --git a/sqlalchemy_utils/functions/orm.py b/sqlalchemy_utils/functions/orm.py index a4f6d05..954ddb5 100644 --- a/sqlalchemy_utils/functions/orm.py +++ b/sqlalchemy_utils/functions/orm.py @@ -724,37 +724,6 @@ def has_changes(obj, attrs=None, exclude=None): ) -def has_any_changes(obj, columns): - """ - Simple shortcut function for checking if any of the given attributes of - given declarative model object have changes. - - - :: - - - from sqlalchemy_utils import has_any_changes - - - user = User() - - has_any_changes(user, ('name', )) # False - - user.name = u'someone' - - has_any_changes(user, ('name', 'age')) # True - - - .. versionadded: 0.26.3 - .. deprecated:: 0.26.6 - User :func:`has_changes` instead. - - :param obj: SQLAlchemy declarative model object - :param attrs: Names of the attributes - """ - return any(has_changes(obj, column) for column in columns) - - def is_loaded(obj, prop): """ Return whether or not given property of given object has been loaded. diff --git a/tests/functions/test_has_any_changes.py b/tests/functions/test_has_any_changes.py deleted file mode 100644 index 2411e55..0000000 --- a/tests/functions/test_has_any_changes.py +++ /dev/null @@ -1,24 +0,0 @@ -import sqlalchemy as sa -from sqlalchemy.ext.declarative import declarative_base - -from sqlalchemy_utils import has_any_changes - - -class TestHasAnyChanges(object): - def setup_method(self, method): - Base = declarative_base() - - class Article(Base): - __tablename__ = 'article_translation' - id = sa.Column(sa.Integer, primary_key=True) - title = sa.Column(sa.String(100)) - - self.Article = Article - - def test_without_changed_attr(self): - article = self.Article() - assert not has_any_changes(article, ['title']) - - def test_with_changed_attr(self): - article = self.Article(title='Some title') - assert has_any_changes(article, ['title', 'id'])