Skip to content
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

the method select of ODataQuery classes should handle iterable parameters #71

Open
amosang opened this issue Oct 24, 2019 · 5 comments
Open
Labels
enhancement New feature or request

Comments

@amosang
Copy link

amosang commented Oct 24, 2019

The generated URL for $select is faulty for a list of properties, and only gives the last property specified. Please see attached Word document for details.
Problem with generated $select HTTP parameter.docx

@filak-sap
Copy link
Contributor

It should be easy to fix but I want to refactor the code to avoid duplication.
Until we fix this, could you pass str instead of list, please?

.select(','.join(['Bukrs', 'Recntype', 'Recntxt'])

PS: Would it be possible to stop communicating via Word and screenshots? I do not have MS Office and screenshots do not allow searching and copying. GitHub allows you to format issues and include pictures (I don't ask for them, I just state it is possible) - https://help.github.com/en/github/writing-on-github/basic-writing-and-formatting-syntax

@filak-sap filak-sap added the enhancement New feature or request label Oct 24, 2019
@filak-sap
Copy link
Contributor

Developer notes:

     def select(self, select):
         """Sets the selection clauses."""
-        self._select = select
+        if isinstance(select, str):
+            self._select = select
+        elif isinstance(select, (list, tuple, set)):
+            self._select = ','.join(select)
+

but we have 2 selects:

  • class QueryRequest
  • class EntityGetRequest

@filak-sap
Copy link
Contributor

Event smarter solution would be:

-    def select(self, select):
+    def select(self, *select):
         """Sets the selection clauses."""
-        self._select = select
+        if not select or select[0] is None:
+            self._select = None
+            return
+
+        for i, select_member in enumerate(select):
+            if isinstance(select, (list, tuple, set)):
+                select[i] = ','.join(select_member)
+
+        self._select = ','.join(select)
+
         return self

@amosang amosang closed this as completed Oct 24, 2019
@amosang amosang reopened this Oct 24, 2019
@filak-sap filak-sap changed the title Generated $select HTTP parameter in URL is faulty the method select of ODataQuery classes should handle iterable parameters Oct 24, 2019
@amosang
Copy link
Author

amosang commented Oct 29, 2019

Thanks for the prompt response, Jakub.
Before we forget, would like to add that it would be good to handle select=* too, as per the OData protocol.

Example:
http://dffes01.h800.local:8000/sap/opu/odata/sap/RE_CN_CONTRACT_ODATA_SRV/ContractDataSet(Bukrs='1001',Recnnr='31000242')?select=*

@filak-sap
Copy link
Contributor

@amosang Good catch. Could you file a new issue, please?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants