fix(uuid): PostgreSQL-compatible partial-UUID resolution#3
Merged
Conversation
UuidResolver::findByPartialBinaryUuid built raw MySQL-only SQL (`SELECT BIN_TO_UUID(id) ... WHERE LOWER(HEX(id)) LIKE ...`). On PostgreSQL, where the Symfony `uuid` type is a native `uuid` column (not BINARY(16)), this threw `function bin_to_uuid(uuid) does not exist` and every partial-UUID lookup returned HTTP 500. Extract the lookup into a public static buildPartialUuidSql() that branches on the platform: `id::text` + REPLACE on PostgreSQL, HEX() + BIN_TO_UUID() on MySQL/MariaDB. Both yield the canonical UUID string and match the same hyphen-stripped hex prefix. Also resolve the id column via metadata instead of hardcoding "id". Adds UuidResolverTest asserting the generated SQL per platform. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
UuidResolver::findByPartialBinaryUuid()built raw MySQL-only SQL:On PostgreSQL the Symfony
uuidtype is a nativeuuidcolumn (notBINARY(16)), soHEX()/BIN_TO_UUID()don't apply and every partial-UUIDlookup failed with
SQLSTATE[42883]: function bin_to_uuid(uuid) does not exist→ HTTP 500 (e.g. the OAuth callback resolving a configuration by partial id).
Fix
Extract the lookup SQL into a
public static buildPartialUuidSql(AbstractPlatform, $table, $idColumn)that branches per platform:
SELECT id::text ... WHERE REPLACE(LOWER(id::text), '-', '') LIKE :partialIdHEX()/BIN_TO_UUID()pathBoth select the canonical hyphenated UUID and match the same hyphen-stripped
hex prefix. The id column is now resolved from metadata instead of hardcoded.
Test
Adds
UuidResolverTestasserting the generated SQL per platform (PostgreSQLuses
id::text/REPLACEand noBIN_TO_UUID; MySQL usesHEX/BIN_TO_UUID) —no database required. Verified end-to-end against PostgreSQL 15 in the consuming
ZA7 application (full functional suite green).
🤖 Generated with Claude Code