-
Notifications
You must be signed in to change notification settings - Fork 442
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
Store primary key column name in lower case #292
Conversation
Now that we have Travis CI working, can you fetch upstream, rebase your branch, and force-push to trigger a rebuild? |
I am not sure if I followed the right steps, but here is what I did:
Please let me know if I messed up or if its all okay. I am not too good at using Git. Thanks. |
@thesocialgeek If you can revert that mistake, that would be great.
But, DO NOT follow these steps UNTIL you've reverted your previous accidental steps. Does that make sense? |
Thanks @Rican7 , my bad - I'm so stupid. Before I mess up again, do you have specific command(s) to revert the right way? I don't wanna end up running weird commands again. Thanks. |
Yea, no problem @thesocialgeek.
Then, follow my previously mentioned steps. |
Thanks @Rican7 :) I will follow these steps as I reach home from work. Thanks. |
Thank you @thesocialgeek! |
Often, developers set the column names in different cases for the $primary_key static field in the Model. However, the object for the Model stores column names as lowercase (in $attributes). This causes confusion at times (for example, when checking if "$attributes[$pk]" is set while inserting a new record). This small bit of code makes sure no matter what case the developer sets his primary key ("myPrimaryKey" or "myprimaryKey"), the key will always be stored in all lowercase ("myprimarykey").
The build process is still broken for some reason, any ideas guys? Thanks! |
@thesocialgeek You did a great job fixing the git issue! Nice job! As far as the build error goes, don't worry, as the only error that's being thrown in the build process is one that we're already aware of: #298 In other words, as far as I can tell, this one's good to merge. |
Thanks @Rican7 :) Thanks for letting me know :) |
But what if the column in the database uses uppercase characters? Doesn't this create problems? Maybe add some tests for this specific case-change. |
@koenpunt good point |
@koenpunt very good point. Thanks. I am sorry for the late reply guys. I will look into the matter at my earliest and see what possible options are there for this if any. Thanks. |
@koenpunt and @Rican7 Atleast that is how PHPActiveRecord's StandardInflector works: https://github.com/kla/php-activerecord/blob/master/lib/Inflector.php#L118 The problem will be: what if someone decides to use a custom inflector by adding his or her own implementation of Inflector, and decides NOT to lowercase the column name, we could have a problem. The solution to that is, in the change that I committed, instead of simply lowercasing the column name, we use the Inflector class's variablize() method itself like so:
Here we are applying the variablize method making sure we use the right inflected name. The message is a rather long one, so please let me know if anything is not clear. What do you guys think? |
I agree on using |
…el $attributes container
I have committed the new change guys. Please let me know if I need to do anything further. Thanks for guiding me so far. |
@jpfuentes2 do I need to take additional steps for this request to process further? Sorry I am kinda new to contributing to open source so I am not aware of all the processed yet. |
Nothing you need to do, @thesocialgeek. We just gotta get our $#!+ together over here and merge some of these open PRs. |
@al-the-x Thanks for that David! Sounds great! :) |
Often, developers set the column names in different cases for the $primary_key static field in the Model. However, the object for the Model stores column names as lowercase (in $attributes). This causes confusion at times (for example, when checking if "$attributes[$pk]" is set while inserting a new record).
This small bit of code makes sure no matter what case the developer sets his primary key ("myPrimaryKey" or "myprimaryKey"), the key will always be stored in all lowercase ("myprimarykey").