Greetings,

Using PyQt, I am having a problem inserting Nulls into a MySql table using the execBatch() method of QSqlQuery. From the documentation, a null QVariant (i.e. QVariant(QVariant.Double)) represents a Null when inserting. When doing a regular query.exec_ it does actually insert Nulls, however when I do a query.execBatch(), zeros get inserted, not Nulls.

Qt Code:
  1. query.prepare(INSERT INTO `table` VALUES (?, ?))
  2.  
  3. var1=[1.0, QVariant(QVariant.Double)]
  4. var2=[QVariant(QVariant.Double), 32.6]
  5.  
  6. query.addBindValue(QVariant(var1))
  7. query.addBindValue(QVariant(var2))
  8. query.execBatch()
To copy to clipboard, switch view to plain text mode 

With the above code, I would expect this to be inserted (Nulls should appear where QVariant objects in the lists are):
Qt Code:
  1. 1.0 Null
  2. Null 32.6
To copy to clipboard, switch view to plain text mode 
Instead what actually gets inserted is:
Qt Code:
  1. 1.0 0
  2. 0 32.6
To copy to clipboard, switch view to plain text mode 
If I were to insert this line by line using just regular exec_ it would work, but I would rather use execBatch as I have many rows to insert at once (above is just an example). I have tried making every item in the lists a QVariant, whether Null or not, but I still get zeros, and I cannot pass in anything other than a QVariant to addBindValue (which I why I wrap the list in one when I call the method).

Any help would be greatly appreciated.
Thank you.