line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DBIx::Class::Row::SQLA2Support; |
2
|
4
|
|
|
4
|
|
382081
|
use strict; |
|
4
|
|
|
|
|
12
|
|
|
4
|
|
|
|
|
121
|
|
3
|
4
|
|
|
4
|
|
22
|
use warnings; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
115
|
|
4
|
4
|
|
|
4
|
|
24
|
use parent 'DBIx::Class::Row'; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
28
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
sub new { |
7
|
3
|
|
|
3
|
1
|
37579
|
my ($class, $attrs) = @_; |
8
|
3
|
|
|
|
|
12
|
my $on_conflict = delete $attrs->{-on_conflict}; |
9
|
3
|
100
|
|
|
|
15
|
my $to_upsert = 1 if delete $attrs->{-upsert}; |
10
|
3
|
|
|
|
|
16
|
my $new = $class->next::method($attrs); |
11
|
3
|
100
|
|
|
|
420
|
$new->{_sqla2_attrs} = { on_conflict => $on_conflict } if defined $on_conflict; |
12
|
3
|
100
|
|
|
|
20
|
if ($to_upsert) { |
13
|
1
|
|
|
|
|
6
|
$to_upsert = {%$attrs}; |
14
|
1
|
|
|
|
|
8
|
my @pks = $new->result_source->primary_columns; |
15
|
1
|
|
|
|
|
14
|
delete @$to_upsert{@pks}; |
16
|
|
|
|
|
|
|
$new->{_sqla2_attrs} |
17
|
|
|
|
|
|
|
= { |
18
|
1
|
|
|
|
|
14
|
on_conflict => { -target => \@pks, -set => { map +($_ => { -ident => "excluded.$_" }), keys %$to_upsert } } }; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
3
|
|
|
|
|
12
|
return $new; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub insert { |
25
|
3
|
|
|
3
|
1
|
46
|
my ($self, @args) = @_; |
26
|
3
|
|
|
|
|
9
|
my $extras = delete $self->{_sqla2_attrs}; |
27
|
|
|
|
|
|
|
# this should allow relations to fail if they don't have a on_conflict defined |
28
|
3
|
|
|
|
|
12
|
local $self->result_source->storage->sql_maker->{_sqla2_insert_attrs} = $extras; |
29
|
3
|
|
|
|
|
342
|
$self->next::method(@args); |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
1 |