macro_rules! assert_columns {
($entity:ty, $fields:expr $(,)?) => { ... };
}Expand description
Assert at compile time that every one of fields has a column on entity.
fields is a &'static [&'static str], e.g. a model’s
<Model as queryweave::PersistedFields>::FIELD_NAMES; entity a type
implementing Columns.
Expands to an anonymous const item, so a missing column fails the build,
cargo check included, with a message naming the field and the entity. The
SQL helpers of this crate run the same check themselves when instantiated
for an entity and a model; this standalone form additionally reports it in
cargo check and the editor.
§Examples
struct Order;
impl queryweave_sql::Columns for Order {
const NAME: &'static str = "Order";
const COLUMNS: &'static [(&'static str, &'static str)] =
&[("number", "number"), ("delivery_date", "delivered_at")];
}
queryweave_sql::assert_columns!(Order, &["number", "delivery_date"]);