Open pof3 opened 1 year ago
Just re wrote the tests using testify. all of them are passing.
Just re wrote the tests using testify. all of them are passing.
you can resolve the discussions has been fixed with this commit. Nice job. :+1:
Thanks, @timpratim !
Yeah, I know regexp are not an ideal solution, in Go we'd rather use the built in functions errors.Is
, errors.Unwrap
, etc. Nonetheless, the current driver works on top of websockets, and no further modifications can be done without immediate effects on other drivers and stacks. As you say, returning the code error at the beginning would be a nice workaround, so we can standardize it and make the proper changes all together. This PR adds a quick way to do the job, so it might be helpful for users, and I think it wouldn't be an issue for backwards compatibility, since the underlying behaviour in future implementation will be the same as expected.
Linking this error ticket which also covers incorrect handling of error responses https://github.com/surrealdb/surrealdb.go/issues/33 Agreed with @timpratim we are happy to go ahead with regex parsing 👍
Just as the
os
module provides users with theos.IsNotExist
function to test if the error was generated by trying to open a non existent file, regardless of its name, this commit adds the same functionality to check if the error comes from trying to insert data to a table with an unique index. This example, which is in the test generated for the function, shows its behavior:Will print: