Skip to content
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

Python type for JSON columns is dict #212

Open
amacfie opened this issue May 12, 2022 · 2 comments
Open

Python type for JSON columns is dict #212

amacfie opened this issue May 12, 2022 · 2 comments

Comments

@amacfie
Copy link

amacfie commented May 12, 2022

In a PostgreSQL database, a JSON or JSONB column is converted to (with the dataclass output)
col_name: Optional[dict] = field(default=None, metadata={'sa': Column(JSONB)}). Usually JSON/JSONB fields correspond to Python types that you get from json.dumps: nested list, dict, int, etc., not just dict.

@agronholm
Copy link
Owner

Sqlacodegen just uses whatever Python type comes from column.type.python_type. You should probably report this as a bug against SQLAlchemy itself. I recently got a similar issue fixed with a PR that implements python_type for the UUID column type.

@CaselIT
Copy link

CaselIT commented Aug 4, 2023

for reference this was reported here sqlalchemy/sqlalchemy#10177

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

No branches or pull requests

3 participants