]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- The warning emitted by the Unicode and String types
authorMike Bayer <mike_mp@zzzcomputing.com>
Sun, 13 Jun 2010 20:09:13 +0000 (16:09 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sun, 13 Jun 2010 20:09:13 +0000 (16:09 -0400)
with convert_unicode=True no longer embeds the actual
value passed.   This so that the Python warning
registry does not continue to grow in size, the warning
is emitted once as per the warning filter settings,
and large string values don't pollute the output.
[ticket:1822]

CHANGES
lib/sqlalchemy/types.py
test/aaa_profiling/test_memusage.py

diff --git a/CHANGES b/CHANGES
index b7a92783d7b91e55e19ad1779cf5c7d79cfd7e50..efd95605de03db506c0ca3e13fc2b4a34663b708 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -6,6 +6,14 @@ CHANGES
 0.6.2
 =====
 - sql
+  - The warning emitted by the Unicode and String types
+    with convert_unicode=True no longer embeds the actual
+    value passed.   This so that the Python warning
+    registry does not continue to grow in size, the warning
+    is emitted once as per the warning filter settings, 
+    and large string values don't pollute the output.
+    [ticket:1822]
+    
   - Fixed bug in Enum type which blew away native_enum
     flag when used with TypeDecorators or other adaption
     scenarios.
index 356ec2ecb73bf9e58d5090145a2f751b3c9765e4..84bd85ff2ddb9b001b71a26997d3a07338334619 100644 (file)
@@ -729,7 +729,7 @@ class String(Concatenable, TypeEngine):
                         if isinstance(value, str):
                         # end Py2K
                             util.warn("Unicode type received non-unicode bind "
-                                      "param value %r" % value)
+                                      "param value.")
                         return value
                     return process
                 else:
@@ -741,7 +741,7 @@ class String(Concatenable, TypeEngine):
                         return encoder(value, self.unicode_error)[0]
                     elif value is not None:
                         util.warn("Unicode type received non-unicode bind "
-                                  "param value %r" % value)
+                                  "param value")
                     return value
             return process
         else:
index 682411093da5205f99b8b8e2feb2024cc61f97a2..491a57fb019bba092ff059284b14a1b58a8ef715 100644 (file)
@@ -7,7 +7,7 @@ from sqlalchemy.util import jython
 import operator
 from sqlalchemy.test import testing, engines
 from sqlalchemy import MetaData, Integer, String, ForeignKey, \
-                            PickleType, create_engine
+                            PickleType, create_engine, Unicode
 from sqlalchemy.test.schema import Table, Column
 import sqlalchemy as sa
 from sqlalchemy.sql import column
@@ -252,6 +252,29 @@ class MemUsageTest(EnsureZeroed):
             go()
         finally:
             metadata.drop_all()
+    
+    def test_unicode_warnings(self):
+        metadata = MetaData(testing.db)
+        table1 = Table("mytable", metadata,
+            Column('col1', Integer, primary_key=True,
+                                test_needs_autoincrement=True),
+            Column('col2', Unicode(30)))
+        
+        metadata.create_all()
+        
+        i = [1]
+        @testing.emits_warning()
+        @profile_memory
+        def go():
+            # execute with a non-unicode object.
+            # a warning is emitted, this warning shouldn't
+            # clog up memory.
+            testing.db.execute(table1.select().where(table1.c.col2=='foo%d' % i[0]))
+            i[0] += 1
+        try:
+            go()
+        finally:
+            metadata.drop_all()
         
     def test_mapper_reset(self):
         metadata = MetaData(testing.db)