From 4a5d3554ff56940ab8a266d5198dec67d2ea2a04 Mon Sep 17 00:00:00 2001 From: Konsta Vesterinen Date: Wed, 30 Oct 2013 14:47:52 +0200 Subject: [PATCH] Added docs for has_changes --- sqlalchemy_utils/functions/__init__.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/sqlalchemy_utils/functions/__init__.py b/sqlalchemy_utils/functions/__init__.py index 80bf863..0ac53be 100644 --- a/sqlalchemy_utils/functions/__init__.py +++ b/sqlalchemy_utils/functions/__init__.py @@ -182,6 +182,22 @@ def has_changes(obj, attr): Simple shortcut function for checking if given attribute of given declarative model object has changed during the transaction. + + :: + + + from sqlalchemy_utils import has_changes + + + user = User() + + has_changes(user, 'name') # False + + user.name = u'someone' + + has_changes(user, 'name') # True + + :param obj: SQLAlchemy declarative model object :param attr: Name of the attribute """