Skip to content

New: Add MySQL implementation of UuidValue expression - #482

Open
KalimeroMK wants to merge 3 commits into
yiisoft:masterfrom
KalimeroMK:add-1152-uuid-value
Open

New: Add MySQL implementation of UuidValue expression#482
KalimeroMK wants to merge 3 commits into
yiisoft:masterfrom
KalimeroMK:add-1152-uuid-value

Conversation

@KalimeroMK

Copy link
Copy Markdown
Q A
Is bugfix?
New feature? ✔️
Breaks BC?
Fixed issues

MySQL/MariaDB half of UuidValue, added in yiisoft/db#1199that PR has to be merged first.

Both store a UUID as 16 raw bytes (ColumnDefinitionBuilder maps ColumnType::UUID to binary(16)), so prepareValue() converts the canonical form with DbUuidHelper::uuidToBlob() and binds it as DataType::LOB rather than letting buildValue() infer DataType::STRING:

$db->createCommand()->insert('{{%page}}', ['id' => new UuidValue(Uuid::uuid7())])->execute();

Verified locally against MySQL 8.4: the round-trip test inserts into a real binary(16) column and reads back 16 bytes that decode to the original UUID.

The branch name matches the one in yiisoft/db#1199, so install-packages resolves the core package from it and CI runs against the new class.

MySQL and MariaDB store a UUID as 16 raw bytes in a `binary(16)` column,
so `prepareValue()` converts the canonical form with
`DbUuidHelper::uuidToBlob()` and binds it as `DataType::LOB`.

Requires yiisoft/db#1199.
@codecov

codecov Bot commented Sep 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.10%. Comparing base (84ec3dd) to head (1ec601c).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##             master     #482   +/-   ##
=========================================
  Coverage     99.10%   99.10%           
- Complexity      256      257    +1     
=========================================
  Files            24       25    +1     
  Lines           779      782    +3     
=========================================
+ Hits            772      775    +3     
  Misses            7        7           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

{
protected function prepareValue(UuidValue $expression): Param
{
return new Param(DbUuidHelper::uuidToBlob($expression->value), DataType::LOB);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will it work when $expression->value is 16 raw bytes or 32 hexadecimal characters? Needs a test

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.

3 participants