App-AutoCRUD
view release on metacpan or search on metacpan
Revision history for Plack-App-AutoCRUD
0.15 25.11.2023
- sort paths in alphabetic order so that they are always displayed in the same order
- fixed inaccuracies in pod doc for App::AutoCRUD::ConfigDomain
0.14 03.02.2021
- pod documentation updated
- fixed failing pod test
- prevent warnings 'uninitialized' in XML view
0.13 08.06.2016
- Added a readonly mode
0.12 29.01.2016
- RT#111511 : Missing last line in Excel view.
0.11 06.04.2015
lib/App/AutoCRUD.pm view on Meta::CPAN
The form shows current values on the right, and has input fields
on the left. Only fields with some user input will be sent for update
to the database.
=head2 Multiple-records update
This form is reached from the L</List page>, when several records
were checked, or when updating the whole result set.
Input fields on the left correspond to the SQL "C<SET>" clause,
i.e. they specify values that will be updated within I<several records>
simultaneously.
Input fields on the right, labelled "where/and", specify some criteria
for the SQL "C<WHERE>" clause.
Needless to say, this is quite a powerful operation which if misused
could easily corrupt your data.
=head2 Delete
lib/App/AutoCRUD/Controller/Table.pm view on Meta::CPAN
# build filtering criteria
my $where = $req_data->{where} or die "update without any '-where' clause";
my $criteria = $datasource->query_parser->parse($where);
$criteria and keys %$criteria or die "update without any '-where' criteria";
# perform the update
my $db_table = $datasource->schema->db_table($table);
my $n_updates = $db_table->update(-set => $to_set, -where => $criteria);
# redirect to a list to display the results
my $message = ($n_updates == 1) ? "1 record was updated"
: "$n_updates records were updated";
# TODO: $message could repeat the $to_set pairs
my $query_string = $self->_query_string(%$where, -message => $message);
$self->redirect("list?$query_string");
}
sub _display_update_form {
my ($self, $table) = @_;
$self->_check_canmodify;
t/00_autocrud.t view on Meta::CPAN
# TODO : test list outputs as xlsx,
# test an update with special and accented characters
my $new_title = q{il était une "bergère"};
utf8::upgrade($new_title);
$res = $cb->(POST "/Chinook/table/Album/update",
{'where.AlbumId' => 1, 'set.Title' => $new_title});
$res = $cb->(GET "/Chinook/table/Album/id/1.json");
my $data = $json_obj->decode($res->content);
is($data->{row}{Title}, $new_title, "updated title");
# update without a -where clause
$res = $cb->(POST "/Chinook/table/Album/update", {'set.Title' => 'foobar'});
is $res->code, 500;
like $res->content, qr(without any '-where'), "update without -where";
# update with an empty -where clause
$res = $cb->(POST "/Chinook/table/Album/update", {'set.Title' => 'foobar',
'where.AlbumId' => ""});
is $res->code, 500;
( run in 0.299 second using v1.01-cache-2.11-cpan-05444aca049 )