Skip to content

OBPIH-6275 Export boolean values as true/false booleans, instead of a…#4881

Merged
awalkowiak merged 2 commits intodevelopfrom
OBPIH-6275
Oct 9, 2024
Merged

OBPIH-6275 Export boolean values as true/false booleans, instead of a…#4881
awalkowiak merged 2 commits intodevelopfrom
OBPIH-6275

Conversation

@kchelstowski
Copy link
Collaborator

…n empty string for false boolean

✨ Description of Change

A concise summary of what is being changed. Please provide enough context for reviewers to be able to understand the change and why it is necessary. If the issue/ticket already provides enough information, you can put "See ticket" as the description.

Link to GitHub issue or Jira ticket:

Description:
Initially I wanted to just parse booleans to string for the product sources export, not to impact the generic export builder, but it turned out, that the validation while importing the template back, would prevent the active field from being imported, as it would be passed as string, not as a boolean.
The change would potentially impact e.g. the Locations export, but I'd say there is nothing wrong with that, as it also fixes the same problem in the locations export, that would be probably addressed in a ticket anyway.


📷 Screenshots & Recordings (optional)

If this PR contains a UI change, consider adding one or more screenshots here or link to a screen recording to help reviewers visualize the change. Otherwise, you can remove this section.

@kchelstowski kchelstowski self-assigned this Oct 8, 2024
@github-actions github-actions bot added the domain: backend Changes or discussions relating to the backend server label Oct 8, 2024
value = element.defaultValue
}
properties[fieldName] = value ?: ""
// We can't just check the truthiness of the actualValue, because the false boolean would be evaluated to an empty string
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"actualValue" -> "value" in these two comments

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I copied it from the other file and forgot to change it

// We can't just check the truthiness of the actualValue, because the false boolean would be evaluated to an empty string
def cellValue = actualValue == null ? "" : actualValue
// POI can't handle objects so we need to convert all objects to strings unless they are numeric or boolean
if (!(cellValue instanceof Number) && !(cellValue instanceof Boolean)) {
Copy link
Member

@ewaterman ewaterman Oct 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we're not passing booleans as strings anymore, what do they appear as in the document?

How does this affect imports? Will existing documents that use the old format still work? If not, this could cause some errors for users who are trying to import old docs. For most cases I imagine this is a non-issue because people do an export (or download template) before an import so will have the latest docs, but I image there are other scenarios where a user might try to use old template because they have it downloaded already.

Copy link
Collaborator Author

@kchelstowski kchelstowski Oct 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can still pass booleans as strings for some imports. This method is used only for exports, it doesn't touch the import, so nothing would be broken in terms of the import.
The only change is that now, if e.g. a location/product source is inactive, it won't be exported as an empty string, but with the actual boolean value:
Screenshot from 2024-10-08 16-35-17
vs
Screenshot from 2024-10-08 16-36-10

This change actually would help users, that they won't eventually have to fill those empty cells with false, as the exported file would already contain the value, that is supposed to be passed during the import.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kchelstowski how will this affect the other Excel documents that are exported and then used for import? Like picklist, product associations, etc? Will these be affected or not at all?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@awalkowiak this would affect e.g. location export, and I mentioned it in the description, but as I said, I believe this could be somewhat expected, as this would fix the same issue in the location export as well (users wouldn't have to fill empty cells with false), as the exported file would be compatible to be imported.
Moreover, in the ticket I had an info bar:

Check Locations export as well, and other exports with active/inactive status

so I believe it would be expected to be done in those as well, but I haven't asked Manon explicitly about that.

TL:DR - I will ask Manon to make sure it's fine to impact/fix this issue in other exports as well and will reach out to you guys.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I confirm that Manon doesn’t have anything against if it impacted other exports, like Locations export.

}
properties[fieldName] = value ?: ""
// We can't just check the truthiness of the value, because the false boolean would be evaluated to an empty string
properties[fieldName] = value == null ? "" : value
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can't we just use elvis operator here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alannadolny no we can't, I explained it in the comment above, that we couldn't just check the truthiness of the value, because the false boolean would be evaluated to an empty string, which we want to avoid.

@awalkowiak awalkowiak merged commit 6b73ce6 into develop Oct 9, 2024
@awalkowiak awalkowiak deleted the OBPIH-6275 branch October 9, 2024 08:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

domain: backend Changes or discussions relating to the backend server

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants