|
Lightweight 0.20261030.0
|
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... | |
| struct | Lightweight::SqlCreateIndexOptions |
Optional settings for SqlMigrationQueryBuilder::CreateIndex. 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::SqlBoundStatement |
| A statement whose values are bound as parameters when it runs. 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::optional< SqlBoundStatement > | Lightweight::ToBoundSql (SqlMigrationPlanElement const &element) |
Renders an Insert(...).IfNotExists(...) step for execution with bound parameters. | |
| 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. | |
Classes and functions for building SQL queries.
The query builder is a high level API for building SQL queries using high level C++ syntax.
| 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 375 of file MigrationPlan.hpp.
| using Lightweight::SqlMigrationPlanElement = typedef std::variant< SqlCreateTablePlan, SqlAlterTablePlan, SqlDropTablePlan, SqlCreateIndexPlan, SqlRawSqlPlan, SqlInsertDataPlan, SqlUpdateDataPlan, SqlDeleteDataPlan > |
Represents a single SQL migration plan element.
This variant represents a single SQL migration plan element.
Definition at line 563 of file MigrationPlan.hpp.
|
strong |
Index type for simplified CreateIndex API.
| Enumerator | |
|---|---|
| NonUnique | Regular (non-unique) index. |
| Unique | Unique index. |
Definition at line 19 of file Migrate.hpp.
|
strong |
Represents a primary key type.
This enumeration represents the primary key type of a column.
Definition at line 204 of file MigrationPlan.hpp.
| 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.
| formatter | The SQL query formatter to use. |
| element | The SQL migration plan element to format. |
| LIGHTWEIGHT_API std::optional< SqlBoundStatement > Lightweight::ToBoundSql | ( | SqlMigrationPlanElement const & | element | ) |
Renders an Insert(...).IfNotExists(...) step for execution with bound parameters.
MigrationManager executes this form, binding the values, while checksums and previews (ToSql) keep showing them as literals, so the checksum of a migration does not depend on how its values reach the database. Callers that run ToSql output themselves (e.g. SqlStatement::MigrateDirect) execute the literal form.
UTF-8 text is bound as UTF-16, so it is stored exactly as its literal rendering would store it. A GUID, date, time or timestamp is bound as the text its literal quotes, so the server parses the same text either way: a native time or timestamp would keep the fraction the literal drops, and SQLite would store a timestamp in another text form that a key comparison never matches. Other values are bound natively. Exact decimals (also at high scale), binary values and bool store exactly as their literals; a double reaches the column as its binary value. That stores the same as the literal for FLOAT/REAL columns and for DECIMAL columns of low scale, but it can differ where the literal is parsed as a decimal: a DECIMAL column with more fractional digits than the double holds exactly (e.g. DECIMAL(28,12) receives 123456.789011999994 rather than 123456.789012000000), SQLite parsing some literals 1-2 ULP off the correctly rounded double the bound value carries, and a double into a text column (SQLite stores 3.0 as "3.0" bound, "3" as a literal). Exact decimals belong in SqlNumeric / SqlDynamicNumeric.
| element | The step to render. |
element is not an IfNotExists insert. | std::invalid_argument | A key column is not one of the insert's columns or holds NULL. |
| 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.
| formatter | The SQL query formatter to use. |
| plans | The SQL migration plans to format. |
|
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.
|
constexpr |
Represents a SQL column type definition of T.
Definition at line 197 of file MigrationPlan.hpp.
Referenced by Lightweight::SqlAlterTableQueryBuilder::AddColumn(), and Lightweight::SqlAlterTableQueryBuilder::AddNotRequiredColumn().