summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2016-01-06 17:27:30 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2016-01-06 17:27:30 -0500
commit5c8bdcab90cf52d74e9c305fc1527a1cb54f2935 (patch)
treeffa109d6a813c836761da5c865ef0c2b2adfdd4d
parentc8b7729338ba32a726be72b5409b4651326042e9 (diff)
downloadsqlalchemy-5c8bdcab90cf52d74e9c305fc1527a1cb54f2935.tar.gz
- add limiting criteria to the JSON tests so that we don't
attempt integer indexed access from a key/value object nor string access from an integer-indexed array, as earlier Postgresql versions (prior to 9.4) don't allow this
-rw-r--r--lib/sqlalchemy/testing/suite/test_types.py19
1 files changed, 16 insertions, 3 deletions
diff --git a/lib/sqlalchemy/testing/suite/test_types.py b/lib/sqlalchemy/testing/suite/test_types.py
index c6e882fb5..f2103f89a 100644
--- a/lib/sqlalchemy/testing/suite/test_types.py
+++ b/lib/sqlalchemy/testing/suite/test_types.py
@@ -5,7 +5,7 @@ from ..assertions import eq_
from ..config import requirements
from sqlalchemy import Integer, Unicode, UnicodeText, select
from sqlalchemy import Date, DateTime, Time, MetaData, String, \
- Text, Numeric, Float, literal, Boolean, cast, null, JSON
+ Text, Numeric, Float, literal, Boolean, cast, null, JSON, and_
from ..schema import Table, Column
from ... import testing
import decimal
@@ -745,16 +745,29 @@ class JSONTest(_LiteralRoundTripFixture, fixtures.TablesTest):
)
def test_crit_spaces_in_key(self):
+ name = self.tables.data_table.c.name
col = self.tables.data_table.c['data']
+
+ # limit the rows here to avoid PG error
+ # "cannot extract field from a non-object", which is
+ # fixed in 9.4 but may exist in 9.3
self._test_index_criteria(
- cast(col["key two"], String) == '"value2"',
+ and_(
+ name.in_(["r1", "r2", "r3"]),
+ cast(col["key two"], String) == '"value2"'
+ ),
"r2"
)
def test_crit_simple_int(self):
+ name = self.tables.data_table.c.name
col = self.tables.data_table.c['data']
+
+ # limit the rows here to avoid PG error
+ # "cannot extract array element from a non-array", which is
+ # fixed in 9.4 but may exist in 9.3
self._test_index_criteria(
- cast(col[1], String) == '"two"',
+ and_(name == 'r4', cast(col[1], String) == '"two"'),
"r4"
)