A table should reject a row that does not fit its schema. Today you make insertion check the number of values and their types before accepting a row.
Reject a row whose length or column types do not match the table's schema, and accept one that does.
A schema is a promise about the shape of every row, and the moment to enforce
that promise is on the way in. Insert validation checks two things: that the
row has exactly one value per column, and that each value’s type matches its
column - an INTEGER column will not accept a text value.
The one exception is NULL, which is allowed to stand in for a value of any
type; that is what makes it the universal “no data here” marker. Reject the two
bad rows with a clear error and the good one silently, and every table in the
database is now self-defending - no query downstream has to wonder whether a row
is well-formed.
func (t *Table) Insert(r Row) error {// 1. len(r.Values) must equal len(schema.Columns)// 2. each value's Kind must match the column Type, unless it is null// return an error describing the first mismatch, else Append}