Browse Source

🔨 moved encode_dict check allowed_keys to be first

pull/13982/head
Ben Brady 2 weeks ago
parent
commit
9266fe3357
  1. 5
      fastapi/encoders.py

5
fastapi/encoders.py

@ -369,12 +369,13 @@ def encode_dict(
allowed_keys -= set(exclude) allowed_keys -= set(exclude)
for key, value in obj.items(): for key, value in obj.items():
if sqlalchemy_safe and isinstance(key, str) and key.startswith("_sa"): if key not in allowed_keys:
continue continue
if value is None and exclude_none: if value is None and exclude_none:
continue continue
if key not in allowed_keys: if sqlalchemy_safe and isinstance(key, str) and key.startswith("_sa"):
continue continue
encoded_key = encode_value( encoded_key = encode_value(
key, key,
by_alias=by_alias, by_alias=by_alias,

Loading…
Cancel
Save