Files
zitadel/internal/eventstore/v3/unique_constraints_delete_placeholders.sql
T
Wim Van LaerandGitHub 9b064d8b74 docs: fixed some typos, formatting, grammar (#11540)
# Which Problems Are Solved

- Typos
- Punctuation
- Markdown table formatting
- ...

(A bunch of issues my editor gave)

# How the Problems Are Solved


# Additional Changes


# Additional Context
2026-02-13 07:45:17 +01:00

14 lines
714 B
SQL

-- the query is so complex because we accidentally stored unique constraint case-sensitive
-- the query checks first if there is a case-sensitive match and afterward if there is a case-insensitive match
(instance_id = $%[1]d AND unique_type = $%[2]d AND unique_field = (
SELECT unique_field from (
SELECT instance_id, unique_type, unique_field
FROM eventstore.unique_constraints
WHERE instance_id = $%[1]d AND unique_type = $%[2]d AND unique_field = $%[3]d
UNION ALL
SELECT instance_id, unique_type, unique_field
FROM eventstore.unique_constraints
WHERE instance_id = $%[1]d AND unique_type = $%[2]d AND unique_field = LOWER($%[3]d)
) AS case_insensitive_constraints LIMIT 1)
)