ORM-модель Parcel мапится на несуществующую таблицу 'parcels' с устаревшими колонками — мёртвый и вводящий в заблуждение код #1570

Closed
opened 2026-06-16 17:06:26 +00:00 by bot-backend · 0 comments
Collaborator

Severity: low · Категория: schema-mismatch · Файл: backend/app/models/parcel.py:16-29

app/models/parcel.py:16-29 — class Parcel(tablename='parcels') с колонками cadastral_number/vri/area_sqm/address/geometry/enrichment. Таблицы 'parcels' в data/sql/ нет (grep пуст); реальные таблицы — cad_parcels (cad_num, quarter_cad_number, land_record_area, specified_area, geom — data/sql/92_cad_bulk_layers.sql:51) и cad_parcels_geom (data/sql/83_cad_parcels_geom.sql:10), ни одна колонка ORM-модели в них не совпадает. Модель не используется ни в одном ORM-запросе (импорты 'Parcel' в коде указывают на app.services.generative.geometry.Parcel — другой класс). Impact: единственный потребитель — alembic autogenerate (env.py:14), который против реальной БД сгенерирует CREATE TABLE parcels для несуществующей таблицы; любой инженер, направивший эту модель на реальные данные участков, получит OperationalError / несоответствие схемы cad_parcels. Fix: удалить мёртвую модель Parcel (и убрать её импорт из env.py) либо переписать под реальную таблицу cad_parcels с корректными именами колонок и типом geom.

Почему баг: This is the single table alembic autogenerate sees (see env.py finding). Against the real DB it emits CREATE TABLE parcels for a table the system does not use, and any future engineer wiring this model to real parcel data queries a table that does not exist (OperationalError) or gets a schema that does not match cad_parcels. The model is dead, stale, and misleading, and it pollutes drift-detection metadata with a phantom table.

Как чинить: Delete the Parcel model (unused, maps to nothing real), or rewrite it to mirror cad_parcels (tablename='cad_parcels', cad_num PK, geom as Geometry('MULTIPOLYGON', 4326), correct columns). Do not leave a phantom parcels table as the only entry in autogenerate metadata.


deep-audit backend v2 (после PR #1543) · verify+harden, confidence 0.82 · unit B07

**Severity:** low · **Категория:** schema-mismatch · **Файл:** `backend/app/models/parcel.py:16-29` app/models/parcel.py:16-29 — class Parcel(__tablename__='parcels') с колонками cadastral_number/vri/area_sqm/address/geometry/enrichment. Таблицы 'parcels' в data/sql/ нет (grep пуст); реальные таблицы — cad_parcels (cad_num, quarter_cad_number, land_record_area, specified_area, geom — data/sql/92_cad_bulk_layers.sql:51) и cad_parcels_geom (data/sql/83_cad_parcels_geom.sql:10), ни одна колонка ORM-модели в них не совпадает. Модель не используется ни в одном ORM-запросе (импорты 'Parcel' в коде указывают на app.services.generative.geometry.Parcel — другой класс). Impact: единственный потребитель — alembic autogenerate (env.py:14), который против реальной БД сгенерирует CREATE TABLE parcels для несуществующей таблицы; любой инженер, направивший эту модель на реальные данные участков, получит OperationalError / несоответствие схемы cad_parcels. Fix: удалить мёртвую модель Parcel (и убрать её импорт из env.py) либо переписать под реальную таблицу cad_parcels с корректными именами колонок и типом geom. **Почему баг:** This is the single table alembic autogenerate sees (see env.py finding). Against the real DB it emits CREATE TABLE parcels for a table the system does not use, and any future engineer wiring this model to real parcel data queries a table that does not exist (OperationalError) or gets a schema that does not match cad_parcels. The model is dead, stale, and misleading, and it pollutes drift-detection metadata with a phantom table. **Как чинить:** Delete the Parcel model (unused, maps to nothing real), or rewrite it to mirror cad_parcels (__tablename__='cad_parcels', cad_num PK, geom as Geometry('MULTIPOLYGON', 4326), correct columns). Do not leave a phantom `parcels` table as the only entry in autogenerate metadata. --- <sub>deep-audit backend v2 (после PR #1543) · verify+harden, confidence 0.82 · unit B07</sub>
bot-backend added the
week ревью 1
label 2026-06-16 17:06:26 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: lekss361/gendesign#1570
No description provided.