Skip to content

BSL234 — Getting objects nested fields data by dot in database query text

Summary

Getting objects nested fields data by dot in database query text

Identifiers

Field Value
Rule code BSL234
Compatible alias QueryNestedFieldsByDot
Severity WARNING
Enabled by default Yes
Implemented Yes
Tags query, performance

Behavior

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

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

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

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

Diagnostics allows you to control the dereference of reference fields through a dot in the 1C query language. The purpose of this diagnostic is to prevent unnecessary implicit joins between tables. and as a result, improve the performance of executing a database query.

Examples

  1. Base dereference through a dot (in temp. db or in select query) ЗаказКлиентаТовары.Ссылка.Организация КАК Организация
  2. Dereference of fields in table join section ВТ_РасчетыСКлиентами КАК ВТ_РасчетыСКлиентами ЛЕВОЕ СОЕДИНЕНИЕ ВТ_ДанныеЗаказовКлиента КАК ВТ_ДанныеЗаказовКлиента ПО ВТ_РасчетыСКлиентами.АналитикаУчетаПоПартнерам.Партнер = ВТ_ДанныеЗаказовКлиента.Партнер
  3. Dereference of fields in virtual tables РегистрНакопления.РасчетыСКлиентами.Обороты( &НачалоПериода, &КонецПериода, , (АналитикаУчетаПоПартнерам.Партнер) В ...
  4. Dereference in cast function result fields ВЫРАЗИТЬ(ВТ_ПланОтгрузок.ДокументПлан КАК Документ.ЗаказКлиента).Валюта.Наценка
  5. Dereference of fields in WHERE section ГДЕ азКлиентаТовары.Ссылка.Дата МЕЖДУ &НачалоПериода И &КонецПериода

Sources

Source: [Dereference of composite type reference fields in the query language (RU)] (https://its.1c.ru/db/v8std/content/654/hdoc)