-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Supply default values for optional values in sequence mapping if omitted by driver. #6683
Conversation
'allocationSize' => (string) $seqGenerator['allocation-size'], | ||
'initialValue' => (string) $seqGenerator['initial-value'] | ||
'allocationSize' => (int) $seqGenerator['allocation-size'], | ||
'initialValue' => (int) $seqGenerator['initial-value'] |
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.
Tbh, sequences are not necessarily int-based
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.
They can be floats? I do not think I can do CREATE SEQUENCE INCREMENT
with anything but integer. Neither PostgreSQL, nor oracle https://docs.oracle.com/database/121/SQLRF/statements_6017.htm#SQLRF01314
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.
Postgres only supports bigint:
Sequences are based on bigint arithmetic, so the range cannot exceed the range of an eight-byte integer (-9223372036854775808 to 9223372036854775807).
https://www.postgresql.org/docs/9.5/static/sql-createsequence.html
But on 32-bit platform, bigint would be string/float...
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.
Interesting. That would be still on PostgreSQL side though. The bug at highlighted line in referenced issue is in PHP side, where SequenceGenerator trying to predict maximum value. It is expecting PHP integer, as enforced by the cast, to do the addition for the prediction. But if value comes from XML parser, prediction calculation fails having second addend being string.
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.
Or are you saying because of this 32-bit corner case, the schema mapping should not be touched, but the cast should be fixed instead wherever the parameters are used? In this case, are you saying xml parser is not root cause, that SequenceGenerator
should be fixed?
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.
Also turns out migrations wants the value to be string. If driver casts to integer itself, migration diff generates INCREMENT BY 0. Unit tests here do not notice that potential regression. so I guess the crash is better fixed at the SequenceGenerator level.
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.
sorry, discovered actual root cause. Thanks @Majkl578 for making me think further about it. Turns out xml driver is not supplying default values for optional fields when they are omitted in mapping file. This results in empty $definition keys, which causes "non numeric value" error during addition, not because it is a casting problem as I originally thought.
Will redo the fix by either validating input in ClassMetadataInfo::setSequenceGeneratorDefinition
where it already does a little bit of parsing validation for sequence_name, but not the other parameters, or maybe I can find why XSD schema is not applied by XML driver.
c96fc53
to
79becf3
Compare
79becf3
to
bfcab4d
Compare
Kept default as string too as @Ocramius suggested, however I will still point out that
|
Supply default values for allocationSize and initialValue optional parameters. Related to: doctrine#6682
bfcab4d
to
b3331b2
Compare
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've rebased the branch and applied some minor changes. It LGTM now!
@alextech we only plan to add type declaration for |
Thank you! I can now get off my custom branch. |
@alextech the best person to answer that would be @guilhermeblanco 😄 |
Fix #6682
Cannot figure out how to get XML to run properly from Ticket directory as in contributor guide. If this is a strict requirement will try again.Figured out.