From: Mike Bayer Date: Sun, 5 Sep 2010 15:28:43 +0000 (-0400) Subject: - mapper _get_col_to_prop private method used X-Git-Tag: rel_0_6_4~10^2~1 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=7217711f46ed41f5d657f5f1b522a73ad2f307a0;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git - 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. - turned TODO in the history example into an assertion with a descriptive reason --- diff --git a/CHANGES b/CHANGES index 2fe9bbe57e..43b6336811 100644 --- a/CHANGES +++ b/CHANGES @@ -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 c2b283f1a0..d2d7c12477 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 f03dd63772..7d487ff2cd 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 78cd74d22c..d09621dc8b 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