]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
merged -r5974:5987 of trunk
authorMike Bayer <mike_mp@zzzcomputing.com>
Thu, 28 May 2009 00:39:12 +0000 (00:39 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Thu, 28 May 2009 00:39:12 +0000 (00:39 +0000)
CHANGES
lib/sqlalchemy/exc.py
lib/sqlalchemy/orm/properties.py
test/base/except.py
test/orm/mapper.py

diff --git a/CHANGES b/CHANGES
index a2ba1c57209a45d970971ea2c7ae8838da8a29ce..4f47bfe09f93c54826b74e14f4855574d5b75e10 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -4,13 +4,29 @@
 CHANGES
 =======
 
+0.5.4p3
+=======
+- orm
+    - Fixed bug introduced in 0.5.4 whereby Composite types
+      fail when default-holding columns are flushed.
+    
 0.5.4p2
 =======
 
 - sql
     - Repaired the printing of SQL exceptions which are not 
-      based on parameters.
-
+      based on parameters or are not executemany() style.
+      
+- postgres
+    - Deprecated the hardcoded TIMESTAMP function, which when
+      used as func.TIMESTAMP(value) would render "TIMESTAMP value".
+      This breaks on some platforms as Postgres doesn't allow
+      bind parameters to be used in this context.  The hard-coded
+      uppercase is also inappropriate and there's lots of other
+      PG casts that we'd need to support.  So instead, use
+      text constructs i.e. select(["timestamp '12/05/09'"]).
+      
+      
 0.5.4p1
 =======
 
index f72bec6fdb1e6541928e48d39ebeae105895398b..f1678743d9397cef9362e8eecfb58b792cca8981 100644 (file)
@@ -132,11 +132,11 @@ class DBAPIError(SQLAlchemyError):
         self.connection_invalidated = connection_invalidated
 
     def __str__(self):
-        if self.params and len(self.params) > 10:
+        if isinstance(self.params, (list, tuple)) and len(self.params) > 10 and isinstance(self.params[0], (list, dict, tuple)):
             return ' '.join((SQLAlchemyError.__str__(self),
                              repr(self.statement),
                              repr(self.params[:2]),
-                             '... and a total of %i bound parameters' % len(self.params)))
+                             '... and a total of %i bound parameter sets' % len(self.params)))
         return ' '.join((SQLAlchemyError.__str__(self),
                          repr(self.statement), repr(self.params)))
 
index 5605cdcd1e83fbbf1dc31a4f00a11d32603b068a..2fa2cbd86488deb11adf67cc40378ae19449658a 100644 (file)
@@ -171,7 +171,7 @@ class CompositeProperty(ColumnProperty):
         obj = state.get_impl(self.key).get(state, state.dict)
         if obj is None:
             obj = self.composite_class(*[None for c in self.columns])
-            state.get_impl(self.key).set(state, obj, None)
+            state.get_impl(self.key).set(state, state.dict, obj, None)
 
         if hasattr(obj, '__set_composite_values__'):
             values = list(obj.__composite_values__())
index eddd9221e29e41b2e0e0c3f8389b862fff01741e..37558e335936af4395fbd848c019957e065d2bac 100644 (file)
@@ -29,7 +29,53 @@ class WrapTest(unittest.TestCase):
                 '', [], OperationalError())
         except sa_exceptions.DBAPIError:
             self.assert_(True)
+    
+    def test_tostring(self):
+        try:
+            raise sa_exceptions.DBAPIError.instance(
+                'this is a message', None, OperationalError())
+        except sa_exceptions.DBAPIError, exc:
+            assert str(exc) == "(OperationalError)  'this is a message' None"
+
+    def test_tostring_large_dict(self):
+        try:
+            raise sa_exceptions.DBAPIError.instance(
+                'this is a message', {'a':1, 'b':2, 'c':3, 'd':4, 'e':5, 'f':6, 'g':7, 'h':8, 'i':9, 'j':10, 'k':11}, OperationalError())
+        except sa_exceptions.DBAPIError, exc:
+            assert str(exc).startswith("(OperationalError)  'this is a message' {")
 
+    def test_tostring_large_list(self):
+        try:
+            raise sa_exceptions.DBAPIError.instance(
+                'this is a message', [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], OperationalError())
+        except sa_exceptions.DBAPIError, exc:
+            assert str(exc).startswith("(OperationalError)  'this is a message' [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]")
+
+    def test_tostring_large_executemany(self):
+        try:
+            raise sa_exceptions.DBAPIError.instance(
+                'this is a message', [{1:1},{1:1},{1:1},{1:1},{1:1},{1:1},{1:1},{1:1},{1:1},{1:1},], OperationalError())
+        except sa_exceptions.DBAPIError, exc:
+            assert str(exc) == "(OperationalError)  'this is a message' [{1: 1}, {1: 1}, {1: 1}, {1: 1}, {1: 1}, {1: 1}, {1: 1}, {1: 1}, {1: 1}, {1: 1}]", str(exc)
+
+        try:
+            raise sa_exceptions.DBAPIError.instance(
+                'this is a message', [{1:1},{1:1},{1:1},{1:1},{1:1},{1:1},{1:1},{1:1},{1:1},{1:1},{1:1},], OperationalError())
+        except sa_exceptions.DBAPIError, exc:
+            assert str(exc) == "(OperationalError)  'this is a message' [{1: 1}, {1: 1}] ... and a total of 11 bound parameter sets"
+
+        try:
+            raise sa_exceptions.DBAPIError.instance(
+                'this is a message', [(1,), (1,), (1,), (1,), (1,), (1,), (1,), (1,), (1,), (1,)], OperationalError())
+        except sa_exceptions.DBAPIError, exc:
+            assert str(exc) == "(OperationalError)  'this is a message' [(1,), (1,), (1,), (1,), (1,), (1,), (1,), (1,), (1,), (1,)]"
+
+        try:
+            raise sa_exceptions.DBAPIError.instance(
+                'this is a message', [(1,), (1,), (1,), (1,), (1,), (1,), (1,), (1,), (1,), (1,), (1,), ], OperationalError())
+        except sa_exceptions.DBAPIError, exc:
+            assert str(exc) == "(OperationalError)  'this is a message' [(1,), (1,)] ... and a total of 11 bound parameter sets"
+        
     def test_db_error_busted_dbapi(self):
         try:
             raise sa_exceptions.DBAPIError.instance(
index 26a76301f29f92bbe600b1132a9419c43c7c2bfa..ee3a8b6f06722a128a79b5d28ab5ece759148a9f 100644 (file)
@@ -1918,6 +1918,13 @@ class CompositeTypesTest(_base.MappedTest):
         sess.flush()
 
         assert f1.foob == FBComposite(2, 5, 15, None)
+        
+        
+        f2 = Foobar()
+        sess.add(f2)
+        sess.flush()
+        assert f2.foob == FBComposite(2, None, 15, None)
+        
     
     @testing.resolve_artifact_names
     def test_set_composite_values(self):