my @tokens = split /\./, $key;
my $curr_class = $class->object_class;
- # find first token which is not a relationship
+ # our key will consist of dot-delimited tokens
+ # like this: order.part.unit.name
+ # each of these tokens except the last one is one of:
+ # - a relationship in the parent object
+ # - a custom filter
+ #
+ # the last token must be
+ # - a custom filter
+ # - a column in the parent object
+ #
+ # find first token which is not a relationship,
+ # so we can pass the rest on
my $i = 0;
while ($i < $#tokens) {
eval {
- $curr_class = $curr_class->meta->relationship($tokens[$_])->class;
+ $curr_class = $curr_class->meta->relationship($tokens[$i])->class;
++$i;
} or do {
last;
use lib 't';
-use Test::More tests => 36;
+use Test::More tests => 37;
use Test::Deep;
use Data::Dumper;
'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';