-
Notifications
You must be signed in to change notification settings - Fork 30
Enhancement: Add validation for unique values for a short text fields #1770
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
base: main
Are you sure you want to change the base?
Conversation
4bcc937
to
8f0684a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't test yet, so far looks good, left minor requests.
However, existing tests seem to be failing. Having additional tests, integration, e2e or both would be appreciated.
8f0684a
to
12a33b3
Compare
276e95d
to
7a20c4b
Compare
@blizzz I've updated PR and 1st message including screenshoots. Now we have user-friendly error message with an explanation why row wasn't added. Old tests should pass. Also I'm trying to add new integration tests here. If anybody can help me with that - welcome |
a3d3049
to
adf32d1
Compare
@blizzz Old tests fixed. Also there is 1 integration test for a new functionality |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few questions.
I did a little bit of smoke testing, and it looks good so far 👍
Three more points I like to raise from this review:
- There is one corner case though: when you have a column with non-unique values, but edit the column and set it to unique, then it works. But obviously the content there is not unique, but new values will be checked for it.
Is this intentional behaviour? An alternative would be to reject the change with the error that the column values are not unique.
-
Another thought came up about the return status code. You set it to 400, which is OK, I am thinking 409 could maybe be more precise. But maybe this is also bike shedding 🤔
-
When you try to update a row to have a duplicated value, the operations fails , but with status code 500 instead of 400. This should be sorted out.
I hope I've covered all points now 🙇 Thank you for the work on this feature!
lib/Controller/AOCSController.php
Outdated
return new DataResponse(['message' => $this->n->t('An error caused by an invalid request occurred. More details can be found in the logs. Please reach out to your administration.')], Http::STATUS_BAD_REQUEST); | ||
return new DataResponse(['message' => $e->getMessage()], Http::STATUS_BAD_REQUEST); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we remove the translated error string?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because now we're providing not generic error message but more self-explanatory Column "My unique column" contains not unique value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's true, but the exception message is not translated either. They should not be translated for the log, but user facing messages should be translated (they can be specific of course, that is an improvement 🙂).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've refactored it a bit and added optional translatedMessage
property to the BadRequestError
exception.
@blizzz thank you for code review and deep testing 🫶 . I'm going to fix your finding later today |
36f6088
to
52d3fab
Compare
hey @blizzz!
Yeah, this is expected behavior. We can improve it later, but as you can see - current PR already huge.
|
35cd347
to
0f62241
Compare
0f62241
to
3a9c5bc
Compare
rebased. Almost green |
seems like we have same error in other PRs: https://github.com/nextcloud/tables/actions/runs/15216779497/job/42804024347 |
3a9c5bc
to
4cf6dca
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please see comments
lib/Controller/AOCSController.php
Outdated
return new DataResponse(['message' => $this->n->t('An error caused by an invalid request occurred. More details can be found in the logs. Please reach out to your administration.')], Http::STATUS_BAD_REQUEST); | ||
return new DataResponse(['message' => $e->getMessage()], Http::STATUS_BAD_REQUEST); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's true, but the exception message is not translated either. They should not be translated for the log, but user facing messages should be translated (they can be specific of course, that is an improvement 🙂).
Signed-off-by: Kostiantyn Miakshyn <[email protected]>
d49fd28
to
26a11d8
Compare
…code review fixes) Signed-off-by: Kostiantyn Miakshyn <[email protected]>
26a11d8
to
119e66b
Compare
This PR adds new toggle that validates short text fields for unique values. Closes #660
🔍 Preview
Trying to insert row with value that already present in table
