Skip to content

Conversation

@nkrishnaswami
Copy link

@nkrishnaswami nkrishnaswami commented Feb 6, 2025

To add support for SQLAlchemy mapped collections, I'd like to add a case for dict origins to the Pydantic v2 get_relationship_to implementation. This PR does so, with a test case using a dictionary with collection class attribute_keyed_dict.

@svlandeg svlandeg changed the title Minimal support for SQLAlchemy keyed dict models ✨ Support SQLAlchemy keyed dict models Feb 20, 2025
@svlandeg svlandeg added the feature New feature or request label Feb 20, 2025
@nkrishnaswami
Copy link
Author

Thanks, @svlandeg!

@dcode
Copy link

dcode commented Feb 26, 2025

Any update on this? This is a great feature add that I need. For now, I'm setting the requirement to use git at this PR.

@nkrishnaswami
Copy link
Author

@svlandeg what is the next step in the process? How do I get this to be reviewed? (Thanks!)

@svlandeg
Copy link
Member

Hi @nkrishnaswami! It's in our review queue, so not much to be done by you at this point in time. We'll get back to you once we've had time to go through this in details 🙏

Copy link

@saky-semicolon saky-semicolon left a comment

Choose a reason for hiding this comment

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

Good addition — the change in _compat.py improves handling of dict annotations, and the new test (test_attribute_keyed_dict.py) clearly validates the functionality with attribute_keyed_dict.

Copy link
Member

@YuriiMotov YuriiMotov left a comment

Choose a reason for hiding this comment

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

Looks good!

We should probably re-export sqlalchemy.orm.collections

@nkrishnaswami nkrishnaswami force-pushed the allow-dict-relationship branch from c7c1402 to a801312 Compare November 3, 2025 23:28
Copy link
Member

@YuriiMotov YuriiMotov left a comment

Choose a reason for hiding this comment

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

@nkrishnaswami, thank you!

Could you please address my review comments?

nkrishnaswami and others added 5 commits November 4, 2025 19:35
Co-authored-by: Motov Yurii <109919500+YuriiMotov@users.noreply.github.com>
Co-authored-by: Motov Yurii <109919500+YuriiMotov@users.noreply.github.com>
@nkrishnaswami nkrishnaswami changed the title ✨ Support SQLAlchemy keyed dict models ✨ Support SQLAlchemy keyed dict models with Pydantic v2 Nov 5, 2025
Copy link
Member

@YuriiMotov YuriiMotov left a comment

Choose a reason for hiding this comment

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

LGTM!

@nkrishnaswami, thank you!

@nkrishnaswami
Copy link
Author

YW, and thanks for reviewing it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants