added SQLite database support 🔥🚀

- 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
This commit is contained in:
silverqx
2021-03-26 16:07:41 +01:00
parent 50ee6625a4
commit 68446e3530
70 changed files with 4205 additions and 860 deletions

View File

@@ -0,0 +1,33 @@
#include "orm/sqliteconnection.hpp"
#include "orm/query/grammars/sqlitegrammar.hpp"
#ifdef TINYORM_COMMON_NAMESPACE
namespace TINYORM_COMMON_NAMESPACE
{
#endif
namespace Orm
{
SQLiteConnection::SQLiteConnection(
const std::function<Connectors::ConnectionName()> &connection,
const QString &database, const QString tablePrefix,
const QVariantHash &config
)
: DatabaseConnection(connection, database, tablePrefix, config)
{
/* We need to initialize a query grammar that is a very important part
of the database abstraction, so we initialize it to the default value
while starting. */
useDefaultQueryGrammar();
}
std::unique_ptr<QueryGrammar> SQLiteConnection::getDefaultQueryGrammar() const
{
return std::make_unique<Query::Grammars::SQLiteGrammar>();
}
} // namespace Orm
#ifdef TINYORM_COMMON_NAMESPACE
} // namespace TINYORM_COMMON_NAMESPACE
#endif