my $guard = $schema->txn_scope_guard;
my $rs = $schema->resultset('TestTable')->search({
status => 'available'
},
{
rows => 1,
'for' => 'update'
});
my $id_before_update = $rs->first->id;
my $updated = $rs->update({
status => 'reserved'
});
$guard->commit;
my $id_at_end = $rs->first->id;
print "id before update: $id_before_update\nid at end: $id_at_end\n";
####
+----+-----------+
| id | status |
+----+-----------+
| 1 | available |
| 2 | available |
| 3 | available |
+----+-----------+
####
+----+-----------+
| id | status |
+----+-----------+
| 1 | reserved |
| 2 | available |
| 3 | available |
+----+-----------+
####
__PACKAGE__->table("test_table");
__PACKAGE__->add_columns(
"id",
{ data_type => "bigint", is_nullable => 0 },
"status",
{ data_type => "varchar", is_nullable => 1, size => 255 },
);
####
id before update: 1
id at end: 2