]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
most ORM tests passing in py3.1 with these changes
authorMike Bayer <mike_mp@zzzcomputing.com>
Tue, 26 May 2009 17:21:41 +0000 (17:21 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Tue, 26 May 2009 17:21:41 +0000 (17:21 +0000)
lib/sqlalchemy/engine/base.py
lib/sqlalchemy/orm/query.py
test/testlib/compat.py
test/testlib/sa_unittest.py

index 9d0f2cb4cd592f6cee09e563974f0899b7eee966..6f45c4ef535249ee84c3d07a9ae2dc9172b649b8 100644 (file)
@@ -1601,8 +1601,11 @@ class ResultProxy(object):
         for i, item in enumerate(metadata):
             colname = item[0]
 
+            # Py3K
+            # Py2K
             if self.dialect.description_encoding:
                 colname = colname.decode(self.dialect.description_encoding)
+            # end Py2K
 
             if '.' in colname:
                 # sqlite will in some circumstances prepend table name to colnames, so strip
index be40b08c658325df289d6465c551f7e8c42ad721..882e25f31b621fd6b34fdd1b6a722bd75b81e713 100644 (file)
@@ -579,7 +579,11 @@ class Query(object):
     def value(self, column):
         """Return a scalar result corresponding to the given column expression."""
         try:
+            # Py3K
+            #return self.values(column).__next__()[0]
+            # Py2K
             return self.values(column).next()[0]
+            # end Py2K
         except StopIteration:
             return None
 
index 674a2d50fb970c8955c584ebac4da22d72a01c89..c6af2ba2740789075cdff3aaf0decf7758906000 100644 (file)
@@ -5,7 +5,7 @@ import types
 import __builtin__
 
 
-__all__ = '_function_named', 'callable', 'py3k', 'jython', 'to_list'
+__all__ = '_function_named', 'callable', 'py3k', 'jython', 'to_list', 'cmp'
 
 py3k = getattr(sys, 'py3kwarning', False) or sys.version_info >= (3, 0)
 
@@ -36,9 +36,13 @@ def to_list(x, default=None):
 if py3k:
     def callable(fn):
         return hasattr(fn, '__call__')
+    def cmp(a, b):
+            return (a > b) - (a < b)
+        
 else:
     callable = __builtin__.callable
-
+    cmp = __builtin__.cmp
+    
 if sys.platform.startswith('java'):
     def gc_collect(*args):
         gc.collect()
index 7d7ea119e977cf45edbf358bc3aec2b14add3414..67a46a469429938ff7db6b05659a5ab03184aa88 100644 (file)
@@ -41,7 +41,7 @@ import sys
 import traceback
 import os
 import types
-from testlib.compat import callable
+from testlib.compat import callable, cmp
 
 ##############################################################################
 # Exported classes and functions