Skip to content

BSL236 — Using non-existent metadata in the query

Summary

Using non-existent metadata in the query

Identifiers

Field Value
Rule code BSL236
Compatible alias QueryToMissingMetadata
Severity ERROR
Enabled by default Yes
Implemented Yes
Tags query, correctness

Behavior

  • The public identifier BSL236 and alias QueryToMissingMetadata 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 = ["BSL236"]
ignore = ["QueryToMissingMetadata"]

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: BSL236
  • bsl-disable:
Value = "example";  // bsl-disable: BSL236
  • compatible BSLLS form:
Value = "example";  // BSLLS:QueryToMissingMetadata-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: BSL236
// code without this diagnostic
// noqa-enable: BSL236

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

// BSLLS:QueryToMissingMetadata-off
// code without this diagnostic
// BSLLS:QueryToMissingMetadata-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

Due to frequent changes to the metadata model, queries may appear that refer to renamed or deleted metadata. Also, errors can occur when you manually change queries, without checking with the query designer.

When accessing non-existent metadata in a query, a runtime error will occur.

Examples

Query for an already deleted register:

SELECT
    Table.Field1 AS Field1
FROM
    InformationRegister.InfoRegOld AS Table
Query with a join to the renamed register:
SELECT
    Table.Field1 AS Field1
FROM
     InformationRegister.InfoReg AS Table
     INNER JOIN InformationRegister.InfoRegOld AS FilterTable
     ON FilterTable.Field2 = Table.Field2

Sources