Skip to content
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

Bug: patch method broken (request method name & typing) #99

Open
2 tasks done
Wouterkoorn opened this issue Apr 1, 2024 · 0 comments
Open
2 tasks done

Bug: patch method broken (request method name & typing) #99

Wouterkoorn opened this issue Apr 1, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@Wouterkoorn
Copy link

Wouterkoorn commented Apr 1, 2024

Describe the bug

The Surreal.patch method is currently broken due to the wrong method name being used in the request.
It is also wrongly typed, the expected input should be a list of dict, not a sole dict. And the return type should allow a single dict.

Steps to reproduce

Currently:

await db.update("table:id", {"field": "value"})

surrealdb.ws.SurrealPermissionException: Method not found


After changing the Request method in Surreal.patch from "modify" to "patch":

await db.update("table:id", {"field": "value"})

surrealdb.ws.SurrealPermissionException: There was a problem with the database: The JSON Patch contains invalid operations. Operations must be an array


Now using an array as documented here: https://surrealdb.com/docs/surrealdb/integration/websocket#patch

await db.patch("table:id", [
    {"op": "replace", "path": "/field", "value": "value"}
])

Success! But typing of both the data param, and the return type, is still wrong.

Expected behaviour

  1. The request method name should be changed from "modify" to "patch", similar to Fix 'merge' in ws.py #85
  2. The data parameter should by typed to expect an Array, e.g. List[Dict[str, Any]]
  3. The return type allows a single dict, same as Bug: Wrong/Incomplete typing on Surreal methods #97

SurrealDB version

1.3.1 for linux on x86_64

surrealdb.py version

0.3.2 (latest as of 2024-04-02)

Contact Details

Ideally in the issue itself. Otherwise: 6qmf6te8@duck.com

Is there an existing issue for this?

  • I have searched the existing issues

Code of Conduct

  • I agree to follow this project's Code of Conduct
@Wouterkoorn Wouterkoorn added the bug Something isn't working label Apr 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant