Skip to content

BSL269 — Using 'LIKE' in query

Summary

Using 'LIKE' in query

Identifiers

Field Value
Rule code BSL269
Compatible alias UsingLikeInQuery
Severity INFORMATION
Enabled by default Yes
Implemented Yes
Tags query, performance

Behavior

  • The public identifier BSL269 and alias UsingLikeInQuery are stable.
  • The rule reports the cases documented on this page.
  • Suppressions and project configuration are applied before publication.
  • The rule requires neither an external analyzer nor network access.

Configuration and suppression

BSL### is the primary stable identifier. The compatible alias is accepted in select, ignore, and compatible block suppression comments.

[tool.onec-hbk-bsl]
select = ["BSL269"]
ignore = ["UsingLikeInQuery"]

All three suppression families support both a current line and a range. When an opening comment follows code, it affects only that line. Use any one form:

  • noqa:
Value = "example";  // noqa: BSL269
  • bsl-disable:
Value = "example";  // bsl-disable: BSL269
  • compatible BSLLS form:
Value = "example";  // BSLLS:UsingLikeInQuery-off

When the same opening comment is on a line by itself, it starts a range. Close it with the matching marker from the same family:

// noqa: BSL269
// code without this diagnostic
// noqa-enable: BSL269

// bsl-disable: BSL269
// code without this diagnostic
// bsl-enable: BSL269

// BSLLS:UsingLikeInQuery-off
// code without this diagnostic
// BSLLS:UsingLikeInQuery-on

To disable the rule until the end of the file, omit the closing noqa-enable, bsl-enable, or BSLLS:…-on marker.

Opening and closing markers must belong to the same family.

Description

In most algorithms, it is possible to do without using the operator LIKE, and in the rest, you must use it carefully. The result in some situations can be very different from the expected, for example, when using different DBMS.

Examples

Correct

Property LIKE "123%"

Incorrect:

Property LIKE Table.Template

Sources