-
Notifications
You must be signed in to change notification settings - Fork 11.7k
[5.2] Cast incrementing IDs to Integer by default #11293
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
[5.2] Cast incrementing IDs to Integer by default #11293
Conversation
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'd rather we used the more conventional int here.
|
@GrahamCampbell Fixed--thanks! |
|
Do we really need this in every call to Why not do it once in the constructor? |
|
@JosephSilber |
|
@adamwathan now that we can do dates in the casts, we should be doing all of that in the constructor. |
Maybe we should change them both in 5.2 in the interest of efficiency? |
|
Maybe leave that to another PR though, to be discussed after this is either rejected or accepted. |
|
I agree we'll probably need to do this one time. How do we want to handle that? |
|
This was unexpected. It breaks previously non-integer primary keys when Notes: Model (5.1) and Model@insertAndSetId (5.1) Edit: |
|
@sherbrow Are there any cases where would you want |
|
@adamwathan It's definitely the case where one would forget to disable |
If a model is incrementing, set a default to cast the primary key to type
integer.This fixes an inconsistency where an instance created with
Model::createwould have an integer ID, but model instances fetched from the database would have a string ID.Written while pairing with @adamwathan.
Also fixes another test which broke when implementing this--it was setting the primary key of an incrementing table to the value
'foo', which is invalid. Updated the test to use a non-incrementing model.