« blib/lib/UR/BoolExpr/Template/PropertyComparison/Matches.pm
↑ Summary
blib/lib/UR/DataSource/RDBMS/Operator/Equals.pm »
| 1 | |||
| 2 | package UR::BoolExpr::Template::PropertyComparison::NotLike; | ||
| 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 | my $escape = '\\'; | ||
| 17 | my $regex = $class-> | ||
| 18 | comparison_value_and_escape_character_to_regex( | ||
| 19 | $comparison_value, | ||
| 20 | $escape | ||
| 21 | ); | ||
| 22 | no warnings 'uninitialized'; | ||
| 23 | foreach my $property_value ( @property_value ) { | ||
| 24 | return '' if ($property_value =~ $regex); | ||
| 25 | } | ||
| 26 | return 1; | ||
| 27 | } | ||
| 28 | |||
| 29 | 1; | ||
| 30 | |||
| 31 | =pod | ||
| 32 | |||
| 33 | =head1 NAME | ||
| 34 | |||
| 35 | UR::BoolExpr::Template::PropertyComparison::NotLike - perform a negated SQL-ish like test | ||
| 36 | |||
| 37 | =head1 DESCRIPTION | ||
| 38 | |||
| 39 | The input test value is assummed to be an SQL 'like' value, where '_' | ||
| 40 | represents a one character wildcard, and '%' means a 0 or more character | ||
| 41 | wildcard. It gets converted to a perl regular expression and used in a | ||
| 42 | negated match against an object's properties | ||
| 43 | |||
| 44 | If the property returns multiple values, this comparison returns false if | ||
| 45 | any of the values matches the pattern | ||
| 46 | |||
| 47 | =cut | ||
| 48 |