Skip to content

Default column value applied when explicit NULL value specified on insert #12

Description

@gordthompson

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions