surrealdb.py
surrealdb.py copied to clipboard
Bug: patch method broken (request method name & typing)
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 https://github.com/surrealdb/surrealdb.py/pull/85
- The
dataparameter should by typed to expect an Array, e.g.List[Dict[str, Any]] - The return type allows a single dict, same as https://github.com/surrealdb/surrealdb.py/issues/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: [email protected]
Is there an existing issue for this?
- [X] I have searched the existing issues
Code of Conduct
- [X] I agree to follow this project's Code of Conduct