Lightweight 0.20261105.1
Loading...
Searching...
No Matches
Lightweight::Driver::SqlDriverConnectionOperations Concept Reference

The connection and transaction operations a driver provides, as free functions found by argument-dependent lookup on its connection handle struct. More...

#include <Concept.hpp>

Concept definition

template<typename D>
concept Lightweight::Driver::SqlDriverConnectionOperations = requires(D::Connection& connection,
D::Connection const& constConnection,
bool enabled,
SqlIsolationMode isolationMode,
CloseDiagnostic closeDiagnostic,
SqlResult result,
std::source_location location) {
{ Allocate(connection) } -> std::same_as<void>;
{ Close(connection, closeDiagnostic) } -> std::same_as<std::expected<void, SqlErrorInfo>>;
{ Disconnect(connection) } -> std::same_as<SqlResult>;
{ IsAllocated(constConnection) } -> std::same_as<bool>;
{ IsAlive(constConnection) } -> std::same_as<bool>;
{ LastError(constConnection) } -> std::same_as<SqlErrorInfo>;
{ ServerName(constConnection) } -> std::same_as<std::string>;
{ ServerVersion(constConnection) } -> std::same_as<std::string>;
{ DriverName(constConnection) } -> std::same_as<std::string>;
{ DatabaseName(constConnection) } -> std::same_as<std::string>;
{ UserName(constConnection) } -> std::same_as<std::string>;
{ TransactionActive(constConnection) } -> std::same_as<bool>;
{ TransactionsAllowed(constConnection) } -> std::same_as<bool>;
{ SetAutoCommit(connection, enabled) } -> std::same_as<SqlResult>;
{ Commit(connection) } -> std::same_as<SqlResult>;
{ Rollback(connection) } -> std::same_as<SqlResult>;
{ SetIsolation(connection, isolationMode) } -> std::same_as<SqlResult>;
{ RollbackOpenTransaction(connection) } -> std::same_as<bool>;
{ CheckResult(constConnection, result, location) } -> std::same_as<CallOutcome>;
{ SearchPatternEscape(constConnection) } -> std::same_as<std::expected<std::string, SqlErrorInfo>>;
}
std::string ServerVersion(ConnectionHandle const &connection)
The version of the DBMS the connection is connected to.
Definition Dispatch.hpp:641
bool TransactionActive(ConnectionHandle const &connection) noexcept
Tells whether a transaction is open, i.e. autocommit is off.
Definition Dispatch.hpp:673
void Allocate(ConnectionHandle &connection) noexcept
Allocates the driver's connection resources, unless the connection already holds them.
Definition Dispatch.hpp:569
SqlResult SetAutoCommit(ConnectionHandle &connection, bool enabled) noexcept
Switches autocommit mode on or off.
Definition Dispatch.hpp:690
std::string ServerName(ConnectionHandle const &connection)
The name of the DBMS the connection is connected to.
Definition Dispatch.hpp:633
SqlResult SetIsolation(ConnectionHandle &connection, SqlIsolationMode mode) noexcept
Sets the transaction isolation level of the connection.
Definition Dispatch.hpp:715
bool RollbackOpenTransaction(ConnectionHandle &connection) noexcept
Rolls back the open transaction and switches autocommit back on.
Definition Dispatch.hpp:723
SqlErrorInfo LastError(ConnectionHandle const &connection)
Reads the connection's diagnostics: the first record its last failed call left.
Definition Dispatch.hpp:613
SqlResult Commit(ConnectionHandle &connection) noexcept
Commits the open transaction.
Definition Dispatch.hpp:698
std::string DriverName(ConnectionHandle const &connection)
The name of the driver (library) the connection runs on.
Definition Dispatch.hpp:649
std::string UserName(ConnectionHandle const &connection)
The name of the user the connection is logged in as.
Definition Dispatch.hpp:665
std::expected< void, SqlErrorInfo > Close(ConnectionHandle &connection, CloseDiagnostic diagnostic) noexcept
Closes the connection: disconnects it, frees its driver resources and leaves connection empty,...
Definition Dispatch.hpp:580
SqlResult Rollback(ConnectionHandle &connection) noexcept
Rolls back the open transaction.
Definition Dispatch.hpp:706
bool TransactionsAllowed(ConnectionHandle const &connection) noexcept
Tells whether the data source supports transactions.
Definition Dispatch.hpp:681
std::string DatabaseName(ConnectionHandle const &connection)
The name of the database in use.
Definition Dispatch.hpp:657
CallOutcome CheckResult(StatementHandle const &statement, SqlResult result, std::source_location location)
The non-throwing, fault-seam-aware verdict on result.
Definition Dispatch.hpp:489
bool IsAlive(ConnectionHandle const &connection) noexcept
Tells whether the driver still considers the connection alive.
Definition Dispatch.hpp:605
The connection and transaction operations a driver provides, as free functions found by argument-depe...
Definition Concept.hpp:268
constexpr auto SearchPatternEscape
The escape character of TablesLike's pattern.

Detailed Description

The connection and transaction operations a driver provides, as free functions found by argument-dependent lookup on its connection handle struct.

Establishing a connection is not part of it: what a connection is opened from differs per driver. Operations that can fail return the driver's result code rather than throwing, so the caller decides how to check it.

Definition at line 268 of file Concept.hpp.