diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2015-12-30 12:00:52 -0500 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2015-12-30 12:00:52 -0500 |
| commit | 827b369f9cd95bc8311dd33597c128d2ba522287 (patch) | |
| tree | ea156a543116f4b81b9282b36f1d9ea13555a8be /lib/sqlalchemy/dialects/postgresql/array.py | |
| parent | b4df64d0053be9c5dca9ebe3e9d6fee18edeb8fa (diff) | |
| download | sqlalchemy-827b369f9cd95bc8311dd33597c128d2ba522287.tar.gz | |
- finish off tests and add some more consistency to how the indexable
types are operating here
Diffstat (limited to 'lib/sqlalchemy/dialects/postgresql/array.py')
| -rw-r--r-- | lib/sqlalchemy/dialects/postgresql/array.py | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/lib/sqlalchemy/dialects/postgresql/array.py b/lib/sqlalchemy/dialects/postgresql/array.py index b88f139de..8492f31a8 100644 --- a/lib/sqlalchemy/dialects/postgresql/array.py +++ b/lib/sqlalchemy/dialects/postgresql/array.py @@ -84,12 +84,19 @@ class array(expression.Tuple): super(array, self).__init__(*clauses, **kw) self.type = ARRAY(self.type) - def _bind_param(self, operator, obj): - return array([ - expression.BindParameter(None, o, _compared_to_operator=operator, - _compared_to_type=self.type, unique=True) - for o in obj - ]) + def _bind_param(self, operator, obj, _assume_scalar=False): + if _assume_scalar or operator is operators.getitem: + # if getitem->slice were called, Indexable produces + # a Slice object from that + assert isinstance(obj, int) + return expression.BindParameter( + None, obj, _compared_to_operator=operator, + _compared_to_type=self.type, unique=True) + + else: + return array([ + self._bind_param(operator, o, _assume_scalar=True) + for o in obj]) def self_group(self, against=None): if (against in ( |
