From b0654a38937bfbd98cc16879831f6153b513678e Mon Sep 17 00:00:00 2001 From: David Brown Date: Mon, 24 Dec 2018 21:43:04 -0800 Subject: [PATCH] Fix #2 Define JSONField Since peewee>3.0 JSONField was moved to extensions modules for both SQLite and Postgres. All we need is a generic one so we wrap TextField. Signed-off-by: David Brown --- social_peewee/storage.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/social_peewee/storage.py b/social_peewee/storage.py index 0562d3c..baa6814 100644 --- a/social_peewee/storage.py +++ b/social_peewee/storage.py @@ -1,12 +1,20 @@ import six import base64 +import json -from peewee import CharField, IntegerField, Model, Proxy, IntegrityError -from playhouse.kv import JSONField - +from peewee import CharField, IntegerField, Model, Proxy, IntegrityError, \ + TextField from social_core.storage import UserMixin, AssociationMixin, NonceMixin, \ CodeMixin, PartialMixin, BaseStorage +class JSONField(TextField): + def db_value(self, value): + return json.dumps(value) + + def python_value(self, value): + if value is not None: + return json.loads(value) + def get_query_by_dict_param(cls, params): query = True