Lightweight 0.20260921.0
Loading...
Searching...
No Matches
Query Builder

Classes and functions for building SQL queries. More...

Classes

class  Lightweight::SqlQueryBuilder
 API Entry point for building SQL queries. More...
 
struct  Lightweight::SqlWildcardType
 SqlWildcardType is a placeholder for an explicit wildcard input parameter in a SQL query. More...
 
class  Lightweight::SqlJoinConditionBuilder
 Query builder for building JOIN conditions. More...
 
class  Lightweight::SqlWhereClauseBuilder< Derived >
 
class  Lightweight::SqlDeleteQueryBuilder
 Query builder for building DELETE FROM ... queries. More...
 
class  Lightweight::SqlInsertQueryBuilder
 Query builder for building INSERT INTO ... queries. More...
 
class  Lightweight::SqlCreateTableQueryBuilder
 Query builder for building CREATE TABLE queries. More...
 
class  Lightweight::SqlAlterTableQueryBuilder
 Query builder for building ALTER TABLE queries. More...
 
class  Lightweight::SqlMigrationInsertBuilder
 Query builder for building INSERT queries in migrations. More...
 
class  Lightweight::SqlMigrationUpdateBuilder
 Query builder for building UPDATE queries in migrations. More...
 
class  Lightweight::SqlMigrationDeleteBuilder
 Query builder for building DELETE queries in migrations. More...
 
class  Lightweight::SqlMigrationQueryBuilder
 Query builder for building SQL migration queries. More...
 
struct  Lightweight::SqlForeignKeyReferenceDefinition
 Represents a foreign key reference definition. More...
 
struct  Lightweight::SqlColumnDeclaration
 Represents a SQL column declaration. More...
 
struct  Lightweight::SqlCompositeForeignKeyConstraint
 Represents a composite foreign key constraint. More...
 
struct  Lightweight::SqlAlterTablePlan
 Represents a SQL ALTER TABLE plan on a given table. More...
 
struct  Lightweight::SqlDropTablePlan
 Represents a SQL DROP TABLE plan. More...
 
struct  Lightweight::SqlRawSqlPlan
 Represents a raw SQL plan. More...
 
struct  Lightweight::SqlInsertDataPlan
 Represents a SQL INSERT data plan for migrations. More...
 
struct  Lightweight::SqlUpdateDataPlan
 Represents a SQL UPDATE data plan for migrations. More...
 
struct  Lightweight::SqlDeleteDataPlan
 Represents a SQL DELETE data plan for migrations. More...
 
struct  Lightweight::SqlCreateIndexPlan
 Represents a SQL CREATE INDEX plan for migrations. More...
 
struct  Lightweight::SqlMigrationPlan
 Represents a SQL migration plan. More...
 
struct  Lightweight::SqlQualifiedTableColumnName
 SqlQualifiedTableColumnName represents a column name qualified with a table name. More...
 

Typedefs

using Lightweight::SqlAlterTableCommand = std::variant< SqlAlterTableCommands::RenameTable, SqlAlterTableCommands::AddColumn, SqlAlterTableCommands::AddColumnIfNotExists, SqlAlterTableCommands::AlterColumn, SqlAlterTableCommands::AddIndex, SqlAlterTableCommands::RenameColumn, SqlAlterTableCommands::DropColumn, SqlAlterTableCommands::DropColumnIfExists, SqlAlterTableCommands::DropIndex, SqlAlterTableCommands::DropIndexIfExists, SqlAlterTableCommands::AddForeignKey, SqlAlterTableCommands::AddCompositeForeignKey, SqlAlterTableCommands::DropForeignKey >
 Represents a single SQL ALTER TABLE command.
 
using Lightweight::SqlMigrationPlanElement = std::variant< SqlCreateTablePlan, SqlAlterTablePlan, SqlDropTablePlan, SqlCreateIndexPlan, SqlRawSqlPlan, SqlInsertDataPlan, SqlUpdateDataPlan, SqlDeleteDataPlan >
 Represents a single SQL migration plan element.
 

Enumerations

enum class  Lightweight::IndexType : std::uint8_t { IndexType::NonUnique , IndexType::Unique }
 Index type for simplified CreateIndex API. More...
 
enum class  Lightweight::SqlPrimaryKeyType : uint8_t { NONE , MANUAL , AUTO_INCREMENT , GUID }
 Represents a primary key type. More...
 

Functions

LIGHTWEIGHT_API std::vector< std::string > Lightweight::ToSql (SqlQueryFormatter const &formatter, SqlMigrationPlanElement const &element)
 
LIGHTWEIGHT_API std::vector< std::string > Lightweight::ToSql (SqlQueryFormatter const &formatter, std::vector< SqlMigrationPlan > const &plans)
 Formats the given SQL migration plan as a list of SQL statements.
 

Variables

constexpr std::size_t Lightweight::SqlMaxBoundSetSize = 2000
 Largest IN-set that WhereIn passes as bound parameters.
 
template<typename T >
constexpr auto Lightweight::SqlColumnTypeDefinitionOf = detail::SqlColumnTypeDefinitionOf<T>::value
 Represents a SQL column type definition of T.
 

Detailed Description

Classes and functions for building SQL queries.

The query builder is a high level API for building SQL queries using high level C++ syntax.

Typedef Documentation

◆ SqlAlterTableCommand

using Lightweight::SqlAlterTableCommand = typedef std::variant<SqlAlterTableCommands::RenameTable, SqlAlterTableCommands::AddColumn, SqlAlterTableCommands::AddColumnIfNotExists, SqlAlterTableCommands::AlterColumn, SqlAlterTableCommands::AddIndex, SqlAlterTableCommands::RenameColumn, SqlAlterTableCommands::DropColumn, SqlAlterTableCommands::DropColumnIfExists, SqlAlterTableCommands::DropIndex, SqlAlterTableCommands::DropIndexIfExists, SqlAlterTableCommands::AddForeignKey, SqlAlterTableCommands::AddCompositeForeignKey, SqlAlterTableCommands::DropForeignKey>

Represents a single SQL ALTER TABLE command.

Definition at line 367 of file MigrationPlan.hpp.

◆ SqlMigrationPlanElement

Represents a single SQL migration plan element.

This variant represents a single SQL migration plan element.

Definition at line 541 of file MigrationPlan.hpp.

Enumeration Type Documentation

◆ IndexType

enum class Lightweight::IndexType : std::uint8_t
strong

Index type for simplified CreateIndex API.

Enumerator
NonUnique 

Regular (non-unique) index.

Unique 

Unique index.

Definition at line 19 of file Migrate.hpp.

◆ SqlPrimaryKeyType

enum class Lightweight::SqlPrimaryKeyType : uint8_t
strong

Represents a primary key type.

This enumeration represents the primary key type of a column.

Definition at line 198 of file MigrationPlan.hpp.

Function Documentation

◆ ToSql() [1/2]

LIGHTWEIGHT_API std::vector< std::string > Lightweight::ToSql ( SqlQueryFormatter const &  formatter,
SqlMigrationPlanElement const &  element 
)

Formats the given SQL migration plan element as a list of SQL statements.

Parameters
formatterThe SQL query formatter to use.
elementThe SQL migration plan element to format.
Returns
A list of SQL statements.

◆ ToSql() [2/2]

LIGHTWEIGHT_API std::vector< std::string > Lightweight::ToSql ( SqlQueryFormatter const &  formatter,
std::vector< SqlMigrationPlan > const &  plans 
)

Formats the given SQL migration plan as a list of SQL statements.

Parameters
formatterThe SQL query formatter to use.
plansThe SQL migration plans to format.
Returns
A list of SQL statements.

Variable Documentation

◆ SqlMaxBoundSetSize

constexpr std::size_t Lightweight::SqlMaxBoundSetSize = 2000
inlineconstexpr

Largest IN-set that WhereIn passes as bound parameters.

Beyond this the set is written into the SQL text as literals, which is what WhereIn did before it learned to bind. Drivers cap how many parameters one statement may carry – MS SQL Server refuses more than 2100 with "07002 COUNT field incorrect" – and a caller filtering on a few thousand keys would otherwise build a statement no driver accepts. The margin below that cap leaves room for the parameters the rest of the statement contributes.

Definition at line 1006 of file Core.hpp.

◆ SqlColumnTypeDefinitionOf

template<typename T >
constexpr auto Lightweight::SqlColumnTypeDefinitionOf = detail::SqlColumnTypeDefinitionOf<T>::value
constexpr

Represents a SQL column type definition of T.

Definition at line 191 of file MigrationPlan.hpp.

Referenced by Lightweight::SqlAlterTableQueryBuilder::AddColumn(), and Lightweight::SqlAlterTableQueryBuilder::AddNotRequiredColumn().