{"record":{"id":"86259ff8f8ba7c08","repo":"YunaiV/ruoyi-vue-pro","slug":"cannot-convert-type-to-a-boolean-value","errorCode":null,"errorMessage":"Cannot convert type {} to a boolean value","messagePattern":"Cannot convert type (.+?) to a boolean value","errorType":"exception","errorClass":"UnexpectedLiquibaseException","httpStatus":null,"severity":"error","filePath":"sql/dm/flowable-patch/src/main/java/liquibase/datatype/core/BooleanType.java","lineNumber":108,"sourceCode":"            } else {\n                returnValue = this.getFalseBooleanValue(database);\n            }\n        } else if (value instanceof Number) {\n            if (value.equals(1) || \"1\".equals(value.toString()) || \"1.0\".equals(value.toString())) {\n                returnValue = this.getTrueBooleanValue(database);\n            } else {\n                returnValue = this.getFalseBooleanValue(database);\n            }\n        } else if (value instanceof DatabaseFunction) {\n            return value.toString();\n        } else if (value instanceof Boolean) {\n            if (((Boolean) value)) {\n                returnValue = this.getTrueBooleanValue(database);\n            } else {\n                returnValue = this.getFalseBooleanValue(database);\n            }\n        } else {\n            throw new UnexpectedLiquibaseException(\"Cannot convert type \" + value.getClass() + \" to a boolean value\");\n        }\n\n        return returnValue;\n    }\n\n    protected boolean isNumericBoolean(Database database) {\n        if (database instanceof Firebird3Database) {\n            return false;\n        }\n        if (database instanceof DerbyDatabase) {\n            return !((DerbyDatabase) database).supportsBooleanDataType();\n        } else if (database instanceof DB2Database) {\n            return !((DB2Database) database).supportsBooleanDataType();\n        }\n        return (database instanceof Db2zDatabase)\n            || (database instanceof FirebirdDatabase)\n            || (database instanceof MSSQLDatabase)\n            || (database instanceof MySQLDatabase)","sourceCodeStart":90,"sourceCodeEnd":126,"githubUrl":"https://github.com/YunaiV/ruoyi-vue-pro/blob/0418084e222612af2fc1141f566af454f9236ab1/sql/dm/flowable-patch/src/main/java/liquibase/datatype/core/BooleanType.java#L90-L126","documentation":"BooleanType's object-to-SQL conversion has explicit branches for String, Long, Number, DatabaseFunction, and Boolean. Any other Java type (e.g. java.math.BigInteger, AtomicInteger, an enum, a custom value object) falls into the final else and throws. It is a programming/data-pipeline error rather than an end-user config issue.","triggerScenarios":"Passing a non-standard numeric or object type as a boolean column value through Liquibase (e.g. a BigInteger from JSON deserialization, a JPA enum converted to its ordinal wrapper, or a custom value holder); a code path that calls BooleanType.objectToSql with an unhandled type.","commonSituations":"Custom Liquibase extensions feeding values from JSON/YAML changesets where numeric parsing yields BigInteger; ORM/Liquibase integration where enums leak through as enum instances.","solutions":["Convert the value to a Boolean, String 'true'/'false', or 1/0 before passing it to BooleanType.","If the type is numeric, coerce to Long/Integer first (e.g. ((Number)value).longValue())."],"exampleFix":"// before\nObject value = someBigInteger; // BooleanType rejects BigInteger\n// after\nObject value = someBigInteger.intValue() != 0;","handlingStrategy":"type-guard","validationCode":"if (value != null && !(value instanceof String || value instanceof Number || value instanceof Boolean || value instanceof DatabaseFunction)) {\n    throw new IllegalArgumentException(\"Unsupported boolean value type: \" + value.getClass());\n}","typeGuard":"static boolean isBooleanConvertible(Object v) {\n    return v == null || v instanceof String || v instanceof Number || v instanceof Boolean || v instanceof DatabaseFunction;\n}","tryCatchPattern":"try {\n    return booleanType.objectToSql(value, db);\n} catch (UnexpectedLiquibaseException e) {\n    return booleanType.objectToSql(String.valueOf(value), db);\n}","preventionTips":["Always coerce non-standard numeric types to Long/Integer before passing to BooleanType","Avoid enums/custom value objects in boolean columns","Add a unit test covering the value types you feed to BooleanType"],"tags":["liquibase","boolean","datatype-conversion","type-mismatch"],"backgroundTag":null,"analyzedSha":"0418084e222612af2fc1141f566af454f9236ab1","analyzedAt":"2026-08-14T00:56:18.412Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}