File tree Expand file tree Collapse file tree
adminforth/dataConnectors Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -155,17 +155,14 @@ class SQLiteConnector extends AdminForthBaseConnector implements IAdminForthData
155155 } else if ( field . type == AdminForthDataTypes . BOOLEAN ) {
156156 return value === null ? null : ! ! value ;
157157 } else if ( field . type == AdminForthDataTypes . JSON ) {
158- if ( field . _underlineType == 'text' || field . _underlineType == 'varchar ') {
158+ if ( typeof value === 'string ') {
159159 try {
160160 return JSON . parse ( value ) ;
161161 } catch ( e ) {
162162 return { 'error' : `Failed to parse JSON: ${ e . message } ` }
163163 }
164- } else {
165- afLogger . warn ( `AdminForth: JSON field is not a string/text but ${ field . _underlineType } , this is not supported yet` ) ;
166164 }
167165 }
168-
169166 return value ;
170167 }
171168
@@ -192,12 +189,10 @@ class SQLiteConnector extends AdminForthBaseConnector implements IAdminForthData
192189 } else if ( field . type == AdminForthDataTypes . BOOLEAN ) {
193190 return value === null ? null : ( value ? 1 : 0 ) ;
194191 } else if ( field . type == AdminForthDataTypes . JSON ) {
195- // check underline type is text or string
196- if ( field . _underlineType == 'text' || field . _underlineType == 'varchar' ) {
197- return JSON . stringify ( value ) ;
198- } else {
199- afLogger . warn ( `AdminForth: JSON field is not a string/text but ${ field . _underlineType } , this is not supported yet` ) ;
192+ if ( value === null || value === undefined ) {
193+ return null ;
200194 }
195+ return typeof value === 'string' ? value : JSON . stringify ( value ) ;
201196 }
202197
203198 return value ;
You can’t perform that action at this time.
0 commit comments