Re: Unique constraints

[prev] [thread] [next] [Date index for 2005/03/04]

From: Tony Bowden
Subject: Re: Unique constraints
Date: 11:04 on 04 Mar 2005
On Fri, Mar 04, 2005 at 10:57:35AM +0000, Will Hawes wrote:
> Is there anything built into CDBI that would allow implementation of a 
> unique constraint on a non-primary key column? Or would that need to be 
> created as a custom constraint by the user?

No. That's usually something that happens at the database level itself.

It shouldn't be too difficult to add such a constraint though.

Something like:

  __PACKAGE__->add_constraint('unique_foo', foo => sub { 
    my ($value, $self) = @_;
    return not $self->search(foo => $value);
  });

Tony

Unique constraints
Will Hawes 10:57 on 04 Mar 2005

Re: Unique constraints
Tony Bowden 11:04 on 04 Mar 2005

Re: Unique constraints
Cees Hek 12:49 on 04 Mar 2005

Re: Unique constraints
Tony Bowden 16:08 on 04 Mar 2005

Re: Unique constraints
Cees Hek 17:28 on 04 Mar 2005

Re: Unique constraints
Tony Bowden 20:46 on 04 Mar 2005

Generated at 20:12 on 07 Mar 2005 by mariachi v0.52