Aniki

 view release on metacpan or  search on metacpan

t/07_insert_on_duplicate.t  view on Meta::CPAN

    });
    is db->select(author => {}, {})->count, 1, 'created.';
    is db->select(author => { name => 'PAPIX' }, { limit => 1 })->first->message, 'hoge';

    db->insert_on_duplicate(author => {
        name => 'PAPIX',
        message => 'fuga',
    }, {
        message => sql_raw('VALUES(message)'),
    });
    is db->select(author => {}, {})->count, 1, 'updated.';
    is db->select(author => { name => 'PAPIX' }, { limit => 1 })->first->message, 'fuga';
};

done_testing();

t/09_update.t  view on Meta::CPAN

use lib File::Spec->catfile('t', 'lib');
use t::Util;

run_on_database {
    db->insert(author => { name => 'MOZNION' });
    db->update(author => { name => 'MOZNION2' }, { name => 'MOZNION' });

    my $rows = db->select(author => {});
    isa_ok $rows, 'Aniki::Result::Collection';
    is $rows->count, 1;
    is $rows->first->name, 'MOZNION2', 'updated';

    my $row = $rows->first;
    my $cnt = db->update($row => { name => 'MOZNION' });
    is $row->name, 'MOZNION2', 'old value';
    is $cnt, 1, 'a row is changed';

    my $new_row = $row->refetch;
    isnt $new_row, $row;
    is $new_row->name, 'MOZNION', 'new value';



( run in 0.267 second using v1.01-cache-2.11-cpan-05444aca049 )