ModeShape/modeshape — pull request #1226 by rhauch (2014-08-29 19:04:12+00:00)
Title: MODE-2286 Corrects the processing of LIKE criteria with paths and SNS indexes

It does it with 2 changes:

1. The engine now internally alters the LIKE expression in a path comparison to include a same-name-sibling index for all literal segments of the path. For example, the path `/a/b/c_/d[%]` is converted to `/a[1]/b[1]/c_[1]/d[%]`, while `/a/%/d[%]` is converted to `/a[1]/%/d[%]`. Obviously this does not affect segments that end in a wildcard or that already have a SNS index (literal or wildcard).
2. When extracting from each row the left-hand values for the LIKE comparison, same-name-sibling indexes are added to all segments.

These changes replace a slightly different technique that did not do #1 but for #2 extracted the idiomatic path (with SNS indexes only where required) and a second value with SNS indexes for all segments. This worked when the LIKE expression specified SNS indexes (wildcard or literals) for all segments, or when the LIKE expression had no SNS indexes at all. But this would not work when the LIKE expression contained some segments with and others without SNS indexes (e.g., `/a/b/c[%]`).

Several new tests validate the behavior, and no regressions were found.