surrealdb / surrealdb.wasm

A WebAssembly engine for the SurrealDB JavaScript SDK
https://surrealdb.com
Apache License 2.0
116 stars 19 forks source link

Bug: UPSERT fails to execute when the entry is present #118

Open orimay opened 1 week ago

orimay commented 1 week ago

Describe the bug

Whenever I use UPSERT statement, and the entry already exists ,I get the following error:

Uncaught ResponseError: There was a problem with a datastore transaction: An IndexedDB error occured: failed to execute indexed db request: ConstraintError: Key already exists in the object store.

Steps to reproduce

import { Surreal } from 'surrealdb';
import { surrealdbWasmEngines } from '@surrealdb/wasm';

const db = new Surreal({
  engines: surrealdbWasmEngines({
    strict: false,
    capabilities: {
      guest_access: true,
      functions: true,
      network_targets: true,
    },
  }),
});

await db.connect(`test://ns/db`);

await db.use({
  namespace: 'ns',
  database: 'db',
});

await db.query('UPSERT _:1 SET q = 1;');
await db.query('UPSERT _:1 SET q = 2;'); // fails

Expected behaviour

Should update on matching id

SurrealDB version

"surrealdb": "^1.0.6", "@surrealdb/wasm": "^1.0.2"

Contact Details

dmitrii.a.baranov@gmail.com

Is there an existing issue for this?

Code of Conduct

orimay commented 1 week ago

Same happens with INSERT with ON DUPLICATE KEY UPDATE