Re: BUG #9088: default are not working

From: Thomas Kellerer <spam_eater(at)gmx(dot)net>
To: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #9088: default are not working
Date: 2014-02-03 22:30:32
Message-ID: 52F01888.4020808@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

plademan(at)comcast(dot)net wrote on 03.02.2014 23:23:> create table default_test
> (
> userId varchar(20) default 'test',
> date1 timestamp default now(),
> date2 timestamp default current_timestamp,
> date3 timestamp default localtimestamp
> );
>
> insert into default_test
> ( userId, date1, date2, date3 )
> values
> ( null, null, null, null );
>
> select * from default_test;

You explicitely stated that you want to put NULL into those columns, therefor the default value does not apply.

The default value is only used if the colum is not listed at all in the INSERT statement.

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Marko Tiikkaja 2014-02-03 22:31:17 Re: BUG #9088: default are not working
Previous Message plademan 2014-02-03 22:23:23 BUG #9088: default are not working