YunaiV/ruoyi-vue-pro · error · UnexpectedLiquibaseException
Cannot convert type {} to a boolean value
Error message
Cannot convert type {} to a boolean value What it means
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.
Source
Thrown at sql/dm/flowable-patch/src/main/java/liquibase/datatype/core/BooleanType.java:108
} else {
returnValue = this.getFalseBooleanValue(database);
}
} else if (value instanceof Number) {
if (value.equals(1) || "1".equals(value.toString()) || "1.0".equals(value.toString())) {
returnValue = this.getTrueBooleanValue(database);
} else {
returnValue = this.getFalseBooleanValue(database);
}
} else if (value instanceof DatabaseFunction) {
return value.toString();
} else if (value instanceof Boolean) {
if (((Boolean) value)) {
returnValue = this.getTrueBooleanValue(database);
} else {
returnValue = this.getFalseBooleanValue(database);
}
} else {
throw new UnexpectedLiquibaseException("Cannot convert type " + value.getClass() + " to a boolean value");
}
return returnValue;
}
protected boolean isNumericBoolean(Database database) {
if (database instanceof Firebird3Database) {
return false;
}
if (database instanceof DerbyDatabase) {
return !((DerbyDatabase) database).supportsBooleanDataType();
} else if (database instanceof DB2Database) {
return !((DB2Database) database).supportsBooleanDataType();
}
return (database instanceof Db2zDatabase)
|| (database instanceof FirebirdDatabase)
|| (database instanceof MSSQLDatabase)
|| (database instanceof MySQLDatabase)View on GitHub (pinned to 0418084e22)
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()).
Example fix
// before Object value = someBigInteger; // BooleanType rejects BigInteger // after Object value = someBigInteger.intValue() != 0;
Defensive patterns
Strategy: type-guard
Validate before calling
if (value != null && !(value instanceof String || value instanceof Number || value instanceof Boolean || value instanceof DatabaseFunction)) {
throw new IllegalArgumentException("Unsupported boolean value type: " + value.getClass());
} Type guard
static boolean isBooleanConvertible(Object v) {
return v == null || v instanceof String || v instanceof Number || v instanceof Boolean || v instanceof DatabaseFunction;
} Try / catch
try {
return booleanType.objectToSql(value, db);
} catch (UnexpectedLiquibaseException e) {
return booleanType.objectToSql(String.valueOf(value), db);
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: Custom Liquibase extensions feeding values from JSON/YAML changesets where numeric parsing yields BigInteger; ORM/Liquibase integration where enums leak through as enum instances.
Related errors
AI-assisted analysis of YunaiV/ruoyi-vue-pro@0418084e22 (2026-08-14).
Data as JSON: /api/errors/86259ff8f8ba7c08.
Report an issue: GitHub.