Skip to content

Commit

Permalink
Replace $row with $result in all docs
Browse files Browse the repository at this point in the history
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
  • Loading branch information
abraxxa committed May 8, 2013
1 parent 78f7b20 commit 878562e
Show file tree
Hide file tree
Showing 13 changed files with 73 additions and 69 deletions.
4 changes: 4 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/DBIx/Class/CDBICompat/ColumnsAsHash.pm
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ See DBIx::Class::CDBICompat for usage directions.
Emulates the I<undocumnted> 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
Expand Down
2 changes: 1 addition & 1 deletion lib/DBIx/Class/FilterColumn.pm
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ exactly two arguments; the first being the column name the second being a hash
reference with C<filter_from_storage> and C<filter_to_storage> 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
Expand Down
2 changes: 1 addition & 1 deletion lib/DBIx/Class/Manual/Cookbook.pod
Original file line number Diff line number Diff line change
Expand Up @@ -1737,7 +1737,7 @@ methods:
numbers => [1, 2, 3]
});

$row->update(
$result->update(
{
numbers => [1, 2, 3]
},
Expand Down
18 changes: 9 additions & 9 deletions lib/DBIx/Class/Manual/FAQ.pod
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ in the cookbook can do the same if you pass a C<rows> attribute to the search.

Use L<DBIx::Class::Row/discard_changes>.

$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
Expand Down Expand Up @@ -384,17 +384,17 @@ object. To fetch the new value, use the C<discard_changes> 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?

Expand Down Expand Up @@ -491,15 +491,15 @@ An another method is to use L<Moose> with your L<DBIx::Class> 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?
Expand Down
4 changes: 2 additions & 2 deletions lib/DBIx/Class/Manual/Intro.pod
Original file line number Diff line number Diff line change
Expand Up @@ -445,10 +445,10 @@ L<delete|DBIx::Class::ResultSet/delete>
For example, the following would not work (assuming C<People> 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:
Expand Down
14 changes: 7 additions & 7 deletions lib/DBIx/Class/Manual/Joining.pod
Original file line number Diff line number Diff line change
Expand Up @@ -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<DBIx::Class::Manual::FAQ> for an explanation.

This type of column restriction has a downside, the resulting $row
This type of column restriction has a downside, the resulting $result

This comment has been minimized.

Copy link
@ribasushi

ribasushi May 9, 2013

Collaborator

"resulting $result" sounds funny - use "returned $result" or something...

This comment has been minimized.

Copy link
@abraxxa

abraxxa May 24, 2013

Author Contributor

thanks, fixed

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<get_column> 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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions lib/DBIx/Class/Relationship/Base.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion lib/DBIx/Class/ResultSource.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Loading

0 comments on commit 878562e

Please sign in to comment.