diff options
author | Oswald Buddenhagen <oswald.buddenhagen@nokia.com> | 2012-04-10 12:48:01 +0200 |
---|---|---|
committer | Oswald Buddenhagen <oswald.buddenhagen@nokia.com> | 2012-04-10 15:31:45 +0200 |
commit | 143c4d3e13a430b951f4f4f8c28db14303f80605 (patch) | |
tree | 2b89637b93fc7d81c674106008566010f986d67c /src/sql/kernel | |
parent | a7ed81b557d593a8ddb43b71bf4bbf3b44ead070 (diff) | |
parent | e5337ad1b1fb02873ce7b5ca8db45f6fd8063352 (diff) |
Merge remote-tracking branch 'origin/master' into api_changes
Conflicts:
configure
src/widgets/styles/qwindowsxpstyle.cpp
tests/auto/gui/kernel/qwindow/qwindow.pro
tests/auto/gui/kernel/qwindow/tst_qwindow.cpp
Change-Id: I624b6d26abce9874c610c04954c1c45bc074bef3
Diffstat (limited to 'src/sql/kernel')
-rw-r--r-- | src/sql/kernel/qsql.qdoc | 24 | ||||
-rw-r--r-- | src/sql/kernel/qsqldriver.cpp | 5 | ||||
-rw-r--r-- | src/sql/kernel/qsqldriver.h | 2 | ||||
-rw-r--r-- | src/sql/kernel/qsqlresult.cpp | 77 |
4 files changed, 46 insertions, 62 deletions
diff --git a/src/sql/kernel/qsql.qdoc b/src/sql/kernel/qsql.qdoc index 0762fa977e..394c255b35 100644 --- a/src/sql/kernel/qsql.qdoc +++ b/src/sql/kernel/qsql.qdoc @@ -39,30 +39,6 @@ */ /*! - \enum QSql::Confirm - \compat - - This enum type describes edit confirmations. - - \value Yes - \value No - \value Cancel -*/ - -/*! - \enum QSql::Op - \compat - - This enum type describes edit operations. - - \value None - \value Insert - \value Update - \value Delete -*/ - - -/*! \enum QSql::Location This enum type describes special SQL navigation locations: diff --git a/src/sql/kernel/qsqldriver.cpp b/src/sql/kernel/qsqldriver.cpp index 28847325d9..f48673f28f 100644 --- a/src/sql/kernel/qsqldriver.cpp +++ b/src/sql/kernel/qsqldriver.cpp @@ -133,10 +133,11 @@ QSqlDriver::~QSqlDriver() /*! \since 5.0 - \fn QSqlDriver::notification(const QString &name, NotificationSource source) + \fn QSqlDriver::notification(const QString &name, NotificationSource source, const QString & payload) This signal is emitted when the database posts an event notification - that the driver subscribes to. \a name identifies the event notification, \a source indicates the signal source. + that the driver subscribes to. \a name identifies the event notification, \a source indicates the signal source, + \a payload holds the extra data optionally delivered with the notification. \sa subscribeToNotification() */ diff --git a/src/sql/kernel/qsqldriver.h b/src/sql/kernel/qsqldriver.h index ff19d660da..b3c83fc678 100644 --- a/src/sql/kernel/qsqldriver.h +++ b/src/sql/kernel/qsqldriver.h @@ -122,7 +122,7 @@ public: Q_SIGNALS: void notification(const QString &name); - void notification(const QString &name, NotificationSource source); + void notification(const QString &name, QSqlDriver::NotificationSource source, const QVariant &payload); protected: virtual void setOpen(bool o); diff --git a/src/sql/kernel/qsqlresult.cpp b/src/sql/kernel/qsqlresult.cpp index 16df1b8b06..f9dbae306b 100644 --- a/src/sql/kernel/qsqlresult.cpp +++ b/src/sql/kernel/qsqlresult.cpp @@ -114,16 +114,18 @@ public: QString executedQuery; QHash<int, QSql::ParamType> types; QVector<QVariant> values; - typedef QHash<QString, int> IndexMap; + typedef QHash<QString, QList<int> > IndexMap; IndexMap indexes; typedef QVector<QHolder> QHolderVector; QHolderVector holders; }; +static QString qFieldSerial(int); + QString QSqlResultPrivate::holderAt(int index) const { - return indexes.key(index); + return holders.size() > index ? holders.at(index).holderName : qFieldSerial(index); } // return a unique id for bound names @@ -159,6 +161,8 @@ QString QSqlResultPrivate::positionalToNamedBinding() for (int i = 0; i < n; ++i) { QChar ch = sql.at(i); if (ch == QLatin1Char('?') && !inQuote) { + // Update the holder position since we are changing the holder name lengths + holders[count].holderPos = result.size(); result += qFieldSerial(count++); } else { if (ch == QLatin1Char('\'')) @@ -188,7 +192,9 @@ QString QSqlResultPrivate::namedToPositionalBinding() int pos = i + 2; while (pos < n && qIsAlnum(sql.at(pos))) ++pos; - indexes[sql.mid(i, pos - i)] = count++; + QString holder(sql.mid(i, pos - i)); + indexes[holder].append(count++); + holders.append(QHolder(holder, i)); result += QLatin1Char('?'); i = pos; } else { @@ -199,6 +205,7 @@ QString QSqlResultPrivate::namedToPositionalBinding() } } result.squeeze(); + values.resize(holders.size()); return result; } @@ -610,27 +617,32 @@ bool QSqlResult::savePrepare(const QString& query) */ bool QSqlResult::prepare(const QString& query) { - int n = query.size(); + if (d->holders.isEmpty()) { + int n = query.size(); - bool inQuote = false; - int i = 0; - - while (i < n) { - QChar ch = query.at(i); - if (ch == QLatin1Char(':') && !inQuote - && (i == 0 || query.at(i - 1) != QLatin1Char(':')) - && (i + 1 < n && qIsAlnum(query.at(i + 1)))) { - int pos = i + 2; - while (pos < n && qIsAlnum(query.at(pos))) - ++pos; + bool inQuote = false; + int i = 0; - d->holders.append(QHolder(query.mid(i, pos - i), i)); - i = pos; - } else { - if (ch == QLatin1Char('\'')) - inQuote = !inQuote; - ++i; + while (i < n) { + QChar ch = query.at(i); + if (ch == QLatin1Char(':') && !inQuote + && (i == 0 || query.at(i - 1) != QLatin1Char(':')) + && (i + 1 < n && qIsAlnum(query.at(i + 1)))) { + int pos = i + 2; + while (pos < n && qIsAlnum(query.at(pos))) + ++pos; + + QString holder(query.mid(i, pos - i)); + d->indexes[holder].append(d->holders.size()); + d->holders.append(QHolder(holder, i)); + i = pos; + } else { + if (ch == QLatin1Char('\'')) + inQuote = !inQuote; + ++i; + } } + d->values.resize(d->holders.size()); } d->sql = query; return true; // fake prepares should always succeed @@ -653,7 +665,7 @@ bool QSqlResult::exec() QString holder; for (i = d->holders.count() - 1; i >= 0; --i) { holder = d->holders.at(i).holderName; - val = d->values.value(d->indexes.value(holder)); + val = d->values.value(d->indexes.value(holder).value(0,-1)); QSqlField f(QLatin1String(""), val.type()); f.setValue(val); query = query.replace(d->holders.at(i).holderPos, @@ -697,7 +709,7 @@ bool QSqlResult::exec() void QSqlResult::bindValue(int index, const QVariant& val, QSql::ParamType paramType) { d->binds = PositionalBinding; - d->indexes[qFieldSerial(index)] = index; + d->indexes[qFieldSerial(index)].append(index); if (d->values.count() <= index) d->values.resize(index + 1); d->values[index] = val; @@ -727,19 +739,14 @@ void QSqlResult::bindValue(const QString& placeholder, const QVariant& val, d->binds = NamedBinding; // if the index has already been set when doing emulated named // bindings - don't reset it - int idx = d->indexes.value(placeholder, -1); - if (idx >= 0) { + QList<int> indexes = d->indexes.value(placeholder); + foreach (int idx, indexes) { if (d->values.count() <= idx) d->values.resize(idx + 1); d->values[idx] = val; - } else { - d->values.append(val); - idx = d->values.count() - 1; - d->indexes[placeholder] = idx; + if (paramType != QSql::In || !d->types.isEmpty()) + d->types[idx] = paramType; } - - if (paramType != QSql::In || !d->types.isEmpty()) - d->types[idx] = paramType; } /*! @@ -776,8 +783,8 @@ QVariant QSqlResult::boundValue(int index) const */ QVariant QSqlResult::boundValue(const QString& placeholder) const { - int idx = d->indexes.value(placeholder, -1); - return d->values.value(idx); + QList<int> indexes = d->indexes.value(placeholder); + return d->values.value(indexes.value(0,-1)); } /*! @@ -798,7 +805,7 @@ QSql::ParamType QSqlResult::bindValueType(int index) const */ QSql::ParamType QSqlResult::bindValueType(const QString& placeholder) const { - return d->types.value(d->indexes.value(placeholder, -1), QSql::In); + return d->types.value(d->indexes.value(placeholder).value(0,-1), QSql::In); } /*! |