On Sun, 6 Jan 2008, Patrick Weemeeuw wrote:

| create table article (
|   artId           integer        NOT NULL DEFAULT 
nextval('article_artid_seq'),
|   day             char(8)        NOT NULL,
|   seqnr           integer        NOT NULL,
|   visibility      char(1)        NOT NULL CHECK ( visibility = 'P' OR 
visibility = 'R' OR visibility = '' ),
|   title           varchar(100)   NOT NULL, -- ftext
|   body            text           NOT NULL, -- ftext
|   UNIQUE (day,seqnr),
|   UNIQUE (artid)
| );

| my $art = $schema->resultset('Article')->find_or_new( { artid => undef } );

| $ perl -I ../lib testme3.pl
| 0.08008
| DBIx::Class::Row::update_or_insert(): DBI Exception: DBD::Pg::st execute failed: ERROR: 
 null value in column "artid" violates not-null constraint
|  [for Statement "INSERT INTO article (artid, body, day, seqnr, title, visibility) 
VALUES (?, ?, ?, ?, ?, ?)" with ParamValues: 6='P', 4='3', 1=undef, 3='20022222', 
2='bbb', 5='ttt'] at testme3.pl line 30



Why are you explicitly setting artid => undef, which translates to artid = NULL ? Just dont supply that column at all, when you want the database to supply the default value.

Jess

_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/[EMAIL PROTECTED]

Reply via email to