Skip to content

Conversation

@AntonDeMeester
Copy link
Contributor

Upgrades to Pydantic 2, using the new pydantic models. This also includes support for Pydantic v1.

@github-actions
Copy link
Contributor

📝 Docs preview for commit e2d4d1f at: https://003fc64c.sqlmodel.pages.dev

@stintel
Copy link

stintel commented Nov 30, 2023

Hey, we're currently investigating to use SQLModel in Willow Application Server. As we're doing some latency sensitive stuff in there, we'd really like to use Pydantic 2, so I gave this PR a try. Creating a table and inserting records seems to work, but when trying a select we hit the following exception:

[2023-11-30T17:41:05] ERROR:    Exception in ASGI application
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/uvicorn/protocols/http/httptools_impl.py", line 426, in run_asgi
    result = await app(  # type: ignore[func-returns-value]
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/uvicorn/middleware/proxy_headers.py", line 84, in __call__
    return await self.app(scope, receive, send)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/fastapi/applications.py", line 292, in __call__
    await super().__call__(scope, receive, send)
  File "/usr/local/lib/python3.12/site-packages/starlette/applications.py", line 122, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/usr/local/lib/python3.12/site-packages/starlette/middleware/errors.py", line 184, in __call__
    raise exc
  File "/usr/local/lib/python3.12/site-packages/starlette/middleware/errors.py", line 162, in __call__
    await self.app(scope, receive, _send)
  File "/usr/local/lib/python3.12/site-packages/starlette/middleware/cors.py", line 83, in __call__
    await self.app(scope, receive, send)
  File "/usr/local/lib/python3.12/site-packages/starlette/middleware/exceptions.py", line 79, in __call__
    raise exc
  File "/usr/local/lib/python3.12/site-packages/starlette/middleware/exceptions.py", line 68, in __call__
    await self.app(scope, receive, sender)
  File "/usr/local/lib/python3.12/site-packages/fastapi/middleware/asyncexitstack.py", line 20, in __call__
    raise e
  File "/usr/local/lib/python3.12/site-packages/fastapi/middleware/asyncexitstack.py", line 17, in __call__
    await self.app(scope, receive, send)
  File "/usr/local/lib/python3.12/site-packages/starlette/routing.py", line 718, in __call__
    await route.handle(scope, receive, send)
  File "/usr/local/lib/python3.12/site-packages/starlette/routing.py", line 276, in handle
    await self.app(scope, receive, send)
  File "/usr/local/lib/python3.12/site-packages/starlette/routing.py", line 66, in app
    response = await func(request)
               ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/fastapi/routing.py", line 273, in app
    raw_response = await run_endpoint_function(
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/fastapi/routing.py", line 190, in run_endpoint_function
    return await dependant.call(**values)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/app/routers/config.py", line 57, in api_get_config
    config = get_config_from_db_pydantic()
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/app/internal/was.py", line 117, in get_config_from_db_pydantic
    statement = select(ConfigTablePydantic).where(ConfigTablePydantic.config_type == "config")
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/sqlmodel/sql/expression.py", line 429, in select
    return SelectOfScalar._create(*entities, **kw)  # type: ignore
           ^^^^^^^^^^^^^^^^^^^^^^
AttributeError: type object 'SelectOfScalar' has no attribute '_create'. Did you mean: '_correlate'?

I understand this is a WIP, so my question is: do you have a rough estimate of when this would be ready?

@AntonDeMeester
Copy link
Contributor Author

See proper PR from @tiangolo here

@tiangolo
Copy link
Member

tiangolo commented Dec 4, 2023

Thank you for your work @AntonDeMeester! I included your commits in #722 (you can see your badge now says "Contributor" 😎 ), I changed a few extra things, more details in that PR. It's now released and available as SQLModel 0.0.14! 🎉 🌮

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.

5 participants