diff options
author | louiz’ <louiz@louiz.org> | 2018-04-29 01:40:46 +0200 |
---|---|---|
committer | louiz’ <louiz@louiz.org> | 2018-04-29 01:40:46 +0200 |
commit | 7592d966e684410f603942e34413375c8d98ac9e (patch) | |
tree | 7b3af3008c6a6532edbf4f4fe3534778886e669e /src/database/column.hpp | |
parent | efa63ee5cb4be3aebc1489dc9db936eea26660d4 (diff) | |
download | biboumi-7592d966e684410f603942e34413375c8d98ac9e.tar.gz biboumi-7592d966e684410f603942e34413375c8d98ac9e.tar.bz2 biboumi-7592d966e684410f603942e34413375c8d98ac9e.tar.xz biboumi-7592d966e684410f603942e34413375c8d98ac9e.zip |
Missing fields in a data-form response are now interpreted as an empty value
Diffstat (limited to 'src/database/column.hpp')
-rw-r--r-- | src/database/column.hpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/database/column.hpp b/src/database/column.hpp index 50c9c14..837aa3f 100644 --- a/src/database/column.hpp +++ b/src/database/column.hpp @@ -9,18 +9,30 @@ struct Column value{default_value} {} Column(): value{} {} + void clear() + { + this->value = {}; + } using real_type = T; T value{}; }; +template <typename T> +struct UnclearableColumn: public Column<T> +{ + using Column<T>::Column; + void clear() + { } +}; + struct ForeignKey: Column<std::size_t> { static constexpr auto name = "fk_"; }; -struct Id: Column<std::size_t> { +struct Id: UnclearableColumn<std::size_t> { static constexpr std::size_t unset_value = static_cast<std::size_t>(-1); static constexpr auto name = "id_"; static constexpr auto options = "PRIMARY KEY"; - Id(): Column<std::size_t>(unset_value) {} + Id(): UnclearableColumn<std::size_t>(unset_value) {} }; |