Skip to content

Commit 94fe84b

Browse files
committed
forget asterisk suffix, match on name
1 parent f926dad commit 94fe84b

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

nexus/db-lookup/src/lookup.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,7 @@ lookup_resource! {
591591

592592
lookup_resource! {
593593
name = "SshKey",
594-
ancestors = [ "Silo", "SiloUser*" ],
594+
ancestors = [ "Silo", "SiloUser" ],
595595
lookup_by_name = true,
596596
soft_deletes = true,
597597
primary_key_columns = [ { column_name = "id", rust_type = Uuid } ]

nexus/db-macros/src/lookup.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -195,14 +195,13 @@ struct Resource {
195195

196196
impl Resource {
197197
fn for_name(name: &str) -> Resource {
198-
let (name, primary_key_is_typed_uuid) =
199-
if name.chars().last() == Some('*') {
200-
let name = &name[0..(name.len() - 1)];
201-
(name, true)
202-
} else {
203-
(name, false)
204-
};
205-
assert!(!name.contains("*"));
198+
// In order to simply the lookup_resource macro invocation, match on the
199+
// resource name here to determine if the associated database column is
200+
// a typed id or not
201+
let primary_key_is_typed_uuid = match name {
202+
"SiloUser" => true,
203+
_ => false,
204+
};
206205

207206
let name_as_snake = heck::AsSnakeCase(&name).to_string();
208207
let name = format_ident!("{}", name);

0 commit comments

Comments
 (0)