X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FRow.pm;h=cb902d23f95eec159ed74120ddc09c7a2b67a9fd;hb=a446d7f8fdc34bde8a31936f7900b77a0c210415;hp=0a2cf4a14be7c09d08b844a8cf09e09076c467a4;hpb=78f7b20c350ff5c2672d6bf49a7260e915e6110f;p=dbsrgits%2FDBIx-Class.git diff --git a/lib/DBIx/Class/Row.pm b/lib/DBIx/Class/Row.pm index 0a2cf4a..cb902d2 100644 --- a/lib/DBIx/Class/Row.pm +++ b/lib/DBIx/Class/Row.pm @@ -9,6 +9,7 @@ use Scalar::Util 'blessed'; use List::Util 'first'; use Try::Tiny; use DBIx::Class::Carp; +use DBIx::Class::_Util 'is_literal_value'; ### ### Internal method @@ -66,9 +67,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 @@ -118,7 +119,7 @@ with NULL as the default, and save yourself a SELECT. =cut ## It needs to store the new objects somewhere, and call insert on that list later when insert is called on this object. We may need an accessor for these so the user can retrieve them, if just doing ->new(). -## This only works because DBIC doesnt yet care to check whether the new_related objects have been passed all their mandatory columns +## This only works because DBIC doesn't yet care to check whether the new_related objects have been passed all their mandatory columns ## When doing the later insert, we need to make sure the PKs are set. ## using _relationship_data in new and funky ways.. ## check Relationship::CascadeActions and Relationship::Accessor for compat @@ -199,7 +200,7 @@ sub new { my ($related,$inflated); foreach my $key (keys %$attrs) { - if (ref $attrs->{$key}) { + if (ref $attrs->{$key} and ! is_literal_value($attrs->{$key}) ) { ## Can we extract this lot to use with update(_or .. ) ? $new->throw_exception("Can't do multi-create without result source") unless $rsrc; @@ -279,18 +280,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 +313,7 @@ is called on the row. =head2 insert - $row->insert; + $result->insert; =over @@ -464,8 +465,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 +487,7 @@ calling L on one, sets it to false. =head2 update - $row->update(\%columns?) + $result->update(\%columns?) =over @@ -497,7 +498,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 +517,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 +527,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 +565,7 @@ sub update { =head2 delete - $row->delete + $result->delete =over @@ -630,7 +631,7 @@ sub delete { =head2 get_column - my $val = $row->get_column($col); + my $val = $result->get_column($col); =over @@ -651,7 +652,7 @@ will be deflated and returned. Note that if you used the C or the C