Skip to content

Remove redundant validates_unique where DB unique index already exists#4930

Merged
philippthun merged 16 commits intocloudfoundry:mainfrom
sap-contributions:feature/remove-extra-validates-unique-check
Mar 19, 2026
Merged

Remove redundant validates_unique where DB unique index already exists#4930
philippthun merged 16 commits intocloudfoundry:mainfrom
sap-contributions:feature/remove-extra-validates-unique-check

Conversation

@serdarozerr
Copy link
Contributor

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 main branch

  • I have run all the unit tests using bundle exec rake

  • I have run CF Acceptance Tests

@johha johha requested a review from philippthun March 18, 2026 07:59
…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 philippthun merged commit c8604dc into cloudfoundry:main Mar 19, 2026
16 of 17 checks passed
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants