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

[Doctrine][Messenger] Use common sequence name to get id from Oracle #54566

Merged
merged 1 commit into from
Oct 6, 2024

Conversation

rjd22
Copy link
Contributor

@rjd22 rjd22 commented Apr 11, 2024

Q A
Branch? 6.4
Bug fix? yes
New feature? no
Deprecations? no
Issues Fix #54193
License MIT

This is a fix for #54193 by using a common sequence name for getting the ID's for Oracle databases.

This will require the user to name their sequences seq_<table_name> or SEQ_<TABLE_NAME> but at least allows you to use messenger with Oracle after properly setting up the table.

@rjd22 rjd22 force-pushed the fix/oracle-sequence-support branch from efe7c35 to 8fd6ff7 Compare April 11, 2024 08:39
@rjd22 rjd22 changed the title fix #54193: use common sequence name to get id from Oracle fix #54193: use common sequence name to get id from Oracle for Messenger Apr 11, 2024
@rjd22 rjd22 changed the title fix #54193: use common sequence name to get id from Oracle for Messenger [Messenger] fix #54193: use common sequence name to get id from Oracle Apr 11, 2024
@rjd22 rjd22 changed the title [Messenger] fix #54193: use common sequence name to get id from Oracle [Messenger] Use common sequence name to get id from Oracle Apr 11, 2024
@derrabus
Copy link
Member

This will require the user to name their sequences seq_<table_name> or SEQ_<TABLE_NAME>

Do we create this sequence during auto-setup?

@rjd22
Copy link
Contributor Author

rjd22 commented Apr 11, 2024

This will require the user to name their sequences seq_<table_name> or SEQ_<TABLE_NAME>

Do we create this sequence during auto-setup?

I'm not sure auto setup works for Oracle. I had to setup the tables manually for them to work properly.

Edit: retested the auto create and it indeed fails with an error because of the json data type.

@nicolas-grekas
Copy link
Member

It'd be great to fix the autosetup and let doctrine manage the sequence.

@nicolas-grekas nicolas-grekas added this to the 6.4 milestone Apr 11, 2024
@nicolas-grekas
Copy link
Member

#54176 might be trying to fix the same issue. Can you please have a look in case this brings inspiration?

@rjd22
Copy link
Contributor Author

rjd22 commented Apr 11, 2024

#54176 might be trying to fix the same issue. Can you please have a look in case this brings inspiration?

That PR solves a different issue that is not really an issue for Oracle versions higher than 12c. You can link the sequence to the id column as identity and it will auto increment the ID column just like the other databases.

This PR solves the part to get the currval of the just inserted ID. I rather not change the method of insertion of the record because that would divert too much from the other implementations.

Still there is some nice inspiration in that PR. And I will check if I can make the auto_setup work.

@fabpot
Copy link
Member

fabpot commented Aug 19, 2024

@rjd22 Any news?

@rjd22
Copy link
Contributor Author

rjd22 commented Aug 21, 2024

@fabpot at this moment this is pending. I need to make some time to finish this and test this.

@rjd22 rjd22 force-pushed the fix/oracle-sequence-support branch from 8fd6ff7 to e799d36 Compare September 13, 2024 11:48
@rjd22
Copy link
Contributor Author

rjd22 commented Sep 13, 2024

@fabpot Sorry it took me longer than expected. These changes should solve the messenger issues with Oracle and also help new users to setup the messenger table correcty.

We could improve on this by splitting all Oracle changes off to an separate OracleConnection (like postgres) but this would also mean quite a rewrite of the Connection itself.

@rjd22
Copy link
Contributor Author

rjd22 commented Sep 17, 2024

Would someone be willing to take a look for me?

@rjd22
Copy link
Contributor Author

rjd22 commented Sep 24, 2024

@nicolas-grekas Sorry for pinging but can you mark this for review? This fixes quite a important block of an upgrade path for Oracle users using messenger.

@xabbuh
Copy link
Member

xabbuh commented Sep 24, 2024

The change itself looks good to me. Works be great to have some Oracle users give their feedback though.

What I wonder though is: Will this break existing setups is they don’t add the sequence manually?

@rjd22
Copy link
Contributor Author

rjd22 commented Sep 24, 2024

The change itself looks good to me. Works be great to have some Oracle users give their feedback though.

What I wonder though is: Will this break existing setups is they don’t add the sequence manually?

Yes and no, all existing setups are already broken after 6.4.3 and to upgrade they have to manually migrate the table or remove it and make the script recreate it. The ones that already have a sequence connected with the correct name (I tried to use the most common name for it). Should start working correctly.

Because of licensing Oracle testers are really hard to come by :).

@rjd22
Copy link
Contributor Author

rjd22 commented Sep 24, 2024

For manual migration the users will have to run the following queries (please adapt to table name if using a different table name):

create sequence seq_messenger_messages
alter table messenger_messages modify id default "seq_messenger_messages.nextval"

@rjd22
Copy link
Contributor Author

rjd22 commented Sep 25, 2024

@xabbuh lets wait for this week and if noone comes forward I recommend merging this and testing this in the field. If any things pop up then we will fix them. Atleast we have the advantage here that we can't make it worse.

@rjd22
Copy link
Contributor Author

rjd22 commented Oct 1, 2024

@xabbuh well not much interest to test it sadly :(. Would it be okay to merge this?

Copy link
Member

@xabbuh xabbuh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

works for me

@carsonbot carsonbot changed the title [Messenger] Use common sequence name to get id from Oracle [Doctrine][Messenger] Use common sequence name to get id from Oracle Oct 1, 2024
@fabpot fabpot force-pushed the fix/oracle-sequence-support branch from e799d36 to 52c3a32 Compare October 6, 2024 09:09
@fabpot
Copy link
Member

fabpot commented Oct 6, 2024

Thank you @rjd22.

@fabpot fabpot merged commit c898802 into symfony:6.4 Oct 6, 2024
9 of 10 checks passed
This was referenced Oct 27, 2024
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.

None yet

6 participants