summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/dialects/sqlite
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sqlalchemy/dialects/sqlite')
-rw-r--r--lib/sqlalchemy/dialects/sqlite/base.py21
1 files changed, 20 insertions, 1 deletions
diff --git a/lib/sqlalchemy/dialects/sqlite/base.py b/lib/sqlalchemy/dialects/sqlite/base.py
index 2685a9243..f228c151c 100644
--- a/lib/sqlalchemy/dialects/sqlite/base.py
+++ b/lib/sqlalchemy/dialects/sqlite/base.py
@@ -570,6 +570,7 @@ When using the per-:class:`.Engine` execution option, note that
""" # noqa
import datetime
+import numbers
import re
from .json import JSON
@@ -599,6 +600,24 @@ from ...types import TIMESTAMP # noqa
from ...types import VARCHAR # noqa
+class _SQliteJson(JSON):
+ def result_processor(self, dialect, coltype):
+ default_processor = super(_SQliteJson, self).result_processor(
+ dialect, coltype
+ )
+
+ def process(value):
+ try:
+ return default_processor(value)
+ except TypeError:
+ if isinstance(value, numbers.Number):
+ return value
+ else:
+ raise
+
+ return process
+
+
class _DateTimeMixin(object):
_reg = None
_storage_format = None
@@ -899,7 +918,7 @@ class TIME(_DateTimeMixin, sqltypes.Time):
colspecs = {
sqltypes.Date: DATE,
sqltypes.DateTime: DATETIME,
- sqltypes.JSON: JSON,
+ sqltypes.JSON: _SQliteJson,
sqltypes.JSON.JSONIndexType: JSONIndexType,
sqltypes.JSON.JSONPathType: JSONPathType,
sqltypes.Time: TIME,