Reputation: 1815
I am trying to update a record in a SQLAlchemy table using it's ORM. Here is the query that I am writing:
localsession.query(Experiment).\
filter(Experiment.UserExperimentNumber==ExperimentId).\
filter(Experiment.UserId==UserId).\
update({Experiment.ExperimentStatus: Experiment.ExperimentStatus - "Approved"})
This gives me an Operational error with MySQL's error code 1292. Following is the error message:
OperationalError: (OperationalError) (1292, "Truncated incorrect DOUBLE value: 'ForReview'") 'UPDATE `Experiment` SET `ExperimentStatus`=(`Experiment`.`ExperimentStatus` - %s) WHERE `Experiment`.`UserExperimentNumber` = %s AND `Experiment`.`UserId` = %s' ('Approved', '102', '1')
I tried looking for the MySQL error mentioned and it seems that the error is being caused by the AND
statement in WHERE
of the MySQL query.
How should I correct this? Is there some other reason behind the error? I understand that I could just as well write the query without the ORM layer but I would like to avoid that because I have used the ORM throughout the application. Thanks in advance!
Upvotes: 0
Views: 168
Reputation: 1815
The error was in the way I was providing the update value in the last line of the query. I changed it to update({Experiment.ExperimentStatus: "Approved"})
and it worked.
Upvotes: 1