-
Notifications
You must be signed in to change notification settings - Fork 12
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
Unmarshalling errors due to DesignDocumentViewsMapReduce.Map schema assumptions #507
Comments
Thanks for reporting we'll look into it. |
It should be possible to use If
Similarly it is possible to write via All that said the expectation is that |
@ricellis Thanks for the followup. My motivation here is to follow the recommended approaches for handling indexes (and since a design document "backs" the index, I was trying to follow best practices for design documents). According to https://cloud.ibm.com/docs/Cloudant?topic=Cloudant-design-document-management we need to manage design documents carefully. One of the suggested approaches is “move and switch” approach which consists of:
I think I can still follow the spirit of "move and switch" using the "higher level" index API instead, and make sure to reference the design doc ID for each call. |
For now #514 has documented a known issue for this: https://github.com/IBM/cloudant-go-sdk/blob/main/KNOWN_ISSUES.md#query-language-design-documents |
Describe the bug
Calls to
CloudantV1.GetDesignDocument
andCloudantV1.GetDesignDocumentWithContext
will fail because the model structDesignDocumentViewsMapReduce
does not take into account other possibilities that can be generated through valid cloudant index creation. To be clear, the struct structure that is causing the problem isDesignDocument.Views.map[<view name>]DesignDocumentViewsMapReduce.Map
.To illustrate the issue, here's a design document that was created as a byproduct of using the
Query Indexes
to create an index:Note that the
doc.language
is aquery
(as opposed to some other query server implementation likejavascript
) and thedoc.views.foo-json-index.map
value contains an object rather than a string as theDesignDocumentViewsMapReduce
model expects. This results in the following unmarshalling error:The code fails when the core.UnmarshalModel function is called:
To Reproduce
+
button and then choseQuery Indexes
.CloudantV1.GetDesignDocument
andCloudantV1.GetDesignDocumentWithContext
against the resulting design document.Expected behavior
I expected that the unmarshalling would succeed by taking into account the type of query server used. Presumably this would require custom unmarshalling logic to handle this scenario.
As a workaround, if there was set of functions to allow access to the raw data such as the following examples:
GetDesignDocumentAsStream
GetDesignDocumentAsStreamWithContext
DesignDocument
schema. Maybe accept a map or just a raw string body?PutDesignDocumentWithMap
PutDesignDocumentWithMapWithContext
Screenshots
Must gather (please complete the following information):
Additional context
I was not able to see another way to handle this aside from rolling my own functions to handle design documents of the type described.
The text was updated successfully, but these errors were encountered: