X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;ds=sidebyside;f=FS%2FFS%2FRecord.pm;h=dfc2abfc4beb32b4780218c2e0c0c9581cda94c3;hb=3bbe0f73c2afbbe182fe8a0a6490ba1700152742;hp=e4bc6c562bc4d211a8b7bef05f031f1cefc8e545;hpb=fb4ab1073f0d15d660c6cdc4e07afebf68ef3924;p=freeside.git diff --git a/FS/FS/Record.pm b/FS/FS/Record.pm index e4bc6c562..dfc2abfc4 100644 --- a/FS/FS/Record.pm +++ b/FS/FS/Record.pm @@ -900,10 +900,12 @@ sub insert { my $error = $self->check; return $error if $error; - #single-field unique keys are given a value if false + #single-field non-null unique keys are given a value if empty #(like MySQL's AUTO_INCREMENT or Pg SERIAL) foreach ( $self->dbdef_table->unique_singles) { - $self->unique($_) unless $self->getfield($_); + next if $self->getfield($_); + next if $self->dbdef_table->column($_)->null eq 'NULL'; + $self->unique($_); } #and also the primary key, if the database isn't going to