ahmetalpbalkan/orman — Issue #35: SQLite Missing Boolean Type Causes Invalid SQL
Author: ahmetalpbalkan
Created: 2011-10-11 13:39:16+00:00
State: open
Labels: Bug, Critical

Example scenario below

@Entity class ToDo { boolean done; String text; }

Logs:

521 [TRACE] Executing: CREATE TABLE to_do (text TEXT, done INTEGER, id INTEGER PRIMARY KEY AUTOINCREMENT)
523 [TRACE] Executing: DROP INDEX IF EXISTS to_do_index
523 [INFO] DDL constructed successfully.
579 [TRACE] Executing: INSERT INTO to_do (text, done) VALUES ('dishes', false)

Exception in thread "main" 580 [ERROR] Query execution error: SQLite error:com.almworks.sqlite4java.SQLiteException: [1] DB[1] exec() no such column: false
org.orman.dbms.exception.QueryExecutionException: Query execution error: SQLite error:com.almworks.sqlite4java.SQLiteException: [1] DB[1] exec() no such column: false
at org.orman.dbms.sqlite.QueryExecutionContainerImpl.throwError(QueryExecutionContainerImpl.java:38)
at org.orman.dbms.sqlite.QueryExecutionContainerImpl.executeOnly(QueryExecutionContainerImpl.java:114)
at org.orman.mapper.Model.insert(Model.java:86)
at demo10todo.Main.main(Main.java:23)

Because SQLite does not have `boolean` but can store `0` and `1` in `int` field and we are serializing boolean variables using `Boolean.toString()` method in `org.orman.sql.util.Serializer.java`.

We should investigate that using `0` instead of `false` and `1` instead of `true` will work in MySQL and also compatible with generic SQL implementations.