Skip to content

[WIP] 1.1 Updates #430

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

Open
wants to merge 60 commits into
base: master
Choose a base branch
from
Open

[WIP] 1.1 Updates #430

wants to merge 60 commits into from

Conversation

koenpunt
Copy link
Collaborator

@koenpunt koenpunt commented Jul 17, 2014

Issues to process

Other

  • Remove snake case #574 -- Update test functions.
    • Remove SnakeCase_PHPUnit_Framework_TestCase
    • Rewrite assert_equals/true/false calls to assertEquals/True/False etc.

Documentation

  • 1.1-dev
    • Tracking Attribute Changes
    • multiple model directories
    • custom inflections
    • aliased methods in serialization
    • validations for "on" events
      (I believe the documentation is already there, only the implementation was missing)
  • master (already released)
    • model caching

Optional

  • Change coding conventions

See the changes of this PR with ?w=1 to ignore whitespace changes

Comments regarding 1.1 should be added to #357

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.
@koenpunt koenpunt changed the title 1.1 Updates [WIP] 1.1 Updates Jul 17, 2014
Repository owner locked and limited conversation to collaborators Jul 17, 2014
@jpfuentes2
Copy link
Owner

This is really awesome work, @koenpunt. Thanks!

@jpfuentes2
Copy link
Owner

Something missing from this is a giant upgrade to the documentation :(.

@koenpunt
Copy link
Collaborator Author

koenpunt commented Dec 9, 2014

Where is the source of the documentation located?

@koenpunt
Copy link
Collaborator Author

koenpunt commented Dec 9, 2014

Added documentation to-do to the description

@jpfuentes2
Copy link
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 phpactiverecord.org

@koenpunt
Copy link
Collaborator Author

koenpunt commented Dec 9, 2014

What about setting it up on readthedocs.org?

@koenpunt
Copy link
Collaborator Author

koenpunt commented Jan 9, 2015

@cvanschalkwijk thanks for the merge, but that's a lot of noise for a single commit..

@koenpunt
Copy link
Collaborator Author

koenpunt commented Jan 9, 2015

Oh I see what happened. I rebase this branch on master once in a while, and you merged master into it.

andyleap and others added 14 commits January 18, 2015 00:58
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.
koenpunt and others added 29 commits June 3, 2017 16:20
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
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
relationship references wrong table
separate connection string parsing from connection
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants