summaryrefslogtreecommitdiffstats
path: root/src/sql
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2018-01-11 18:01:13 +0100
committerLiang Qi <liang.qi@qt.io>2018-01-11 18:10:41 +0100
commitf4d8cafc1b034f544ca84b849c23ab99bc1600e7 (patch)
treef1150b5aeaec4753f2ddfcd17643666b3a82dd9d /src/sql
parente5b422382a512a8267a0eb24e6543a8cf84478d9 (diff)
parentb03133231b99922a72831c4ec23faf55516ef404 (diff)
Merge remote-tracking branch 'origin/5.10' into dev
Conflicts: src/3rdparty/harfbuzz-ng/src/hb-private.hh src/sql/doc/snippets/code/doc_src_sql-driver.cpp src/sql/doc/src/sql-driver.qdoc Change-Id: I38f0e82fcd37926cbf3c1915e009a731040d4598
Diffstat (limited to 'src/sql')
-rw-r--r--src/sql/doc/snippets/code/doc_src_sql-driver.cpp12
-rw-r--r--src/sql/doc/src/sql-driver.qdoc6
-rw-r--r--src/sql/kernel/qsqlrecord.cpp15
3 files changed, 26 insertions, 7 deletions
diff --git a/src/sql/doc/snippets/code/doc_src_sql-driver.cpp b/src/sql/doc/snippets/code/doc_src_sql-driver.cpp
index e7dfbd90d5..2c0e824db3 100644
--- a/src/sql/doc/snippets/code/doc_src_sql-driver.cpp
+++ b/src/sql/doc/snippets/code/doc_src_sql-driver.cpp
@@ -127,3 +127,15 @@ while (query1.next()) {
} // query1, and cause the loop to quit
}
//! [37]
+
+
+//! [39]
+QSqlDatabase db = QSqlDatabase::addDatabase("QODBC3");
+QString connectString = QStringLiteral(
+ "DRIVER=/path/to/installation/libodbcHDB.so;"
+ "SERVERNODE=hostname:port;"
+ "UID=USER;"
+ "PWD=PASSWORD;"
+ "SCROLLABLERESULT=true");
+db.setDatabaseName(connectString);
+//! [39]
diff --git a/src/sql/doc/src/sql-driver.qdoc b/src/sql/doc/src/sql-driver.qdoc
index 70205d5552..dc8d52b572 100644
--- a/src/sql/doc/src/sql-driver.qdoc
+++ b/src/sql/doc/src/sql-driver.qdoc
@@ -299,6 +299,12 @@
e.g., the SQLSTATEs. Before setting this connect option, consult
your ODBC documentation about behavior differences you can expect.
+ When using the SAP HANA database, the connection has to be
+ established using the option "SCROLLABLERESULT=TRUE", as the
+ HANA ODBC driver does not provide scrollable results by default, e.g.:
+
+ \snippet code/doc_src_sql-driver.cpp 39
+
If you experience very slow access of the ODBC datasource, make sure
that ODBC call tracing is turned off in the ODBC datasource manager.
diff --git a/src/sql/kernel/qsqlrecord.cpp b/src/sql/kernel/qsqlrecord.cpp
index 1c9ad5ec63..ecbe3eacdb 100644
--- a/src/sql/kernel/qsqlrecord.cpp
+++ b/src/sql/kernel/qsqlrecord.cpp
@@ -232,18 +232,19 @@ QString QSqlRecord::fieldName(int index) const
int QSqlRecord::indexOf(const QString& name) const
{
- QString tableName;
- QString fieldName = name;
+ QStringRef tableName;
+ QStringRef fieldName(&name);
const int idx = name.indexOf(QLatin1Char('.'));
if (idx != -1) {
- tableName = name.left(idx);
- fieldName = name.mid(idx + 1);
+ tableName = name.leftRef(idx);
+ fieldName = name.midRef(idx + 1);
}
- for (int i = 0; i < count(); ++i) {
+ const int cnt = count();
+ for (int i = 0; i < cnt; ++i) {
// Check the passed in name first in case it is an alias using a dot.
// Then check if both the table and field match when there is a table name specified.
- const auto currentField = d->fields.at(i);
- const auto currentFieldName = currentField.name();
+ const auto &currentField = d->fields.at(i);
+ const auto &currentFieldName = currentField.name();
if (currentFieldName.compare(name, Qt::CaseInsensitive) == 0
|| (idx != -1 && currentFieldName.compare(fieldName, Qt::CaseInsensitive) == 0
&& currentField.tableName().compare(tableName, Qt::CaseInsensitive) == 0)) {