-
Notifications
You must be signed in to change notification settings - Fork 94
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
Cannot access entity with Edm.Binary key #187
Comments
Thanks, that's good. Even better would be with metadata file, as something that can be actually run locally, for example like https://github.com/phanak-sap/pyodata-issue-files/tree/master/%23142. Feel free to add PR to that repository, with new folder "#187" so its easy to link with this particular issue |
Okay, I'd like to answer this #186 (comment) here, as that's the more appropriate place and any effort to fix this issue probably needs a new PR.
Of course it should be correct in all components of the URL. According to URI Conventions there could be two place in the URI with value content: The Key Value in the Resource Path (3.1.) and Filter System Query Option (4.5.). Both cases refer to the so called Literal, that is specific to the Primitive Data Type.
Full agreement on the separation of concerns, thanks for pointing that out. With that in mind, maybe it wasn't precise enough to call this an URL generation issue. Actually it's an issue with the generation of the so called Literal. And I'm afraid this can't be fixed in the So for the key value the path component is fetched from python-pyodata/pyodata/v2/service.py Lines 371 to 372 in 21a99b5
to_literal in the EntityKey class python-pyodata/pyodata/v2/service.py Line 218 in 21a99b5
The same is true for the filter value in the query component, that calls python-pyodata/pyodata/v2/service.py Line 990 in 21a99b5
So if anybody is ever going to specifiy OData V2 over another fancy protocol, there'd still be an adressing scheme, that would probably also refer to the type depended literals. And that makes this issue touch the model domain. |
OK, "OData V2 over another fancy protocol" will probably never happen. I was trying to illustrate a point about separation, but not stating a valid, although hypothetical requirement. My bad. So let's consider to stick OData V2 only. And with that it mind, even the only encoding/decoding strictly base64-base16 will suffice for now. You are also correct with all the comments about service.py:218 and service.py:990, the So I would probably continue with #186 as currently is, by adding/modifying tests and call it a day :) Option 2 defined there ("Values are stored in their Python native representation") is more dangerous. The backward compatibility break is a reason enough not to do it. But also (maybe I am again missing something), in the end, there would need to be basically same difference in binary encoding for the reading of the value (e.g. generating POST body) and for the to_literal() method (generating URL key/params), as in Option 1; so in the end, option 1 with extra steps. Am I Right? |
That's allright. I got the point.
Agree, so for Option 1 that means: to/from_json does nothing and to/from_literal does base64 to base16 and vice versa.
Okay, I will dig into the tests. |
While Edm.Binary values are Base64 encoded in JSON payload [1][1], the specification demands a prefixed and quoted Base16 encoding for values in URIs and HTTP headers [2][2]. As there has been no specific conversion for Edm.Binary so far and we want to stay backward compatible, the Python side representation shall remain a string with the Base64 encoded payload. However there are cases, where the literal is generated from the payload and sent to the server, that expects it in the correct format. E.g. this happens when building the resource path while using a Edm.Binary property as an entity key (see #187 and phanak-sap/pyodata-issue-files#2). Another case might be when using the $include filter for a Edm.Binary property. To meet those requirements, we want to have these representations: JSON | Python | Literal --------|--------------|------------------------ Base64 | str (Base64) | prefixed quoted Base16 This adds a specific type for Edm.Binary with the necessary conversions. Further it extends the test cases to cover those conversions. As the Edm.Binary type has been used to test the generic prefixed conversions, we need to switch this to the Edm.Byte type, that remains generic. [1](https://www.odata.org/documentation/odata-version-2-0/json-format) [2](https://www.odata.org/documentation/odata-version-2-0/overview/)
Entity URL segment is generated as
EntityNameSet(BASE64)
though the server expectsEntityNameSet(binary'BASE16')
.Reproducer:
Debug output here.
The text was updated successfully, but these errors were encountered: