Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change primary key value #2094

Open
MartinMuzatko opened this issue Dec 9, 2020 · 0 comments
Open

Change primary key value #2094

MartinMuzatko opened this issue Dec 9, 2020 · 0 comments

Comments

@MartinMuzatko
Copy link

Introduction

We tried to update the id (primary key) of a model.

Issue Description

model.forge({id: 1}).save({id: 2}, {method: 'update'})

I get this error:

error Error: Empty .update() call detected! Update data does not contain any values to update. This will result in a faulty query. Table: DeviceInstances. Columns: .
    at QueryCompiler_MySQL._prepUpdate (server/node_modules/knex/lib/query/compiler.js:822:13)
    at QueryCompiler_MySQL.update (server/node_modules/knex/lib/dialects/mysql/query/compiler.js:24:26)
    at QueryCompiler_MySQL.toSQL (server/node_modules/knex/lib/query/compiler.js:64:29)
    at Builder.toSQL (server/node_modules/knex/lib/query/builder.js:77:44)
    at server/node_modules/knex/lib/runner.js:31:36
    at server/node_modules/knex/lib/runner.js:260:24

we also experimented with {patch: true} and {required: false}
No Luck

Steps to reproduce issue

model.forge({id: 1}).save({id: 2}, {method: 'update'})

Expected behaviour

it should perform this SQL statement:

UPDATE model SET id=2 WHERE id = 1

Actual behaviour

Error. See above

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant