summaryrefslogtreecommitdiffstats
path: root/src/sql
diff options
context:
space:
mode:
Diffstat (limited to 'src/sql')
-rw-r--r--src/sql/doc/snippets/code/doc_src_sql-driver.qdoc59
-rw-r--r--src/sql/doc/src/sql-driver.qdoc87
-rw-r--r--src/sql/kernel/qsqlcachedresult.cpp8
-rw-r--r--src/sql/kernel/qsqlcachedresult_p.h9
-rw-r--r--src/sql/kernel/qsqldatabase.cpp6
-rw-r--r--src/sql/kernel/qsqldriver.cpp5
-rw-r--r--src/sql/kernel/qsqldriver.h16
-rw-r--r--src/sql/kernel/qsqldriver_p.h17
-rw-r--r--src/sql/kernel/qsqlindex.cpp3
-rw-r--r--src/sql/kernel/qsqlquery.cpp3
-rw-r--r--src/sql/kernel/qsqlresult_p.h35
-rw-r--r--src/sql/models/qsqlrelationaltablemodel.cpp14
-rw-r--r--src/sql/models/qsqltablemodel.cpp2
13 files changed, 162 insertions, 102 deletions
diff --git a/src/sql/doc/snippets/code/doc_src_sql-driver.qdoc b/src/sql/doc/snippets/code/doc_src_sql-driver.qdoc
index 9709deeccb..b869b309b7 100644
--- a/src/sql/doc/snippets/code/doc_src_sql-driver.qdoc
+++ b/src/sql/doc/snippets/code/doc_src_sql-driver.qdoc
@@ -70,7 +70,6 @@ BEGIN
END
//! [1]
-
//! [3]
cd $QTDIR/qtbase/src/plugins/sqldrivers
qmake -- MYSQL_PREFIX=/usr/local
@@ -86,14 +85,15 @@ make install
//! [5]
cd %QTDIR%\qtbase\src\plugins\sqldrivers
-qmake -- MYSQL_INCDIR=C:/MySQL/include "MYSQL_LIBDIR=C:/MYSQL/MySQL Server <version>/lib/opt"
+qmake -- MYSQL_INCDIR="C:/Program Files/MySQL/MySQL Connector C 6.1/include" MYSQL_LIBDIR="C:/Program Files/MySQL/MySQL Connector C 6.1/lib"
nmake sub-mysql
+nmake install
//! [5]
//! [6]
cd $QTDIR/qtbase/src/plugins/sqldrivers
-qmake -- "OCI_INCDIR=$ORACLE_HOME/rdbms/public" OCI_LIBDIR=$ORACLE_HOME/lib "OCI_LIBS=-lclntsh -lwtc9"
+qmake -- OCI_INCDIR="$ORACLE_HOME/rdbms/public" OCI_LIBDIR="$ORACLE_HOME/lib" OCI_LIBS="-lclntsh -lwtc9"
make sub-oci
//! [6]
@@ -142,6 +142,7 @@ make sub-psql
cd %QTDIR%\qtbase\src\plugins\sqldrivers
qmake -- PSQL_INCDIR=C:/psql/include PSQL_LIBDIR=C:/psql/lib/ms
nmake sub-psql
+nmake install
//! [15]
@@ -156,6 +157,7 @@ make sub-tds
cd %QTDIR%\qtbase\src\plugins\sqldrivers
qmake
nmake sub-tds
+nmake install
//! [17]
@@ -168,8 +170,9 @@ make sub-db2
//! [20]
cd %QTDIR%\qtbase\src\plugins\sqldrivers
-qmake -- "DB2_PREFIX=<DB2 home>/sqllib"
+qmake -- DB2_PREFIX="<DB2 home>/sqllib"
nmake sub-db2
+nmake install
//! [20]
@@ -184,6 +187,7 @@ make sub-sqlite
cd %QTDIR%\qtbase\src\plugins\sqldrivers
qmake -- -system-sqlite SQLITE3_PREFIX=C:/SQLITE
nmake sub-sqlite
+nmake install
//! [23]
@@ -205,6 +209,7 @@ make sub-ibase
cd %QTDIR%\qtbase\src\plugins\sqldrivers
qmake -- IBASE_INCDIR=C:/interbase/include
nmake sub-ibase
+nmake install
//! [29]
@@ -212,24 +217,25 @@ nmake sub-ibase
cd %QTDIR%\qtbase\src\plugins\sqldrivers
qmake -- IBASE_INCDIR=C:/interbase/include IBASE_LIBS=-lfbclient
nmake sub-ibase
+nmake install
//! [30]
//! [32]
-configure OCI_INCDIR=/usr/include/oracle/10.1.0.3/client OCI_LIBDIR=/usr/lib/oracle/10.1.0.3/client/lib -R /usr/lib/oracle/10.1.0.3/client/lib "OCI_LIBS=-lclntsh -lnnz10"
+configure OCI_INCDIR=/usr/include/oracle/10.1.0.3/client OCI_LIBDIR=/usr/lib/oracle/10.1.0.3/client/lib -R /usr/lib/oracle/10.1.0.3/client/lib OCI_LIBS="-lclntsh -lnnz10"
make
//! [32]
//! [33]
cd $QTDIR/qtbase/src/plugins/sqldrivers
-qmake -- OCI_INCDIR=/usr/include/oracle/10.1.0.3/client OCI_LIBDIR=/usr/lib/oracle/10.1.0.3/client/lib "OCI_LIBS=-Wl,-rpath,/usr/lib/oracle/10.1.0.3/client/lib -lclntsh -lnnz10"
+qmake -- OCI_INCDIR=/usr/include/oracle/10.1.0.3/client OCI_LIBDIR=/usr/lib/oracle/10.1.0.3/client/lib OCI_LIBS="-Wl,-rpath,/usr/lib/oracle/10.1.0.3/client/lib -lclntsh -lnnz10"
make sub-oci
//! [33]
//! [35]
QSqlDatabase: QPSQL driver not loaded
-QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7
+QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QMARIADB QODBC QODBC3 QPSQL QPSQL7
Could not create database object
//! [35]
@@ -250,3 +256,42 @@ q.exec(QString("CREATE TABLE %1 (id INTEGER)").arg(tableString));
// Call toLower() on the string so that it can be matched
QSqlRecord rec = database.record(tableString.toLower());
//! [40]
+
+//! [41]
+C:\Qt5\5.13.2\Src\qtbase\src\plugins\sqldrivers>qmake -version
+QMake version 3.1
+Using Qt version 5.13.2 in C:/Qt5/5.13.2/mingw73_64/lib
+C:\Qt5\5.13.2\Src\qtbase\src\plugins\sqldrivers>qmake -- MYSQL_INCDIR="C:/Program Files/MySQL/MySQL Connector C 6.1/include" MYSQL_LIBDIR="C:/Program Files/MySQL/MySQL Connector C 6.1/lib"
+Info: creating stash file C:\Qt5\5.13.2\Src\qtbase\src\plugins\sqldrivers\.qmake.stash
+
+Running configuration tests...
+Checking for DB2 (IBM)... no
+Checking for InterBase... no
+Checking for MySQL... yes
+Checking for OCI (Oracle)... no
+Checking for ODBC... yes
+Checking for PostgreSQL... no
+Checking for SQLite (version 2)... no
+Checking for TDS (Sybase)... no
+Done running configuration tests.
+
+Configure summary:
+
+Qt Sql Drivers:
+ DB2 (IBM) .............................. no
+ InterBase .............................. no
+ MySql .................................. yes
+ OCI (Oracle) ........................... no
+ ODBC ................................... yes
+ PostgreSQL ............................. no
+ SQLite2 ................................ no
+ SQLite ................................. yes
+ Using system provided SQLite ......... no
+ TDS (Sybase) ........................... no
+
+Qt is now configured for building. Just run 'mingw32-make'.
+Once everything is built, you must run 'mingw32-make install'.
+Qt will be installed into 'C:\Qt5\5.13.2\mingw73_64'.
+
+Prior to reconfiguration, make sure you remove any leftovers from the previous build.
+//! [41]
diff --git a/src/sql/doc/src/sql-driver.qdoc b/src/sql/doc/src/sql-driver.qdoc
index c6ac4d17ff..4d6df63749 100644
--- a/src/sql/doc/src/sql-driver.qdoc
+++ b/src/sql/doc/src/sql-driver.qdoc
@@ -48,7 +48,7 @@
\header \li Driver name \li DBMS
\row \li \l{#QDB2}{QDB2} \li IBM DB2 (version 7.1 and above)
\row \li \l{#QIBASE}{QIBASE} \li Borland InterBase
- \row \li \l{#QMYSQL}{QMYSQL} \li MySQL
+ \row \li \l{#QMYSQL}{QMYSQL / MARIADB} \li MySQL or MariaDB (version 5.0 and above)
\row \li \l{#QOCI}{QOCI} \li Oracle Call Interface Driver
\row \li \l{#QODBC}{QODBC}
\li Open Database Connectivity (ODBC) - Microsoft SQL Server and other
@@ -70,7 +70,8 @@
access to the API exposed by the DBMS, and is typically shipped with it.
Most installation programs also allow you to install "development
libraries", and these are what you need. These libraries are responsible
- for the low-level communication with the DBMS.
+ for the low-level communication with the DBMS. Also make sure to install
+ the correct database libraries for your Qt architecture (32 or 64 bit).
\note When using Qt under Open Source terms but with a proprietary
database, verify the client library's license compatibility with
@@ -91,11 +92,21 @@
may be necessary to specify these paths using the \c *_INCDIR=,
\c *_LIBDIR=, or \c *_PREFIX= command-line options. For example,
if your MySQL files are installed in \c /usr/local/mysql (or in
- \c{C:\mysql} on Windows), then pass the following parameter to
- configure: \c MYSQL_PREFIX=/usr/local/mysql
- (or \c{MYSQL_PREFIX=C:\mysql} for Windows).
+ \c{C:/Program Files/MySQL/MySQL Connector C 6.1} on Windows), then pass the
+ following parameter to configure: \c MYSQL_PREFIX=/usr/local/mysql
+ (or \c{MYSQL_PREFIX="C:/Program Files/MySQL/MySQL Connector C 6.1"} for Windows).
The particulars for each driver are explained below.
+ If something goes wrong and you want qmake to recheck your
+ available drivers, you must remove \e{config.cache} in
+ \e{<QTDIR>/qtbase/src/plugins/sqldrivers} - otherwise qmake will not
+ search for the available drivers again. If you encounter an error during
+ the qmake stage, open \e{config.log} to see what went wrong.
+
+ A typical qmake run (in this case to configure for MySQL) looks like this:
+
+ \snippet code/doc_src_sql-driver.qdoc 41
+
Due to the practicalities of dealing with external dependencies,
only the SQLite3 plugin is shipped with binary builds of Qt.
To be able to add additional drivers to the Qt installation
@@ -112,11 +123,17 @@
\section1 Driver Specifics
\target QMYSQL
- \section2 QMYSQL for MySQL 4 and higher
+ \section2 QMYSQL for MySQL or MariaDB 5 and higher
+
+ MariaDB is a fork of MySQL intended to remain free and open-source software
+ under the GNU General Public License. MariaDB intended to maintain high
+ compatibility with MySQL, ensuring a drop-in replacement capability with
+ library binary parity and exact matching with MySQL APIs and commands.
+ Therefore the plugin for MySQL and MariaDB are combined into one Qt plugin.
\section3 QMYSQL Stored Procedure Support
- MySQL 5 introduces stored procedure support at the SQL level, but no
+ MySQL 5 has stored procedure support at the SQL level, but no
API to control IN, OUT, and INOUT parameters. Therefore, parameters
have to be set and read using SQL commands instead of QSqlQuery::bindValue().
@@ -147,28 +164,53 @@
\section3 How to Build the QMYSQL Plugin on Unix and \macos
- You need the MySQL header files, as well as the shared library
- \c{libmysqlclient.so}. Depending on your Linux distribution, you may
- need to install a package which is usually called "mysql-devel".
+ You need the MySQL / MariaDB header files, as well as the shared library
+ \c{libmysqlclient.so} / \c{libmariadb.so}. Depending on your Linux distribution,
+ you may need to install a package which is usually called "mysql-devel"
+ or "mariadb-devel".
- Tell \l qmake where to find the MySQL header files and shared
- libraries (here it is assumed that MySQL is installed in
+ Tell \l qmake where to find the MySQL / MariaDB header files and shared
+ libraries (here it is assumed that MySQL / MariaDB is installed in
\c{/usr/local}) and run \c{make}:
\snippet code/doc_src_sql-driver.qdoc 3
\section3 How to Build the QMYSQL Plugin on Windows
- You need to get the MySQL installation files. Run \c SETUP.EXE and
- choose "Custom Install". Install the "Libs & Include Files" Module.
- Build the plugin as follows (here it is assumed that MySQL is
- installed in \c{C:\MySQL}):
+ You need to get the MySQL installation files (e.g.
+ \l {https://dev.mysql.com/downloads/installer/}{mysql-installer-web-community-8.0.18.0.msi}) or
+ \l {https://downloads.mariadb.org/connector-c/3.1.5/}{mariadb-connector-c-3.1.5-win64.msi}.
+ Run the installer,
+ select custom installation and install the MySQL C Connector
+ which matches your Qt installation (x86 or x64).
+ After installation make sure that the needed files are there:
+ \list
+ \li \c {<MySQL dir>/lib/libmysql.lib}
+ \li \c {<MySQL dir>/lib/libmysql.dll}
+ \li \c {<MySQL dir>/include/mysql.h}
+ \endlist
+ and for MariaDB
+ \list
+ \li \c {<MariaDB dir>/lib/libmariadb.lib}
+ \li \c {<MariaDB dir>/lib/libmariadb.dll}
+ \li \c {<MariaDB dir>/include/mysql.h}
+ \endlist
+
+ Build the plugin as follows (here it is assumed that the MySQL
+ C Connector is installed in
+ \c{C:/Program Files/MySQL/MySQL Connector C 6.1}):
\snippet code/doc_src_sql-driver.qdoc 5
If you are not using a Microsoft compiler, replace \c nmake with \c
mingw32-make in the line above.
+ When you distribute your application, remember to include libmysql.dll / libmariadb.dll
+ in your installation package. It must be placed in the same folder
+ as the application executable. \e libmysql.dll additionally needs the
+ MSVC runtime libraries which can be installed with vcredist.exe
+ (\l {https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads}{vcredist.exe}
+
\target QOCI
\section2 QOCI for the Oracle Call Interface (OCI)
@@ -329,10 +371,6 @@
Windows NT based systems, this is the default. Note that the ODBC
driver and the DBMS must also support Unicode.
- Some driver managers and drivers do not support UNICODE. To use the
- QODBC plugin with such drivers, it has to be compiled with
- Q_ODBC_VERSION_2 defined.
-
For the Oracle 9 ODBC driver (Windows), it is necessary to check
"SQL_WCHAR support" in the ODBC driver manager otherwise Oracle
will convert all Unicode strings to local 8-bit.
@@ -398,11 +436,6 @@
\snippet code/doc_src_sql-driver.qdoc 40
- \section3 QPSQL BLOB Support
-
- Binary Large Objects are supported through the \c BYTEA field type in
- PostgreSQL server versions >= 7.1.
-
\section3 QPSQL Forward-only query support
To use forward-only queries, you must build the QPSQL plugin with
@@ -463,6 +496,10 @@
Users of MinGW may wish to consult the following online document:
\l{http://www.postgresql.org/docs/current/static/installation-platform-notes.html#INSTALLATION-NOTES-MINGW}{PostgreSQL MinGW/Native Windows}.
+ When you distribute your application, remember to include libpq.dll
+ in your installation package. It must be placed in the same folder
+ as the application executable.
+
\target QTDS
\section2 QTDS for Sybase Adaptive Server
diff --git a/src/sql/kernel/qsqlcachedresult.cpp b/src/sql/kernel/qsqlcachedresult.cpp
index c335d7d8fe..1e76154f82 100644
--- a/src/sql/kernel/qsqlcachedresult.cpp
+++ b/src/sql/kernel/qsqlcachedresult.cpp
@@ -60,14 +60,6 @@ QT_BEGIN_NAMESPACE
static const uint initial_cache_size = 128;
-QSqlCachedResultPrivate::QSqlCachedResultPrivate(QSqlCachedResult *q, const QSqlDriver *drv)
- : QSqlResultPrivate(q, drv),
- rowCacheEnd(0),
- colCount(0),
- atEnd(false)
-{
-}
-
void QSqlCachedResultPrivate::cleanup()
{
cache.clear();
diff --git a/src/sql/kernel/qsqlcachedresult_p.h b/src/sql/kernel/qsqlcachedresult_p.h
index 543a902554..1bca1fd090 100644
--- a/src/sql/kernel/qsqlcachedresult_p.h
+++ b/src/sql/kernel/qsqlcachedresult_p.h
@@ -101,7 +101,8 @@ class Q_SQL_EXPORT QSqlCachedResultPrivate: public QSqlResultPrivate
Q_DECLARE_PUBLIC(QSqlCachedResult)
public:
- QSqlCachedResultPrivate(QSqlCachedResult *q, const QSqlDriver *drv);
+ using QSqlResultPrivate::QSqlResultPrivate;
+
bool canSeek(int i) const;
inline int cacheCount() const;
void init(int count, bool fo);
@@ -110,9 +111,9 @@ public:
void revertLast();
QSqlCachedResult::ValueCache cache;
- int rowCacheEnd;
- int colCount;
- bool atEnd;
+ int rowCacheEnd = 0;
+ int colCount = 0;
+ bool atEnd = false;
};
QT_END_NAMESPACE
diff --git a/src/sql/kernel/qsqldatabase.cpp b/src/sql/kernel/qsqldatabase.cpp
index 01726d79ef..32338c1fe2 100644
--- a/src/sql/kernel/qsqldatabase.cpp
+++ b/src/sql/kernel/qsqldatabase.cpp
@@ -84,7 +84,7 @@ Q_GLOBAL_STATIC(QConnectionDict, dbDict)
class QSqlDatabasePrivate
{
public:
- QSqlDatabasePrivate(QSqlDatabase *d, QSqlDriver *dr = 0):
+ QSqlDatabasePrivate(QSqlDatabase *d, QSqlDriver *dr = nullptr):
ref(1),
q(d),
driver(dr),
@@ -178,7 +178,7 @@ DriverDict &QSqlDatabasePrivate::driverDict()
QSqlDatabasePrivate *QSqlDatabasePrivate::shared_null()
{
static QSqlNullDriver dr;
- static QSqlDatabasePrivate n(NULL, &dr);
+ static QSqlDatabasePrivate n(nullptr, &dr);
return &n;
}
@@ -702,7 +702,7 @@ void QSqlDatabasePrivate::init(const QString &type)
qWarning("QSqlDatabase: %s driver not loaded", type.toLatin1().data());
qWarning("QSqlDatabase: available drivers: %s",
QSqlDatabase::drivers().join(QLatin1Char(' ')).toLatin1().data());
- if (QCoreApplication::instance() == 0)
+ if (QCoreApplication::instance() == nullptr)
qWarning("QSqlDatabase: an instance of QCoreApplication is required for loading driver plugins");
driver = shared_null()->driver;
}
diff --git a/src/sql/kernel/qsqldriver.cpp b/src/sql/kernel/qsqldriver.cpp
index e0ddc4ca84..adf4421c89 100644
--- a/src/sql/kernel/qsqldriver.cpp
+++ b/src/sql/kernel/qsqldriver.cpp
@@ -51,11 +51,10 @@ QT_BEGIN_NAMESPACE
static QString prepareIdentifier(const QString &identifier,
QSqlDriver::IdentifierType type, const QSqlDriver *driver)
{
- Q_ASSERT( driver != NULL );
+ Q_ASSERT(driver != nullptr);
QString ret = identifier;
- if (!driver->isIdentifierEscaped(identifier, type)) {
+ if (!driver->isIdentifierEscaped(identifier, type))
ret = driver->escapeIdentifier(identifier, type);
- }
return ret;
}
diff --git a/src/sql/kernel/qsqldriver.h b/src/sql/kernel/qsqldriver.h
index ca9f7dc51e..31de63be15 100644
--- a/src/sql/kernel/qsqldriver.h
+++ b/src/sql/kernel/qsqldriver.h
@@ -100,7 +100,7 @@ public:
virtual QStringList tables(QSql::TableType tableType) const;
virtual QSqlIndex primaryIndex(const QString &tableName) const;
virtual QSqlRecord record(const QString &tableName) const;
- virtual QString formatValue(const QSqlField& field, bool trimStrings = false) const;
+ virtual QString formatValue(const QSqlField &field, bool trimStrings = false) const;
virtual QString escapeIdentifier(const QString &identifier, IdentifierType type) const;
virtual QString sqlStatement(StatementType type, const QString &tableName,
@@ -113,12 +113,12 @@ public:
virtual void close() = 0;
virtual QSqlResult *createResult() const = 0;
- virtual bool open(const QString& db,
- const QString& user = QString(),
- const QString& password = QString(),
- const QString& host = QString(),
+ virtual bool open(const QString &db,
+ const QString &user = QString(),
+ const QString &password = QString(),
+ const QString &host = QString(),
int port = -1,
- const QString& connOpts = QString()) = 0;
+ const QString &connOpts = QString()) = 0;
virtual bool subscribeToNotification(const QString &name);
virtual bool unsubscribeFromNotification(const QString &name);
virtual QStringList subscribedToNotifications() const;
@@ -135,10 +135,6 @@ public Q_SLOTS:
virtual bool cancelQuery();
Q_SIGNALS:
-#if QT_DEPRECATED_SINCE(5, 15)
- QT_DEPRECATED_X("Use the 3-args version of notification() instead.")
- void notification(const QString &name);
-#endif
void notification(const QString &name, QSqlDriver::NotificationSource source, const QVariant &payload);
protected:
diff --git a/src/sql/kernel/qsqldriver_p.h b/src/sql/kernel/qsqldriver_p.h
index c8ec961124..614fbf69a1 100644
--- a/src/sql/kernel/qsqldriver_p.h
+++ b/src/sql/kernel/qsqldriver_p.h
@@ -63,19 +63,16 @@ class QSqlDriverPrivate : public QObjectPrivate
Q_DECLARE_PUBLIC(QSqlDriver)
public:
- QSqlDriverPrivate()
- : QObjectPrivate(),
- isOpen(false),
- isOpenError(false),
- precisionPolicy(QSql::LowPrecisionDouble),
- dbmsType(QSqlDriver::UnknownDbms)
- { }
+ QSqlDriverPrivate(QSqlDriver::DbmsType dbmstype = QSqlDriver::UnknownDbms)
+ : QObjectPrivate()
+ , dbmsType(dbmstype)
+ {}
- uint isOpen;
- uint isOpenError;
QSqlError error;
- QSql::NumericalPrecisionPolicy precisionPolicy;
+ QSql::NumericalPrecisionPolicy precisionPolicy = QSql::LowPrecisionDouble;
QSqlDriver::DbmsType dbmsType;
+ bool isOpen = false;
+ bool isOpenError = false;
};
QT_END_NAMESPACE
diff --git a/src/sql/kernel/qsqlindex.cpp b/src/sql/kernel/qsqlindex.cpp
index 60b0ef6965..5781f24b5c 100644
--- a/src/sql/kernel/qsqlindex.cpp
+++ b/src/sql/kernel/qsqlindex.cpp
@@ -44,9 +44,6 @@
QT_BEGIN_NAMESPACE
-// ### Qt 6: remove the static assertion, the 'sorts' field was changed from QList to QVector in Qt 5.6
-Q_STATIC_ASSERT((sizeof(QList<bool>) == sizeof(QVector<bool>)));
-
/*!
\class QSqlIndex
\brief The QSqlIndex class provides functions to manipulate and
diff --git a/src/sql/kernel/qsqlquery.cpp b/src/sql/kernel/qsqlquery.cpp
index 8947ed1084..ce6c997919 100644
--- a/src/sql/kernel/qsqlquery.cpp
+++ b/src/sql/kernel/qsqlquery.cpp
@@ -182,6 +182,9 @@ QSqlQueryPrivate::~QSqlQueryPrivate()
You can retrieve the values of all the fields in a single variable
(a map) using boundValues().
+ \note Not all SQL operations support binding values. Refer to your database
+ system's documentation to check their availability.
+
\section1 Approaches to Binding Values
Below we present the same example using each of the four
diff --git a/src/sql/kernel/qsqlresult_p.h b/src/sql/kernel/qsqlresult_p.h
index f0816a7fb5..3b9697046d 100644
--- a/src/sql/kernel/qsqlresult_p.h
+++ b/src/sql/kernel/qsqlresult_p.h
@@ -79,16 +79,9 @@ class Q_SQL_EXPORT QSqlResultPrivate
public:
QSqlResultPrivate(QSqlResult *q, const QSqlDriver *drv)
: q_ptr(q),
- sqldriver(const_cast<QSqlDriver*>(drv)),
- idx(QSql::BeforeFirstRow),
- active(false),
- isSel(false),
- forwardOnly(false),
- precisionPolicy(QSql::LowPrecisionDouble),
- bindCount(0),
- binds(QSqlResult::PositionalBinding)
+ sqldriver(const_cast<QSqlDriver *>(drv))
{ }
- virtual ~QSqlResultPrivate() { }
+ virtual ~QSqlResultPrivate() = default;
void clearValues()
{
@@ -111,7 +104,7 @@ public:
void clear()
{
clearValues();
- clearIndex();;
+ clearIndex();
}
virtual QString fieldSerial(int) const;
@@ -119,27 +112,27 @@ public:
QString namedToPositionalBinding(const QString &query);
QString holderAt(int index) const;
- QSqlResult *q_ptr;
+ QSqlResult *q_ptr = nullptr;
QPointer<QSqlDriver> sqldriver;
- int idx;
QString sql;
- bool active;
- bool isSel;
QSqlError error;
- bool forwardOnly;
- QSql::NumericalPrecisionPolicy precisionPolicy;
-
- int bindCount;
- QSqlResult::BindingSyntax binds;
QString executedQuery;
QHash<int, QSql::ParamType> types;
QVector<QVariant> values;
- typedef QHash<QString, QVector<int> > IndexMap;
+ using IndexMap = QHash<QString, QVector<int> >;
IndexMap indexes;
- typedef QVector<QHolder> QHolderVector;
+ using QHolderVector = QVector<QHolder>;
QHolderVector holders;
+
+ QSqlResult::BindingSyntax binds = QSqlResult::PositionalBinding;
+ QSql::NumericalPrecisionPolicy precisionPolicy = QSql::LowPrecisionDouble;
+ int idx = QSql::BeforeFirstRow;
+ int bindCount = 0;
+ bool active = false;
+ bool isSel = false;
+ bool forwardOnly = false;
};
QT_END_NAMESPACE
diff --git a/src/sql/models/qsqlrelationaltablemodel.cpp b/src/sql/models/qsqlrelationaltablemodel.cpp
index b0e26d7378..4f5f00bf96 100644
--- a/src/sql/models/qsqlrelationaltablemodel.cpp
+++ b/src/sql/models/qsqlrelationaltablemodel.cpp
@@ -137,7 +137,7 @@ class QRelatedTableModel;
struct QRelation
{
public:
- QRelation(): model(0), m_parent(0), m_dictInitialized(false) {}
+ QRelation(): model(nullptr), m_parent(nullptr), m_dictInitialized(false) {}
void init(QSqlRelationalTableModel *parent, const QSqlRelation &relation);
void populateModel();
@@ -161,7 +161,7 @@ struct QRelation
class QRelatedTableModel : public QSqlTableModel
{
public:
- QRelatedTableModel(QRelation *rel, QObject *parent = 0, const QSqlDatabase &db = QSqlDatabase());
+ QRelatedTableModel(QRelation *rel, QObject *parent = nullptr, const QSqlDatabase &db = QSqlDatabase());
bool select() override;
private:
bool firstSelect;
@@ -174,7 +174,7 @@ private:
*/
void QRelation::init(QSqlRelationalTableModel *parent, const QSqlRelation &relation)
{
- Q_ASSERT(parent != NULL);
+ Q_ASSERT(parent != nullptr);
m_parent = parent;
rel = relation;
}
@@ -183,7 +183,7 @@ void QRelation::populateModel()
{
if (!isValid())
return;
- Q_ASSERT(m_parent != NULL);
+ Q_ASSERT(m_parent != nullptr);
if (!model) {
model = new QRelatedTableModel(this, m_parent, m_parent->database());
@@ -202,7 +202,7 @@ void QRelation::populateDictionary()
if (!isValid())
return;
- if (model == NULL)
+ if (model == nullptr)
populateModel();
QSqlRecord record;
@@ -234,13 +234,13 @@ void QRelation::clearDictionary()
void QRelation::clear()
{
delete model;
- model = 0;
+ model = nullptr;
clearDictionary();
}
bool QRelation::isValid()
{
- return (rel.isValid() && m_parent != NULL);
+ return (rel.isValid() && m_parent != nullptr);
}
diff --git a/src/sql/models/qsqltablemodel.cpp b/src/sql/models/qsqltablemodel.cpp
index d6810cc6af..4d20915c09 100644
--- a/src/sql/models/qsqltablemodel.cpp
+++ b/src/sql/models/qsqltablemodel.cpp
@@ -1305,7 +1305,7 @@ Qt::ItemFlags QSqlTableModel::flags(const QModelIndex &index) const
Q_D(const QSqlTableModel);
if (index.internalPointer() || index.column() < 0 || index.column() >= d->rec.count()
|| index.row() < 0)
- return 0;
+ return { };
bool editable = true;