mirror of
https://github.com/silverqx/TinyORM.git
synced 2025-12-31 15:59:33 -06:00
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
64 lines
1.7 KiB
C++
64 lines
1.7 KiB
C++
#include "orm/sqliteconnection.hpp"
|
|
|
|
#include "orm/query/grammars/sqlitegrammar.hpp"
|
|
#include "orm/query/processors/sqliteprocessor.hpp"
|
|
#include "orm/schema/grammars/sqliteschemagrammar.hpp"
|
|
#include "orm/schema/sqliteschemabuilder.hpp"
|
|
|
|
TINYORM_BEGIN_COMMON_NAMESPACE
|
|
|
|
namespace Orm
|
|
{
|
|
|
|
SQLiteConnection::SQLiteConnection(
|
|
std::function<Connectors::ConnectionName()> &&connection,
|
|
const QString &database, const QString &tablePrefix,
|
|
const QVariantHash &config
|
|
)
|
|
: DatabaseConnection(std::move(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();
|
|
|
|
useDefaultPostProcessor();
|
|
}
|
|
|
|
std::unique_ptr<SchemaBuilder> SQLiteConnection::getSchemaBuilder()
|
|
{
|
|
if (!m_schemaGrammar)
|
|
useDefaultSchemaGrammar();
|
|
|
|
return std::make_unique<SchemaNs::SQLiteSchemaBuilder>(*this);
|
|
}
|
|
|
|
std::unique_ptr<QueryGrammar> SQLiteConnection::getDefaultQueryGrammar() const
|
|
{
|
|
// Ownership of a unique_ptr()
|
|
auto grammar = std::make_unique<Query::Grammars::SQLiteGrammar>();
|
|
|
|
withTablePrefix(*grammar);
|
|
|
|
return grammar;
|
|
}
|
|
|
|
std::unique_ptr<SchemaGrammar> SQLiteConnection::getDefaultSchemaGrammar() const
|
|
{
|
|
// Ownership of a unique_ptr()
|
|
auto grammar = std::make_unique<SchemaNs::Grammars::SQLiteSchemaGrammar>();
|
|
|
|
withTablePrefix(*grammar);
|
|
|
|
return grammar;
|
|
}
|
|
|
|
std::unique_ptr<QueryProcessor> SQLiteConnection::getDefaultPostProcessor() const
|
|
{
|
|
return std::make_unique<Query::Processors::SQLiteProcessor>();
|
|
}
|
|
|
|
} // namespace Orm
|
|
|
|
TINYORM_END_COMMON_NAMESPACE
|