Skip to content

fix(litestar DTO): Ensure ORM descriptor fields are not evaluated during DTO creation#664

Merged
provinzkraut merged 1 commit intomainfrom
fix-descriptor-handling
Feb 1, 2026
Merged

fix(litestar DTO): Ensure ORM descriptor fields are not evaluated during DTO creation#664
provinzkraut merged 1 commit intomainfrom
fix-descriptor-handling

Conversation

@provinzkraut
Copy link
Copy Markdown
Member

Fix #646.

When processing property fields on SQLAlchemy models for the Litestar DTO, there was sometimes unexpected behaviour caused by the inspecting code evaluating the ORM descriptors such as hybrid_property.

Fix this behaviour by skipping all known ORM fields (as reported by the ORM), and not using inspect.getmembers.

@sonarqubecloud
Copy link
Copy Markdown

@codecov-commenter
Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.66667% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 79.08%. Comparing base (ebc1c2a) to head (598922b).

Files with missing lines Patch % Lines
advanced_alchemy/extensions/litestar/dto.py 91.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #664      +/-   ##
==========================================
+ Coverage   79.06%   79.08%   +0.01%     
==========================================
  Files          99       99              
  Lines        7915     7922       +7     
  Branches     1073     1073              
==========================================
+ Hits         6258     6265       +7     
- Misses       1315     1316       +1     
+ Partials      342      341       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Member

@cofin cofin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - much more elegant than what I tried to do.

@provinzkraut provinzkraut merged commit 658d417 into main Feb 1, 2026
21 checks passed
@provinzkraut provinzkraut deleted the fix-descriptor-handling branch February 1, 2026 15:04
@cofin cofin linked an issue Feb 22, 2026 that may be closed by this pull request
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Problem with certain hybrid properties starting with 1.8.0 Bug: Cannot use sqlalchemy hybrid_methods with Litestar

3 participants