diff options
| -rw-r--r-- | CHANGES | 5 | ||||
| -rw-r--r-- | examples/versioning/history_meta.py | 6 | ||||
| -rw-r--r-- | lib/sqlalchemy/orm/mapper.py | 12 | ||||
| -rw-r--r-- | lib/sqlalchemy/test/testing.py | 1 |
4 files changed, 22 insertions, 2 deletions
@@ -160,6 +160,11 @@ CHANGES with significant (~90%) runtime mapper.py call count reduction in heavily polymorphic mapping configurations. + - mapper _get_col_to_prop private method used + by the versioning example is deprecated; + now use mapper.get_property_by_column() which + will remain the public method for this. + - sql - Added basic math expression coercion for Numeric->Integer, diff --git a/examples/versioning/history_meta.py b/examples/versioning/history_meta.py index c2b283f1a..d2d7c1247 100644 --- a/examples/versioning/history_meta.py +++ b/examples/versioning/history_meta.py @@ -123,7 +123,7 @@ def create_version(obj, session, deleted = False): # mapped column. this will allow usage of MapperProperties # that have a different keyname than that of the mapped column. try: - prop = obj_mapper._get_col_to_prop(obj_col) + prop = obj_mapper.get_property_by_column(obj_col) except UnmappedColumnError: # in the case of single table inheritance, there may be # columns on the mapped table intended for the subclass only. @@ -144,7 +144,9 @@ def create_version(obj, session, deleted = False): elif u: attr[hist_col.key] = u[0] else: - raise Exception("TODO: what makes us arrive here ?") + assert False, "Attribute had no previous state. "\ + "This indicates active_history isn't "\ + "working as expected." if not obj_changed and not deleted: return diff --git a/lib/sqlalchemy/orm/mapper.py b/lib/sqlalchemy/orm/mapper.py index f03dd6377..7d487ff2c 100644 --- a/lib/sqlalchemy/orm/mapper.py +++ b/lib/sqlalchemy/orm/mapper.py @@ -931,7 +931,19 @@ class Mapper(object): "Mapper '%s' has no property '%s'" % (self, key)) else: return None + + @util.deprecated('0.7', + 'Call to deprecated function mapper._get_col_to_pr' + 'op(). Use mapper.get_property_by_column()') + def _get_col_to_prop(self, col): + return self._columntoproperty[col] + + def get_property_by_column(self, column): + """Given a :class:`.Column` object, return the + :class:`.MapperProperty` which maps this column.""" + return self._columntoproperty[column] + @property def iterate_properties(self): """return an iterator of all MapperProperty objects.""" diff --git a/lib/sqlalchemy/test/testing.py b/lib/sqlalchemy/test/testing.py index 78cd74d22..d09621dc8 100644 --- a/lib/sqlalchemy/test/testing.py +++ b/lib/sqlalchemy/test/testing.py @@ -398,6 +398,7 @@ def uses_deprecated(*messages): verbiage emitted by the sqlalchemy.util.deprecated decorator. """ + def decorate(fn): def safe(*args, **kw): # todo: should probably be strict about this, too |
