diff options
author | Honglei Zhang <honglei.zhang@nokia.com> | 2012-03-07 12:02:02 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-04-02 23:06:30 +0200 |
commit | 50ad785bdd38fcff9c47125fc545762435aaa158 (patch) | |
tree | a5ff6f76544d0a223a4efe7da87bd2e6f5d1d3e6 /src/sql/drivers/sqlite | |
parent | 1967c147373be39f3e9f38967044812ce13ad10e (diff) |
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 <michael.goddard@nokia.com>
Reviewed-by: Mark Brand <mabrand@mabrand.nl>
Diffstat (limited to 'src/sql/drivers/sqlite')
-rw-r--r-- | src/sql/drivers/sqlite/qsql_sqlite.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
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: |