ucanaccess
ucanaccess copied to clipboard
Default column value applied when explicit NULL value specified on insert
UCanAccess version 5.1.2-SNAPSHOT
Attempting to insert an explicit NULL value into a column that is nullable and has a default value causes the default value to be inserted instead of the NULL value.
UCanAccess>create table zzz (id text(50) primary key, int_col integer null default 0);
UCanAccess>No rows affected
UCanAccess>insert into zzz (id) values ('int_col omitted');
UCanAccess>1 row(s) affected
UCanAccess>select * from zzz;
·-----------------+---------·
| id | int_col |
·-----------------+---------·
| int_col omitted | 0 |
·-----------------+---------·
UCanAccess>insert into zzz (id, int_col) values ('int_col explicit NULL', NULL);
UCanAccess>1 row(s) affected
UCanAccess>select * from zzz;
·-----------------------+---------·
| id | int_col |
·-----------------------+---------·
| int_col explicit NULL | 0 |
| int_col omitted | 0 |
·-----------------------+---------·
UCanAccess>insert into zzz (id, int_col) values ('int_col some value', 123);
UCanAccess>1 row(s) affected
UCanAccess>select * from zzz;
·-----------------------+---------·
| id | int_col |
·-----------------------+---------·
| int_col explicit NULL | 0 |
| int_col omitted | 0 |
| int_col some value | 123 |
·-----------------------+---------·
The same behaviour is observed for Integer, Long Integer, Double, Decimal, and Short Text columns.