During implementation of BulkCopy support in linq2db we found out that binary types inserted incorrectly using BulkCopy API (other types seems to work).
Looks like inserted data inserted like binary -> hex string -> binary:
Columns containing binary data must be mapped using an expression that uses the UNHEX function.
The underlying reason is that MySqlBulkCopy just uses the LOAD DATA command, which accepts string data, and I don't think there's a way to safely escape arbitrary binary data (e.g., that contains newlines.
This is definitely a usability problem for the API, though. At the (small) cost of reading the destination table schema, MySqlConnector could detect destination columns that are binary, and automatically set up the UNHEX expression. This would also be helpful for BIT columns, that need a custom expression, too.
MaceWindu commentedMay 10, 2020
During implementation of BulkCopy support in linq2db we found out that binary types inserted incorrectly using BulkCopy API (other types seems to work).
Looks like inserted data inserted like
binary -> hex string -> binary
:The text was updated successfully, but these errors were encountered: