Error "Statement affected 0 row(s), but was expected to affect 1."

This error is also (sometimes?) caused by specifying a value for Id in fibery.createEntity:

AND - the entity is NOT created.

const utils     = context.getService('utils')
const entity    = args.currentEntities[0]
const type = entity.Type
const dateTime  = new Date().toString()
console.log(`\n=========== Mark as Done "${type}" - ${dateTime} ===========\n`)
const newId     = utils.uuid()
const templ     = {
    "Rank": 10000,
    "Name": entity.Name + ' ' + dateTime,
    "Id":   newId, //-- setting this causes error
    "State": "Not Started",
    "Enabled": true,
}
console.log( `🚗 create new entity "${type}": ${JSON.stringify(templ,null,2)}` )

const result = await fibery.createEntity(type, templ)
console.log( `  result: ${JSON.stringify(result, null, 2)}` )

Wow. Didn’t expect anyone to manually set Id, while agree it can be useful in some cases.
This is a bug from our side, fixed and will be released in an hour.

2 Likes