Skip to content
This repository has been archived by the owner on Aug 31, 2020. It is now read-only.

What if user id is not integer? #29

Open
danaki opened this issue Sep 4, 2018 · 5 comments
Open

What if user id is not integer? #29

danaki opened this issue Sep 4, 2018 · 5 comments

Comments

@danaki
Copy link

danaki commented Sep 4, 2018

In my project, I defined user ids as uuid. When I use the built-in 'doctrine' channel, I get the following error:

"An error has occurred during the notification process of message \"transaction_state_change\" for channel \"Yokai\\MessengerBundle\\Channel\\DoctrineChannel\". Exception : Doctrine\\DBAL\\DBALException - An exception occurred while executing 'INSERT INTO yokai_messenger_notification (subject, body, recorded_at, recipient_class, recipient_id, delivered_at) VALUES (?, ?, ?, ?, ?, ?)' with params [\"Transaction status change\", \"0c0bbf47-f5ba-4b3c-9aa7-8810ca97230c\\n\", \"2018-09-04 20:24:58\", \"App\\\\Entity\\\\User\", \"a1385654-fb9e-48ef-864b-9c9de4b8193f\", null]:\n\nNotice: Object of class App\\Entity\\Id\\UserUuid could not be converted to int"
  • How can I override the Notification entity to use uuid as the user type? (May be this issue can help?
  • I'm using your yokai-token-bundle and there you define user id as varchar(255) which is ok in my case.
  • If the only way to override bundle mappings is thru overriding an xml config, it would be great to reflect it in the documentation because I guess it's an often used case when people want to bind Notification entity to User thru relations and vice versa.
@danaki
Copy link
Author

danaki commented Sep 4, 2018

Seems that overriding xml mappings doesn't work, here another issue I've just opened doctrine/DoctrineBundle#846

@yann-eugone
Copy link
Collaborator

The easiest solution for me is to change the field type to a string.

Mapping overriding in doctrine is painful, I don't want to document something like this.

The last possible solution I see, is that you implement your own channel.

@danaki
Copy link
Author

danaki commented Sep 5, 2018

Yes, convert id to string just for consistency with your other bundle. You see it appears that overriding in doctrine is broken or not documented enough, let's see how the related issue resolves. I've checked the source, there's nothing wrong in built-in doctrine channel, it's type-agnostic against recpientId.

yann-eugone added a commit that referenced this issue Sep 5, 2018
yann-eugone added a commit that referenced this issue Sep 5, 2018
…integration with other identifier types (#31)
@danaki
Copy link
Author

danaki commented Sep 5, 2018

May be it's even better if messenger-bundle doesn't provide Entity at all but requires it's user to create such Notification entity (of course with known interface) by himself and configure the bundle providing the class name then?

@yann-eugone
Copy link
Collaborator

Yes, it is. But currenly I've not enough time to prepare the bundle for this.

(I'm already thinking about the next major, with more abstraction everywhere)

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

No branches or pull requests

2 participants