summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sqlalchemy')
-rw-r--r--lib/sqlalchemy/engine/base.py4
-rw-r--r--lib/sqlalchemy/sql/expression.py3
-rw-r--r--lib/sqlalchemy/types.py31
3 files changed, 18 insertions, 20 deletions
diff --git a/lib/sqlalchemy/engine/base.py b/lib/sqlalchemy/engine/base.py
index dbc1ff820..d4ced4cca 100644
--- a/lib/sqlalchemy/engine/base.py
+++ b/lib/sqlalchemy/engine/base.py
@@ -734,7 +734,9 @@ class Connection(Connectable):
distilled_params = _distill_params(multiparams, params)
if distilled_params:
- keys = list(distilled_params[0])
+ # need list() + keys() here to suit
+ # both dict and RowProxy
+ keys = list(distilled_params[0].keys())
else:
keys = []
diff --git a/lib/sqlalchemy/sql/expression.py b/lib/sqlalchemy/sql/expression.py
index aff5512d3..2c7b91fe6 100644
--- a/lib/sqlalchemy/sql/expression.py
+++ b/lib/sqlalchemy/sql/expression.py
@@ -2204,7 +2204,7 @@ class _DefaultColumnComparator(operators.ColumnOperators):
def _check_literal(self, expr, operator, other):
if isinstance(other, (ColumnElement, TextClause)):
if isinstance(other, BindParameter) and \
- isinstance(other.type, sqltypes.NullType):
+ isinstance(other.type, sqltypes.NullType):
# TODO: perhaps we should not mutate the incoming
# bindparam() here and instead make a copy of it.
# this might be the only place that we're mutating
@@ -3116,7 +3116,6 @@ class Executable(Generative):
def execute(self, *multiparams, **params):
"""Compile and execute this :class:`.Executable`."""
-
e = self.bind
if e is None:
label = getattr(self, 'description', self.__class__.__name__)
diff --git a/lib/sqlalchemy/types.py b/lib/sqlalchemy/types.py
index 4fbadcb0c..ffcd793c6 100644
--- a/lib/sqlalchemy/types.py
+++ b/lib/sqlalchemy/types.py
@@ -1115,12 +1115,7 @@ class String(Concatenable, TypeEngine):
self.convert_unicode != 'force':
if self._warn_on_bytestring:
def process(value):
-# start Py3K
- if isinstance(value, bytes):
-# end Py3K
-# start Py2K
-# if isinstance(value, str):
-# end Py2K
+ if isinstance(value, util.binary_type):
util.warn("Unicode type received non-unicode bind "
"param value.")
return value
@@ -1132,7 +1127,7 @@ class String(Concatenable, TypeEngine):
warn_on_bytestring = self._warn_on_bytestring
def process(value):
- if isinstance(value, str):
+ if isinstance(value, util.text_type):
return encoder(value, self.unicode_error)[0]
elif warn_on_bytestring and value is not None:
util.warn("Unicode type received non-unicode bind "
@@ -1173,7 +1168,7 @@ class String(Concatenable, TypeEngine):
@property
def python_type(self):
if self.convert_unicode:
- return str
+ return util.text_type
else:
return str
@@ -1744,7 +1739,7 @@ class _Binary(TypeEngine):
def coerce_compared_value(self, op, value):
"""See :meth:`.TypeEngine.coerce_compared_value` for a description."""
- if isinstance(value, str):
+ if isinstance(value, util.string_types):
return self
else:
return super(_Binary, self).coerce_compared_value(op, value)
@@ -2001,7 +1996,7 @@ class Enum(String, SchemaType):
convert_unicode = kw.pop('convert_unicode', None)
if convert_unicode is None:
for e in enums:
- if isinstance(e, str):
+ if isinstance(e, util.string_types):
convert_unicode = True
break
else:
@@ -2454,13 +2449,6 @@ BOOLEANTYPE = Boolean()
STRINGTYPE = String()
_type_map = {
- str: String(),
-# start Py3K
- bytes: LargeBinary(),
-# end Py3K
-# start Py2K
-# unicode: Unicode(),
-# end Py2K
int: Integer(),
float: Numeric(),
bool: BOOLEANTYPE,
@@ -2471,3 +2459,12 @@ _type_map = {
dt.timedelta: Interval(),
NoneType: NULLTYPE
}
+
+if util.py3k:
+ _type_map[bytes] = LargeBinary()
+ _type_map[str] = Unicode()
+else:
+ _type_map[unicode] = Unicode()
+ _type_map[str] = String()
+
+