NAME
DBIx::Class::SQLA2 - SQL::Abstract v2 support in DBIx::Class
SYNOPSIS
# resultset code
package MyApp::Schema::ResultSet;
__PACKAGE__->load_components('ResultSet::SQLA2Support');
# client code
my $rs = $schema->resultset('Album')->populate([{ name => 'thing' }, { name => 'stuff' } ], -sqla2 => { on_conflict => 0 }})
DESCRIPTION
This is a work in progress for simplifying using SQLA2 with DBIC. This is for using w/ the most recent version of DBIC.
EXPERIMENTAL
Allows you to passthru sqla2 options as an extra arg to populate, as in the SYNOPSIS. In addition, provides some extra methods.
METHODS
- upsert
-
# on conflict, add this name to the existing name $rs->upsert({ name => 'thingy', id => 9001 }, { name => \"name || ' ' || excluded.name" });
The first argument is the same as you would pass to a call to
insert
, except we generate an ON CONFLICT clause which will upsert all non-primary-key values. You can pass a hashref as the second argument to override the default on conflict value. You can pass in anything (literal SQL is quite helpful here) and it will be retrieved by DBIC on the insert using DBIC's return_on_insert functionality. - populate_upsert
-
# on conflict, add this name to the existing name $rs->populate_upsert([{ name => 'thingy', id => 9001 }, { name => 'over 9000', id => 9002 }], { name => \"name || ' ' || excluded.name" });
Same as
upsert
above, just forpopulate
. Dies a horrible death if called in non-void context.