B
B
BonBon Slick2021-04-30 19:06:28
Doctrine ORM
BonBon Slick, 2021-04-30 19:06:28

Composite unique constraint for specific values?

<unique-constraints>
                        <unique-constraint columns="is_enabled,is_default" name="unique_locale_default_enabled"/>
                        <unique-constraint columns="is_enabled,is_fallback" name="unique_locale_fallback"/>
        </unique-constraints>


Such code will naturally not work, because there are other locales, which are the majority, where both values ​​will be false.
Is there any way to check for uniqueness other than programmatically when updating the locale?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
tukreb, 2021-05-01
@BonBonSlick

Solution, via Partial Unique Index with where
https://www.postgresql.org/docs/current/indexes-pa...
via Doctrine Annotations (Example with partial indexes)
https://www.doctrine-project.org/ projects/doctrine...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question