-
-
Notifications
You must be signed in to change notification settings - Fork 783
Added typecheck to sqlalchemy JSON #931
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
Changes from 3 commits
19859fa
87401ca
44d0d79
e0df9d8
367b317
65b3c1d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -51,7 +51,7 @@ | |
| from sqlalchemy.orm.decl_api import DeclarativeMeta | ||
| from sqlalchemy.orm.instrumentation import is_instrumented | ||
| from sqlalchemy.sql.schema import MetaData | ||
| from sqlalchemy.sql.sqltypes import LargeBinary, Time | ||
| from sqlalchemy.sql.sqltypes import JSON, LargeBinary, Time | ||
| from typing_extensions import Literal, deprecated, get_origin | ||
|
|
||
| from ._compat import ( # type: ignore[attr-defined] | ||
|
|
@@ -612,6 +612,8 @@ def get_sqlalchemy_type(field: Any) -> Any: | |
| return AutoString | ||
| if issubclass(type_, uuid.UUID): | ||
| return GUID | ||
| if issubclass(type_, JSON): | ||
| return JSON | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't you want Also it is probably not clear if JSON or JSONB is the desired type. Maybe better to document the workaround in the docs
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't it be if issubclass(type_, (Sequence, Mapping, Json)):
return JSON |
||
| raise ValueError(f"{type_} has no matching SQLAlchemy type") | ||
|
|
||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This type was not imported, is better to return sqlalchemy UUID type. That's why test are failing