Remove deprecated has_any_changes function
This commit is contained in:
@@ -8,6 +8,7 @@ Here you can see the full list of changes between each SQLAlchemy-Utils release.
|
|||||||
^^^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
- Added is_loaded utility function
|
- Added is_loaded utility function
|
||||||
|
- Removed deprecated has_any_changes
|
||||||
|
|
||||||
|
|
||||||
0.27.7 (2014-11-03)
|
0.27.7 (2014-11-03)
|
||||||
|
@@ -24,7 +24,6 @@ from .functions import (
|
|||||||
get_referencing_foreign_keys,
|
get_referencing_foreign_keys,
|
||||||
get_tables,
|
get_tables,
|
||||||
group_foreign_keys,
|
group_foreign_keys,
|
||||||
has_any_changes,
|
|
||||||
has_changes,
|
has_changes,
|
||||||
has_index,
|
has_index,
|
||||||
has_unique_index,
|
has_unique_index,
|
||||||
@@ -80,7 +79,7 @@ from .types import (
|
|||||||
from .models import Timestamp
|
from .models import Timestamp
|
||||||
|
|
||||||
|
|
||||||
__version__ = '0.27.7'
|
__version__ = '0.27.8'
|
||||||
|
|
||||||
|
|
||||||
__all__ = (
|
__all__ = (
|
||||||
@@ -114,7 +113,6 @@ __all__ = (
|
|||||||
get_referencing_foreign_keys,
|
get_referencing_foreign_keys,
|
||||||
get_tables,
|
get_tables,
|
||||||
group_foreign_keys,
|
group_foreign_keys,
|
||||||
has_any_changes,
|
|
||||||
has_changes,
|
has_changes,
|
||||||
has_index,
|
has_index,
|
||||||
identity,
|
identity,
|
||||||
|
@@ -35,7 +35,6 @@ from .orm import (
|
|||||||
get_query_entities,
|
get_query_entities,
|
||||||
get_tables,
|
get_tables,
|
||||||
getdotattr,
|
getdotattr,
|
||||||
has_any_changes,
|
|
||||||
has_changes,
|
has_changes,
|
||||||
identity,
|
identity,
|
||||||
is_loaded,
|
is_loaded,
|
||||||
@@ -63,7 +62,6 @@ __all__ = (
|
|||||||
'get_tables',
|
'get_tables',
|
||||||
'getdotattr',
|
'getdotattr',
|
||||||
'group_foreign_keys',
|
'group_foreign_keys',
|
||||||
'has_any_changes',
|
|
||||||
'has_changes',
|
'has_changes',
|
||||||
'identity',
|
'identity',
|
||||||
'is_loaded',
|
'is_loaded',
|
||||||
|
@@ -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):
|
def is_loaded(obj, prop):
|
||||||
"""
|
"""
|
||||||
Return whether or not given property of given object has been loaded.
|
Return whether or not given property of given object has been loaded.
|
||||||
|
@@ -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'])
|
|
Reference in New Issue
Block a user