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
{{ message }}
Repository navigation
bug: get-by-id field raises KeyError when id_field_name differs from the primary key attribute #413
A single-type root field built by strawchemy.field() exposes its primary key argument under id_field_name (config.default_id_field_name, or the field's own id_field_name), but the repository looks the value up under the primary key attribute name.
src/strawchemy/schema/field.py (auto_arguments): for a single primary key, the argument is StrawberryArgument(self.id_field_name, ...).
src/strawchemy/repository/sqlalchemy/_async.py (get_one/by-id lookup) and its _sync.py counterpart: kwargs.pop(field_def.name), where field_def.name is the mapper's primary key attribute.
When the two names differ, the lookup raises KeyError.
{ fruit(pk: 1) { name } } fails with KeyError: 'id'.
tests/unit/schemas/custom_id_field_name.py only snapshots the schema, so no test executes this path. Composite primary keys are unaffected: their arguments use the attribute names.
changed the title [-]bug: get-by-id field raises KeyError when id_field_name differs from the primary key attribute[/-][+]bug: `get-by-id` field raises KeyError when `id_field_name` differs from the primary key attribute[/+]on Oct 8, 2026
changed the title [-]bug: `get-by-id` field raises KeyError when `id_field_name` differs from the primary key attribute[/-][+]bug: `get-by-id` field raises `KeyError` when `id_field_name` differs from the primary key attribute[/+]on Oct 8, 2026
Activity
[-]bug: get-by-id field raises KeyError when id_field_name differs from the primary key attribute[/-][+]bug: `get-by-id` field raises KeyError when `id_field_name` differs from the primary key attribute[/+][-]bug: `get-by-id` field raises KeyError when `id_field_name` differs from the primary key attribute[/-][+]bug: `get-by-id` field raises `KeyError` when `id_field_name` differs from the primary key attribute[/+]test(#413): cover composite primary key get-by-id
fix(#413): skip id argument rename when user arguments omit it
fix(#413): rename id argument to the primary key's aliased name
fix(#413): map custom id field name to primary key in get-by-id (#414)