-
Notifications
You must be signed in to change notification settings - Fork 297
fix(pretty_export): stringify related objects when joining list values #1112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
2fc8040
9a3e5a6
d4b0691
5586c9f
16f3fc3
ed1f827
01a93b6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,7 +26,7 @@ async def _base_export_cell( | |
| """ | ||
| if name in model_view._relation_names: | ||
| if isinstance(value, list): | ||
| cell_value = ",".join(formatted_value) | ||
| cell_value = ",".join(str(item) for item in formatted_value) | ||
| else: | ||
| cell_value = formatted_value | ||
This comment was marked as resolved.
Sorry, something went wrong.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Keyed collections ( Two runs of the same export over the same rows: Which is the opposite of the comment three lines up — sets became reproducible in 9a3e5a6 had this right via |
||
| else: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -125,6 +125,32 @@ class UserAdmin(ModelView, model=User): | |
| assert values[1] == "John Doe" | ||
| assert values[2] == "TRUE" | ||
|
|
||
| async def test_get_export_row_values_with_relationship(self): | ||
| class UserAdmin(ModelView, model=User): | ||
| column_list = ["id", "name", "addresses"] | ||
| session_maker = session_maker | ||
| is_async = False | ||
|
|
||
| with session_maker() as session: | ||
| user = User(id=1, name="John Doe", email="john@example.com") | ||
| session.add(user) | ||
| session.add(Address(id=1, street="Main St", user_id=1)) | ||
| session.add(Address(id=2, street="Second St", user_id=1)) | ||
| session.commit() | ||
| user = session.get(User, 1) | ||
|
|
||
| model_view = UserAdmin() | ||
| column_names = ["id", "name", "addresses"] | ||
|
|
||
| values = await PrettyExport._get_export_row_values( | ||
| model_view, user, column_names | ||
| ) | ||
|
|
||
| assert len(values) == 3 | ||
| assert values[0] == 1 | ||
| assert values[1] == "John Doe" | ||
| assert values[2] == ",".join(str(address) for address in user.addresses) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add |
||
|
|
||
| async def test_get_export_row_values_with_none_values(self): | ||
| class UserAdmin(ModelView, model=User): | ||
| column_list = ["id", "name", "email"] | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.