Skip to content

fix(types): обратное преобразование данных формы сохраняет колонки - #4405

Merged
nixel2007 merged 1 commit into
developfrom
fix/form-attribute-to-value-table-columns
Aug 4, 2026
Merged

fix(types): обратное преобразование данных формы сохраняет колонки#4405
nixel2007 merged 1 commit into
developfrom
fix/form-attribute-to-value-table-columns

Conversation

@sfaqer

@sfaqer sfaqer commented Aug 4, 2026

Copy link
Copy Markdown
Member

Проблема

РеквизитФормыВЗначение("Таблица") отдавал объявленный тип реквизита голым — просто
ТаблицаЗначений. Колонки такого реквизита объявлены в самой форме (блок <Columns>)
и до сих пор попадали только на форменную сторону, в строку ДанныеФормыКоллекция.
На сервере получалась таблица без единой колонки: ни обхода с полями строки, ни
Колонки, ни ВыгрузитьКолонку.

Решение

Колонки кладутся в объявленный тип полями строки — тем же представлением, в котором
их видит таблица значений, собранная в коде (Новый ТаблицаЗначений + Колонки.Добавить).
Это представление уже читают обход коллекции, Колонки, Выгрузить и ВыгрузитьКолонку,
поэтому чинить каждого потребителя отдельно не понадобилось. Дерево значений закрывается
тем же кодом — отличается только обход, через Строки.

Тем же путём закрыты два соседних случая, где дефект тот же:

  • явный второй параметр: РеквизитФормыВЗначение("Таблица", Тип("ТаблицаЗначений"))
    брал названный тип голым и уточнения терял. Теперь набор сужается до названного типа,
    а уточнения остаются. Если названный тип другой — поведение прежнее;
  • ДанныеФормыВЗначение(Данные, Тип("ТаблицаЗначений")): объявления реквизита тут нет
    вовсе, поэтому колонки берутся у самих преобразуемых данных
    (TableCollectionInference.columnsOf читает и накопленные поля, и члены
    зарегистрированного типа строки). Таблица и дерево — оба.

Расчёт колонок для ДанныеФормыВЗначение идёт только когда преобразуют именно в таблицу
или дерево значений: иначе на каждом вызове зря выводился бы тип первого аргумента.

Проверка

Тесты в FormModuleInferenceTest — на реальной фикстуре конфигурации
(initServerContext(PATH_TO_METADATA)), а не на одиночном inline-модуле: проверяются сам
набор типов, обход с обращением к колонке, та же таблица через переменную, вариант с явным
типом, дерево через Строки и оба варианта ДанныеФормыВЗначение. В фикстуру формы
добавлен реквизит-дерево ДеревоПодбора — проверять дерево раньше было не на чем.

Полный check зелёный: 666 классов, 4142 теста, 0 падений.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Improved type inference for form table and tree data conversions.
    • Preserved declared columns when working with form attributes and converted form data.
    • Added more accurate row-field and column access inference, including iteration scenarios.
  • Bug Fixes

    • Improved narrowing of inferred types when an explicit target type is provided.

`РеквизитФормыВЗначение("Таблица")` отдавал объявленный тип реквизита голым,
хотя колонки таблицы (дерева) значений объявлены в самой форме (`<Columns>`):
на сервер приезжала таблица без единой колонки.

Колонки кладутся в объявленный тип полями строки — тем же представлением,
в котором их видит таблица, собранная в коде. Его уже читают обход коллекции,
`Колонки`, `Выгрузить` и `ВыгрузитьКолонку`, поэтому чинить каждого
потребителя отдельно не понадобилось. Дерево значений — тот же код,
обход через `Строки`.

Тем же путём закрыты два соседних случая:

- явный второй параметр (`Тип("ТаблицаЗначений")`) больше не отменяет
  уточнения — набор сужается до названного типа;
- у `ДанныеФормыВЗначение` объявления нет вовсе, поэтому колонки берутся
  у самих преобразуемых данных.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 2c41dd46-feef-455a-9360-b902f0fb0c2c

📥 Commits

Reviewing files that changed from the base of the PR and between 9ace646 and af7a2fc.

⛔ Files ignored due to path filters (1)
  • src/test/resources/metadata/designer/Documents/Документ1/Forms/ФормаДокумента/Ext/Form.xml is excluded by !src/test/resources/**
📒 Files selected for processing (7)
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/types/CLAUDE.md
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/types/inferencer/ExpressionTypeInferencer.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/types/inferencer/FormExpressionInference.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/types/inferencer/TableCollectionInference.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/types/registry/FormAttributeTypeIndex.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/types/registry/FormDataTypesRegistrar.java
  • src/test/java/com/github/_1c_syntax/bsl/languageserver/types/FormModuleInferenceTest.java

📝 Walkthrough

Walkthrough

Form type registration now preserves declared table and tree columns. Conversion inference derives columns from form data and narrows results to explicit types. Table collection inference constructs typed row collections, with tests covering tables, trees, iteration, and column access.

Changes

Form collection inference

Layer / File(s) Summary
Form-declared collection columns
src/main/java/com/github/_1c_syntax/bsl/languageserver/types/registry/FormDataTypesRegistrar.java, src/main/java/com/github/_1c_syntax/bsl/languageserver/types/registry/FormAttributeTypeIndex.java
Form table and tree attributes now use row types with fields for declared columns. The declaredType documentation describes this behavior.
Typed table and tree results
src/main/java/com/github/_1c_syntax/bsl/languageserver/types/inferencer/TableCollectionInference.java
Table collection inference maps collection types to row types and builds typed table or tree results from row fields.
Form conversion inference and validation
src/main/java/com/github/_1c_syntax/bsl/languageserver/types/inferencer/FormExpressionInference.java, src/main/java/com/github/_1c_syntax/bsl/languageserver/types/inferencer/ExpressionTypeInferencer.java, src/test/java/com/github/_1c_syntax/bsl/languageserver/types/FormModuleInferenceTest.java, src/main/java/com/github/_1c_syntax/bsl/languageserver/types/CLAUDE.md
Form conversion methods recursively infer source expressions, preserve columns, and narrow results to explicit types. Tests cover table and tree conversion, row iteration, and column access. Documentation records the column inference rules.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant ExpressionTypeInferencer
  participant FormExpressionInference
  participant TableCollectionInference
  ExpressionTypeInferencer->>FormExpressionInference: convertedValueType(..., inferInternal)
  FormExpressionInference->>ExpressionTypeInferencer: infer the first conversion argument
  FormExpressionInference->>TableCollectionInference: columnsOf(source type)
  TableCollectionInference-->>FormExpressionInference: source columns
  FormExpressionInference-->>ExpressionTypeInferencer: narrowed table or tree type
Loading

Possibly related PRs

Suggested reviewers: nixel2007

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 45.45% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed Заголовок точно описывает основное изменение: сохранение колонок при обратном преобразовании данных формы.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/form-attribute-to-value-table-columns

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@sonarqubecloud

sonarqubecloud Bot commented Aug 4, 2026

Copy link
Copy Markdown

@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Test Results

 3 996 files   3 996 suites   51m 27s ⏱️
 4 142 tests  4 071 ✅  71 💤 0 ❌
24 852 runs  24 422 ✅ 430 💤 0 ❌

Results for commit af7a2fc.

♻️ This comment has been updated with latest results.

@nixel2007

Copy link
Copy Markdown
Member

javadoc упал?

@sfaqer

sfaqer commented Aug 4, 2026

Copy link
Copy Markdown
Member Author

javadoc упал?

Угу, сокет таймаут

@nixel2007
nixel2007 merged commit a86d262 into develop Aug 4, 2026
44 of 48 checks passed
@nixel2007
nixel2007 deleted the fix/form-attribute-to-value-table-columns branch August 4, 2026 17:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants