Commit Graph

560 Commits

Author SHA1 Message Date
silverqx
a2714be30e added schema builder 🔥🚀
Added practically everything I wanted to have in except for updating
columns.
Needed to name the schema namespace as Orm::SchemaNs to avoid collision
with the Orm::Schema class.

 - unit tests with great coverage
 - new schema constants
 - a new prefix_indexes and engine DB conncetion configurations

Others:

 - IsModel tag
 - enhanced columnize in the BaseGrammar
 - used a new columnize logic in all grammars
 - new constants
 - new container utils class for joining containers
 - new DB::driver() getter for QSqlDriver
 - avoid possible crash in tests with pretend, added empty log checks
 - clang tidy, excluded to word from short variable names
2022-03-22 09:53:33 +01:00
silverqx
a7ace30999 unified constexpr static 2022-03-07 09:20:34 +01:00
silverqx
3bc8f43fd3 missing connection parameter in DB/DM
Added connection parameter to all methods in DB/DM.
2022-03-06 12:45:19 +01:00
silverqx
6751ac849b added containsConnection() to DB/DatabaseManager 2022-03-06 12:44:13 +01:00
silverqx
8e75deb53a added on() alias for connection()
It allows shorter syntax like DB::on(connection).
2022-03-06 12:43:08 +01:00
silverqx
25e5c066ff divided table() to table()/tableAs()
This allows to call table(table, connection) and it avoids following
call table(table, "", connection) if 'as' is empty.
2022-03-06 12:42:02 +01:00
silverqx
f268166f8f avoid to create physical connection for pretending
Added getQtQueryForPretend() that avoids to create physical connection
during pretend call when a physical DB connection was not created.
2022-03-06 12:37:48 +01:00
silverqx
80a1623b1d unified static constexpr
- also added const for STORE_TYPE
2022-03-06 12:34:36 +01:00
silverqx
1f4da6a6e4 missing inline 2022-03-06 12:33:46 +01:00
silverqx
98c207a7d9 added comment 2022-03-06 12:33:27 +01:00
silverqx
bbd36faeba added todo tasks 2022-03-06 12:32:43 +01:00
silverqx
9a54b520bc added isOpen()/connectEagerly()/pingDatabase()
- added connectEagerly() that allows to force connection to the DB
 - added isOpen()
 - exposed isOpen()/connectEagerly()/pingDatabase() to DB and
   DatabaseManager
2022-03-06 12:31:10 +01:00
silverqx
e79be8906c used __has_include() to check mysql.h
Used __has_include() in #if macro directives instead of checking
_MSC_VER or __MINGW32__ to include mysql.h file.

 - also modified #error directive calls
2022-03-06 12:22:04 +01:00
silverqx
4fc92a6e53 updated comment 2022-03-01 16:13:49 +01:00
silverqx
c932f091c4 updated comments and renamed method
- clarified comments about connect/reconnect logic
   in the DatabaseConnection
 - renamed refreshQtConnection() method.
2022-03-01 15:30:17 +01:00
silverqx
39b92f5716 bugfix during disconnect
Do nothing if TinyORM connection is not resolved.

 - also throw RuntimeError in getRawQtConnection() if TinyORM
   connection is not resolved
2022-03-01 15:28:51 +01:00
silverqx
839a9fe16f exported (dll) DetectsLostConnections 2022-03-01 15:24:24 +01:00
silverqx
136a32c5fe added DatabaseConnection::isOpen()
It is a proxy to the QSqlDatabase::isOpen() method.
2022-03-01 15:23:08 +01:00
silverqx
fbee3297ac handle lost connection during transactions
- bugfix reset transactions when lost connection occurs during
   commit()/rollBack()/savepoint()/rollBackToSavepoint() method calls
 - enhanced beginTransaction(), reconnect when connection was lost
2022-02-23 11:29:28 +01:00
silverqx
d5ad16fb06 added SIZE constant 2022-02-20 15:21:49 +01:00
silverqx
e4a7ec5593 added todo tasks 2022-02-14 17:26:27 +01:00
silverqx
1991c8a959 modified Model's CRTP problem exception 2022-02-14 17:26:10 +01:00
silverqx
c165469f5d bugfix return QString for __tiny_func__ 2022-02-14 17:25:08 +01:00
silverqx
5956cb86c5 added OrmError base class for all exceptions 2022-02-14 17:23:31 +01:00
silverqx
a898660dfa enable/disable debugging of SQL queries
Added possibility to enable/disable debugging of SQL queries per
connection (logging to the console using qDebug()).
2022-02-12 18:49:26 +01:00
silverqx
df0c1d666a added todo tasks 2022-02-12 13:17:05 +01:00
silverqx
cde15172c0 shared_ptr for DatabaseManager factory methods
Refactored from an unique_ptr to shared_ptr, I think this is a better
approach. Now it will be clear that a few DatabaseManager pointers are
stored somewhere in the TinyORM.

 - return std:shared_ptr from DatabaseManager factory methods
 - store a shared_ptr<DatabaseManager> in private data members in
   DatabaseManager and DB classes
2022-02-10 15:02:43 +01:00
silverqx
ac32a6d3c4 qmake enhanced precompiled headers 2022-02-09 07:41:47 +01:00
silverqx
76ad095241 added Concerns::ExplainQueries
It is not enabled because Qt sql driver doesn't support EXPLAIN queries.
2022-01-18 11:07:57 +01:00
silverqx
71d22f2034 unified almost all throw exceptions 2022-01-17 19:07:59 +01:00
silverqx
245fd10a70 removed fixed todo task 2022-01-17 16:42:48 +01:00
silverqx
043e26b920 removed empty cpp files 2022-01-17 16:25:29 +01:00
silverqx
880e0bac65 bugfix bad usage of Q_ASSERT() 2022-01-17 15:28:23 +01:00
silverqx
28568f2236 bugfix copy/move Model instance
In the release build HasRelationStore::m_relationStore will be always
empty during copied/moved operation.
In the debug mode are enabled Q_ASSERT() checks to inform a user.

A Model class can not be copied/moved during any HasRelationStore
operation.
2022-01-17 15:11:48 +01:00
silverqx
ed3f0b446e disabled copy/move ctors 2022-01-17 10:45:33 +01:00
silverqx
f61d777276 explicitly declared constructors 2022-01-17 10:37:03 +01:00
silverqx
1fcfefce94 init. QueryBuilder operators only once 2022-01-17 10:22:28 +01:00
silverqx
73fa6d2246 explicitly declared ctors
In QueryBuilder and JoinClause, to be clearly visible that deleted
assignment operators are expected.
2022-01-17 10:21:47 +01:00
silverqx
35f139fda9 removed const in Model::AttributeReference 2022-01-16 18:27:24 +01:00
silverqx
7a017855f8 disabled copy constructors
Disabled on all relations, tiny builder and all base classes
2022-01-16 18:26:40 +01:00
silverqx
8794b8b285 extracted relation types to own header file 2022-01-16 18:24:05 +01:00
silverqx
aeb20613a0 removed const in SqlError 2022-01-16 18:22:28 +01:00
silverqx
5cab0ae779 cleanup of DatabaseConnection 2022-01-15 11:46:58 +01:00
silverqx
1976a1ca1f revert removed alias
Clang tidy 12 buggy report, fixed in Clang tidy 13.
2022-01-15 11:18:05 +01:00
silverqx
b734a09b53 fixed includes and typos 2022-01-15 11:08:01 +01:00
silverqx
23ce64689f removed redundant protected specifier 2022-01-14 22:03:06 +01:00
silverqx
9b5ff78ef4 made logConnected()/logDisconnected() private 2022-01-14 22:00:57 +01:00
silverqx
bbfca1594e extracted transactions to ManagesTransactions
Transactions extracted to the Concerns::ManagesTransactions base class.

 - bugfix includes
 - logConnected()/logDisconnected() code wrapped in TINYORM_MYSQL_PING
 - hitTransactionalCounters() extracted to Concerns::CountsQueries
 - convertNamedToPositionalBindings() extracted to Concerns::LogsQueries
2022-01-14 21:26:02 +01:00
silverqx
ff0697e1a5 extracted logging queries to LogQueries
Logging queries extracted to the Concerns::LogsQueries base class.
2022-01-14 17:37:58 +01:00
silverqx
e188239e37 added public section 2022-01-14 16:39:50 +01:00