From ca400e36ea0a450a5b37b25c2778f3c922184e9d Mon Sep 17 00:00:00 2001 From: Robert Szefner Date: Sat, 9 Mar 2019 22:50:47 +0100 Subject: [PATCH 1/3] Inline TSqlQuery functions that only call base implementation --- src/tsqlquery.cpp | 52 ----------------------------------------------- src/tsqlquery.h | 52 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 52 deletions(-) diff --git a/src/tsqlquery.cpp b/src/tsqlquery.cpp index 5da4a3299..e6b31bfc3 100644 --- a/src/tsqlquery.cpp +++ b/src/tsqlquery.cpp @@ -176,55 +176,3 @@ bool TSqlQuery::exec() Tf::writeQueryLog(executedQuery(), ret, lastError()); return ret; } - -/*! - Returns the number of rows affected by the result's SQL statement, or -1 - if it cannot be determined. Note that for SELECT statements, the value is - undefined; use size() instead. If the query is not active, -1 is returned. - */ -int TSqlQuery::numRowsAffected() const -{ - return QSqlQuery::numRowsAffected(); -} - -/*! - Returns the size of the result (number of rows returned), or -1 if the size - cannot be determined or if the database does not support reporting information - about query sizes. Note that for non-SELECT statements (isSelect() returns - false), size() will return -1. If the query is not active (isActive() returns - false), -1 is returned. - To determine the number of rows affected by a non-SELECT statement, use - numRowsAffected(). - */ -int TSqlQuery::size() const -{ - return QSqlQuery::size(); -} - -/*! - Retrieves the next record in the result, if available, and positions the - query on the retrieved record. Note that the result must be in the active - state and isSelect() must return true before calling this function or it - will do nothing and return false. - */ -bool TSqlQuery::next() -{ - return QSqlQuery::next(); -} - -/*! - Returns the value of field index in the current record. - */ -QVariant TSqlQuery::value(int index) const -{ - return QSqlQuery::value(index); -} - -/*! - Returns the value of the field called name in the current record. - If field name does not exist an invalid variant is returned. - */ -QVariant TSqlQuery::value(const QString &name) const -{ - return QSqlQuery::value(name); -} diff --git a/src/tsqlquery.h b/src/tsqlquery.h index f325bdc51..a9dd341fe 100644 --- a/src/tsqlquery.h +++ b/src/tsqlquery.h @@ -77,4 +77,56 @@ inline QVariant TSqlQuery::getNextValue() return (next()) ? record().value(0) : QVariant(); } +/*! + Returns the number of rows affected by the result's SQL statement, or -1 + if it cannot be determined. Note that for SELECT statements, the value is + undefined; use size() instead. If the query is not active, -1 is returned. + */ +inline int TSqlQuery::numRowsAffected() const +{ + return QSqlQuery::numRowsAffected(); +} + +/*! + Returns the size of the result (number of rows returned), or -1 if the size + cannot be determined or if the database does not support reporting information + about query sizes. Note that for non-SELECT statements (isSelect() returns + false), size() will return -1. If the query is not active (isActive() returns + false), -1 is returned. + To determine the number of rows affected by a non-SELECT statement, use + numRowsAffected(). + */ +inline int TSqlQuery::size() const +{ + return QSqlQuery::size(); +} + +/*! + Retrieves the next record in the result, if available, and positions the + query on the retrieved record. Note that the result must be in the active + state and isSelect() must return true before calling this function or it + will do nothing and return false. + */ +inline bool TSqlQuery::next() +{ + return QSqlQuery::next(); +} + +/*! + Returns the value of field index in the current record. + */ +inline QVariant TSqlQuery::value(int index) const +{ + return QSqlQuery::value(index); +} + +/*! + Returns the value of the field called name in the current record. + If field name does not exist an invalid variant is returned. + */ +inline QVariant TSqlQuery::value(const QString &name) const +{ + return QSqlQuery::value(name); +} + #endif // TSQLQUERY_H From 977e89f72a6edd7da6621bcd24293a3b57599937 Mon Sep 17 00:00:00 2001 From: Robert Szefner Date: Sat, 9 Mar 2019 22:54:01 +0100 Subject: [PATCH 2/3] Removed unnecessary brackets --- src/tsqlquery.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tsqlquery.h b/src/tsqlquery.h index a9dd341fe..02dd6d9e4 100644 --- a/src/tsqlquery.h +++ b/src/tsqlquery.h @@ -74,7 +74,7 @@ inline TSqlQuery &TSqlQuery::addBind(const QVariant &val) */ inline QVariant TSqlQuery::getNextValue() { - return (next()) ? record().value(0) : QVariant(); + return next() ? record().value(0) : QVariant(); } /*! From 7c8d3e3f894370e5aef0fb981e82e8fa3777d377 Mon Sep 17 00:00:00 2001 From: Robert Szefner Date: Sat, 9 Mar 2019 23:05:40 +0100 Subject: [PATCH 3/3] Use QStringLiteral in formatValue() --- src/tsqlquery.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tsqlquery.cpp b/src/tsqlquery.cpp index e6b31bfc3..4a7beefb5 100644 --- a/src/tsqlquery.cpp +++ b/src/tsqlquery.cpp @@ -129,7 +129,7 @@ QString TSqlQuery::formatValue(const QVariant &val, QVariant::Type type, const Q type = val.type(); } - QSqlField field("dummy", type); + QSqlField field(QStringLiteral("dummy"), type); field.setValue(val); return database.driver()->formatValue(field); }