sonata-project / SonataAdminBundle

The missing Symfony Admin Generator
https://docs.sonata-project.org/projects/SonataAdminBundle
MIT License
2.11k stars 1.26k forks source link

Uuid and Ulid support for Sonata #7327

Closed jordisala1991 closed 1 year ago

jordisala1991 commented 3 years ago

Feature Request

Should we support Uuids for primary keys in Sonata? Is someone already using them actually?

I just want to open a discussion to know the interest from the contributors and @sonata-project/contributors .

There are a lot of places that IMO should be changed in order to support them but let's see if it is interesting to someone.

Another way of using uuid is not as primary keys, but having as a separate property (and let the uuid as integer)

Gasjki commented 3 years ago

Hey! I just came here to report this kind of situation, so yeah, you might start supporting this kind of behavior. See the attached image.

As you can see, I'm using Uid component as my PK for my Server entity. However, when I added a child admin called Comment, when its trying to query, it's using the string version, even if it should use the hex version.

sonata admin bug

Do you have any workaround or I should stick with the classic PK implementation?

VincentLanglet commented 3 years ago

Do you have any workaround or I should stick with the classic PK implementation?

PR are welcomed if you want to add support

Gasjki commented 3 years ago

I'd like to assist, but I'd need some guidance. Can you help me with that? Macro level, not the specific file or line :)

VincentLanglet commented 3 years ago

I'd like to assist, but I'd need some guidance. Can you help me with that? Macro level, not the specific file or line :)

Sure, but my first question would be "What is all the things which doesn't work currently with Uuid ?", We'll have to list all the currently non-compatible feature. Since I don't use them, I cannot test by myself.

For your query, I would search in the vendor where the uuid is passed and when it's transformed. For instance, if you're issue is that we're using the string representation of the $id, it's possibly because we're casting it somewhere like in the modelManager: https://github.com/sonata-project/SonataDoctrineORMAdminBundle/blob/3.x/src/Model/ModelManager.php#L333

Gasjki commented 3 years ago

That's a good question! I'll start by using a custom ModelManager in my app and as things go, I'll try to submit a PR with all issues found and solved.

Chris53897 commented 2 years ago

It would be great to have fully support of Uuids as primary key. This would help to migrate projects (That already use uuid) to sonata.

VincentLanglet commented 2 years ago

It would be great to have fully support of Uuids as primary key. This would help to migrate projects (That already use uuid) to sonata.

It would be great to have sponsor or contributors ;)

Chris53897 commented 2 years ago

I totally agree. I will do if we decide to migrate to sonata.

jordisala1991 commented 1 year ago

Started work here: https://github.com/sonata-project/SonataDoctrineORMAdminBundle/pull/1738

I think most of the changes should be done on the ORM persistence.