You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The bug is reproducible against the latest release or master.
There are no similar issues or pull requests to fix it yet.
Describe the bug
If we use postgresql JSON field in mode like data: Mapped[dict[any, any]] = mapped_column(JSON)
it works file on frontend site - shows default as '{}' for json field and correctly checks json format, but on create i got error: "descriptor 'encode' for 'str' objects doesn't apply to a 'dict' object"
it happens because raw dict object later pass to asyncpg as is - but it should be passed not like {"key": "value"} but in single quaters: {"key": "value"}
Steps to reproduce the bug
Try to use JSON field with asyncpg and create record.
Expected behavior
0.20.1
Actual behavior
No response
Debugging material
No response
Environment
alembic 1.14.0 A database migration tool for SQLAlchemy.
annotated-types 0.7.0 Reusable constraint types to use with typing.Annotated
anyio 4.6.2.post1 High level compatibility layer for multiple asynchronous event loop implementations
asyncpg 0.29.0 An asyncio PostgreSQL driver
fastapi 0.112.4 FastAPI framework, high performance, easy to learn, fast to code, ready for production
fastapi-cli 0.0.5 Run and manage FastAPI apps from the command line with FastAPI CLI. 🚀
greenlet 3.1.1 Lightweight in-process concurrent programming
httpcore 1.0.6 A minimal low-level HTTP client.
httptools 0.6.4 A collection of framework independent HTTP protocol utils.
httpx 0.27.2 The next generation HTTP client.
identify 2.6.2 File identification library for Python
idna 3.10 Internationalized Domain Names in Applications (IDNA)
iniconfig 2.0.0 brain-dead simple config-ini parsing
itsdangerous 2.2.0 Safely pass data to untrusted environments and back.
jinja2 3.1.4 A very fast and expressive template engine.
mako 1.3.6 A super-fast templating language that borrows the best ideas from the existing templating languages.
markdown 3.7 Python implementation of John Gruber's Markdown.
markdown-code-blocks 3.1.0 Generate html from markdown with code-block highlighting
markdown-it-py 3.0.0 Python port of markdown-it. Markdown parsing, done right!
markupsafe 3.0.2 Safely add untrusted strings to HTML/XML markup.
mdurl 0.1.2 Markdown URL utilities
mistune 2.0.5 A sane Markdown parser with useful plugins and renderers
mypy 1.13.0 Optional static typing for Python
mypy-extensions 1.0.0 Type system extensions for programs checked with the mypy type checker.
nodeenv 1.9.1 Node.js virtual environment builder
oauthlib 3.2.2 A generic, spec-compliant, thorough implementation of the OAuth request-signing logic
orjson 3.10.11 Fast, correct Python JSON library supporting dataclasses, datetimes, and numpy
packaging 24.2 Core utilities for Python packages
pathspec 0.12.1 Utility library for gitignore style pattern matching of file paths.
platformdirs 4.3.6 A small Python package for determining appropriate platform-specific dirs, e.g. a user data dir.
pluggy 1.5.0 plugin and hook calling mechanisms for python
pre-commit 3.8.0 A framework for managing and maintaining multi-language pre-commit hooks.
psycopg2-binary 2.9.10 psycopg2 - Python-PostgreSQL Database Adapter
pycparser 2.22 C parser in Python
pydantic 2.9.2 Data validation using Python type hints
pydantic-core 2.23.4 Core functionality for Pydantic validation and serialization
pydantic-settings 2.6.1 Settings management using Pydantic
pygments 2.18.0 Pygments is a syntax highlighting package written in Python.
pytest 8.3.3 pytest: simple powerful testing with Python
pytest-asyncio 0.24.0 Pytest support for asyncio
python-dotenv 1.0.1 Read key-value pairs from a .env file and set them as environment variables
python-multipart 0.0.17 A streaming multipart parser for Python
pyyaml 6.0.2 YAML parser and emitter for Python
requests 2.32.3 Python HTTP for Humans.
requests-oauthlib 2.0.0 OAuthlib authentication support for Requests.
rich 13.9.4 Render rich text, tables, progress bars, syntax highlighting, markdown and more to the terminal
ruff 0.5.7 An extremely fast Python linter and code formatter, written in Rust.
sentry-sdk 2.18.0 Python client for Sentry (https://sentry.io)
shellingham 1.5.4 Tool to Detect Surrounding Shell
sniffio 1.3.1 Sniff out which async library your code is running under
sqladmin 0.20.1 SQLAlchemy admin for FastAPI and Starlette
sqlalchemy 2.0.36 Database Abstraction Library
starlette 0.38.6 The little ASGI library that shines.
structlog 24.4.0 Structured Logging for Python
structlog-sentry 2.2.1 Sentry integration for structlog
testcontainers 4.8.2 Python library for throwaway instances of anything that can run in a Docker container
typer 0.13.0 Typer, build great CLIs. Easy to code. Based on Python type hints.
typing-extensions 4.12.2 Backported and Experimental Type Hints for Python 3.8+
urllib3 2.2.3 HTTP library with thread-safe connection pooling, file post, and more.
uvicorn 0.30.6 The lightning-fast ASGI server.
uvloop 0.21.0 Fast implementation of asyncio event loop on top of libuv
virtualenv 20.27.1 Virtual Python Environment builder
watchfiles 0.24.0 Simple, modern and high performance file watching and code reload in python.
websockets 14.1 An implementation of the WebSocket Protocol (RFC 6455 & 7692)
werkzeug 3.1.3 The comprehensive WSGI web application library.
wrapt 1.16.0 Module for decorators, wrappers and monkey patching.
wtforms 3.1.2 Form validation and rendering for Python web development.
Additional context
No response
The text was updated successfully, but these errors were encountered:
Checklist
master
.Describe the bug
If we use postgresql JSON field in mode like
data: Mapped[dict[any, any]] = mapped_column(JSON)
it works file on frontend site - shows default as '{}' for json field and correctly checks json format, but on create i got error: "descriptor 'encode' for 'str' objects doesn't apply to a 'dict' object"
it happens because raw dict object later pass to asyncpg as is - but it should be passed not like {"key": "value"} but in single quaters:
{"key": "value"}
Steps to reproduce the bug
Try to use JSON field with asyncpg and create record.
Expected behavior
0.20.1
Actual behavior
No response
Debugging material
No response
Environment
alembic 1.14.0 A database migration tool for SQLAlchemy.
annotated-types 0.7.0 Reusable constraint types to use with typing.Annotated
anyio 4.6.2.post1 High level compatibility layer for multiple asynchronous event loop implementations
asyncpg 0.29.0 An asyncio PostgreSQL driver
fastapi 0.112.4 FastAPI framework, high performance, easy to learn, fast to code, ready for production
fastapi-cli 0.0.5 Run and manage FastAPI apps from the command line with FastAPI CLI. 🚀
greenlet 3.1.1 Lightweight in-process concurrent programming
httpcore 1.0.6 A minimal low-level HTTP client.
httptools 0.6.4 A collection of framework independent HTTP protocol utils.
httpx 0.27.2 The next generation HTTP client.
identify 2.6.2 File identification library for Python
idna 3.10 Internationalized Domain Names in Applications (IDNA)
iniconfig 2.0.0 brain-dead simple config-ini parsing
itsdangerous 2.2.0 Safely pass data to untrusted environments and back.
jinja2 3.1.4 A very fast and expressive template engine.
mako 1.3.6 A super-fast templating language that borrows the best ideas from the existing templating languages.
markdown 3.7 Python implementation of John Gruber's Markdown.
markdown-code-blocks 3.1.0 Generate html from markdown with code-block highlighting
markdown-it-py 3.0.0 Python port of markdown-it. Markdown parsing, done right!
markupsafe 3.0.2 Safely add untrusted strings to HTML/XML markup.
mdurl 0.1.2 Markdown URL utilities
mistune 2.0.5 A sane Markdown parser with useful plugins and renderers
mypy 1.13.0 Optional static typing for Python
mypy-extensions 1.0.0 Type system extensions for programs checked with the mypy type checker.
nodeenv 1.9.1 Node.js virtual environment builder
oauthlib 3.2.2 A generic, spec-compliant, thorough implementation of the OAuth request-signing logic
orjson 3.10.11 Fast, correct Python JSON library supporting dataclasses, datetimes, and numpy
packaging 24.2 Core utilities for Python packages
pathspec 0.12.1 Utility library for gitignore style pattern matching of file paths.
platformdirs 4.3.6 A small Python package for determining appropriate platform-specific dirs, e.g. a
user data dir
.pluggy 1.5.0 plugin and hook calling mechanisms for python
pre-commit 3.8.0 A framework for managing and maintaining multi-language pre-commit hooks.
psycopg2-binary 2.9.10 psycopg2 - Python-PostgreSQL Database Adapter
pycparser 2.22 C parser in Python
pydantic 2.9.2 Data validation using Python type hints
pydantic-core 2.23.4 Core functionality for Pydantic validation and serialization
pydantic-settings 2.6.1 Settings management using Pydantic
pygments 2.18.0 Pygments is a syntax highlighting package written in Python.
pytest 8.3.3 pytest: simple powerful testing with Python
pytest-asyncio 0.24.0 Pytest support for asyncio
python-dotenv 1.0.1 Read key-value pairs from a .env file and set them as environment variables
python-multipart 0.0.17 A streaming multipart parser for Python
pyyaml 6.0.2 YAML parser and emitter for Python
requests 2.32.3 Python HTTP for Humans.
requests-oauthlib 2.0.0 OAuthlib authentication support for Requests.
rich 13.9.4 Render rich text, tables, progress bars, syntax highlighting, markdown and more to the terminal
ruff 0.5.7 An extremely fast Python linter and code formatter, written in Rust.
sentry-sdk 2.18.0 Python client for Sentry (https://sentry.io)
shellingham 1.5.4 Tool to Detect Surrounding Shell
sniffio 1.3.1 Sniff out which async library your code is running under
sqladmin 0.20.1 SQLAlchemy admin for FastAPI and Starlette
sqlalchemy 2.0.36 Database Abstraction Library
starlette 0.38.6 The little ASGI library that shines.
structlog 24.4.0 Structured Logging for Python
structlog-sentry 2.2.1 Sentry integration for structlog
testcontainers 4.8.2 Python library for throwaway instances of anything that can run in a Docker container
typer 0.13.0 Typer, build great CLIs. Easy to code. Based on Python type hints.
typing-extensions 4.12.2 Backported and Experimental Type Hints for Python 3.8+
urllib3 2.2.3 HTTP library with thread-safe connection pooling, file post, and more.
uvicorn 0.30.6 The lightning-fast ASGI server.
uvloop 0.21.0 Fast implementation of asyncio event loop on top of libuv
virtualenv 20.27.1 Virtual Python Environment builder
watchfiles 0.24.0 Simple, modern and high performance file watching and code reload in python.
websockets 14.1 An implementation of the WebSocket Protocol (RFC 6455 & 7692)
werkzeug 3.1.3 The comprehensive WSGI web application library.
wrapt 1.16.0 Module for decorators, wrappers and monkey patching.
wtforms 3.1.2 Form validation and rendering for Python web development.
Additional context
No response
The text was updated successfully, but these errors were encountered: