line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package OPTiMaDe::Filter::Property; |
2
|
|
|
|
|
|
|
|
3
|
6
|
|
|
6
|
|
493
|
use strict; |
|
6
|
|
|
|
|
16
|
|
|
6
|
|
|
|
|
207
|
|
4
|
6
|
|
|
6
|
|
31
|
use warnings; |
|
6
|
|
|
|
|
10
|
|
|
6
|
|
|
|
|
478
|
|
5
|
|
|
|
|
|
|
|
6
|
2393
|
|
|
2393
|
|
6288
|
use overload '@{}' => sub { return $_[0]->{name} }, |
7
|
6
|
|
|
6
|
|
7429
|
'""' => sub { return $_[0]->to_filter }; |
|
6
|
|
|
473
|
|
6431
|
|
|
6
|
|
|
|
|
70
|
|
|
473
|
|
|
|
|
55280
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $identifier_re = q/([a-z_][a-z0-9_]*)/; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub new { |
12
|
222
|
|
|
222
|
0
|
482
|
my $class = shift; |
13
|
222
|
|
|
|
|
434
|
return bless { name => [ map { lc } @_ ] }, $class; |
|
223
|
|
|
|
|
1095
|
|
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub to_filter |
17
|
|
|
|
|
|
|
{ |
18
|
687
|
|
|
687
|
0
|
1153
|
my( $self ) = @_; |
19
|
687
|
|
|
|
|
1452
|
$self->validate; |
20
|
686
|
|
|
|
|
1456
|
return join '.', @$self; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub to_SQL |
24
|
|
|
|
|
|
|
{ |
25
|
82
|
|
|
82
|
0
|
157
|
my( $self, $options ) = @_; |
26
|
82
|
|
|
|
|
222
|
$self->validate; |
27
|
|
|
|
|
|
|
|
28
|
82
|
50
|
|
|
|
190
|
$options = {} unless $options; |
29
|
|
|
|
|
|
|
my( $delim, $placeholder ) = ( |
30
|
|
|
|
|
|
|
$options->{delim}, |
31
|
|
|
|
|
|
|
$options->{placeholder}, |
32
|
82
|
|
|
|
|
177
|
); |
33
|
82
|
50
|
|
|
|
173
|
$delim = "'" unless $delim; |
34
|
|
|
|
|
|
|
|
35
|
82
|
50
|
|
|
|
137
|
if( @$self > 2 ) { |
36
|
0
|
|
|
|
|
0
|
die 'no SQL representation for properties of more than two ' . |
37
|
|
|
|
|
|
|
"identifiers\n"; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
82
|
|
|
|
|
149
|
my $sql = join '.', map { "${delim}$_${delim}" } @$self; |
|
83
|
|
|
|
|
332
|
|
41
|
|
|
|
|
|
|
|
42
|
82
|
50
|
|
|
|
187
|
if( wantarray ) { |
43
|
82
|
|
|
|
|
274
|
return ( $sql, [] ); |
44
|
|
|
|
|
|
|
} else { |
45
|
0
|
|
|
|
|
0
|
return $sql; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub modify |
50
|
|
|
|
|
|
|
{ |
51
|
3
|
|
|
3
|
0
|
5
|
my $self = shift; |
52
|
3
|
|
|
|
|
4
|
my $code = shift; |
53
|
|
|
|
|
|
|
|
54
|
3
|
|
|
|
|
23
|
return $code->( $self, @_ ); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub validate |
58
|
|
|
|
|
|
|
{ |
59
|
769
|
|
|
769
|
0
|
1095
|
my $self = shift; |
60
|
769
|
50
|
|
|
|
1359
|
die 'name undefined for OPTiMaDe::Filter::Property' if !@$self; |
61
|
|
|
|
|
|
|
|
62
|
769
|
|
|
|
|
1295
|
for my $name (@$self) { |
63
|
779
|
100
|
|
|
|
4309
|
next if $name =~ /^$identifier_re$/; |
64
|
1
|
|
|
|
|
12
|
die "name '$name' does not match identifier syntax: $identifier_re"; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
1; |