Repository navigation
fix!: default use_orjson_serialization to False, so the [settings] quick start runs - #66
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
…ick start runs BREAKING CHANGE: BasePostgresConfig.use_orjson_serialization now defaults to False, matching AsyncSessionManager and the builder. A service that has orjson installed, kept the default, and writes values only orjson serializes (datetime, UUID, Decimal, non-str keys) into JSON columns now gets StatementError (TypeError: Object of type datetime is not JSON serializable). Set use_orjson_serialization=True to keep the old behaviour.
AlexeyShalaev
force-pushed
the
fix/59-orjson-default
branch
from
October 16, 2026 19:54
a9f2226 to
a851fb9
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #59.
Problem
BasePostgresConfig.use_orjson_serializationdefaulted toTrue, but orjson ships only with the[orjson]/[all]extras. Following the quick start (pip install "sqlalchemy-foundation-kit[settings]", a config with defaults,create_async_session_manager(config)) failed withImportError: orjson is requiredbefore anything connected. So did the dishka and dependency-injector integrations. Every other entry point (AsyncSessionManager, the builder) already defaults toFalse.Change
use_orjson_serializationdefaults toFalse. The field docstring says why it's opt-in.json.dumpsrejects),docs/agents.md(theBasePostgresConfigrow, the extras rule, a "Fixed since" row), the README and the protocol docstring example.Considered and rejected
Nonemeaning "orjson if importable". It would keep current installs unchanged, but how JSON columns serialize would then depend on whether another package happened to pull orjson in. That's the coupling the issue argued against.[settings]. Same coupling, tied to the configuration extra instead.Breaking change
fix!:, with aBREAKING CHANGE:footer. Who notices: services that have orjson installed, kept the default, and write values into JSON columns that only orjson serializes. Measured on PostgreSQL 17 throughAsyncSessionManager:Migration:
use_orjson_serialization=True(or the matching env var) keeps the old behaviour. Services whose JSON columns hold plain JSON types see no difference. With#56also!, the next release is a minor (0.5.0) underbump-minor-pre-major. No org repo pins this package.Evidence
New tests against the old
contrib/settings/postgres.py(swapped in fromorigin/master): the quick-start test fails with the reporter's exactImportError: orjson is required ... pip install 'sqlalchemy-foundation-kit[orjson]'. The companion test, where opting in without the extra still raises naming the extra, passes on both.The reporter's script after the fix, with
orjsonblocked from importing:Gate:
make checkclean;make test628 passed.