Divided to 5 commits for simpler review.
Fifth commit:
- renamed toVector() methods
- updated all comments
- also renamed toVectorVariantList() to toListVariantList() and
attributesToVector() to attributesToList()
These methods must be renamed, they must be toList() because in the
future there can be toVector() method that will convert to
std::vector<>.
Also, all symbols described below which contain the word [Vv]ector will
not be renamed to [Ll]ist, the reason for this is that the QList<> is
vector and in the future when the QtCore dependency will be dropped 😮
this will be the std::vector<>. 😎
- variable names that are of type QList<>
- method names which are operating on the QList<>
- comments like: Vector of attached models IDs.
Moved all features which aren't used through CONFIG+=xyz and are loaded
using the load(private/xyz) function to the qmake/features/private/
folder.
Currently, the qmake/features/ folder contains only features which
should be used using the CONFIG+= qmake variable.
This is part 2 of: used TinyDrivers exceptions everywhere.
The Drivers::SqlError was dropped and renamed to DummySqlError which
does nothing and it exists only for API compatibility with QtSql module
and it also helps to avoid #ifdef-s in users/client code.
There are 3 exceptions (what is all this about) and they are SqlError,
QueryError, and SqlTransactionError. The SqlError is a general SQL
exception class that is thrown eg. during connecting to SQL server
or during all other SQL API calls that are not database queries or
transaction queries.
The second part of this commit was to modify all error handling
in TinyOrm library and adapt it to exceptions thrown from
the TinyDrivers library.
Many #ifdef-s were added because of this because QtSql module returns
bool and then you need to obtain the QSqlError and TinyDrivers library
throws exceptions.
This commit was huge, also it's very weird and this error handling
things are unpopular and everybody has different opinion on this, but
it is what it is.
There is not way I would return bool and set error state instead of
exceptions in TinyDrivers, never.
Also, there is no way I would catch Drivers::SqlError/QueryError/
SqlTransactionError in TinyOrm library and translate these TinyDrivers
exceptions to TinyOrm exceptions with the same names to throw only one
set of exceptions, no way. TinyDrivers throws its own exceptions and
TinyOrm linked against QtSql throws its own exceptions (with the same
names but in different namespace).
- removed all setLastError() and throw exceptions instead
- added new constants
- optimized #include-s
- changed the causedByLostConnection() method signature
- enhanced the ManagesTransactions class
- extracted code to the mysqlClose()
- removed MySqlDriverPrivate::q_ptr (not needed anymore)
- removed createError() and createStmtError() (not needed anymore) and
added prepareMySqlError() and prepareStmtError() as counterparts
- renamed method to errorMessageForStmtFetch()
- extracted the replaceBindingsInSql() because it's used from both
TinyOrm and TinyDrivers libraries
- enhanced replaceBindingsInSql()
- added support for BLOB-s
- the SqlError, QueryError, and SqlTransactionError are excluded from
TinyOrm library build and include path if compiled against
the TinyDrivers library (they are not needed and used anymore)
- added connection name to SqlResult class, it's used in exception
messages
- also updated auto tests
bugfix-es:
- qmake propagate the TINYDRIVERS_MYSQL_DRIVER DEFINE (made it public),
cmake build is OK
- removed mysql_thread_init()
- changed call order for the mysql_thread_end()
As the TinyDrivers library uses smart pointers everywhere it stores
the SqlDriver as std::shared_ptr<>/weak_ptr<> and because of this
we end up with API compatibility problems, exactly
the exposed SqlDriver *driver() method was problematic.
This commit solves this problem. The idea was to provide compatible API
related to this driver() method but also to still be able use smart
pointers internally.