diff options
author | Bill King <bill.king@nokia.com> | 2010-03-05 06:53:54 (GMT) |
---|---|---|
committer | Bill King <bill.king@nokia.com> | 2010-03-05 06:53:54 (GMT) |
commit | 46d5f85a03bd87708152baba2674f2e5f36afe22 (patch) | |
tree | 01ca9b3b551d610c062e7b71c2765bde96c38197 /src/sql | |
parent | 3e6a330d2aa6f139347fe29947721368a5186cc3 (diff) | |
download | Qt-46d5f85a03bd87708152baba2674f2e5f36afe22.zip Qt-46d5f85a03bd87708152baba2674f2e5f36afe22.tar.gz Qt-46d5f85a03bd87708152baba2674f2e5f36afe22.tar.bz2 |
Fixes: Mysql truncation of integer values + some autotest cleanup
Task-number: QTBUG-5765
Diffstat (limited to 'src/sql')
-rw-r--r-- | src/sql/drivers/mysql/qsql_mysql.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/sql/drivers/mysql/qsql_mysql.cpp b/src/sql/drivers/mysql/qsql_mysql.cpp index c0f866e..2261887 100644 --- a/src/sql/drivers/mysql/qsql_mysql.cpp +++ b/src/sql/drivers/mysql/qsql_mysql.cpp @@ -320,6 +320,16 @@ static bool qIsBlob(int t) || t == MYSQL_TYPE_LONG_BLOB; } +static bool qIsInteger(int t) +{ + return t == MYSQL_TYPE_TINY + || t == MYSQL_TYPE_SHORT + || t == MYSQL_TYPE_LONG + || t == MYSQL_TYPE_LONGLONG + || t == MYSQL_TYPE_INT24; +} + + void QMYSQLResultPrivate::bindBlobs() { int i; @@ -368,6 +378,13 @@ bool QMYSQLResultPrivate::bindInValues() fieldInfo->length = 0; hasBlobs = true; } else { + // fieldInfo->length specifies the display width, which may be too + // small to hold valid integer values (see + // http://dev.mysql.com/doc/refman/5.0/en/numeric-types.html ), so + // always use the MAX_BIGINT_WIDTH for integer types + if (qIsInteger(fieldInfo->type)) { + fieldInfo->length = MAX_BIGINT_WIDTH; + } fieldInfo->type = MYSQL_TYPE_STRING; } bind = &inBinds[i]; |