Skip to content

Commit cdba848

Browse files
authored
🔥 Remove old/unused parameter sqlalchemy_safe from jsonable_encoder (#1864)
1 parent 64ca596 commit cdba848

File tree

1 file changed

+2
-14
lines changed

1 file changed

+2
-14
lines changed

‎fastapi/encoders.py

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ def jsonable_encoder(
3232
exclude_defaults: bool = False,
3333
exclude_none: bool = False,
3434
custom_encoder: dict = {},
35-
sqlalchemy_safe: bool = True,
3635
) -> Any:
3736
if include is not None and not isinstance(include, set):
3837
include = set(include)
@@ -57,7 +56,6 @@ def jsonable_encoder(
5756
exclude_none=exclude_none,
5857
exclude_defaults=exclude_defaults,
5958
custom_encoder=encoder,
60-
sqlalchemy_safe=sqlalchemy_safe,
6159
)
6260
if isinstance(obj, Enum):
6361
return obj.value
@@ -68,30 +66,22 @@ def jsonable_encoder(
6866
if isinstance(obj, dict):
6967
encoded_dict = {}
7068
for key, value in obj.items():
71-
if (
72-
(
73-
not sqlalchemy_safe
74-
or (not isinstance(key, str))
75-
or (not key.startswith("_sa"))
76-
)
77-
and (value is not None or not exclude_none)
78-
and ((include and key in include) or not exclude or key not in exclude)
69+
if (value is not None or not exclude_none) and (
70+
(include and key in include) or not exclude or key not in exclude
7971
):
8072
encoded_key = jsonable_encoder(
8173
key,
8274
by_alias=by_alias,
8375
exclude_unset=exclude_unset,
8476
exclude_none=exclude_none,
8577
custom_encoder=custom_encoder,
86-
sqlalchemy_safe=sqlalchemy_safe,
8778
)
8879
encoded_value = jsonable_encoder(
8980
value,
9081
by_alias=by_alias,
9182
exclude_unset=exclude_unset,
9283
exclude_none=exclude_none,
9384
custom_encoder=custom_encoder,
94-
sqlalchemy_safe=sqlalchemy_safe,
9585
)
9686
encoded_dict[encoded_key] = encoded_value
9787
return encoded_dict
@@ -108,7 +98,6 @@ def jsonable_encoder(
10898
exclude_defaults=exclude_defaults,
10999
exclude_none=exclude_none,
110100
custom_encoder=custom_encoder,
111-
sqlalchemy_safe=sqlalchemy_safe,
112101
)
113102
)
114103
return encoded_list
@@ -144,5 +133,4 @@ def jsonable_encoder(
144133
exclude_defaults=exclude_defaults,
145134
exclude_none=exclude_none,
146135
custom_encoder=custom_encoder,
147-
sqlalchemy_safe=sqlalchemy_safe,
148136
)

0 commit comments

Comments
 (0)