| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package DBICx::TxnInsert; |
|
2
|
4
|
|
|
4
|
|
81261
|
use warnings; |
|
|
4
|
|
|
|
|
23
|
|
|
|
4
|
|
|
|
|
206
|
|
|
3
|
4
|
|
|
4
|
|
22
|
use strict; |
|
|
4
|
|
|
|
|
13
|
|
|
|
4
|
|
|
|
|
193
|
|
|
4
|
4
|
|
|
4
|
|
22
|
use base 'DBIx::Class::Row'; |
|
|
4
|
|
|
|
|
18
|
|
|
|
4
|
|
|
|
|
4902
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 NAME |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
DBICx::TxnInsert - wrap all inserts into transaction |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=cut |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
This component wrap all inserts into transactions. |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
package My::Schema::Entity; |
|
20
|
|
|
|
|
|
|
__PACKAGE__->load_components(qw/DBICx::TxnInsert Core/); |
|
21
|
|
|
|
|
|
|
... |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 WARNING |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
This module uses DBIx::Class internals, may be not compatible with future versions of DBIx::Class. |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
You need to use it only in one case: last_insert_id should be called in same transaction as insert itself. |
|
28
|
|
|
|
|
|
|
For example in case you config is Application(DBIx::Class) <-> pgbouncer <-> postgresql server. |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head1 METHODS |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head2 insert |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
see DBIx::Class::Row::insert |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=cut |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub insert { |
|
39
|
3
|
|
|
3
|
1
|
338147
|
my $self = shift; |
|
40
|
3
|
|
|
|
|
27
|
my $source = $self->result_source; |
|
41
|
3
|
50
|
33
|
|
|
211
|
$source ||= $self->result_source( $self->result_source_instance ) if $self->can('result_source_instance'); |
|
42
|
3
|
50
|
|
|
|
180
|
$self->throw_exception("No result_source set on this object; can't insert") unless $source; |
|
43
|
|
|
|
|
|
|
|
|
44
|
3
|
|
|
|
|
21
|
my $rollback_guard = $source->storage->txn_scope_guard; |
|
45
|
|
|
|
|
|
|
|
|
46
|
3
|
|
|
|
|
9337
|
my $ret = $self->next::method(@_); |
|
47
|
|
|
|
|
|
|
|
|
48
|
3
|
|
|
|
|
41020
|
$rollback_guard->commit; |
|
49
|
|
|
|
|
|
|
|
|
50
|
3
|
|
|
|
|
860
|
return $ret; |
|
51
|
|
|
|
|
|
|
} |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head1 AUTHOR |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
Vladimir Timofeev, C<< >> |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head1 BUGS |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through |
|
60
|
|
|
|
|
|
|
the web interface at L. I will be notified, and then you'll |
|
61
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head1 SUPPORT |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
perldoc DBICx::TxnInsert |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=over 4 |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
L |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
L |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=item * CPAN Ratings |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
L |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=item * Search CPAN |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
L |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=back |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
Copyright 2009 Vladimir Timofeev, all rights reserved. |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
|
95
|
|
|
|
|
|
|
under the same terms as Perl itself. |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=cut |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
1; # End of DBICx::TxnInsert |