From: Mike Bayer Date: Fri, 25 Oct 2019 17:10:30 +0000 (-0400) Subject: Perform an active check for sqlite json extension X-Git-Tag: rel_1_4_0b1~653 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c2e8b48a668a7ae7c1467a00e44fb1e4daa660a3;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git Perform an active check for sqlite json extension Apparently some Python builds may not have json enabled for sqlite even though version > 3.9, add an active check for the json functions. Fixes: #4946 Change-Id: I1a1ce7ef72da8da9ad9576e1281d1df415c6af4f --- diff --git a/test/requirements.py b/test/requirements.py index 739f90b955..bd6fc8133d 100644 --- a/test/requirements.py +++ b/test/requirements.py @@ -5,6 +5,7 @@ import sys +from sqlalchemy import exc from sqlalchemy import util from sqlalchemy.testing import exclusions from sqlalchemy.testing.exclusions import against @@ -816,10 +817,26 @@ class DefaultRequirements(SuiteRequirements): ) ), "postgresql >= 9.3", - "sqlite >= 3.9", + self._sqlite_json, ] ) + def _sqlite_json(self, config): + if not against(config, "sqlite >= 3.9"): + return False + else: + with config.db.connect() as conn: + try: + return ( + conn.scalar( + """select json_extract('{"foo": "bar"}', """ + """'$."foo"')""" + ) + == "bar" + ) + except exc.DBAPIError: + return False + @property def reflects_json_type(self): return only_on(