|
Lightweight 0.20261105.1
|
Query builder for building INSERT queries in migrations. More...
#include <Migrate.hpp>
Public Member Functions | |
| SqlMigrationInsertBuilder (SqlInsertDataPlan &plan) | |
| Constructs a migration INSERT builder. | |
| template<typename T > | |
| SqlMigrationInsertBuilder & | Set (std::string columnName, T const &value) |
| Sets a column value for the INSERT. | |
| LIGHTWEIGHT_API SqlMigrationInsertBuilder & | IfNotExists (std::vector< std::string > keyColumns) |
| Makes the INSERT skip its row when a row with the same key values already exists. | |
Query builder for building INSERT queries in migrations.
Definition at line 389 of file Migrate.hpp.
|
inlineexplicit |
Constructs a migration INSERT builder.
Definition at line 393 of file Migrate.hpp.
|
inline |
Sets a column value for the INSERT.
Definition at line 400 of file Migrate.hpp.
| LIGHTWEIGHT_API SqlMigrationInsertBuilder & Lightweight::SqlMigrationInsertBuilder::IfNotExists | ( | std::vector< std::string > | keyColumns | ) |
Makes the INSERT skip its row when a row with the same key values already exists.
Renders INSERT INTO t (...) SELECT ... WHERE NOT EXISTS (SELECT 1 FROM t WHERE key = ...), so a seed row a database already holds no longer fails the migration. An existing row is left as it is, even when its non-key columns differ from the values given here. Rendering the plan throws std::invalid_argument when a key column is not one of the Set columns or its value is NULL.
| keyColumns | The columns identifying the row; must not be empty. |
| std::invalid_argument | keyColumns is empty. |