Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix UUID parsing issue due to hyphenated format in MariaDB #2485

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

rito528
Copy link
Contributor

@rito528 rito528 commented Jan 31, 2025

PR Info

This pull request resolves an issue where Uuid values retrieved from MariaDB (I am using 10.11.10) were not correctly parsed, leading to runtime errors such as:

Query Error: error occurred while decoding column "column": invalid length: expected 16 bytes, found 36

The problem occurred because MariaDB's UUID type stores UUIDs as hyphenated strings (e.g., f8aa-ed66-1a1b-11ec-ab4e-f859-713e-4be4), while uuid::Uuid in Rust expects a non-hyphenated byte format. The current implementation attempted to directly convert the database value into Uuid, which caused errors due to this mismatch in format and byte length. The behavior on other database systems or versions has not been tested.

Changes

  • Modified the handling of UUID values retrieved from MariaDB to account for the fact that MariaDB stores UUIDs as hyphenated strings.
  • The try_get method now retrieves the UUID value as an Option<Vec<u8>>, because we cannot determine whether the database is MariaDB or MySQL and need a more general approach.
  • If the UUID cannot be directly parsed, the value is first converted to a string and then parsed using uuid::Uuid::parse_str, ensuring correct handling of the hyphenated UUID format.

This change ensures that UUID values retrieved from MariaDB are handled correctly, preventing runtime errors related to the incorrect length or format, while maintaining compatibility with the database's UUID storage format.

@rito528 rito528 changed the title Fix Uuid parsing issue by converting String to Uuid Fix Uuid Parsing Issue in MySQL Jan 31, 2025
@rito528 rito528 marked this pull request as draft January 31, 2025 10:08
@rito528 rito528 changed the title Fix Uuid Parsing Issue in MySQL Fix Uuid Parsing Issue in MariaDB Jan 31, 2025
@rito528 rito528 changed the title Fix Uuid Parsing Issue in MariaDB Fix UUID Parsing Issue Due to Hyphenated Format in MariaDB Jan 31, 2025
@rito528 rito528 marked this pull request as ready for review January 31, 2025 12:45
@rito528
Copy link
Contributor Author

rito528 commented Jan 31, 2025

Ready for review!

@rito528 rito528 changed the title Fix UUID Parsing Issue Due to Hyphenated Format in MariaDB Fix UUID parsing issue due to hyphenated format in MariaDB Jan 31, 2025
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.

1 participant