You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ResponseError: There was a problem with the database: Can not execute INSERT statement using value 'foobar:⟨789⟩'
at Surreal.insert (/home/knackstedt/source/test/surrealdb-2/node_modules/surrealdb/dist/index.cjs:1:51805)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at async /home/knackstedt/source/test/surrealdb-2/src/main.ts:31:5
However, using this syntax will only fail if the record already exists. Otherwise it will successfully insert a record into the "foobar" table. await db.insert("foobar", { id: "exact_id1", thing: true });
This behavior is different and either needs to be documented that it's intentional or reviewed for where it departs from the expected behaviour -- I honestly don't know what the real intention is for the behavior here but this isn't clear from the API that this is how the SDK intends to behave.
Personally, if the intention is to be strict, please throw errors from the client where a developer or the input is invalid. This makes it much easier to debug where something is being done incorrectly.
Steps to reproduce
Install Surrealdb 2.x.x and get the JS SDK 1.0.6
Expected behaviour
The error should be checked on the client side, and throw something like "Cannot insert value with ID, use upsert instead."
Describe the bug
There is an issue with the error the SDK throws when incorrectly using the insert method.
These will fail always:
await db.insert(new RecordId('foobar', '789'), { thing: true });
await db.insert({ id: "foobar:741", thing: true });
Both yield this error:
However, using this syntax will only fail if the record already exists. Otherwise it will successfully insert a record into the "foobar" table.
await db.insert("foobar", { id: "exact_id1", thing: true });
This behavior is different and either needs to be documented that it's intentional or reviewed for where it departs from the expected behaviour -- I honestly don't know what the real intention is for the behavior here but this isn't clear from the API that this is how the SDK intends to behave.
Personally, if the intention is to be strict, please throw errors from the client where a developer or the input is invalid. This makes it much easier to debug where something is being done incorrectly.
Steps to reproduce
Install Surrealdb 2.x.x and get the JS SDK 1.0.6
Expected behaviour
The error should be checked on the client side, and throw something like "Cannot insert value with ID, use upsert instead."
SurrealDB version
2.0.4 for linux on x86_64
JavaScript SDK version
1.0.6
Contact Details
[email protected]
Is there an existing issue for this?
Code of Conduct
The text was updated successfully, but these errors were encountered: