fastapi-users-db-sqlmodel icon indicating copy to clipboard operation
fastapi-users-db-sqlmodel copied to clipboard

Pydantic V2 Configuration Warning

Open patrickwasp opened this issue 1 year ago • 1 comments

Pydantic V2 Configuration Warning with FastAPI Users + SQLModel

Describe the bug

Pydantic V2 configuration warning appears when using FastAPI Users with SQLModel: UserWarning: Valid config keys have changed in V2: 'orm_mode' has been renamed to 'from_attributes'

To Reproduce

Steps to reproduce the behavior:

  1. Create a FastAPI application using SQLModel and FastAPI Users
  2. Import the fastapi_users_db_sqlmodel module
  3. Run the application
  4. Warning appears in console output from pydantic internal config

Expected behavior

No warnings should appear when using FastAPI Users with SQLModel, as the configuration should be compatible with Pydantic V2.

Configuration

  • Python version: 3.12
  • FastAPI version: latest
  • FastAPI Users version: latest

FastAPI Users configuration

from fastapi_users.db import SQLAlchemyBaseUserTable
from sqlmodel import SQLModel

class User(SQLModel, SQLAlchemyBaseUserTable):
    class Config:
        arbitrary_types_allowed = True

Additional context

  • The warning appears to be related to the interaction between Pydantic V2's configuration changes and SQLModel's internal usage of Pydantic
  • This occurs specifically when importing fastapi_users_db_sqlmodel
  • The warning suggests updating 'orm_mode' to 'from_attributes', but this configuration is likely internal to one of the dependencies
  • Reference: https://github.com/fastapi/sqlmodel/blob/6b562358fc1e857dd1ce4b8b23a9f68c0337430d/sqlmodel/main.py#L680

patrickwasp avatar Nov 14 '24 21:11 patrickwasp

hi @patrickwasp got recently the same issue thats pr that solves the problem -> https://github.com/fastapi-users/fastapi-users-db-sqlmodel/pull/19 (if nothin happen just fork and solve the issue by yourself)

@frankie567 with every newer versions of fastapi/pydantic/sqlmodel, fastapi-users becomes less compatible without continuous development, package ll be useless

also request for review of the "deprecations" prs 🙌

janas-adam avatar Jan 18 '25 12:01 janas-adam

@frankie567 why hasn't the pr: fastapi-users/fastapi-users-db-sqlmodel#19 been merged yet !

bassemkaroui avatar Jun 11 '25 06:06 bassemkaroui