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
Added CONFIG option inline_constants/extern_constants, in shared library
build is used extern_constants option ( can be overridden by
inline_constants option ) and in static library build is used
inline_constants option ( can not be overridden, extern constants cause
crash ).
- refactored exports in TinyUtils
- bugfix on tst_version for static build
Discarded configuration of the version header file by version.hpp.in,
instead the project version is obtained from version.hpp file.
- also added autotest to test these versions
- like cherries on a cake, a real Product/FileVersion in exe/dll of the
TinyOrm.dll and utils.dll is tested too 😲😎
- added new Fs library class to the utils dll
- renamed macro defines in utils project to TINYUTILS_XYZ_HPP
- support for querying nested relations existence/absence
- added tests for all possible overloads 😲, 28 unit tests and 14
functional tests
- added has() related proxies to the Model and Relation
- added documentation
- gcc and clang specific fixes
others:
- used clazy exclude comments instead of suppressing warnings in IDE
groupBy() methods now take column expressions.
- added all proxies
- added new perfectly forwarded groupBy(&&...args) overload
- all new code tested manually in the TinyOrmPlayground
- 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
The HasOne and BelongsTo can now return default model instead
of the nullptr.
- also added tests
- added documentation
- updated test db structure, null foreign key in previewable files
- to the test db into the previewable files added row without parent
- relation factory methods return actual creating type instead of
the general base Relation type
- 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
- fixed mysql query builder unit tests
- every query builder unit tests will have own test project, sqlite
test project will be in the next commit to preserve commit history
- 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
Relationship can be created by the BaseModel::belongsToMany method.
Added common Pivot model class for a pivot table that extends
the BasePivot<PivotModel>, so a user can extend this class to define
custom pivot model class.
Pivot relation is saved under the pivot key and can be customized by
the BelongsToMany::as method.
Can be selected custom columns in the pivot table by the help with
the withPivot() method.
Can be selected default or custom timestamp columns with withTimestamps
method.
Added example model classes Tag and Tagged for the pivot table, which
demonstrates all implemented features.
Pivot model relations are ignored during refresh.
- added torrent_tags and tag_torrent tables to the test database
- added tag_properties to the test table to test eager load relations
on the pivot table
- added Tag model and Tagged pivot model
- used friend declaration instead of friend class
- fixed typos and whitespaces
- removed unnecessary empty cpp files, without any implementation
methods
- used using BaseModel::BaseModel in all models
- fixed template parameter names in the Relation class
- moved the getKeys method up to the Relation class
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
- every connection is configurable
- can be added more connections, for now only to the MySQL database
- code is ready to add PostgreSQL, SqlLite, and Microsoft SqlServer or
any DB supported by underlying QSqlDatabase class
- added MySQL connection and MySQL connector
- removed QueryBuilder::table() and getTable() methods
- added 'as' parameter to the QueryBuilder::from() method, but does
nothing for now
- BaseModel implements HasConnectionResolver interface
- DatabaseConnection::queryBuilder() renamed to query()
- removed EntityManager, all methods are implemented
in the DatabaseManager
- removed RepositoryFactory, have to be implemented in the future