From 50ad785bdd38fcff9c47125fc545762435aaa158 Mon Sep 17 00:00:00 2001 From: Honglei Zhang Date: Wed, 7 Mar 2012 12:02:02 +0200 Subject: Convert Boolean value into integer According to documentation, SQLite doesn't have a separate Boolean storage class. Instead, values are stored as integers 0(false) and 1(true). In QSqlQuery::bindValue(), if a boolean value is bound to a placeholder, it is converted to text true and false. This fix converts boolean value to integer 0 and 1. Task-number: QTBUG-23895 Change-Id: I4945971172f0b5e5819446700390033a1a4ce301 Reviewed-by: Michael Goddard Reviewed-by: Mark Brand --- src/sql/drivers/sqlite/qsql_sqlite.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/sql/drivers/sqlite/qsql_sqlite.cpp') diff --git a/src/sql/drivers/sqlite/qsql_sqlite.cpp b/src/sql/drivers/sqlite/qsql_sqlite.cpp index deb29f8059..168500e5a8 100644 --- a/src/sql/drivers/sqlite/qsql_sqlite.cpp +++ b/src/sql/drivers/sqlite/qsql_sqlite.cpp @@ -92,6 +92,9 @@ static QVariant::Type qGetColumnType(const QString &tpName) return QVariant::Double; if (typeName == QLatin1String("blob")) return QVariant::ByteArray; + if (typeName == QLatin1String("boolean") + || typeName == QLatin1String("bool")) + return QVariant::Bool; return QVariant::String; } @@ -413,6 +416,7 @@ bool QSQLiteResult::exec() ba->size(), SQLITE_STATIC); break; } case QVariant::Int: + case QVariant::Bool: res = sqlite3_bind_int(d->stmt, i + 1, value.toInt()); break; case QVariant::Double: -- cgit v1.2.3