Skip to content

Commit

Permalink
Merge 9ffd172 into b8d2d9e
Browse files Browse the repository at this point in the history
  • Loading branch information
seth-p committed Dec 8, 2014
2 parents b8d2d9e + 9ffd172 commit 806c786
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ nosetests.xml
.project
.pydevproject

# PyCharm
.idea

# virtualenv
/env

Expand Down
4 changes: 4 additions & 0 deletions alchy/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,10 @@ def expunge(self, *args, **kargs):
"""Call ``session.expunge()`` on ``self``"""
self.session().expunge(self, *args, **kargs)

def is_modified(self, *args, **kargs):
"""Call ``session.is_modified()`` on ``self``"""
return self.session().is_modified(self, *args, **kargs)

@classmethod
def get(cls, *args, **kargs):
"""Proxy to ``cls.query.get()``"""
Expand Down
10 changes: 10 additions & 0 deletions tests/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,3 +465,13 @@ class Obj2(Model, Mixin, Abstract):

self.assertEqual(Obj2.__mapper_args__,
{'column_prefix': '__', 'order_by': 'string'})

def test_is_modified(self):
record = Foo.get(1)
self.assertEqual(record.is_modified(), False)

record.number += 1
self.assertEqual(record.is_modified(), True)

record.refresh()
self.assertEqual(record.is_modified(), False)

0 comments on commit 806c786

Please sign in to comment.