| 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
| |||||||||||
| 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
| |||||||||||
| 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 | |||||||||||