Lightweight 0.1.0
Loading...
Searching...
No Matches
SqlQueryFormatter Class Referenceabstract

API to format SQL queries for different SQL dialects. More...

#include <SqlQueryFormatter.hpp>

Inherited by SQLiteQueryFormatter.

Public Types

using StringList = std::vector< std::string >
 

Public Member Functions

 SqlQueryFormatter (SqlQueryFormatter &&)=default
 
 SqlQueryFormatter (SqlQueryFormatter const &)=default
 
SqlQueryFormatteroperator= (SqlQueryFormatter &&)=default
 
SqlQueryFormatteroperator= (SqlQueryFormatter const &)=default
 
virtual std::string_view BooleanLiteral (bool value) const noexcept=0
 Converts a boolean value to a string literal.
 
virtual std::string StringLiteral (std::string_view value) const noexcept=0
 Converts a string value to a string literal.
 
virtual std::string StringLiteral (char value) const noexcept=0
 Converts a character value to a string literal.
 
virtual std::string Insert (std::string_view intoTable, std::string_view fields, std::string_view values) const =0
 
virtual std::string QueryLastInsertId (std::string_view tableName) const =0
 Retrieves the last insert ID of the given table.
 
virtual std::string SelectAll (bool distinct, std::string_view fields, std::string_view fromTable, std::string_view fromTableAlias, std::string_view tableJoins, std::string_view whereCondition, std::string_view orderBy, std::string_view groupBy) const =0
 Constructs an SQL SELECT query for all rows.
 
virtual std::string SelectFirst (bool distinct, std::string_view fields, std::string_view fromTable, std::string_view fromTableAlias, std::string_view tableJoins, std::string_view whereCondition, std::string_view orderBy, size_t count) const =0
 Constructs an SQL SELECT query for the first row.
 
virtual std::string SelectRange (bool distinct, std::string_view fields, std::string_view fromTable, std::string_view fromTableAlias, std::string_view tableJoins, std::string_view whereCondition, std::string_view orderBy, std::string_view groupBy, std::size_t offset, std::size_t limit) const =0
 Constructs an SQL SELECT query for a range of rows.
 
virtual std::string SelectCount (bool distinct, std::string_view fromTable, std::string_view fromTableAlias, std::string_view tableJoins, std::string_view whereCondition) const =0
 Constructs an SQL SELECT query retrieve the count of rows matching the given condition.
 
virtual std::string Update (std::string_view table, std::string_view tableAlias, std::string_view setFields, std::string_view whereCondition) const =0
 Constructs an SQL UPDATE query.
 
virtual std::string Delete (std::string_view fromTable, std::string_view fromTableAlias, std::string_view tableJoins, std::string_view whereCondition) const =0
 Constructs an SQL DELETE query.
 
virtual std::string ColumnType (SqlColumnTypeDefinition const &type) const =0
 Convert the given column type definition to the SQL type.
 
virtual StringList CreateTable (std::string_view tableName, std::vector< SqlColumnDeclaration > const &columns) const =0
 Constructs an SQL CREATE TABLE query.
 
virtual StringList AlterTable (std::string_view tableName, std::vector< SqlAlterTableCommand > const &commands) const =0
 Constructs an SQL ALTER TABLE query.
 
virtual StringList DropTable (std::string_view const &tableName) const =0
 Constructs an SQL DROP TABLE query.
 

Static Public Member Functions

static SqlQueryFormatter const & Sqlite ()
 Retrieves the SQL query formatter for SQLite.
 
static SqlQueryFormatter const & SqlServer ()
 Retrieves the SQL query formatter for Microsoft SQL server.
 
static SqlQueryFormatter const & PostgrSQL ()
 Retrieves the SQL query formatter for PostgreSQL.
 
static SqlQueryFormatter const & OracleSQL ()
 Retrieves the SQL query formatter for Oracle database.
 
static SqlQueryFormatter const * Get (SqlServerType serverType) noexcept
 Retrieves the SQL query formatter for the given SqlServerType.
 

Detailed Description

API to format SQL queries for different SQL dialects.

Definition at line 16 of file SqlQueryFormatter.hpp.

Member Typedef Documentation

◆ StringList

using SqlQueryFormatter::StringList = std::vector<std::string>

Definition at line 100 of file SqlQueryFormatter.hpp.

Member Function Documentation

◆ Insert()

virtual std::string SqlQueryFormatter::Insert ( std::string_view  intoTable,
std::string_view  fields,
std::string_view  values 
) const
pure virtual

Constructs an SQL INSERT query.

Parameters
intoTableThe table to insert into.
fieldsThe fields to insert into.
valuesThe values to insert.

The fields and values must be in the same order.


The documentation for this class was generated from the following file: