From: Alexander Hartmaier Date: Wed, 8 May 2013 16:09:35 +0000 (+0200) Subject: Replace $row with $result in all docs X-Git-Tag: v0.08260~211 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=47d7b769c034e04989840b1efc2f5991518cff23;p=dbsrgits%2FDBIx-Class.git Replace $row with $result in all docs to be consistent and to clarify various return values for example: $result->update() returns $result before the example was $row->update() returns $result which doesn't make clear that it's the same object the method was called on --- diff --git a/Changes b/Changes index 0ac2321..771a55e 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,9 @@ Revision history for DBIx::Class + * Misc + - Replace $row with $result in all docs to be consistent and to + clarify various return values + 0.08250 2013-04-29 22:00 (UTC) * New Features / Changes - Rewrite from scratch the result constructor codepath - many bugfixes diff --git a/lib/DBIx/Class/CDBICompat/ColumnsAsHash.pm b/lib/DBIx/Class/CDBICompat/ColumnsAsHash.pm index 494dbb9..fa572d6 100644 --- a/lib/DBIx/Class/CDBICompat/ColumnsAsHash.pm +++ b/lib/DBIx/Class/CDBICompat/ColumnsAsHash.pm @@ -17,7 +17,7 @@ See DBIx::Class::CDBICompat for usage directions. Emulates the I behavior of Class::DBI where the object can be accessed as a hash of columns. This is often used as a performance hack. - my $column = $row->{column}; + my $column = $result->{column}; =head2 Differences from Class::DBI diff --git a/lib/DBIx/Class/FilterColumn.pm b/lib/DBIx/Class/FilterColumn.pm index feef4f1..cee647e 100644 --- a/lib/DBIx/Class/FilterColumn.pm +++ b/lib/DBIx/Class/FilterColumn.pm @@ -201,7 +201,7 @@ exactly two arguments; the first being the column name the second being a hash reference with C and C set to either a method name or a code reference. In either case the filter is invoked as: - $row_obj->$filter_specification ($value_to_filter) + $result->$filter_specification ($value_to_filter) with C<$filter_specification> being chosen depending on whether the C<$value_to_filter> is being retrieved from or written to permanent diff --git a/lib/DBIx/Class/Manual/Cookbook.pod b/lib/DBIx/Class/Manual/Cookbook.pod index 588c315..9b9f9ce 100644 --- a/lib/DBIx/Class/Manual/Cookbook.pod +++ b/lib/DBIx/Class/Manual/Cookbook.pod @@ -1737,7 +1737,7 @@ methods: numbers => [1, 2, 3] }); - $row->update( + $result->update( { numbers => [1, 2, 3] }, diff --git a/lib/DBIx/Class/Manual/FAQ.pod b/lib/DBIx/Class/Manual/FAQ.pod index 7f063b7..cd75555 100644 --- a/lib/DBIx/Class/Manual/FAQ.pod +++ b/lib/DBIx/Class/Manual/FAQ.pod @@ -312,7 +312,7 @@ in the cookbook can do the same if you pass a C attribute to the search. Use L. - $row->discard_changes + $result->discard_changes Discarding changes and refreshing from storage are two sides fo the same coin. When you want to discard your local changes, just re-fetch the row from storage. When you want @@ -384,17 +384,17 @@ object. To fetch the new value, use the C method on the Row. # will return the scalar reference: - $row->somecolumn() + $result->somecolumn() # issue a select using the PK to re-fetch the row data: - $row->discard_changes(); + $result->discard_changes(); # Now returns the correct new value: - $row->somecolumn() + $result->somecolumn() To update and refresh at once, chain your calls: - $row->update({ 'somecolumn' => { -ident => 'othercolumn' } })->discard_changes; + $result->update({ 'somecolumn' => { -ident => 'othercolumn' } })->discard_changes; =item .. store JSON/YAML in a column and have it deflate/inflate automatically? @@ -491,15 +491,15 @@ An another method is to use L with your L package. With either of these methods the resulting use of the accesssor would be - my $row; + my $result; - # assume that somewhere in here $row will get assigned to a MyTable row + # assume that somewhere in here $result will get assigned to a MyTable row - $row->non_column_data('some string'); # would set the non_column_data accessor + $result->non_column_data('some string'); # would set the non_column_data accessor # some other stuff happens here - $row->update(); # would not inline the non_column_data accessor into the update + $result->update(); # would not inline the non_column_data accessor into the update =item How do I use DBIx::Class objects in my TT templates? diff --git a/lib/DBIx/Class/Manual/Intro.pod b/lib/DBIx/Class/Manual/Intro.pod index 382f72d..d6c218d 100644 --- a/lib/DBIx/Class/Manual/Intro.pod +++ b/lib/DBIx/Class/Manual/Intro.pod @@ -445,10 +445,10 @@ L For example, the following would not work (assuming C does not have a declared PK): - my $row = $schema->resultset('People') + my $result = $schema->resultset('People') ->search({ last_name => 'Dantes' }) ->next; - $row->update({ children => 2 }); # <-- exception thrown because $row isn't + $result->update({ children => 2 }); # <-- exception thrown because $result isn't # necessarily unique So instead the following should be done: diff --git a/lib/DBIx/Class/Manual/Joining.pod b/lib/DBIx/Class/Manual/Joining.pod index 5785349..1948be6 100644 --- a/lib/DBIx/Class/Manual/Joining.pod +++ b/lib/DBIx/Class/Manual/Joining.pod @@ -154,17 +154,17 @@ Which will produce the query: Note that the '+as' does not produce an SQL 'AS' keyword in the output, see the L for an explanation. -This type of column restriction has a downside, the resulting $row +This type of column restriction has a downside, the returned $result object will have no 'track_name' accessor: - while(my $row = $search_rs->next) { - print $row->track_name; ## ERROR + while(my $result = $search_rs->next) { + print $result->track_name; ## ERROR } Instead C must be used: - while(my $row = $search_rs->next) { - print $row->get_column('track_name'); ## WORKS + while(my $result = $search_rs->next) { + print $result->get_column('track_name'); ## WORKS } =head2 Incomplete related objects @@ -193,8 +193,8 @@ Which will produce same query as above; Now you can access the result using the relationship accessor: - while(my $row = $search_rs->next) { - print $row->tracks->name; ## WORKS + while(my $result = $search_rs->next) { + print $result->tracks->name; ## WORKS } However, this will produce broken objects. If the tracks id column is diff --git a/lib/DBIx/Class/Relationship/Base.pm b/lib/DBIx/Class/Relationship/Base.pm index cd9749f..f4b2bb2 100644 --- a/lib/DBIx/Class/Relationship/Base.pm +++ b/lib/DBIx/Class/Relationship/Base.pm @@ -206,7 +206,7 @@ With the bind values: '4', '1990', '1979' Note that in order to be able to use -L<< $row->create_related|DBIx::Class::Relationship::Base/create_related >>, +L<< $result->create_related|DBIx::Class::Relationship::Base/create_related >>, the coderef must not only return as its second such a "simple" condition hashref which does not depend on joins being available, but the hashref must contain only plain values/deflatable objects, such that the result can be @@ -423,8 +423,8 @@ $rel_name. =back # These pairs do the same thing - $row = $cd->related_resultset('artist')->single; # has_one relationship - $row = $cd->artist; + $result = $cd->related_resultset('artist')->single; # has_one relationship + $result = $cd->artist; $rs = $cd->related_resultset('tracks'); # has_many relationship $rs = $cd->tracks; diff --git a/lib/DBIx/Class/ResultSource.pm b/lib/DBIx/Class/ResultSource.pm index f5d2112..7d3bb0f 100644 --- a/lib/DBIx/Class/ResultSource.pm +++ b/lib/DBIx/Class/ResultSource.pm @@ -96,7 +96,7 @@ You can retrieve the result source at runtime in the following ways: =item From a Result object: - $row->result_source; + $result->result_source; =item From a ResultSet object: diff --git a/lib/DBIx/Class/Row.pm b/lib/DBIx/Class/Row.pm index 0a2cf4a..995b37b 100644 --- a/lib/DBIx/Class/Row.pm +++ b/lib/DBIx/Class/Row.pm @@ -66,9 +66,9 @@ objects. Refer to L for more info. =head2 new - my $row = My::Class->new(\%attrs); + my $result = My::Class->new(\%attrs); - my $row = $schema->resultset('MySource')->new(\%colsandvalues); + my $result = $schema->resultset('MySource')->new(\%colsandvalues); =over @@ -279,18 +279,18 @@ sub new { # Each pair does the same thing # (un-inflated, regular column) - my $val = $row->get_column('first_name'); - my $val = $row->first_name; + my $val = $result->get_column('first_name'); + my $val = $result->first_name; - $row->set_column('first_name' => $val); - $row->first_name($val); + $result->set_column('first_name' => $val); + $result->first_name($val); # (inflated column via DBIx::Class::InflateColumn::DateTime) - my $val = $row->get_inflated_column('last_modified'); - my $val = $row->last_modified; + my $val = $result->get_inflated_column('last_modified'); + my $val = $result->last_modified; - $row->set_inflated_column('last_modified' => $val); - $row->last_modified($val); + $result->set_inflated_column('last_modified' => $val); + $result->last_modified($val); =over @@ -312,7 +312,7 @@ is called on the row. =head2 insert - $row->insert; + $result->insert; =over @@ -464,8 +464,8 @@ sub insert { =head2 in_storage - $row->in_storage; # Get value - $row->in_storage(1); # Set value + $result->in_storage; # Get value + $result->in_storage(1); # Set value =over @@ -486,7 +486,7 @@ calling L on one, sets it to false. =head2 update - $row->update(\%columns?) + $result->update(\%columns?) =over @@ -497,7 +497,7 @@ calling L on one, sets it to false. =back Throws an exception if the result object is not yet in the database, -according to L. +according to L. Returns the object itself. This method issues an SQL UPDATE query to commit any changes to the object to the database if required (see L). @@ -516,9 +516,9 @@ to C, e.g. ( { %{ $href } } ) If the values passed or any of the column values set on the object contain scalar references, e.g.: - $row->last_modified(\'NOW()')->update(); + $result->last_modified(\'NOW()')->update(); # OR - $row->update({ last_modified => \'NOW()' }); + $result->update({ last_modified => \'NOW()' }); The update will pass the values verbatim into SQL. (See L docs). The values in your Result object will NOT change @@ -526,7 +526,7 @@ as a result of the update call, if you want the object to be updated with the actual values from the database, call L after the update. - $row->update()->discard_changes(); + $result->update()->discard_changes(); To determine before calling this method, which column values have changed and will be updated, call L. @@ -564,7 +564,7 @@ sub update { =head2 delete - $row->delete + $result->delete =over @@ -630,7 +630,7 @@ sub delete { =head2 get_column - my $val = $row->get_column($col); + my $val = $result->get_column($col); =over @@ -651,7 +651,7 @@ will be deflated and returned. Note that if you used the C or the C