merge default

This commit is contained in:
Mike Bayer
2013-04-22 17:08:11 -04:00
3 changed files with 12 additions and 32 deletions
+3 -6
View File
@@ -11,12 +11,9 @@
:tickets: 2681
The operators for the Postgresql ARRAY type supports
input types of sets, generators, etc. but only when a dimension
is specified for the ARRAY; otherwise, the dialect
needs to peek inside of "arr[0]" to guess how many
dimensions are in use. If this occurs with a non
list/tuple type, the error message is now informative
and directs to specify a dimension for the ARRAY.
input types of sets, generators, etc. even when
a dimension is not specified, by turning the given
iterable into a collection unconditionally.
.. change::
:tags: bug, mysql
+6 -16
View File
@@ -669,23 +669,13 @@ class ARRAY(sqltypes.Concatenable, sqltypes.TypeEngine):
def compare_values(self, x, y):
return x == y
def _test_array_of_scalars(self, arr):
if not arr:
return True
else:
try:
return not isinstance(arr[0], (list, tuple))
except TypeError:
raise TypeError(
"Cannot auto-coerce ARRAY value of type "
"%s unless dimensions are specified "
"for ARRAY type" % type(arr))
def _proc_array(self, arr, itemproc, dim, collection):
if dim == 1 or (
dim is None and
self._test_array_of_scalars(arr)
):
if dim is None:
if arr is None:
arr = []
else:
arr = list(arr)
if dim == 1 or dim is None and not hasattr(arr[0], '__iter__'):
if itemproc:
return collection(itemproc(x) for x in arr)
else:
+3 -10
View File
@@ -2279,21 +2279,14 @@ class ArrayTest(fixtures.TablesTest, AssertsExecutionResults):
)
def test_undim_array_contains_set_exec(self):
assert_raises_message(
exc.StatementError,
"Cannot auto-coerce ARRAY value of type",
self._test_undim_array_contains_typed_exec, set
)
self._test_undim_array_contains_typed_exec(set)
def test_undim_array_contains_list_exec(self):
self._test_undim_array_contains_typed_exec(list)
def test_undim_array_contains_generator_exec(self):
assert_raises_message(
exc.StatementError,
"Cannot auto-coerce ARRAY value of type",
self._test_undim_array_contains_typed_exec, lambda elem: (x for x in elem)
)
self._test_undim_array_contains_typed_exec(
lambda elem: (x for x in elem))
def _test_dim_array_contains_typed_exec(self, struct):
dim_arrtable = self.tables.dim_arrtable