Files
吴世元 4e5e0133ea [ISSUE #15718] Escape every LIKE predicate in the embedded role search (#15719)
* [ISSUE #15718] Escape every LIKE predicate in the embedded role search

The embedded role search appended ESCAPE '\' once, after both LIKE predicates
had been built. ESCAPE qualifies only the predicate it immediately follows, so
the clause applied to the role filter alone and the username filter was left
without one. generateLikeArgument had already rewritten _ into \_, so Derby
matched the backslash literally and the query returned no row whenever both
filters were combined and the username contained an underscore.

Append the clause to each LIKE predicate instead, matching how the user and
permission searches in the same module already build theirs.

Add a Derby test that executes the generated SQL with the bound parameters,
since asserting the SQL text alone cannot prove which predicate the clause
qualifies, and document the rule in the default auth plugin spec.

Assisted-by: Claude Code
Signed-off-by: 吴世元 <wushiyuanwork@outlook.com>

* [ISSUE #15718] Escape the auth name searches like the paged searches

findRolesLikeRoleName and findUserLikeUsername bound "%" + value + "%"
directly, while findRolesLike4Page and findUsersLike4Page routed the same
value through generateLikeArgument. An underscore therefore stayed a
wildcard in the name searches backing the console autocompletion and was a
literal character in the paged searches, so one keyword selected different
rows depending on which control the operator used. Searching ro_le matched
both ro_le and roXle in the dropdown and only ro_le in the table.

Route the argument through generateLikeArgument in all four services. The
embedded SQL already declared ESCAPE '\' on these predicates, so it now
qualifies an argument that actually carries the escape; the external SQL
keeps relying on the backslash that MySQL and PostgreSQL default to, exactly
as its own paged search does.

Extend the Derby test to execute the name search against the real database,
since asserting the bound argument alone cannot prove the underscore stops
matching, and state the parity rule in the default auth plugin spec.

Assisted-by: Claude Code
Signed-off-by: 吴世元 <wushiyuanwork@outlook.com>

---------

Signed-off-by: 吴世元 <wushiyuanwork@outlook.com>
2026-08-20 11:29:15 +08:00
..