summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/sql
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2014-01-17 17:36:43 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2014-01-17 17:36:43 -0500
commit882f615c68cd2d244a8d2cf480f3532a84bdb6fa (patch)
tree546c82bc04351bca317f570f1a696ebc3ae5674e /lib/sqlalchemy/sql
parent4765895d10ff4bc89f30c99fa709438fa9764b6c (diff)
downloadsqlalchemy-882f615c68cd2d244a8d2cf480f3532a84bdb6fa.tar.gz
- rework Oracle to no longer do its own unicode conversion; this has been observed
to be very slow. this now has the effect of producing "conditional" unicode conversion for the Oracle backend, as it still returns NVARCHAR etc. as unicode [ticket:2911] - add new "conditional" functionality to unicode processors; the C-level function now uses PyUnicode_Check() as a fast alternative to the isinstance() check in Python
Diffstat (limited to 'lib/sqlalchemy/sql')
-rw-r--r--lib/sqlalchemy/sql/sqltypes.py17
1 files changed, 4 insertions, 13 deletions
diff --git a/lib/sqlalchemy/sql/sqltypes.py b/lib/sqlalchemy/sql/sqltypes.py
index 702e77360..0cc90f26b 100644
--- a/lib/sqlalchemy/sql/sqltypes.py
+++ b/lib/sqlalchemy/sql/sqltypes.py
@@ -204,20 +204,11 @@ class String(Concatenable, TypeEngine):
dialect.encoding, self.unicode_error)
if needs_isinstance:
- # we wouldn't be here unless convert_unicode='force'
- # was specified, or the driver has erratic unicode-returning
- # habits. since we will be getting back unicode
- # in most cases, we check for it (decode will fail).
- def process(value):
- if isinstance(value, util.text_type):
- return value
- else:
- return to_unicode(value)
- return process
+ return processors.to_conditional_unicode_processor_factory(
+ dialect.encoding, self.unicode_error)
else:
- # here, we assume that the object is not unicode,
- # avoiding expensive isinstance() check.
- return to_unicode
+ return processors.to_unicode_processor_factory(
+ dialect.encoding, self.unicode_error)
else:
return None