qlik-oss / mongocursorpagination

MIT License
5 stars 9 forks source link

Support finding key for a tags with additional flags #12

Closed diptanw closed 5 years ago

diptanw commented 5 years ago

If the bson tag has more than just a key in its value (for example, additional flags, such asomitempty), the findStructFieldNameByBsonTag() function cannot find the corresponding field name when generating a cursor for a given paginated field. As a result, the application crashes when trying to get the field value.

// Find the result struct field name that has a tag matching the paginated filed name
resultStructFieldName := findStructFieldNameByBsonTag(reflect.TypeOf(result), paginatedField)
// Get the value of the resultStructFieldName
paginatedFieldValue := reflect.ValueOf(result).FieldByName(resultStructFieldName).Interface()

This PR enables to use an additional bson tag flags without panicing, by parsing the tag and handling the errors.

qlikossbuild commented 5 years ago

Hi, and thanks for contributing!

Note: If you are part of Qlik R&D, you can ignore this process (but let us know in a comment below!)

Before we can handle your pull request we need you to sign our contributor license agreement. This is a one-time thing and enables you to contribute without hassle to any of the qlik-oss repositories in the future.

And it only takes a few minutes! Here are some useful links to get you started:

Having troubles? Feel free to reach out to us either here or on Slack!

diptanw commented 5 years ago

This PR was submitted by the Qlik R&D member @diptanw

janmiderback commented 5 years ago

@diptanw - Could you provide a more detailed description of what problem this PR solves. Background, context etc, perhaps with an example of what can now be handled which was not previously possible?