pub fn parse_constraint_detail_value(detail: Option<&str>) -> Option<String>Expand description
Extracts the conflicting value from a PostgreSQL constraint violation detail message.
PostgreSQL formats unique violation details as:
Key (column)=(value) already exists. — but lc_messages localises the
surrounding words (and sometimes the quote characters) around that
(column)=(value) core, so this anchors on the first =( and the last
) in the detail rather than on the English ") already". Every fixed
case below (plain, composite, a value containing ) or , , an empty
value, and a translated detail) is honoured by this rule unchanged.
Returns None if the detail is missing or doesn’t match the expected format.
Known weakness, accepted: trailing text after the value that itself
contains a ) (not something PostgreSQL’s own detail format produces)
would overshoot and swallow it into the returned value.
Security note: the extracted value is attacker-influenced input that was rejected by a unique constraint and may be PII (e.g. an email address). Returning it to untrusted API clients enables user enumeration; logging it may place PII in log pipelines.