diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2013-04-22 17:08:02 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2013-04-22 17:08:02 -0400 |
commit | d2f8c83e25ea7abb49315c30518f6415b497f1a7 (patch) | |
tree | 38710ed38b7e3924084680431262db5e4a9ff1e2 /lib/sqlalchemy/dialects/postgresql/base.py | |
parent | 422f4718715ad89346f42caf03bdd2ed745e5a23 (diff) | |
download | sqlalchemy-d2f8c83e25ea7abb49315c30518f6415b497f1a7.tar.gz |
- change to [ticket:2681], pre-coerce the array to list
unconditonally instead so that it works in all cases.
Diffstat (limited to 'lib/sqlalchemy/dialects/postgresql/base.py')
-rw-r--r-- | lib/sqlalchemy/dialects/postgresql/base.py | 22 |
1 files changed, 6 insertions, 16 deletions
diff --git a/lib/sqlalchemy/dialects/postgresql/base.py b/lib/sqlalchemy/dialects/postgresql/base.py index f3a88ff70..82660d96c 100644 --- a/lib/sqlalchemy/dialects/postgresql/base.py +++ b/lib/sqlalchemy/dialects/postgresql/base.py @@ -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: |