Remove redundant validates_unique where DB unique index already exists#4930
Merged
philippthun merged 16 commits intocloudfoundry:mainfrom Mar 19, 2026
Conversation
- Model's that already has uniqueness constraint on db level are refactored. sequel validate_unique method removed from list.
…s validation in service_broker_registraion service to refraing http call invalid brokers
…s validation in service_key_manager to refraing http call in service_key_create
philippthun
requested changes
Mar 18, 2026
spec/unit/controllers/services/service_brokers_controller_spec.rb
Outdated
Show resolved
Hide resolved
… tests are reintroduced in unit/models.
…res name_overlap and that leads misleading error
…e broker registration The around_save hook on the ServiceBroker model catches unique constraint violations and adds errors to the model before raising ValidationFailed. The rescue block returns nil, and callers access errors via the delegated errors method.
…s used as guard before calling some http endpoint in check in service_broker_registration. Comments are added
philippthun
approved these changes
Mar 19, 2026
ari-wg-gitbot
added a commit
to cloudfoundry/capi-release
that referenced
this pull request
Mar 19, 2026
Changes in cloud_controller_ng:
- Remove redundant validates_unique where DB unique index already exists
PR: cloudfoundry/cloud_controller_ng#4930
Author: serdar özer <serdar.oezer@sap.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Models with a DB-level unique index were performing an extra SELECT on every save via Sequel's validates_unique. This PR removes that redundant check and relies on around_save to catch Sequel::UniqueConstraintViolation instead, letting the database enforce what it already enforces.
I have reviewed the contributing guide
I have viewed, signed, and submitted the Contributor License Agreement
I have made this pull request to the
mainbranchI have run all the unit tests using
bundle exec rakeI have run CF Acceptance Tests