Database connection can run in a thread, if you create a connection in
a thread, then you have to use it only from that thread, moving it to
another thread is disallowed.
All restrictions for QSqlDatabase are true also for TinyORM.
The most important work was in DatabaseManager because more threads can
access it at once.
DatabaseManager has to be created only once in the whole application,
so it means when it will be created in a non-main thread, then it has
to be used from this non-main thread the whole time, I didn't try it
to move to another thread, the conclusion is that DatabaseManager can be
created and used from a worker thread.
- refactored db configuration
- added DatabaseConnectionsMap to outsource ConnectionsType and make it
thread_local
- added resetDefaultConnection()
- m_queryLogId is atomic
- made all class static data members thread_local
Thread unrelated:
- added two new addConnections() overloads
- added Thread utils class
- added NameThreadForDebugging()
- enhanced tst_DatabaseManager
- explicitly declared all virtual destructors
- inline for pure dtors moved to the declaration
- used override/final where appropriate
- made some dtors pure virtual where appropriate
- removed all occurrences of QT_NO_DEBUG_OUTPUT, it is up to user
- TINYORM_DEBUG_SQL is enabled in debug builds and TINYORM_NO_DEBUG_SQL
in release builds, user still can override debug build with
TINYORM_NO_DEBUG_SQL
- enhanced debug output in DatabaseConnection class
- added driverNamePrintable(), databaseName(), hostName() to
DB/DatabaseManager/DatabaseConnection
- logquery added to NS and created library class for it
- also all tests pass, problem was only with bool values and truncate
statement ( can't be send as prepared statement )
- updated migration and seeds, added PostgreSQL connection
- bugfix in migration script ?? vs ?:
- added DatabaseConnection::unprepared()
- added query log
- added pretending (dry run) feature
- pretending has separate logging logic for qDebug()
- added records have been modified flag to the database connection
- deleted copy/move ctors for connection classes
Removed std::tuple<bool, QSqlQuery>, exactly bool ok return value
for non-affecting statements, used the QSqlQuery only.
- also unified return values in the Model::save()
- added u_fillable on models used in tests that need it
- added documentation for mass assignment
- added tests for mass assignment feature
- added new Torrent models for tests, which have set up u_fillable and
u_guarded differently
- added schema grammar, query post-processor, and schema builder, they
was needed for database column listing during a mass assignment
guarded attributes check, used to check if the given attribute is
a valid guardable column
- all tests are ran against SQLite test database too 🎉🔥
- removed default models connection for tests, because I'm testing
models for all database connections and the connection is controlled
by global test data, so every test is ran against all the
supported databases
- added test code controlled by TINYORM_TESTS_CODE preprocessor macro,
which enables connection override in the BaseModel
- build tests only when the "CONFIG += build_tests" was added to the
qmake command
added php script to create databases
- script creates MySQL and SQLite databases
- script populate this databases with test data
- connection credentials are provided through the DB_ env. variables
other changes
- added api to enable statement counters for the given connections
- added BaseModel::truncate test
The BelongsToMany::attach overloads are able to accept also Model instance/s.
The many-to-many relation also supports touching timestamps on the pivot table and also touching parent timestamps.
Added queries execution time counter and the number of executed queries
counter, it counts normal, affecting and transactional queries.
Also added proxy methods to the DB facade and DatabaseManager.
The DatabaseManager also contains api to be able enable/disable counters
on all connections or get/reset counters on all connections.
- tried to compile without PCH and added all the missing includes
Huge commit, added following documentation pages:
- Database: Getting Started
- Database: Query Builder
- TinyORM: Getting Started
- TinyORM: Relationships
Also fixed and added many features to match behavior described
in the documentation.
- added Orm::DB facade
- made DatabaseManager strict singleton
- added BaseModel/TinyBuilder::without method and also tests
- bugfix affecting statements always returned 1
- removed defaultConnection argument from the DatabaseManager::create
- added many proxy methods from DatabaseManager -> DatabaseConnection,
for transactions, select, update, remove, ... type methods and
DB::raw method
- added JoinClause::orOn method
- added QueryBuilder::groupBy overload
- added where type proxy methods to the Tiny::Relations::Relation
- added some missing where and order type proxy methods
to the TinyBuilder
- fixed typos and some minor fixes in a comment texts
- added feature which logs also transaction queries
- added a new exception class SqlTransactionError
- added overloaded methods to the
ConnectionInterface::savepoint/rollbackToSavepoint that takes size_t
- into the QueryBuilder, TinyBuilder and BaseModel
- added latest()/oldest() methods into the QueryBuilder, TinyBuilder
and BaseModel
- created_at/updated_at columns are touched during insert/update
- a user can control if the model should be timestamped with
the u_timestamps data member in Models
- a user can change the storage format of the model's date columns
with the u_dateFormat data member in Models
- a user can override CREATED_AT/UPDATED_AT static data members
in Models
- added some shortcut methods related to timestamping into the Relation
class
- added reconnector, which reconnects when a connection lost
- when connection fails or lost, the SqlError exception will be thrown
- throw the QueryError exception when executed query failed
- ConnectionInterface is passed around instead of
the DatabaseConnection
- renamed some methods in the DatabaseConnection to match Eloquent