mirror of
https://github.com/silverqx/TinyORM.git
synced 2026-01-07 11:29:44 -06:00
added connection configuration getters to DB/DM
Added getters for obtaining connection configuration. - original configurations from the DatabaseManager - and configurations from the DatabaseConnection
This commit is contained in:
@@ -291,6 +291,23 @@ namespace Query
|
||||
/*! Return the host name of the connected database. */
|
||||
const QString &hostName(const QString &connection = "");
|
||||
|
||||
/* Connection configuration - saved in the DatabaseManager */
|
||||
/*! Get an original configuration for the given connection
|
||||
(passed to the DB::create, original/unchanged). */
|
||||
const QVariantHash &originalConfig(const QString &connection = "") const;
|
||||
/*! Get an original configuration option value for the given connection
|
||||
(passed to the DB::create, original/unchanged). */
|
||||
QVariant originalConfigValue(const QString &option,
|
||||
const QString &connection = "") const;
|
||||
|
||||
/* Connection configuration - proxies to the DatabaseConnection */
|
||||
/*! Get the configuration for the current connection. */
|
||||
const QVariantHash &getConfig(const QString &connection = "");
|
||||
/*! Get an option value from the configuration options. */
|
||||
QVariant getConfig(const QString &option, const QString &connection = "");
|
||||
/*! Check whether the configuration contains the given option. */
|
||||
bool hasConfig(const QString &option, const QString &connection = "");
|
||||
|
||||
/* Pretending */
|
||||
/*! Execute the given callback in "dry run" mode. */
|
||||
QVector<Log>
|
||||
|
||||
@@ -290,6 +290,22 @@ namespace Orm
|
||||
/*! Return the host name of the connected database. */
|
||||
static const QString &hostName(const QString &connection = "");
|
||||
|
||||
/* Connection configuration - saved in the DatabaseManager */
|
||||
/*! Get the configuration for a connection. */
|
||||
static const QVariantHash &originalConfig(const QString &connection = "");
|
||||
/*! Get a configuration option value from the configuration for a connection. */
|
||||
static QVariant originalConfigValue(const QString &option,
|
||||
const QString &connection = "");
|
||||
|
||||
/* Connection configuration - proxies to the DatabaseConnection */
|
||||
/*! Get the configuration for the current connection. */
|
||||
static const QVariantHash &getConfig(const QString &connection = "");
|
||||
/*! Get an option value from the configuration options. */
|
||||
static QVariant getConfigValue(const QString &option,
|
||||
const QString &connection = "");
|
||||
/*! Check whether the configuration contains the given option. */
|
||||
static bool hasConfigValue(const QString &option, const QString &connection = "");
|
||||
|
||||
/* Pretending */
|
||||
/*! Execute the given callback in "dry run" mode. */
|
||||
static QVector<Log>
|
||||
|
||||
@@ -759,6 +759,42 @@ DatabaseManager::hostName(const QString &connection)
|
||||
return this->connection(connection).getHostName();
|
||||
}
|
||||
|
||||
/* Connection configuration - saved in the DatabaseManager */
|
||||
|
||||
QVariant
|
||||
DatabaseManager::originalConfigValue(const QString &option,
|
||||
const QString &connection) const
|
||||
{
|
||||
return originalConfig(connection).value(option);
|
||||
}
|
||||
|
||||
const QVariantHash &
|
||||
DatabaseManager::originalConfig(const QString &connection) const
|
||||
{
|
||||
const auto &connectionName = parseConnectionName(connection);
|
||||
|
||||
throwIfNoConfiguration(connectionName);
|
||||
|
||||
return (*m_configuration).at(connectionName);
|
||||
}
|
||||
|
||||
/* Connection configuration - proxies to the DatabaseConnection */
|
||||
|
||||
QVariant DatabaseManager::getConfig(const QString &option, const QString &connection)
|
||||
{
|
||||
return this->connection(connection).getConfig(option);
|
||||
}
|
||||
|
||||
const QVariantHash &DatabaseManager::getConfig(const QString &connection)
|
||||
{
|
||||
return this->connection(connection).getConfig();
|
||||
}
|
||||
|
||||
bool DatabaseManager::hasConfig(const QString &option, const QString &connection)
|
||||
{
|
||||
return this->connection(connection).hasConfig(option);
|
||||
}
|
||||
|
||||
/* Pretending */
|
||||
|
||||
QVector<Log>
|
||||
|
||||
@@ -507,6 +507,43 @@ const QString &DB::hostName(const QString &connection)
|
||||
return manager().connection(connection).getHostName();
|
||||
}
|
||||
|
||||
/* Connection configuration - saved in the DatabaseManager */
|
||||
|
||||
/* Difference between a connection config. saved in the DatabaseManager and
|
||||
DatabaseConnection can differ in some cases. A configuration saved
|
||||
in the DatabaseConnection is already processed by the ConnectionFactory and Connector.
|
||||
Eg. the host config. option can differ because a user can pass a QStringList of hosts,
|
||||
so in the DM will be this QStringList, but in the DatabaseConnection will be only
|
||||
the QString, a hostname to which the connection was successful. */
|
||||
|
||||
const QVariantHash &DB::originalConfig(const QString &connection)
|
||||
{
|
||||
return manager().originalConfig(connection);
|
||||
}
|
||||
|
||||
QVariant
|
||||
DB::originalConfigValue(const QString &option, const QString &connection)
|
||||
{
|
||||
return manager().originalConfigValue(option, connection);
|
||||
}
|
||||
|
||||
/* Connection configuration - proxies to the DatabaseConnection */
|
||||
|
||||
const QVariantHash &DB::getConfig(const QString &connection)
|
||||
{
|
||||
return manager().connection(connection).getConfig();
|
||||
}
|
||||
|
||||
QVariant DB::getConfigValue(const QString &option, const QString &connection)
|
||||
{
|
||||
return manager().connection(connection).getConfig(option);
|
||||
}
|
||||
|
||||
bool DB::hasConfigValue(const QString &option, const QString &connection)
|
||||
{
|
||||
return manager().connection(connection).hasConfig(option);
|
||||
}
|
||||
|
||||
/* Pretending */
|
||||
|
||||
QVector<Log>
|
||||
|
||||
Reference in New Issue
Block a user