-
Notifications
You must be signed in to change notification settings - Fork 24
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
Validate input for CrudEntry.fromRow explicitly #239
Validate input for CrudEntry.fromRow explicitly #239
Conversation
@simolus3 Here's the new branch - sorry for the move, I'm a bit of a stickler for accurate branch names |
I think this is not going to change the issue fundamentally - maybe the error will be a little clear, but in the reported scenario the user will still end up with an upload queue being "stuck". What I meant by "validation" for this is we need to validate the type of the field when writing, which is when the mismatch occurs. The best place for that is probably in the triggers, such as here. |
Okay, will try that out and update PR later |
I discussed with @simolus3 - The additional casts here are still good to have, we just additionally need validations when writing. |
@rkistner Should I make a PR in the sqlite repo as well then? |
I have two ideas - either to The regex I believe will work is this (assuming /[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-4[a-fA-F0-9]{3}-[89abAB][a-fA-F0-9]{3}-[a-fA-F0-9]{12}/ |
We support any TEXT ids, not only UUIDs (although we do recommend UUIDs for most use cases). I think validating that the id is TEXT is the best route here (probably using the sqlite typeof function), since automatically casting could cause unexpected behavior for developers down the line. |
Right, I remember that somewhere in the back of my mind. I agree, auto-casting would be confusing - rather just raise an error. I imagine something like this? SELECT CASE
WHEN (NEW.id IS NULL)
THEN RAISE (FAIL, 'id is required')
WHEN (typeof(NEW.id) != 'text')
THEN RAISE (FAIL, 'id should be text')
END; |
e3e8bb4
to
5938c3a
Compare
Then it looks like I've just ruined it by pushing applying the same principle to the entire I think I got the explicit casts right - unit tests pass and I've also tested these changes against the |
Yes, that should work |
As suggested in #137.