]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Don't use repr() for Column/ColumnClause in warning
authorMike Bayer <mike_mp@zzzcomputing.com>
Mon, 11 Sep 2017 03:08:30 +0000 (23:08 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Mon, 11 Sep 2017 03:08:30 +0000 (23:08 -0400)
for #4073, use the string version of the column expression
in the warning, otherwise the repr() is showing the hex id
which causes unlimited warnings.

Change-Id: I6869b685b237e7f02c7b5071701dd63a3577182a

lib/sqlalchemy/orm/evaluator.py
test/orm/test_evaluator.py

index 3f2a83a0295294280138934ecb1aa0b3f9347243..c58aaebbf91c7df3ed273e51fda5da1280b5af09 100644 (file)
@@ -62,9 +62,10 @@ class EvaluatorCompiler(object):
             key = parentmapper._columntoproperty[clause].key
         else:
             key = clause.key
-            if self.target_cls and key in inspect(self.target_cls).column_attrs:
+            if self.target_cls and \
+                    key in inspect(self.target_cls).column_attrs:
                 util.warn(
-                    "Evaluating non-mapped column expression '%r' onto "
+                    "Evaluating non-mapped column expression '%s' onto "
                     "ORM instances; this is a deprecated use case.  Please "
                     "make use of the actual mapped columns in ORM-evaluated "
                     "UPDATE / DELETE expressions." % clause)
index dc96dc15da2e2d8e4016304a433d304cbb3587ea..fca050ccf09beb24f1736d95dbc53b53701aff34 100644 (file)
@@ -91,7 +91,7 @@ class EvaluateTest(fixtures.MappedTest):
         compiler = evaluator.EvaluatorCompiler(User)
 
         with expect_warnings(
-            r"Evaluating non-mapped column expression 'Column\('othername'.* "
+            r"Evaluating non-mapped column expression 'othername' "
                 "onto ORM instances; this is a deprecated use case."):
             meth = compiler.process(User.name == Column('othername', String))