summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/sqlalchemy/util.py18
-rw-r--r--test/dialect/postgres.py4
2 files changed, 18 insertions, 4 deletions
diff --git a/lib/sqlalchemy/util.py b/lib/sqlalchemy/util.py
index f2f2cdd79..297dd738f 100644
--- a/lib/sqlalchemy/util.py
+++ b/lib/sqlalchemy/util.py
@@ -4,7 +4,7 @@
# This module is part of SQLAlchemy and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
-import inspect, itertools, new, operator, sets, sys, warnings, weakref
+import inspect, itertools, new, operator, sys, warnings, weakref
import __builtin__
types = __import__('types')
@@ -18,8 +18,20 @@ except ImportError:
import dummy_threading as threading
from dummy_threading import local as ThreadLocal
-# TODO: 2.6 will whine about importing `sets`, but I think we still need it to
-# around to support older DB-API modules that return the 2.3 style set.
+if sys.version_info < (2, 6):
+ import sets
+else:
+ # 2.6 deprecates sets.Set, but we still need to be able to detect them
+ # in user code and as return values from DB-APIs
+ ignore = ('ignore', None, DeprecationWarning, None, 0)
+ try:
+ warnings.filters.insert(0, ignore)
+ except Exception:
+ import sets
+ else:
+ import sets
+ warnings.filters.remove(ignore)
+
set_types = set, sets.Set
EMPTY_SET = frozenset()
diff --git a/test/dialect/postgres.py b/test/dialect/postgres.py
index caafb39f6..45f9d289a 100644
--- a/test/dialect/postgres.py
+++ b/test/dialect/postgres.py
@@ -96,9 +96,11 @@ class ReturningTest(TestBase, AssertsExecutionResults):
self.assertEqual(result.fetchall(), [(1,)])
# Multiple inserts only return the last row
+ testing.db.echo = True
result2 = table.insert(postgres_returning=[table]).execute(
[{'persons': 2, 'full': False}, {'persons': 3, 'full': True}])
-
+ from pdb import set_trace; set_trace()
+ print vars(result2)
self.assertEqual(result2.fetchall(), [(3,3,True)])
result3 = table.insert(postgres_returning=[(table.c.id*2).label('double_id')]).execute({'persons': 4, 'full': False})