Description:
For whom may concern mysql connector for django backends.
I'm not sure my endpoint is whether correct or not, I couldn't find github repository at least. You had references, so please - kindly hand over this message one with the authority.
I found a tiny but destructive bug that can be somewhat critical here,
mysql.connector.django.operations, function bulk_insert_sql.
I'm using python 3.5 at the moment, however, It's pretty sure that can be repeated on several other environments.
Your code (line 223 on my side):
>> return "VALUES " + ", ".join([items_sql] * num_values)
will fail when you have num_values=1, python2/3, either.
That is basically because tuple __str__() returns with dangling comma; as you might already know.
i.e. If you never heard of it, please try>> str(tuple('1'))
And the fact will make gradually failing django migration, admin login, and anywhere you can insert a single entry.
It's not yours, technically speaking, though I hope this bug to be avoided with simple if-else.
please refer
http://stackoverflow.com/questions/40523809/having-trouble-with-mysql-migration-cant-multi...
How to repeat:
python 3.5
django 1.10
try to login admin interface with mysql connection.
Suggested fix:
== was ==
def bulk_insert_sql(self, fields, num_values):
items_sql = "({0})".format(", ".join(["%s"] * len(fields)))
return "VALUES " + ", ".join([items_sql] * num_values)
== tobe ==
def bulk_insert_sql(self, fields, num_values) :
items_sql = "(%s)"
if 1<len(fields) : items_sql = "({0})".format(", ".join(["%s"] * len(fields)))
return "VALUES " + ", ".join([items_sql]*num_values) if 1<num_values else items_sql