File tree Expand file tree Collapse file tree 4 files changed +11
-3
lines changed
adminforth/dataConnectors Expand file tree Collapse file tree 4 files changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -308,7 +308,13 @@ export default class AdminForthBaseConnector implements IAdminForthDataSourceCon
308308 return this . setFieldValue ( field , null ) ;
309309 }
310310 if ( typeof value !== 'boolean' ) {
311- throw new Error ( `Value is not a boolean. Field ${ field . name } with type is ${ field . type } , but got value: ${ value } with type ${ typeof value } ` ) ;
311+ const errorMessage = `Value is not a boolean. Field ${ field . name } with type is ${ field . type } , but got value: ${ value } with type ${ typeof value } ` ;
312+ if ( value !== 1 && value !== 0 ) {
313+ throw new Error ( errorMessage ) ;
314+ } else {
315+ afLogger . warn ( errorMessage ) ;
316+ afLogger . warn ( `Ignore this warn, if you are using an sqlite database` ) ;
317+ }
312318 }
313319 return this . setFieldValue ( field , value ) ;
314320 }
Original file line number Diff line number Diff line change @@ -192,7 +192,7 @@ class ClickhouseConnector extends AdminForthBaseConnector implements IAdminForth
192192 return iso ;
193193 }
194194 } else if ( field . type == AdminForthDataTypes . BOOLEAN ) {
195- return value === null ? null : ( value ? 1 : 0 ) ;
195+ return value === null ? null : ( value ? true : false ) ;
196196 } else if ( field . type == AdminForthDataTypes . JSON ) {
197197 // check underline type is text or string
198198 if ( field . _underlineType . startsWith ( 'String' ) || field . _underlineType . startsWith ( 'FixedString' ) ) {
Original file line number Diff line number Diff line change @@ -225,7 +225,7 @@ class MysqlConnector extends AdminForthBaseConnector implements IAdminForthDataS
225225 }
226226 return dayjs ( value ) . format ( 'YYYY-MM-DD HH:mm:ss' ) ;
227227 } else if ( field . type == AdminForthDataTypes . BOOLEAN ) {
228- return value === null ? null : ( value ? 1 : 0 ) ;
228+ return value === null ? null : ( value ? true : false ) ;
229229 } else if ( field . type == AdminForthDataTypes . JSON ) {
230230 if ( field . _underlineType === 'json' ) {
231231 return value ;
Original file line number Diff line number Diff line change @@ -176,6 +176,8 @@ class SQLiteConnector extends AdminForthBaseConnector implements IAdminForthData
176176 }
177177 return JSON . stringify ( value ) ;
178178 } else if ( field . type == AdminForthDataTypes . BOOLEAN ) {
179+ // SQLite does not have a native boolean type, it uses 0 and 1
180+ // valid only for sqlite
179181 return value === null ? null : ( value ? 1 : 0 ) ;
180182 } else if ( field . type == AdminForthDataTypes . JSON ) {
181183 // check underline type is text or string
You can’t perform that action at this time.
0 commit comments