Skip to content

Commit

Permalink
Merge pull request #2856 from sap-contributions/override-dataset-any
Browse files Browse the repository at this point in the history
Use Sequel's any_not_empty extension
  • Loading branch information
philippthun authored Sep 12, 2022
2 parents acf3f08 + e075d01 commit 5b358a0
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions app/models/services/service_broker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ def space_scoped?
end

def has_service_instances?
!VCAP::CloudController::ServiceInstance.
VCAP::CloudController::ServiceInstance.
join(:service_plans, id: :service_plan_id).
join(:services, id: :service_id).
where(services__service_broker_id: id).
empty?
any?
end

def self.user_visibility_filter(user)
Expand Down
1 change: 1 addition & 0 deletions lib/cloud_controller/db.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ def self.load_models_without_migrations_check(db_config, logger)
Sequel::Model.plugin :validation_helpers

Sequel::Database.extension(:current_datetime_timestamp)
Sequel::Database.extension(:any_not_empty)

require 'cloud_controller/encryptor'
Sequel::Model.include VCAP::CloudController::Encryptor::FieldEncryptor
Expand Down
4 changes: 2 additions & 2 deletions spec/unit/models/services/service_broker_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ module VCAP::CloudController
end

it 'does a single db query' do
expect { service_broker.has_service_instances? }.to have_queried_db_times(/select/i, 1)
expect { service_broker.has_service_instances? }.to have_queried_db_times(/select 1.*limit 1/i, 1)
end
end

Expand All @@ -223,7 +223,7 @@ module VCAP::CloudController
end

it 'does a single db query' do
expect { service_broker.has_service_instances? }.to have_queried_db_times(/select/i, 1)
expect { service_broker.has_service_instances? }.to have_queried_db_times(/select 1.*limit 1/i, 1)
end
end
end
Expand Down

0 comments on commit 5b358a0

Please sign in to comment.