pub struct AddedColumnRisk {
pub null_without_default: bool,
pub non_constant_default: bool,
pub generated_stored: bool,
}Expand description
What an added column would do to rows that already exist.
SQLite refuses PRIMARY KEY and UNIQUE while it is still compiling,
because no table can take them however empty it is. The other three it
defers: a NOT NULL column with no default, a non-constant default and a
STORED generated column are refused only when there is a row to break,
and are accepted on an empty table. That is not a quirk worth smoothing
over - it is the difference between a migration that runs on a fresh
database and one that runs on a populated one - so the binder records what
it saw and the executor, which knows the row count, decides.
Fields§
§null_without_default: boolNOT NULL with nothing to fill the existing rows with.
non_constant_default: boolA DEFAULT the existing rows cannot all be given one answer from.
generated_stored: boolGENERATED ALWAYS AS (...) STORED, which needs a value in every record.
Implementations§
Source§impl AddedColumnRisk
impl AddedColumnRisk
Sourcepub fn refusal(&self) -> Option<&'static str>
pub fn refusal(&self) -> Option<&'static str>
Returns the refusal a table with rows in it owes, in SQLite’s wording.
The capitalisation is the reference’s own and is inconsistent between the three; it is reproduced rather than tidied, because a caller matching on the message is matching on what SQLite prints.