summaryrefslogtreecommitdiffstats
path: root/src/sql/kernel
diff options
context:
space:
mode:
authorTobias Koenig <tobias.koenig.qnx@kdab.com>2013-12-02 14:01:59 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-03-20 10:36:34 +0100
commit1f6e461533f531a25bdb9cf60c1cafc125aa06ba (patch)
tree0eadc41efa9464e09061919043ce9a0d7cb34ef3 /src/sql/kernel
parent943fc7d782207b0dc35057ee934169bd8cb2a322 (diff)
Fix positional binding values order in QSqlQuery
Adapt the stringification code, that is used to produce the keys for QSqlQuery::boundValues() return value, to keep the right order of the binding values. Task-number: QTBUG-12186 Change-Id: Ic11a455bfd9ffd1418b1b021ce5cf78cae9b4504 [ChangeLog][QtSql] Fixed the order of values with positional binding in a QSqlQuery Reviewed-by: Andy Shaw <andy.shaw@digia.com> Reviewed-by: Mark Brand <mabrand@mabrand.nl>
Diffstat (limited to 'src/sql/kernel')
-rw-r--r--src/sql/kernel/qsqlresult.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/sql/kernel/qsqlresult.cpp b/src/sql/kernel/qsqlresult.cpp
index 31b05ab9e9..6959dc39f7 100644
--- a/src/sql/kernel/qsqlresult.cpp
+++ b/src/sql/kernel/qsqlresult.cpp
@@ -64,15 +64,20 @@ QString QSqlResultPrivate::holderAt(int index) const
// return a unique id for bound names
QString QSqlResultPrivate::fieldSerial(int i) const
{
- ushort arr[] = { ':', 'f', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
- ushort *ptr = &arr[1];
+ ushort arr[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+ ushort *end = &arr[(sizeof(arr)/sizeof(*arr))];
+ ushort *ptr = end;
while (i > 0) {
- *(++ptr) = 'a' + i % 16;
+ *(--ptr) = 'a' + i % 16;
i >>= 4;
}
- return QString(reinterpret_cast<const QChar *>(arr), int(ptr - arr) + 1);
+ const int nb = end - ptr;
+ *(--ptr) = 'a' + nb;
+ *(--ptr) = ':';
+
+ return QString::fromUtf16(ptr, int(end - ptr));
}
static bool qIsAlnum(QChar ch)