+
+test {
+ 'description:substr:multi::ilike' => q|term1 "term2 and half" 'term3 and stuff'|,
+}, {
+ query => [
+ and => [
+ description => { ilike => '%term1%' },
+ description => { ilike => '%term2 and half%' },
+ description => { ilike => '%term3 and stuff%' },
+ ]
+ ]
+}, ':multi with complex tokenizing';
+
+# test tokenizing for custom filters by monkeypatching a custom filter into Part
+SL::DB::Manager::Part->add_filter_specs(
+ test => sub {
+ my ($key, $value, $prefix, @additional) = @_;
+ return "$prefix$key" => { @additional, $value };
+ }
+);
+
+test {
+ 'part.test.what' => 2,
+}, {
+ query => [
+ 'part.test' => { 'what', 2 },
+ ]
+}, 'additional tokens', class => 'SL::DB::Manager::OrderItem';
+
+test {
+ 'part.test.what:substr::ilike' => 2,
+}, {
+ query => [
+ 'part.test' => { 'what', { ilike => '%2%' } },
+ ]
+}, 'additional tokens + filters + methods', class => 'SL::DB::Manager::OrderItem';
+
+test {
+ 'orderitems.part.test.what:substr::ilike' => 2,
+}, {
+ query => [
+ 'orderitems.part.test' => { 'what', { ilike => '%2%' } },
+ ]
+}, 'relationship + additional tokens + filters + methods', class => 'SL::DB::Manager::Order';
+
+test {
+ part => {
+ 'obsolete::lazy_bool_eq' => '0',
+ },
+}, {
+ query => [
+ or => [
+ 'part.obsolete' => undef,
+ 'part.obsolete' => 0
+ ],
+ ],
+ with_objects => [ 'part' ],
+}, 'complex methods modifying the key';
+
+
+test {
+ 'customer:substr::ilike' => ' Meyer'
+}, {
+ query => [ customer => { ilike => '%Meyer%' } ]
+}, 'auto trim 1';
+
+test {
+ 'customer:head::ilike' => ' Meyer '
+}, {
+ query => [ customer => { ilike => 'Meyer%' } ]
+}, 'auto trim 2';
+
+test {
+ 'customer:tail::ilike' => "\nMeyer\x{a0}"
+}, {
+ query => [ customer => { ilike => '%Meyer' } ]
+}, 'auto trim 2';