Skip to content

Add complex_helper support to pg_update_dict/pg_update - #16

Merged
aersam merged 2 commits into
mainfrom
feature/pg-update-dict-complex-helper
Jul 28, 2026
Merged

Add complex_helper support to pg_update_dict/pg_update#16
aersam merged 2 commits into
mainfrom
feature/pg-update-dict-complex-helper

Conversation

@aersam

@aersam aersam commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

pg_update_dict had no way to adapt composite/enum column values the way pg_insert/pg_upsert_dict already do via ComplexHelper, so updating an enum-typed column through it fails with a type mismatch unless the caller hand-writes the UPDATE with an explicit ::type cast. New complex_helper kwarg defaults to None, preserving existing call sites exactly.

pg_update_dict had no way to adapt composite/enum column values the way
pg_insert/pg_upsert_dict already do via ComplexHelper, so updating an
enum-typed column through it fails with a type mismatch unless the caller
hand-writes the UPDATE with an explicit ::type cast. New complex_helper
kwarg defaults to None, preserving existing call sites exactly.
@aersam
aersam force-pushed the feature/pg-update-dict-complex-helper branch from d28ab52 to a97bcf9 Compare July 28, 2026 12:47
test_update_enum_column_requires_complex_helper asserted that updating an
enum column without a ComplexHelper raises -- verified against a real
Postgres that this is false: psycopg already binds a plain str to an
enum-typed UPDATE target fine on its own. Replaced it with a composite-column
test, which is the actual case that fails without complex_helper (psycopg
has no adapter for a plain dict against a composite type). Kept the enum
test as a plain round-trip check instead of a failure assertion.
@aersam
aersam merged commit b0f1ecc into main Jul 28, 2026
2 checks passed
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

Successfully merging this pull request may close these issues.

1 participant