line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Search::Query::Field::SQL; |
2
|
2
|
|
|
2
|
|
10
|
use Moo; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
11
|
|
3
|
|
|
|
|
|
|
extends 'Search::Query::Field'; |
4
|
|
|
|
|
|
|
|
5
|
2
|
|
|
2
|
|
638
|
use namespace::autoclean; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
21
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
has 'type' => ( is => 'rw' ); |
8
|
|
|
|
|
|
|
has 'fuzzy_op' => ( is => 'rw' ); |
9
|
|
|
|
|
|
|
has 'fuzzy_not_op' => ( is => 'rw' ); |
10
|
|
|
|
|
|
|
has 'is_int' => ( is => 'rw' ); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = '0.305'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 NAME |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
Search::Query::Field::SQL - query field representing a database column |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 SYNOPSIS |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
my $field = Search::Query::Field::SQL->new( |
21
|
|
|
|
|
|
|
name => 'foo', |
22
|
|
|
|
|
|
|
alias_for => [qw( bar bing )], |
23
|
|
|
|
|
|
|
); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 DESCRIPTION |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
Search::Query::Field::SQL implements field |
28
|
|
|
|
|
|
|
validation and aliasing in SQL search queries. |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head1 METHODS |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
This class is a subclass of Search::Query::Field. Only new or overridden |
33
|
|
|
|
|
|
|
methods are documented here. |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head2 BUILD |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
Available params are also standard attribute accessor methods. |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=over |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=item type |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
The column type. |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=item fuzzy_op |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=item fuzzy_not_op |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=item is_int |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
Set if C matches m/int|float|bool|time|date/. |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=back |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=cut |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub BUILD { |
58
|
17
|
|
|
17
|
1
|
3232
|
my $self = shift; |
59
|
|
|
|
|
|
|
|
60
|
17
|
|
100
|
|
|
91
|
$self->{type} ||= 'char'; |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
# numeric types |
63
|
17
|
100
|
|
|
|
95
|
if ( $self->{type} =~ m/int|float|bool|time|date/ ) { |
64
|
2
|
|
50
|
|
|
18
|
$self->{fuzzy_op} ||= '>='; |
65
|
2
|
|
50
|
|
|
12
|
$self->{fuzzy_not_op} ||= '! >='; |
66
|
2
|
|
|
|
|
54
|
$self->{is_int} = 1; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
# text types |
70
|
|
|
|
|
|
|
else { |
71
|
15
|
|
50
|
|
|
70
|
$self->{fuzzy_op} ||= 'ILIKE'; |
72
|
15
|
|
50
|
|
|
65
|
$self->{fuzzy_not_op} ||= 'NOT ILIKE'; |
73
|
15
|
|
|
|
|
379
|
$self->{is_int} = 0; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
1; |