multiFK2
This commit is contained in:
@@ -670,12 +670,11 @@ pub(crate) fn validate_identifier(
|
||||
"{label} may only use lowercase letters, digits and underscores."
|
||||
));
|
||||
}
|
||||
// Only the system columns are reserved. The `_id` suffix is free: no
|
||||
// column name is derived from a table name any more, so it collides with
|
||||
// nothing.
|
||||
if reject_table_reserved
|
||||
&& (value == "id"
|
||||
|| value == "deleted"
|
||||
|| value == "created_at"
|
||||
|| value == "row_revision"
|
||||
|| value.ends_with("_id"))
|
||||
&& matches!(value, "id" | "deleted" | "created_at" | "row_revision")
|
||||
{
|
||||
return Some(format!("{label} uses a reserved name."));
|
||||
}
|
||||
@@ -1127,8 +1126,6 @@ pub(crate) mod tests {
|
||||
|
||||
draft.name_input = "Total".to_string();
|
||||
assert!(draft.add_from_inputs().is_err());
|
||||
draft.name_input = "customer_id".to_string();
|
||||
assert!(draft.add_from_inputs().is_err());
|
||||
draft.name_input = "created_at".to_string();
|
||||
assert!(draft.add_from_inputs().is_err());
|
||||
|
||||
@@ -1334,3 +1331,27 @@ pub(crate) mod tests {
|
||||
assert_eq!(draft.selected_index_names(), vec!["number"]);
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod link_alias_tests {
|
||||
use super::validate_identifier;
|
||||
|
||||
/// The `_id` suffix is an ordinary part of a column's name: nothing is
|
||||
/// derived from a table name any more.
|
||||
#[test]
|
||||
fn a_column_name_may_end_in_id() {
|
||||
assert_eq!(validate_identifier("external_id", "Column name", true), None);
|
||||
}
|
||||
|
||||
/// The system columns stay reserved, since they share one namespace with
|
||||
/// user columns in a data request.
|
||||
#[test]
|
||||
fn the_system_columns_stay_reserved() {
|
||||
for name in ["id", "deleted", "created_at", "row_revision"] {
|
||||
assert!(
|
||||
validate_identifier(name, "Column name", true).is_some(),
|
||||
"`{name}` must stay reserved"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user