bulk_insert
bulk_insert copied to clipboard
Falsey column defaults not used
Column default values like ''
or false
aren't used when a value is omitted for that column.
For example, if I have a table foo
with a column bar
that has a default value of ''
, and I don't provide a value for bar
in my call to bulk_insert
, the newly-inserted row will have a bar
value of NULL
, and not ''
like I expect.
The issue seems to be the use of #present?
to determine a column has a default value: https://github.com/jamis/bulk_insert/blob/3ded6b059af8d239ca0f5fbecca0de6138d49592/lib/bulk_insert/worker.rb#L50
Hi @harto , thank you very much for raising his issue. Would you be able to short snippet to reproduce the issue?
If you can write a unit test and suggest a change, I will be happy to review your pr