self.returns_unicode_strings = self._check_unicode_returns(connection)
+ if self.description_encoding is not None and \
+ self._check_unicode_description(connection):
+ self._description_decoder = self.description_encoding = None
+
self.do_rollback(connection.connection)
def on_connect(self):
else:
return unicode_for_varchar
+ def _check_unicode_description(self, connection):
+ # all DBAPIs on Py2K return cursor.description as encoded,
+ # until pypy2.1beta2 with sqlite, so let's just check it -
+ # it's likely others will start doing this too in Py2k.
+
+ if util.py2k and not self.supports_unicode_statements:
+ cast_to = util.binary_type
+ else:
+ cast_to = util.text_type
+
+ cursor = connection.connection.cursor()
+ cursor.execute(
+ cast_to(
+ expression.select([
+ expression.literal_column("'x'").label("some_label")
+ ]).compile(dialect=self)
+ )
+ )
+ return isinstance(cursor.description[0][0], util.text_type)
+
def type_descriptor(self, typeobj):
"""Provide a database-specific :class:`.TypeEngine` object, given
the generic object which comes from the types module.
except AttributeError:
pass
else:
- return rec.checkout_existing()
+ if rec is not None:
+ return rec.checkout_existing()
return _ConnectionFairy.checkout(self, self._threadconns)
[pk]
)
- @exclusions.fails_if(lambda: util.pypy, "lastrowid not maintained after "
- "connection close")
+ # failed on pypy1.9 but seems to be OK on pypy 2.1
+ #@exclusions.fails_if(lambda: util.pypy, "lastrowid not maintained after "
+ # "connection close")
@requirements.dbapi_lastrowid
def test_native_lastrowid_autoinc(self):
r = config.db.execute(
control = set()
def assert_eq():
- self.assert_(set(direct) == canary.data)
- self.assert_(set(adapter) == canary.data)
- self.assert_(direct == control)
+ eq_(set(direct), canary.data)
+ eq_(set(adapter), canary.data)
+ eq_(direct, control)
def addall(*values):
for item in values:
addall(e)
addall(e)
- if hasattr(direct, 'pop'):
- direct.pop()
- control.pop()
- assert_eq()
if hasattr(direct, 'remove'):
e = creator()
control.clear()
assert_eq()
+ if hasattr(direct, 'pop'):
+ addall(creator())
+ direct.pop()
+ control.pop()
+ assert_eq()
+
if hasattr(direct, 'difference_update'):
zap()
e = creator()
except TypeError:
assert True
+
def _test_set_bulk(self, typecallable, creator=None):
if creator is None:
creator = self.entity_maker
from test.orm import _fixtures
from sqlalchemy.testing.assertsql import CompiledSQL
import logging
+import logging.handlers
class MapperTest(_fixtures.FixtureTest, AssertsCompiledSQL):
__dialect__ = 'default'
def non_broken_pickle(self):
from sqlalchemy.util import pickle
return only_if(
- lambda: pickle.__name__ == 'cPickle' or sys.version_info >= (3, 2),
- "Needs cPickle or newer Python 3 pickle"
+ lambda: not util.pypy and pickle.__name__ == 'cPickle'
+ or sys.version_info >= (3, 2),
+ "Needs cPickle+cPython or newer Python 3 pickle"
)