Skip to content

Commit

Permalink
use joinable to make our joins more cute
Browse files Browse the repository at this point in the history
  • Loading branch information
david-crespo committed Oct 11, 2023
1 parent 1de49fc commit 7259531
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
1 change: 1 addition & 0 deletions nexus/db-model/src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
10 changes: 2 additions & 8 deletions nexus/db-queries/src/db/datastore/ip_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 7259531

Please sign in to comment.