Properties Handling When Exporting
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 2/5
- Estimated time
- Under an hour
- Newbie friendliness
- 85/100
Research direction
The issue targets sql_export/wizard/wizard_file.py; first adjust the property validation block at lines 31-37 to skip the required value check for boolean-type properties, then update the property value lookup at lines 44-51 to add a handler for selection-type properties that maps the stored option hash to the human-readable label from the prop["selection"] tuple list. Verify the fix by running the existing export wizard tests for boolean and selection property types.
Written by the indexing model from the issue text.
Description
Some types of Properties are not handled properly when Exporting from the Execute Query wizard
Module
sql__export
Describe the bug
When executing an SQL Export with Propeties of types checkbox and selection there are some problems, from user point of view:
- Boolean (checkbox) Property cannot be set to False because it will fail the bad_props check where the value of te Property is required to evaluate to True (see below).
- Selection value is returned as the hash of the option, which is not intuitive as the hash is not user-defined and not visible during the Property setting. User only see the "label" of the option. The hash values can only be ontained through debugging, or by exporting the values of various Options - not convenient.
To Reproduce
Versions Affected: 16.0, 17.0, 18.0 (basically all versions to date since the inclusion of Properties field):
Steps to reproduce the behavior:
- Create a working SQL Export with Properties of those types, (e.g. Boolean Test with Checkbox type, and Selecttion Test with Selection type - create a few Options for the Selection) exporting the value of the Properties into the result. (e.g. SELECT %(Selection Test)s::TEXT AS "Selection", %(Boolean Test)s::TEXT AS "Boolean")
- Validate the SQL Export by clicking the "Validate SQL Expression" button, then execute it by clicking the "Execute Query" button that appears.
- To test the Boolean type Property case, uncheck the Boolean Test Property, then click the "Export" button in the wizard. It will prompt an error "Please enter a values for the following properties : Boolean Test"
- Close the error message by clicking the "OK" button, then check the Boolean Test Property
- To test the Selection type Property case, select an Option in the Selection Test Property, and, keeping any checkboxes checked, click the "Export" button. Save and open the resulting file. Observe the value of the Selection column, it is a unknown hash value instead of the selected Option's label.
Expected behavior
At step 3, the wizard should not prompt error as it may be intentional.
At step 5, the value of Selection should be something that the user can recognise, which, presently, only the Option's label is available.
Additional context
The issue with the Selection value also happened for Properties of type Tags. However instead of unknown hash, the value is set to the Tag Label's value in lower case. So, it is still manageable though may not be intuitive.
Here is the code that blocks non-True values:
https://github.com/OCA/reporting-engine/blob/52e03a544f25b789ed34a0e842603ce0b80f36aa/sql_export/wizard/wizard_file.py#L31-L37
Line 31 shold exclude evaluation if prop["type"] == "boolean".
Here is the code that returns the value of Properties:
https://github.com/OCA/reporting-engine/blob/52e03a544f25b789ed34a0e842603ce0b80f36aa/sql_export/wizard/wizard_file.py#L44-L51
There should be a special handler for prop["type"] == "selection", something in the line of:
elif prop["type"] == "selection":
_sel_dict = dict(prop["selection"])
variable_dict[prop["string"]] = _sel_dict.get(prop["value"], "")
similar treatment may be preferred if prop["type"] == "tags", getting the list of Tags from tags key of the prop variable. However it cannot use the same approach as selection as the value of the tags key is a list of tuple of 3 values, not 2 values such as Selection.
Some aspects of this issue has been discussed in https://github.com/OCA/reporting-engine/issues/1085
- Dominant language
- HTML
- Stars
- 435
- Forks
- 929
- Avg merge
- 6d 18h
- Merged PRs (30d)
- 2
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from OCA/reporting-engine
-
Migration to version 20.0Possibly taken A pull request linked to this issue is open or already merged. Openhelp wanted no stale work in progress
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
OCA/reporting-engine#1206 · 3 comments ·
Maintainers usually reply within 1 day
-
bug
Difficulty 1/5 Under an hour Newbie friendliness 85/100
OCA/reporting-engine#1187 · 5 comments ·
Maintainers usually reply within 1 day
-
enhancement
Difficulty 3/5 1-2 days Newbie friendliness 65/100
OCA/reporting-engine#1197 · 2 comments ·
Maintainers usually reply within 1 day
-
bug stale
Difficulty 4/5 3-5 days Newbie friendliness 22/100
OCA/reporting-engine#1136 · 2 comments ·
Maintainers usually reply within 1 day
-
Migration to version 19.0Possibly taken A pull request linked to this issue is open or already merged. Openhelp wanted no stale work in progress
Difficulty 4/5 3-5 days Newbie friendliness 30/100
OCA/reporting-engine#1070 · 12 comments ·
Maintainers usually reply within 1 day
All issues in OCA/reporting-engine
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
milind-soni/OpenMausBot#5829 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
finos/fluxnova-bpm-platform#387 ·
Maintainers usually reply within 4 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
OHDSI/Data2Evidence#3693 ·
Maintainers usually reply within 3 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Project-N-E-K-O/N.E.K.O#3725 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
kubernetes-sigs/headlamp#8408 ·
Maintainers usually reply within 1 day