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()
- added a new tst_Blobs functional test case that inserts
binary()/text() and mediumBinary()/mediumText()
- updated schema builder unit tests, added all supported binary types
- updated migrations
- added Lorem ipsum paragraphs generator
include exception headers (silverqx/TinyORM#16)
The querybuilders' unit tests fail to compile due to some Exception
classes being undefined if ORM compilation is disabled via cmake.
The undefined exceptions are actually being built as part of the
querybuilder. However, the unit tests deep-end on models/user.hpp to
include the header files for the exception classes they are using,
but the corresponding include directive is skipped for builds that
disable ORM.
Close#16
---------
Co-authored-by: Silver Zachara <silver.zachara@gmail.com>
For the MySQL schema grammar added:
- optional column keyword for add, change, or modify alter operations
- optional index keyword for fulltext and unique index alter operations
Added the change() method which allows to modify the type and attributes
of existing columns.
- added renameTo() for MySQL which can be used with the change()
- added tests
- updated docs
MariaDB doesn't support setting a nullable modifier (NULL or NOT NULL)
on generated columns, a query fails if nullable is set. The best that
can be done is to ignore it. 🫤
- added tests
Added the MariaDB connections and verified and passed all auto tests.
There was not too much to fix. The TLS connections are still not
enabled.
- fixed upsert
- fixed tests
- enhanced upsert tests
- refactored tst_mysql_qdatetime to be able test both, the MySQL and
also MariaDB database connections
- added a few new MariaDB related tests
- refactored PostgreSQL grammar for generated columns
- unified nullable() on generated columns, now it behaves the same for
all supported databases and also behaves the same as everywhere else
- used an optional "generated always as" for all databases instead of
only "as ()" because it better expresses what it means, "as ()" looks
very similar like a column alias
- temporarily disabled logic in MySQL::nullable() for MariaDB, I'm
going to prepare and set up the MariaDB dev. env. to correctly
support it, then I will finish it
- added tests
Others:
- tests for MySQL and PostgreSQL added tests to test multiple
auto-increment starting values (startingValue() or from() alias)
Used TinyORM modifiers to set a default value and for the MySQL also
"on update" value for the datetime and timestamp column types.
Previously, the SQL for a default value and for the "on update" was
generated right away, now, the ColumnDefinition instance is modified
and later in the SQL generation process will be this clauses generated.
- updated tests, the order of the null value and default values were
switched
Refactored whereExists() to accept the std::shared_ptr<QueryBuilder> and
QueryBuilder &.
- added unit and functional test
- updated docs
- updated all proxies
Added ability to call the table and column comments related code with
the SQLite driver, it do nothing though and it can't throw exception.
- added unit tests
The table comment can be added for the MySQL and PostgreSQL databases.
The SQLite database doesn't support it.
- added unit and functional tests
- added docs