From 7259531cf975ccd6ecda611243152dfcd411fb97 Mon Sep 17 00:00:00 2001 From: David Crespo Date: Wed, 11 Oct 2023 11:43:57 -0500 Subject: [PATCH] use joinable to make our joins more cute --- nexus/db-model/src/schema.rs | 1 + nexus/db-queries/src/db/datastore/ip_pool.rs | 10 ++-------- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/nexus/db-model/src/schema.rs b/nexus/db-model/src/schema.rs index c1ba3f4299..4995e40286 100644 --- a/nexus/db-model/src/schema.rs +++ b/nexus/db-model/src/schema.rs @@ -1149,6 +1149,7 @@ joinable!(system_update_component_update -> component_update (component_update_i allow_tables_to_appear_in_same_query!(ip_pool_range, ip_pool, ip_pool_resource); joinable!(ip_pool_range -> ip_pool (ip_pool_id)); +joinable!(ip_pool_resource -> ip_pool (ip_pool_id)); allow_tables_to_appear_in_same_query!( dataset, diff --git a/nexus/db-queries/src/db/datastore/ip_pool.rs b/nexus/db-queries/src/db/datastore/ip_pool.rs index 9feaef0c14..1ec724002f 100644 --- a/nexus/db-queries/src/db/datastore/ip_pool.rs +++ b/nexus/db-queries/src/db/datastore/ip_pool.rs @@ -100,10 +100,7 @@ impl DataStore { // join ip_pool to ip_pool_resource and filter ip_pool::table - .inner_join( - ip_pool_resource::table - .on(ip_pool::id.eq(ip_pool_resource::ip_pool_id)), - ) + .inner_join(ip_pool_resource::table) .filter( (ip_pool_resource::resource_type .eq(IpPoolResourceType::Silo) @@ -143,10 +140,7 @@ impl DataStore { // We assume there is only one pool for that silo, or at least, // if there is more than one, it doesn't matter which one we pick. let (authz_pool, pool) = ip_pool::table - .inner_join( - ip_pool_resource::table - .on(ip_pool::id.eq(ip_pool_resource::ip_pool_id)), - ) + .inner_join(ip_pool_resource::table) .filter(ip_pool::time_deleted.is_null()) .filter( ip_pool_resource::resource_type