From 4131bfb2c28d0554805bbfcf009b422bda820c09 Mon Sep 17 00:00:00 2001 From: Mark Brand Date: Thu, 21 Mar 2013 22:32:40 +0100 Subject: make QSqlResultPrivate::fieldSerial() virtual The Qt psql driver has its own implementation of fieldSerial() it uses when it invokes positionalToNamedBinding() to generate a query using its native naming style. Now that QPSQLResultPrivate is derived from QSqlResultPrivate this can be implemented more conventionally using a virtual function instead of pointers to static functions. Note that this change preserves the current behavior of executedQuery() which will continue to return the query with positional syntax that is presented to virtual prepare() by QSqlResult::savePrepare(). Since the driver does not have the NamedPlaceholders feature, QSqlResult::savePrepare() will not use positionaltoNamedBinding() to set executedQuery. Although QPSQLResult::prepare() calls positionaltoNamedBinding(), it does not put the result into executedQuery. Change-Id: I7740f386cbfec9eadd9e4d6a7df3e590294655a5 Reviewed-by: Israel Lins Albuquerque Reviewed-by: Mark Brand --- src/sql/drivers/psql/qsql_psql.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/sql/drivers/psql') diff --git a/src/sql/drivers/psql/qsql_psql.cpp b/src/sql/drivers/psql/qsql_psql.cpp index 6b642dcb15..13c985d1df 100644 --- a/src/sql/drivers/psql/qsql_psql.cpp +++ b/src/sql/drivers/psql/qsql_psql.cpp @@ -202,7 +202,7 @@ public: preparedQueriesEnabled(false) { } - static QString fieldSerial(int i) { return QLatin1Char('$') + QString::number(i + 1); } + QString fieldSerial(int i) const { return QLatin1Char('$') + QString::number(i + 1); } void deallocatePreparedStmt(); const QPSQLDriverPrivate * privDriver() const {Q_Q(const QPSQLResult); return reinterpret_cast(q->driver())->d; } @@ -594,7 +594,7 @@ bool QPSQLResult::prepare(const QString &query) d->deallocatePreparedStmt(); const QString stmtId = qMakePreparedStmtId(); - const QString stmt = QString::fromLatin1("PREPARE %1 AS ").arg(stmtId).append(QSqlResultPrivate::positionalToNamedBinding(query, QPSQLResultPrivate::fieldSerial)); + const QString stmt = QString::fromLatin1("PREPARE %1 AS ").arg(stmtId).append(d->positionalToNamedBinding(query)); PGresult *result = d->privDriver()->exec(stmt); -- cgit v1.2.3