Skip to content

Commit

Permalink
Add back ensure_list
Browse files Browse the repository at this point in the history
  • Loading branch information
sloria committed Jan 11, 2025
1 parent 4a24499 commit 43efd4c
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/marshmallow_sqlalchemy/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,7 @@ def __init__(
if columns is None:
columns = column
super().__init__(**kwargs)
cols = columns or []
self.columns = cast(
list[str],
cols if is_iterable_but_not_string(cols) else [cast(str, cols)],
)
self.columns = cast(list[str], ensure_list(columns or []))

@property
def model(self) -> type[DeclarativeMeta] | None:
Expand Down Expand Up @@ -165,3 +161,7 @@ def get_primary_keys(model: type[DeclarativeMeta]) -> list[MapperProperty]:
"""
mapper = model.__mapper__ # type: ignore[attr-defined]
return [mapper.get_property_by_column(column) for column in mapper.primary_key]


def ensure_list(value):
return value if is_iterable_but_not_string(value) else [value]

0 comments on commit 43efd4c

Please sign in to comment.