Conversation
The logic in the Model::__set() magic method allowed for either an aliased attribute *or* a custom setter, but not both. If a custom setter method was defined for an aliased attribute, then the attribute value would be set without going through the custom setter method. Changed the logic so that the _set() method first normalizes an aliased attribute into the real attribute name, then checks to see if an there is a custom setter method defined and runs it if it exists.
Repository owner
locked and limited conversation to collaborators
Jul 17, 2014
Owner
|
This is really awesome work, @koenpunt. Thanks! |
975878c to
6309d9e
Compare
Owner
|
Something missing from this is a giant upgrade to the documentation :(. |
Collaborator
Author
|
Where is the source of the documentation located? |
Collaborator
Author
|
Added documentation to-do to the description |
Owner
|
Hilariously, it is on a private Redmine-based repo. That could be dropped for a static site since we don't need the forums and everything else we have on |
Collaborator
Author
|
What about setting it up on readthedocs.org? |
Collaborator
Author
|
@cvanschalkwijk thanks for the merge, but that's a lot of noise for a single commit.. |
Collaborator
Author
|
Oh I see what happened. I rebase this branch on master once in a while, and you merged master into it. |
The default PHP boolean-to-string casting does not work for some database connection types (e.g. PostgreSQL). Added a BOOLEAN type to the Column class, and then the cast() method delegates to the a new boolean_to_string() method in the Connection class. By default the boolean_to_string() method returns the standard PHP string cast for the boolean, retaining the original behavior. This method can be overridden in adapter classes to provides custom casting of boolean values. Added an overridden boolean_to_string() method into the adapters/PgsqlAdapter.php class which casts the boolean values false and true to the strings "0" and "1" respectively. These string values are then recognized by the Postgres database as boolean values, as opposed to the values "" and "1" generated by the standard PHP cast.
Updated the ColumnTest::assert_cast() to test that boolean values are being casted using the Connection boolean_to_string() method. Added a PostgreSQL specific test to ensure that boolean values are being casted as the correct string value.
Modified the boolean_to_string() method in the PgsqlAdapter class to properly convert values that PHP considers a boolean, as well as what PostgreSQL considers a boolean value. E.g., PostgreSQL considers the values 'f', 'false', 'n', 'no', and 'off' as valid values for `false`, but PHP does not. The original implementation of this method would return `true` for one of these values which is incorrect for a PostgreSQL database. Also modified the base Connection class boolean_to_string() method to first cast its `$value` parameter as a boolean before casting it to a string. This will account for PHP's loose type-casting and make sure the method returns a consistent casted value.
While the previous version was explicit and descriptive, it wasn't that elegant. This is much nicer.
Protect mass assignment by filtering input data using StrongParameters
$user_params = new ActiveRecord\StrongParameters($_POST['user']);
$user_params->permit('name', 'bio');
$user = new User($user_params);
$user->save();
parse_str is about 60% faster than custom parsing using foreach loop
sscanf is about 40% faster than using a regex
code formatting
fetching values is now also possible using ArrayAccess.
So instead of
$params->fetch('name')
You can now also do:
$params['name'];
add missing tables to pgsql fixture add password to users table make test more readable
Feature: StrongParameters
Cache validation result.
Include @suxxes changes
relationship references wrong table
separate connection string parsing from connection
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issues to process
Clean merge of fixed mysql datetime handling #440 (Better Datetime handling #317) -- cast to DateTime via connection(invalid issue)Other
SnakeCase_PHPUnit_Framework_TestCaseassert_equals/true/falsecalls toassertEquals/True/Falseetc.Documentation
(I believe the documentation is already there, only the implementation was missing)
Optional
See the changes of this PR with
?w=1to ignore whitespace changesComments regarding 1.1 should be added to #357