Bug: patch method broken (request method name & typing)
Wouterkoorn opened this issue · 0 comments
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
- The request method name should be changed from "modify" to "patch", similar to #85
- The
data
parameter should by typed to expect an Array, e.g.List[Dict[str, Any]]
- The return type allows a single dict, same as #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