Description
countByQuery is select count(*) from scale_rule <if test="metricName != null"> and metric_name = #{metricName} </if> with no <where> element and no leading WHERE. When metricName is non-null the rendered SQL is select count(*) from scale_rule and metric_name = ? → syntax error. (When null it runs as an unbounded full count.) Additionally selectByQuery uses metric_name LIKE '%...%' while countByQuery uses metric_name = — a count/list predicate mismatch. Currently no caller in ScaleRuleServiceImpl.
Location
shenyu-admin/src/main/resources/mappers/scale-rule-sqlmap.xml:157-162
Impact
Latent broken SQL + count/list divergence; wiring scale-rule pagination would throw on any name filter.
Suggested fix
Wrap in <where> and use LIKE CONCAT('%', #{metricName}, '%') to match selectByQuery.
Related existing
Distinct from N22 (#6691, DataPermission selector/rule count-vs-list) — this is scale_rule, a different mapper and statement, and additionally has the missing-WHERE syntax error which N22 does not.
Description
countByQueryisselect count(*) from scale_rule <if test="metricName != null"> and metric_name = #{metricName} </if>with no<where>element and no leadingWHERE. WhenmetricNameis non-null the rendered SQL isselect count(*) from scale_rule and metric_name = ?→ syntax error. (When null it runs as an unbounded full count.) AdditionallyselectByQueryusesmetric_name LIKE '%...%'whilecountByQueryusesmetric_name =— a count/list predicate mismatch. Currently no caller inScaleRuleServiceImpl.Location
shenyu-admin/src/main/resources/mappers/scale-rule-sqlmap.xml:157-162Impact
Latent broken SQL + count/list divergence; wiring scale-rule pagination would throw on any name filter.
Suggested fix
Wrap in
<where>and useLIKE CONCAT('%', #{metricName}, '%')to matchselectByQuery.Related existing
Distinct from N22 (#6691, DataPermission selector/rule count-vs-list) — this is
scale_rule, a different mapper and statement, and additionally has the missing-WHERE syntax error which N22 does not.