lib/UR/BoolExpr/Template/PropertyComparison/Like.pm

filter: Statementstmt 68.1% 15 / 22 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 80.0% 4 / 5 Podpod n/a totaltotal 61.2% 19 / 31 CC 4 SCAR 18.5
CC
4
Cov
58%
_compare
11.8
BEGIN
1.0
BEGIN
1.0
CRAP 6.4
« blib/lib/UR/Context/Process.pm ↑ Summary blib/lib/above.pm »
1  
2 package UR::BoolExpr::Template::PropertyComparison::Like;
3  
4 266 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 266 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 266 ▶use UR;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 265 our $VERSION = "0.47"; # UR $VERSION;
8  
9 265 UR::Object::Type->define(
10 class_name => __PACKAGE__,
11 is => ['UR::BoolExpr::Template::PropertyComparison'],
12 );
13  
14 0 ▶sub _compare {
Subroutine _compare: not called CC=4 SCAR=24.6
15 0 my ($class,$comparison_value,@property_value) = @_;
16 0 ▶ return '' unless defined ($comparison_value); # property like NULL should always be false
Branch: 1 branch
BranchTrueFalseTotal
unless defined $comparison_value 0 0 0
17 0 my $escape = '\\';
18 0 my $regex = $class->
19 comparison_value_and_escape_character_to_regex(
20 $comparison_value,
21 $escape
22 );
23 265 ▶ no warnings 'uninitialized';
Subroutine BEGIN: called CC=1 SCAR=0.0
24 0 foreach my $value ( @property_value ) {
25 0 ▶ return 1 if $value =~ $regex;
Branch: 1 branch
BranchTrueFalseTotal
if $value =~ /$regex/ 0 0 0
26 }
27 0 return '';
28 }
29  
30 265 1;
31  
32 =pod
33  
34 =head1 NAME
35  
36 UR::BoolExpr::Template::PropertyComparison::Like - perform an SQL-ish like test
37  
38 =head1 DESCRIPTION
39  
40 The input test value is assumed to be an SQL 'like' value, where '_'
41 represents a one character wildcard, and '%' means a 0 or more character
42 wildcard. It gets converted to a perl regular expression and used to match
43 against an object's properties.
44  
45 If the property returns multiple values, this comparison returns true if any of the values
46 match.
47  
48  
49 =cut
50  
« blib/lib/UR/Context/Process.pm ↑ Summary blib/lib/above.pm »