-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Update SurrealDB client to v1.0.0 API and remove obsolete Connection #2501
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: development
Are you sure you want to change the base?
Update SurrealDB client to v1.0.0 API and remove obsolete Connection #2501
Conversation
|
Hii @Umang01-hash, can you please look into this and suggest if any more changes are required. |
@vtushar06 Your PR contains a lot of **Code Quality Issues**, Kindly resolve them so that we can review and test your PR.
|
|
yeah sure @Umang01-hash, will update you soon. |
|
Hi @Umang01-hash, do these changes look good to you so we can merge them? |
Umang01-hash
left a comment
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.
Hey @vtushar06
I reviewed and tested your PR. While testing my GET /person/{id} handler with type::thing() queries, I found that the updated code was throwing "unexpected result type: expected []any" errors.
The issue was in extractRecord - SurrealDB returns records as map[string]any but the code only handled map[any]any. I fixed it by checking for map[string]any first before falling back to map[any]any.
Also i think we can add a check in processQueryResults to handle single records returned as maps directly (not wrapped in arrays) from type::thing() queries.
I would also advice you to check the other methods also to assure we don't have any other bug there. Please let me know if i can help you in any way resovling this.
… map[string]any and map[any]any formats
|
Hii @Umang01-hash, I have recently checked errors in ExtraRecords now All these are being resolved, once you get the time you can re-review this and If any more changes are required please let me know. |
|
@vtushar06 Your PR has some code quality issues:
Please address them. Once the workflow passes complpetely then only we will be able to merge it. |
…xtraction and improve code readability
|
Hii @Umang01-hash, I have fixed code Quality Issue, can you have a look why they are taking to much time to get pass. |
|
May be because branch is not updated?? |
|
@Umang01-hash ,Can you please help why the code quality issue is persisting even after fixing issue. |
|
@vtushar06 I have resolved the linter error but I found this:
I think completely updating the directory with new dependency will also include the tests to be refactored. It will be really helpful if you can fix the tests too. |
|
Hii @Umang01-hash, I had removed outdated tests, Can you please have a look at the changes. |
|
@vtushar06 You just removed all the test cases. The correct way here is to update the mock_interface.go with reference to new version and then fix the tests to attain atleast previous coverage. We can't push a code to development that reduces the code coverage of a datasource. |
|
@Umang01-hash ,The test file still uses the old SurrealDB API, so it won’t work with v1.0.0. Mock types like NewMockConnection, Send(), QueryResult, and QueryResponse no longer exist, and v1.0.0 uses package-level generic functions that can’t be mocked without an interface wrapper. So we have two options: Which approach should I take? |
We can proceed with the first approach. For reference, please look at the FTP implementation to understand how interface wrapping and mocking can help here. Also, could you update the documentation to clarify that—even though SurrealDB exposes multiple methods—many of them internally call the same underlying function. This means the change does not impact users, and the exposed interface remains stable without any breaking changes, if at all something like that is happening. |



Pull Request Template
Description:
Changes Made:
Breaking Changes (if applicable):
Additional Information:
Build status: Package builds successfully with zero errors
Documentation: Added CHANGES.md with beginner-friendly explanation
Backward compatibility: All public methods work exactly as before
Checklist:
goimportandgolangci-lint.Thank you for your contribution!