nextcloud / tables

🍱 Nextcloud tables app
https://apps.nextcloud.com/apps/tables
GNU Affero General Public License v3.0
148 stars 23 forks source link

fix(api): ContextMapper now coerces the row ID to an int for proper comparison #954

Closed elzody closed 7 months ago

elzody commented 7 months ago

Overview

I've been having an issue where, after I add a Context and try to re-fetch all Contexts from /ocs/v2.php/apps/tables/api/2/contexts/, the response returned by the API is a Context[] as expected, but the values are all null.

Example from before fix ```json { "data": [ { "id": null, "name": null, "iconName": null, "description": null, "owner": null, "ownerType": null, "sharing": [], "nodes": [], "pages": [] } ] } ```

This issue was preventing me from properly reviewing pull requests, so I decided to look into it. The problem was found in ContextMapper.php, where the row IDs were of type string, and the context ID variable held ints. They were being compared using === operator which, in addition to value, checks for type equivalence. string and int are not of the same type, so the comparison was failing, resulting in null values.

Upon further investigation and with help from @juliushaertl, it is thought that it is due to sqlite storing the id as a string by default. The solution here would be to cast the row ID to an int so that the strict comparison succeeds and to maintain compatibility with sqlite.

github-actions[bot] commented 7 months ago

Hello there, Thank you so much for taking the time and effort to create a pull request to our Nextcloud project.

We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process.

Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6

Thank you for contributing to Nextcloud and we hope to hear from you soon!