Update not actually updating data
See original GitHub issueHi,
I’m executing an update on a row in my ‘field’ table where the type was previously ‘2’:
return this.knex.table('field')
.where({id : 1 })
.update({type : 3})
.returning('*')
This call does not fail, but the return shows that the type is STILL 2 and querying postgres shows that is in in fact still 2. Other calls, such as insert, are working fine.
Furthermore, I added a .toQuery() and copied and pasted the query directly to my database, and that worked (type was updated to 3).
Issue Analytics
- State:
- Created 7 years ago
- Reactions:2
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Why is my update query not actually updating? - Stack Overflow
Based on your comment, you have JOIN on the wrong column. Here is the fix. UPDATE x SET x.sheet_expedient=db_data.sheet_expedient FROM ...
Read more >sql server - UPDATE performance where no data changes
If I have an UPDATE statement that does not actually change any data (because the data is already in the updated state), is...
Read more >update() function not actually updating record - ServiceNow
The problem is the update() function is not actually updating the record. According to the SN Docs site, Update() will return the sys_id...
Read more >Data Sources Refreshing but Workbook Not Updating
I currently have the online sync client refreshing my data source every morning. It is updating successfully and even showing that the published...
Read more >Data Refresh not updating table - Microsoft Power BI Community
try the follow: ` 1) check all the table queries, go to properties and be sure all have the update on refresh option...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
So this is something that will probably be addressed before 1.0 (at least with a warning), but queries aren’t actually executed until something triggers the promise (calling
.then
,.catch
, etc. or another associated method).If you put a
.then()
at the end of the.returning('*')
does the query run? If that’s not the issue is there any chance you’re in a transaction that isn’t being committed?Yep, documentation page doesn’t execute queries, but only prints out SQL that is generated by the query.
Anyhow nowadays preferred method to trigger query builder is to do