X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Controller-DBIC-API.git;a=blobdiff_plain;f=lib%2FCatalyst%2FController%2FDBIC%2FAPI.pm;h=229237d28ec7b7a470c5f8cd2be1c31ea8a0e854;hp=0fe7635668de223966f5d04728a4a815ac8fcc8f;hb=2abdb8310c404d431fd1f229cc231237b5b93bb8;hpb=8516bd760abada937d6e36871b0bae0a3b04c78d diff --git a/lib/Catalyst/Controller/DBIC/API.pm b/lib/Catalyst/Controller/DBIC/API.pm index 0fe7635..229237d 100644 --- a/lib/Catalyst/Controller/DBIC/API.pm +++ b/lib/Catalyst/Controller/DBIC/API.pm @@ -374,6 +374,7 @@ sub list =method_protected list_munge_parameters list_munge_parameters is a noop by default. All arguments will be passed through without any manipulation. In order to successfully manipulate the parameters before the search is performed, simply access $c->req->search_parameters|search_attributes (ArrayRef and HashRef respectively), which correspond directly to ->search($parameters, $attributes). Parameter keys will be in already-aliased form. +To store the munged parameters call $c->req->_set_search_parameters($newparams) and $c->req->_set_search_attributes($newattrs). =cut @@ -766,8 +767,22 @@ insert_object_from_params sets the columns for the object, then calls ->insert sub insert_object_from_params { my ($self, $c, $object, $params) = @_; - $object->set_columns($params); + + my %rels; + while (my ($k, $v) = each %{ $params }) { + if (ref $v && !($v == JSON::Any::true || $v == JSON::Any::false)) { + $rels{$k} = $v; + } + else { + $object->set_column($k => $v); + } + } + $object->insert; + + while (my ($k, $v) = each %rels) { + $object->create_related($k, $v); + } } =method_protected delete_objects