Skip to content

Fix UniqueException message to indicate unique index violation#856

Merged
abnegate merged 1 commit intounique-exceptionfrom
copilot/fix-unique-exception-message
Apr 15, 2026
Merged

Fix UniqueException message to indicate unique index violation#856
abnegate merged 1 commit intounique-exceptionfrom
copilot/fix-unique-exception-message

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 15, 2026

UniqueException was using the same "Document already exists" message as DuplicateException, making it impossible to distinguish between a duplicate document ID and a unique index constraint violation from the error message alone.

  • Updated the UniqueException message to "Unique index violation" in all three adapters: MariaDB, SQLite, and Postgres
  • DuplicateException messages remain unchanged as "Document already exists" is correct for that case

…f 'Document already exists'

Agent-Logs-Url: https://github.com/utopia-php/database/sessions/bd2e3ddb-ca02-49dc-9939-bb42093478e2

Co-authored-by: abnegate <5857008+abnegate@users.noreply.github.com>
@abnegate abnegate marked this pull request as ready for review April 15, 2026 08:34
@abnegate abnegate merged commit 7ce3ae6 into unique-exception Apr 15, 2026
@abnegate abnegate deleted the copilot/fix-unique-exception-message branch April 15, 2026 08:34
@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented Apr 15, 2026

Greptile Summary

Updates the UniqueException message from "Document already exists" to "Unique index violation" across all three adapters (MariaDB, Postgres, SQLite), making it distinguishable from DuplicateException's "Document already exists" message. The change is consistent across all adapters, the DuplicateException messages are correctly left unchanged, and existing tests check by instance type rather than message string so they remain unaffected.

Confidence Score: 5/5

Safe to merge — minimal, focused message-string change with no logic impact.

All three adapters are updated consistently, no detection logic was altered, and no tests check the literal message text. No P0/P1 findings.

No files require special attention.

Important Files Changed

Filename Overview
src/Database/Adapter/MariaDB.php Changed UniqueException message from 'Document already exists' to 'Unique index violation' at line 1805; DuplicateException messages unchanged.
src/Database/Adapter/Postgres.php Changed UniqueException message from 'Document already exists' to 'Unique index violation' at line 1929; DuplicateException messages unchanged.
src/Database/Adapter/SQLite.php Changed UniqueException message from 'Document already exists' to 'Unique index violation' at line 1258; DuplicateException messages unchanged.

Reviews (1): Last reviewed commit: "Fix UniqueException message to say 'Uniq..." | Re-trigger Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants