# Copyright (c) 1999-2009 bivio Software, Inc. All rights reserved. # # Visit http://www.bivio.biz for more info. # # This library is free software; you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as # published by the Free Software Foundation; either version 2.1 of the # License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; If not, you may get a copy from: # http://www.opensource.org/licenses/lgpl-license.html # # $Id: Constraint.pm,v 2.5 2009/11/20 17:48:39 nagler Exp $ package Bivio::SQL::Constraint; use strict; use Bivio::Base 'Type.Enum'; our($VERSION) = sprintf('%d.%02d', q$Revision: 2.5 $ =~ /\d+/g); my($_TE) = b_use('Bivio::TypeError'); my($_E) = b_use('Type.Enum'); __PACKAGE__->compile([ NONE => [0], PRIMARY_KEY => [1], NOT_NULL => [2], NOT_NULL_UNIQUE => [3], NOT_ZERO_ENUM => [4], IS_SPECIFIED => [5], ]); sub check_value { my($self, $type, $value) = @_; return if $self->eq_none; return $_TE->NULL unless defined($value); if ($self->equals_by_name(qw(NOT_ZERO_ENUM IS_SPECIFIED))) { return $_TE->UNSPECIFIED unless $type->is_specified($value); } return; } 1;