Skip to content

New: Add Oracle implementation of UuidValue expression - #411

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

New: Add Oracle implementation of UuidValue expression#411
KalimeroMK wants to merge 6 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

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

Oracle stores a UUID as 16 raw bytes (ColumnDefinitionBuilder maps ColumnType::UUID to raw(16)), so prepareValue() converts the canonical form with DbUuidHelper::uuidToBlob() and binds it as DataType::LOB.

Draft, because I could not verify this locally — pdo_oci is not available on my machine, so I am relying on CI for the round-trip test against a real raw(16) column. The SQLite and MySQL counterparts (yiisoft/db-sqlite#432, yiisoft/db-mysql#482) are verified locally.

The open question is whether bindValue($name, $bytes, PDO::PARAM_LOB) is right for a raw(16) column under PDO_OCI, since this driver otherwise represents binary values as an inline HEXTORAW('...') literal via QueryBuilder::prepareBinary(). If CI shows the LOB parameter does not work, the alternative is to build the literal in build() instead:

return "HEXTORAW('" . str_replace('-', '', $expression->value) . "')";

That needs no binding and is safe here because the value is already validated as a UUID, but it inlines the value rather than passing a parameter. Happy to take whichever you prefer.

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.

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

Requires yiisoft/db#1199.
CI showed PDO_OCI inserts NULL when the raw bytes are bound as a large
object, so build the `HEXTORAW()` literal directly — the representation
this driver already uses for binary values.
@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 97.83%. Comparing base (7415aab) to head (b136c5e).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##             master     #411   +/-   ##
=========================================
  Coverage     97.82%   97.83%           
- Complexity      250      251    +1     
=========================================
  Files            26       27    +1     
  Lines           828      831    +3     
=========================================
+ Hits            810      813    +3     
  Misses           18       18           

☔ 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.

public function build(ExpressionInterface $expression, array &$params = []): string
{
/** @var UuidValue $expression */
return "HEXTORAW('" . str_replace('-', '', $expression->value) . "')";

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? 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 are an input form rather than a state the builder can observe. That is what makes inlining the literal safe: stripping the dashes always leaves exactly 32 hexadecimal characters.

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 HEXTORAW('738146be87b149f2991336142fb6fcbe') for each, and testInsertAndSelectUuid() does a real-database round-trip per form. Green on Oracle 18 and 21 across PHP 8.1-8.5.

@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