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

filter: Statementstmt 0.0% 0 / 22 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 5 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 32 SCAR 24.8
CC
3
Cov
0%
_compare
12.0
BEGIN
2.0
BEGIN
2.0
CRAP 12.0
1  
2 package UR::BoolExpr::Template::PropertyComparison::Like;
3  
4 use strict;
5 use warnings;
6 use UR;
7 our $VERSION = "0.46"; # UR $VERSION;
8  
9 UR::Object::Type->define(
10 class_name => __PACKAGE__,
11 is => ['UR::BoolExpr::Template::PropertyComparison'],
12 );
13  
14 sub _compare {
15 my ($class,$comparison_value,@property_value) = @_;
16 return '' unless defined ($comparison_value); # property like NULL should always be false
17 my $escape = '\\';
18 my $regex = $class->
19 comparison_value_and_escape_character_to_regex(
20 $comparison_value,
21 $escape
22 );
23 no warnings 'uninitialized';
24 foreach my $value ( @property_value ) {
25 return 1 if $value =~ $regex;
26 }
27 return '';
28 }
29  
30 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 assummed 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