Skip to content

New: Add SQLite implementation of UuidValue expression - #432

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

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

Conversation

@KalimeroMK

@KalimeroMK KalimeroMK commented Sep 8, 2026

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

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

SQLite stores a UUID as 16 raw bytes (ColumnDefinitionBuilder maps ColumnType::UUID to blob(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();

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.

SQLite stores a UUID as 16 raw bytes in a `blob(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 98.48%. Comparing base (cb067f1) to head (7fdf83b).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##             master     #432   +/-   ##
=========================================
  Coverage     98.48%   98.48%           
- Complexity      329      330    +1     
=========================================
  Files            22       23    +1     
  Lines          1055     1058    +3     
=========================================
+ Hits           1039     1042    +3     
  Misses           16       16           

☔ 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

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

$expression->value is always the canonical lowercase form — UuidValue::__construct() normalizes through DbUuidHelper::toUuid(), so 16 raw bytes and 32 hexadecimal characters are input forms rather than states the builder can observe.

Both tests in UuidValueBuilderTest are now data-provider driven over every accepted form — canonical, canonical uppercase, 32 hex, 32 hex uppercase and 16 raw bytes. The build test asserts the same Param(uuidToBlob(...), DataType::LOB) for each, and testInsertAndSelectUuid() does a real-database round-trip per form.

@KalimeroMK

Copy link
Copy Markdown
Author

These composer-dependency-analyser failures aren't from this PR's code — Yiisoft\Db\Expression\Value\UuidValue and its builder don't exist in any released yiisoft/db yet, they arrive with yiisoft/db#1199. The same five failures are on the other two driver PRs.

The other workflows don't hit it because they install the core from the PR branch: static.yml, rector-cs.yml, build.yml and mutation.yml pass required-packages: ['db'] to the reusable workflow, while composer-dependency-analyser.yml passes only php.

It clears itself once #1199 is merged and 2.0.2 is tagged. If you'd rather see it green before that, adding required-packages: ['db'] there is three lines and I can send it separately. Your call.

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