summaryrefslogtreecommitdiffstats
path: root/src/sql
diff options
context:
space:
mode:
authorTasuku Suzuki <stasuku@gmail.com>2013-06-17 10:44:09 +0900
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-12-01 23:14:15 +0100
commitc3c424b384b06354116e232bf4055514f9b205ce (patch)
treeae76f4b7881413ea3093440a6d1cbfe9e3477c19 /src/sql
parentded6a7081b8b34906ee875e68e2048570c2e98d8 (diff)
QSqlQuery::isNull string overload
Introduce isNull overload to take field name as a parameter. This is corresponding to the commit 7e6e1412348fb8d8df844d821ee80d6d3de69517 Change-Id: I122f79707d26eaa09c2f38dc31aeee1dac7de33b Reviewed-by: Mark Brand <mabrand@mabrand.nl>
Diffstat (limited to 'src/sql')
-rw-r--r--src/sql/kernel/qsqlquery.cpp18
-rw-r--r--src/sql/kernel/qsqlquery.h1
2 files changed, 19 insertions, 0 deletions
diff --git a/src/sql/kernel/qsqlquery.cpp b/src/sql/kernel/qsqlquery.cpp
index e5f4c5fc56..e040257c62 100644
--- a/src/sql/kernel/qsqlquery.cpp
+++ b/src/sql/kernel/qsqlquery.cpp
@@ -326,6 +326,24 @@ bool QSqlQuery::isNull(int field) const
}
/*!
+ \overload
+
+ Returns true if there is no field with this \a name; otherwise
+ returns isNull(int index) for the corresponding field index.
+
+ This overload is less efficient than \l{QSqlQuery::}{isNull()}
+*/
+
+bool QSqlQuery::isNull(const QString &name) const
+{
+ int index = d->sqlResult->record().indexOf(name);
+ if (index > -1)
+ return isNull(index);
+ qWarning("QSqlQuery::isNull: unknown field name '%s'", qPrintable(name));
+ return true;
+}
+
+/*!
Executes the SQL in \a query. Returns \c true and sets the query state
to \l{isActive()}{active} if the query was successful; otherwise
diff --git a/src/sql/kernel/qsqlquery.h b/src/sql/kernel/qsqlquery.h
index 3719643174..ef48b91298 100644
--- a/src/sql/kernel/qsqlquery.h
+++ b/src/sql/kernel/qsqlquery.h
@@ -70,6 +70,7 @@ public:
bool isValid() const;
bool isActive() const;
bool isNull(int field) const;
+ bool isNull(const QString &name) const;
int at() const;
QString lastQuery() const;
int numRowsAffected() const;