Commit Graph

9 Commits

Author SHA1 Message Date
silverqx
c4430453e6 drivers added SqlDatabase::record(tableName)
It allows to obtain a SqlRecord for the given table.

Populating the Default Column Values works the same way as
for the SqlQuery/SqlResult couterparts.

The recordCached() counterparts in SqlResult were not implemented
because of cache invalidation problems (not possible with the current
API, it's hard to implement).

This API always select-s all columns from the information_schema.columns
table, that's why the SqlResult::recordWithDefaultValues(allColumns)
has the allColumns parameter, it's used but this API/feature.

 - added functional tests
 - added a new empty_with_default_values table
 - logic that doesn't fit into the MySqlDriver class was extracted
   to the SelectsAllColumnsWithLimit0 concern 🕺
2024-07-20 19:58:54 +02:00
silverqx
22966e62c2 drivers final review
This commit contains a huge amount of small fixes and changes, almost
every file was edited.

I still have 21 new todos to finish/revisit and also, all todos defined
in mysqlresult/_p.cpp and sqlquery.cpp (~33).

 - bugfix in MySqlUtilsPrivate::decodeMySqlType()
 - updated NOTES.txt - TinyOrm headres used in TinyDrivers
2024-04-07 18:12:02 +02:00
silverqx
039e9fcf4b drivers get rid of Drivers::SqlError 🔥🚀🥳
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()
2024-04-07 18:12:00 +02:00
silverqx
b4bd2da02f drivers used TinyDrivers exceptions everywhere
- added a new exception class OutOfRange
 - unified exceptions
2024-04-07 18:11:59 +02:00
silverqx
247bb5e936 tom added TinyDrivers to tom about
- and also to the tom --version
 - added components to Dependencies section
 - prints info also about TinyMySql
 - takes into account all build types static/shared/loadable
 - tests both build systems qmake/CMake
2024-04-07 18:11:56 +02:00
silverqx
64bab2e792 drivers added basic exception classes 2024-04-07 18:11:38 +02:00
silverqx
6a3337be57 drivers renamed SqlDriverError to SqlError 2024-04-07 18:11:35 +02:00
silverqx
9c3143dd16 drivers renamed SqlQuery1 to SqlQuery 2024-04-07 18:11:35 +02:00
silverqx
018f9d70ee drivers initial qmake build 2024-04-07 18:11:34 +02:00