Skip to content

Enhance Database Modeling and SQLAlchemy Compatibility #1593

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

cubxxw
Copy link

@cubxxw cubxxw commented Apr 29, 2025

This pull request makes several changes to the backend/app/models.py file to enhance database modeling and improve compatibility with SQLAlchemy. The key updates include adjustments to field definitions, changes to relationships, and the removal of certain constraints.

Changes to field definitions:

  • Updated the email field in UserBase to explicitly use sa_type=String(255) for better SQLAlchemy compatibility.
  • Changed the email field type in UserRegister, UserUpdate, and UserUpdateMe from EmailStr to str for consistency and to avoid type-related issues.

Changes to relationships:

  • Modified the items relationship in the User model to include sa_relationship_kwargs for defining cascading behavior and specifying join conditions.
  • Updated the owner_id field in the Item model to remove the foreign_key constraint while keeping it indexed for performance. Added sa_relationship_kwargs to the owner relationship for explicit join conditions.

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.

1 participant