QSqlQuery::value() incorrectly returns "0" for large id numbers
Hi,
I'm using QT 4.2, to access some tables in a MySQL database.
Everything was working OK until my (autoincrement) ID field for one of my tables reached 1,000,000.
Now, when I use QSqlQuery to read rows in that table... the id fields always come back as "0", instead of something like "1000085"
The offending code goes something like this:
Code:
p.prepare("select id from mytable where col1=? and col2=?");
p.addBindValue(var1);
p.addBindValue(var2);
q.exec();
while (q.next()){
// this incorrectly reports "0" for records with id numbers over 1 million
qDebug() << v.typeName(); // reports 'uint'
qDebug() << v.toString();
}
Anyone know what the heck is going on? :confused:
Thanks,
Peter
Re: QSqlQuery::value() incorrectly returns "0" for large id numbers
Doh! I figured it out. The id field in my table was defined as "INT(6) UNSIGNED".
It seems that the 6 was preventing QT from reading values longer than 6 digits. (Even though they are perfectly legal in my table.) I changed the column to INT UNSIGNED, and things are working again. Seems like a bug to me... :eek: