-
Notifications
You must be signed in to change notification settings - Fork 892
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 up UUID binary16 support #2239
Conversation
@@ -40,7 +40,7 @@ class SQLiteAdapter extends PdoAdapter | |||
protected static array $supportedColumnTypes = [ | |||
self::PHINX_TYPE_BIG_INTEGER => 'biginteger', | |||
self::PHINX_TYPE_BINARY => 'binary_blob', | |||
self::PHINX_TYPE_BINARYUUID => 'binary_blob', | |||
self::PHINX_TYPE_BINARYUUID => 'uuid_blob', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about binary(16)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isnt Binary always 16 in this case?
https://stackoverflow.com/questions/17277735/using-uuids-in-sqlite#:~:text=SQLite%20allows%20to%20use%20any,small%20that%20the%20difference%20matters).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not able to find any documentation on SQLite's support for uuid_blob
, but I do know that sqlite only has 5 real types, and that it will preserve but not enforce column lengths. By mapping binaryuuid
to binary(16)
in phinx, we would not have to update cakephp as it already detects binary(16)
as binaryuuid
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What would that change look like?
What type string string should we use here to map?
You just want it to be binary
with length of 16
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WAH
I accidently pushed directly instead of creating a PR: 5a78c76
We can revert if needed!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I checked, and it returns binary without length, as such this is not working out.
How can we also include the length I wonder.
[
'type' => 'binary',
'length' => null,
'null' => false,
'default' => null,
'precision' => null,
'comment' => null
]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I must be missing sth
On my local system, in Cake (and thus my app and tests) it always ends up as UUID_BLOB
, and still seems to require a change in cakephp/cakephp directly (as in my other PR).
I cannot reproduce the CI result locally, making it hard to debug..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I found working was to set it to binaryuuid
self::PHINX_TYPE_BINARYUUID => 'binaryuuid',
and then change the core code to at least add
if ($col === 'binaryuuid') {
return ['type' => TableSchemaInterface::TYPE_BINARY_UUID, 'length' => null];
}
https://github.com/dereuromark/cakephp-sandbox/actions/runs/6864095226/job/18665132299
Also note that pgsql also has still "uuid" only here:
https://github.com/dereuromark/cakephp-sandbox/actions/runs/6864095226/job/18665133009#step:11:25
But the test doesnt fail, interesting enough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now I understand: You mean literally binary(16)
. Didnt know that works.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can confirm that works!
Only Postgres is still a bit questionable. No errors, but it seems to be using the Uuid type instead of BinaryUuid type.
[
'type' => 'uuid',
'length' => null,
'default' => null,
'null' => false,
'comment' => null,
'precision' => null
]
Since it doesnt fail, maybe its OK
The entity itself contains
'uuid' => 'eb25610d-7bfa-4e34-812c-ad72b100fb26'
when reading a record.
I wonder if the actual DB column here is using binary16, it seems uuid is a native type.
So we probably dont have to care about it and all is good.
# Conflicts: # src/Phinx/Db/Adapter/SQLiteAdapter.php
Confirmed to be working I will squash merge this then, as the current one in master is faulty. |
I don't think using |
@MasterOdin What value would you then consider to be working here? Or should we go with the |
Yeah, Though, does CakePHP core need anything special for that or since it's just text, it's fine? |
It wouldn't map it to "binaryuuid" or "binary" with length 16 and as such to the correct BinaryUuid type class Or is there a way to map it to "binary" and the length of 16 for Sqlite? I only saw these options for mysql etc. |
Looking at that, it's already doing a bit of special logic for
where the regex gives:
|
I opened the PRs |
Follow #1734
But doesn't quite fix cakephp/cakephp#17420 yet - also needs cakephp/cakephp#17421 then