Tuesday, 2 May 2017

Previous row gets updated while inserting new record in mysql from a node.js application

I'm trying to insert two records in parallel which have two properties that are different. For example:

object1 = {
firstfk_id : 13,
text_value: "admin",
secondfk_id: 99,
created_date: Date()
}

object2 = {
    firstfk_id : 13,
    text_value: "non-admin",
    secondfk_id: 100,
    created_date: Date()
}

I'm using .create() function of sequelize.js and it creates two records in the database but both having text_value as "non-admin". I introduced delay to see what is happening behind the scene.

It creates a record with text_value of "admin", ends the connection, creates another record with text_value "non-admin" and updates the first record at the same time from "admin" to "non-admin". I'm not sure why a CREATE statement would update previous row.

I've tested this with prepared statement as well and the results are same.



via Wahid Kadwaikar

No comments:

Post a Comment