line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catalyst::Plugin::ErrorCatcher::Plugin::CleanUp::Pg::UniqueConstraintViolation; |
2
|
|
|
|
|
|
|
$Catalyst::Plugin::ErrorCatcher::Plugin::CleanUp::Pg::UniqueConstraintViolation::VERSION = '0.0.8.18'; |
3
|
|
|
|
|
|
|
{ |
4
|
|
|
|
|
|
|
$Catalyst::Plugin::ErrorCatcher::Plugin::CleanUp::Pg::UniqueConstraintViolation::DIST = 'Catalyst-Plugin-ErrorCatcher'; |
5
|
|
|
|
|
|
|
} |
6
|
9
|
|
|
9
|
|
8237
|
use strict; |
|
9
|
|
|
|
|
21
|
|
|
9
|
|
|
|
|
382
|
|
7
|
9
|
|
|
9
|
|
49
|
use warnings; |
|
9
|
|
|
|
|
17
|
|
|
9
|
|
|
|
|
1459
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub tidy_message { |
10
|
28
|
|
|
28
|
1
|
62
|
my $plugin = shift; |
11
|
28
|
|
|
|
|
47
|
my $errstr_ref = shift; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# update or delete on table "foo" violates foreign key constraint |
14
|
|
|
|
|
|
|
# "foobar_fkey" on table "baz" |
15
|
28
|
|
|
|
|
51
|
${$errstr_ref} =~ s{ |
|
28
|
|
|
|
|
80
|
|
16
|
|
|
|
|
|
|
\A |
17
|
|
|
|
|
|
|
.+? |
18
|
|
|
|
|
|
|
DBI \s Exception: |
19
|
|
|
|
|
|
|
.+? |
20
|
|
|
|
|
|
|
ERROR:\s+ |
21
|
|
|
|
|
|
|
duplicate \s+ key \s+ value \s+ |
22
|
|
|
|
|
|
|
violates \s unique \s constraint \s |
23
|
|
|
|
|
|
|
"(.+?)" \s |
24
|
|
|
|
|
|
|
.+? |
25
|
|
|
|
|
|
|
Key \s+ \( |
26
|
|
|
|
|
|
|
(.+?) |
27
|
|
|
|
|
|
|
\) |
28
|
|
|
|
|
|
|
\= \( |
29
|
|
|
|
|
|
|
(.+?) |
30
|
|
|
|
|
|
|
\) |
31
|
|
|
|
|
|
|
\s+ already \s+ exists |
32
|
|
|
|
|
|
|
.+ |
33
|
|
|
|
|
|
|
$ |
34
|
|
|
|
|
|
|
}{Unique constraint violation: $2 -> $3 [$1]}xmsg; |
35
|
|
|
|
|
|
|
|
36
|
28
|
|
|
|
|
80
|
$errstr_ref; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
1; |
40
|
|
|
|
|
|
|
# ABSTRACT: cleanup foreign key violation messages from Pg |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
__END__ |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=pod |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=encoding UTF-8 |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head1 NAME |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
Catalyst::Plugin::ErrorCatcher::Plugin::CleanUp::Pg::UniqueConstraintViolation - cleanup foreign key violation messages from Pg |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head1 VERSION |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
version 0.0.8.18 |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head2 tidy_message($self, $stringref) |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
Tidy up Postgres messages where the error is related to a I<duplicate key with a unique constraint>. |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head1 AUTHOR |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
Chisel <chisel@chizography.net> |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
This software is copyright (c) 2015 by Chisel Wright. |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
69
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=cut |