Giter Site home page Giter Site logo

Comments (3)

aminalaee avatar aminalaee commented on May 9, 2024

Hey, thanks for reporting this.
Can you provide the traceback of what went wrong?

from sqladmin.

tr11 avatar tr11 commented on May 9, 2024

Basically, the UUID type doesn't implement python_type method defined in the sqla docs.

Here's an example:

from sqlalchemy import Column, String, text
from sqlalchemy.dialects.postgresql import UUID
from .db import Base

class User(Base):
    __tablename__ = "users"

    id = Column(UUID, primary_key=True, server_default=text("public.uuid_generate_v4()"))
    name = Column(String, index=True, nullable=True)

Here's the traceback:

500 Server Error
NotImplementedError:
Traceback
File .venv/lib/python3.10/site-packages/sqlalchemy/sql/type_api.py, line 518, in python_type‒
515.         in practice.
516.
517.         """
518.         raise NotImplementedError()
519.
520.     def with_variant(self, type_, dialect_name):
521.         r"""Produce a new type object that will utilize the given

File .venv/lib/python3.10/site-packages/sqladmin/models.py, line 373, in get_model_by_pk‒
370.         return pagination
371.
372.     async def get_model_by_pk(self, value: Any) -> Any:
373.         stmt = select(self.model).where(self.pk_column == self.pk_column.type.python_type(value))
374.
375.         for _, relation in self._details_relations:
376.             stmt = stmt.options(selectinload(relation.key))

File .venv/lib/python3.10/site-packages/sqladmin/application.py, line 249, in details‒
246.
247.         model_admin = self._find_model_admin(request.path_params["identity"])
248.
249.         model = await model_admin.get_model_by_pk(request.path_params["pk"])
250.         if not model:
251.             raise HTTPException(status_code=404)
252.

File .venv/lib/python3.10/site-packages/starlette/routing.py, line 61, in app‒
58.     async def app(scope: Scope, receive: Receive, send: Send) -> None:
59.         request = Request(scope, receive=receive, send=send)
60.         if is_coroutine:
61.             response = await func(request)
62.         else:
63.             response = await run_in_threadpool(func, request)
64.         await response(scope, receive, send)

File .venv/lib/python3.10/site-packages/starlette/routing.py, line 259, in handle‒
256.                 response = PlainTextResponse("Method Not Allowed", status_code=405)
257.             await response(scope, receive, send)
258.         else:
259.             await self.app(scope, receive, send)
260.
261.     def __eq__(self, other: typing.Any) -> bool:
262.         return (

File .venv/lib/python3.10/site-packages/starlette/routing.py, line 656, in __call__‒
653.             match, child_scope = route.matches(scope)
654.             if match == Match.FULL:
655.                 scope.update(child_scope)
656.                 await route.handle(scope, receive, send)
657.                 return
658.             elif match == Match.PARTIAL and partial is None:
659.                 partial = route

File .venv/lib/python3.10/site-packages/starlette/exceptions.py, line 71, in __call__‒
68.             await send(message)
69.
70.         try:
71.             await self.app(scope, receive, sender)
72.         except Exception as exc:
73.             handler = None
74.

File .venv/lib/python3.10/site-packages/starlette/exceptions.py, line 82, in __call__‒
79.                 handler = self._lookup_exception_handler(exc)
80.
81.             if handler is None:
82.                 raise exc
83.
84.             if response_started:
85.                 msg = "Caught handled exception, but response already started."

File .venv/lib/python3.10/site-packages/starlette/middleware/errors.py, line 159, in __call__‒
156.             await send(message)
157.
158.         try:
159.             await self.app(scope, receive, _send)
160.         except Exception as exc:
161.             if not response_started:
162.                 request = Request(scope)

from sqladmin.

aminalaee avatar aminalaee commented on May 9, 2024

I've tried to get column type with column.type.impl.python_type or column.type.python_type and neither work for UUID. So what you suggested seems reasonable.

from sqladmin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.