Skip to content

Commit

Permalink
Fix(col): Fix JSONValidator
Browse files Browse the repository at this point in the history
Refs: #159.
  • Loading branch information
phdru committed Nov 21, 2020
1 parent 6d5d0c2 commit 3a4e35f
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions sqlobject/col.py
Expand Up @@ -1978,11 +1978,13 @@ class JsonbCol(Col):
baseClass = SOJsonbCol


class JSONValidator(StringValidator):
class JSONValidator(SOValidator):

def to_python(self, value, state):
if value is None:
return None
if isinstance(value, (bool, int, float, long, dict, list)):
return value
if isinstance(value, string_type):
return json.loads(value)
raise validators.Invalid(
Expand All @@ -2005,8 +2007,7 @@ def from_python(self, value, state):
class SOJSONCol(SOStringCol):

def createValidators(self):
return [JSONValidator(name=self.name)] + \
super(SOJSONCol, self).createValidators()
return [JSONValidator(name=self.name)]

def _sqlType(self):
return 'JSON'
Expand Down

0 comments on commit 3a4e35f

Please sign in to comment.