Open Hyney opened 1 year ago
same , how to resove
Same problem, here is my solution.
MySQL's INSERT ... ON DUPLICATE KEY UPDATE
syntax does not support the alias syntax AS new_domain
to refer to the newly inserted values. To refer to the newly inserted values, should use the VALUES(column_name)
function directly.
INSERT INTO `domain` (`domain_name`,`describe`) VALUES (%s,%s) ON DUPLICATE KEY UPDATE
`domain_name` = VALUES(`domain_name`),
`describe` = VALUES(`describe`);
Describe the bug bulk_create works not correctly with on_conflicts. raise tortoise.exceptions.OperationalError: (1064, "You have an error in your SQL syntax")
To Reproduce
The SQL syntax seems to be error on Mysql-5.7.28
cls.MODEL.bulk_create(results, update_fields=['update_time'], on_conflict=['domain_name']).sql()
Exception