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

Allow UUIDs for Blameable fields #2642

Merged

Conversation

fwolfsjaeger
Copy link
Contributor

@fwolfsjaeger fwolfsjaeger commented Jun 29, 2023

Feature request: #2641

I'm using UUID as primary key fields and I would like to store the users' UUID in the createdBy/updatedBy fields using the Blameable annotation/attribute.

To allow UUIDs, I've extended the validTypes array in the annotation/XML/YAML driver with 'uuid'.

Moved to separate PR: #2645
In order to convert the given value to whatever type is required, in my case UuidV6 from the Symfony UID component, I've amended the functionality of src/AbstractTrackingListener.php. I'm checking for a setter method to use that one instead of setting the property value directly.

@fwolfsjaeger
Copy link
Contributor Author

I think it would make sense to move the src/AbstractTrackingListener.php changes to another PR and make it configurable. Any objections?

@fwolfsjaeger
Copy link
Contributor Author

I've added the CHANGELOG.md entry, but without requiring ramsey/uuid-doctrine this can't be tested. I can add it as a DEV requirement if you want?

@fwolfsjaeger
Copy link
Contributor Author

Do you require/want any additional changes?

@phansys
Copy link
Collaborator

phansys commented Aug 22, 2023

Do you require/want any additional changes?

Yes. Please, review the failing CI jobs. The pipeline must succeed in order to merge.

@fwolfsjaeger
Copy link
Contributor Author

It seems that ramsey/uuid-doctrine requires PHP 7.4 or higher.

@fwolfsjaeger fwolfsjaeger force-pushed the feature/blameable-allow-uuid branch from db09694 to 1284926 Compare August 31, 2023 14:24
@fwolfsjaeger fwolfsjaeger force-pushed the feature/blameable-allow-uuid branch from 1284926 to 1727d18 Compare September 19, 2023 15:00
@fwolfsjaeger fwolfsjaeger force-pushed the feature/blameable-allow-uuid branch from 1727d18 to c93928d Compare December 1, 2023 14:51
@fwolfsjaeger fwolfsjaeger force-pushed the feature/blameable-allow-uuid branch from c93928d to 9ba8180 Compare January 9, 2024 11:12
@fwolfsjaeger
Copy link
Contributor Author

I've updated the branch and moved the CHANGELOG.md entry to [Unreleased].

@mbabker
Copy link
Contributor

mbabker commented Feb 27, 2024

It seems that ramsey/uuid-doctrine requires PHP 7.4 or higher.

Instead of using that package, the tests I set up looking at #2701 uses Symfony's UID and Doctrine Bridge packages (the latter of which is already pulled in thanks to the dev dependency chain).

The PHP version constraint isn't an issue anymore, but, I'd say we'd want to support both uuid and ulid types in all extensions (both ramsey/uuid-doctrine and Symfony use uuid as the name for that type, so implicitly supporting one should explicitly support both), and using the Symfony packages would let us test support for both types.

@fwolfsjaeger fwolfsjaeger force-pushed the feature/blameable-allow-uuid branch from 9ba8180 to bb28d1c Compare February 27, 2024 15:44
@fwolfsjaeger
Copy link
Contributor Author

When I created this PR, Doctrine was mostly using ramsey/uuid-doctrine for UUIDs. As of now all my projects are using symfony/uid as well.

I've added ulid as allowed type and replaced the DEV package now.

The packages are interchangeable, you just have to replace the generator in the annotation/attribute as well.

composer.json Outdated Show resolved Hide resolved
Co-authored-by: Michael Babker <michael.babker@gmail.com>
@fwolfsjaeger
Copy link
Contributor Author

@mbabker Would you mind taking a look at #2645 as well?

@franmomu franmomu merged commit 4461c5f into doctrine-extensions:main Jun 8, 2024
@franmomu
Copy link
Collaborator

franmomu commented Jun 8, 2024

Thanks @fwolfsjaeger! and @mbabker

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants