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
(cherry picked from commit
c2e8b48a668a7ae7c1467a00e44fb1e4daa660a3)
import sys
+from sqlalchemy import exc
from sqlalchemy import util
from sqlalchemy.testing import exclusions
from sqlalchemy.testing.exclusions import against
)
),
"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(