Mercurial > pub > Impl
diff Lib/IMPL/SQL/Schema/Column.pm @ 167:1f7a6d762394
SQL schema in progress
author | sourcer |
---|---|
date | Thu, 12 May 2011 08:57:19 +0400 |
parents | 76515373dac0 |
children | 6148f89bb7bf |
line wrap: on
line diff
--- a/Lib/IMPL/SQL/Schema/Column.pm Sat Apr 23 23:12:06 2011 +0400 +++ b/Lib/IMPL/SQL/Schema/Column.pm Thu May 12 08:57:19 2011 +0400 @@ -2,15 +2,16 @@ package IMPL::SQL::Schema::Column; use parent qw(IMPL::Object IMPL::Object::Autofill); -use IMPL::Class::Property; +use IMPL::lang qw( :DEFAULT :compare :declare :constants ); use IMPL::Class::Property::Direct; +use IMPL::Exception(); BEGIN { - public _direct property name => prop_get; - public _direct property type => prop_get; - public _direct property isNullable => prop_get; - public _direct property defaultValue => prop_get; - public _direct property tag => prop_get; + public _direct property name => PROP_GET; + public _direct property type => PROP_GET; + public _direct property isNullable => PROP_GET; + public _direct property defaultValue => PROP_GET; + public _direct property tag => PROP_GET; } __PACKAGE__->PassThroughArgs; @@ -18,43 +19,24 @@ sub CTOR { my $this = shift; - $this->{$name} or die new IMPL::InvalidArgumentException('a column name is required'); - $this->{$isNullable} = 0 if not exists $this->{$isNullable}; - UNIVERSAL::isa($this->{$type},'IMPL::SQL::Schema::Type') or die new IMPL::InvalidArgumentException('a type is required for the column',$this->{$name}); -} - -sub isEqualsStr { - my ($a,$b) = @_; + $this->{$name} or + die new IMPL::InvalidArgumentException('A column name is required'); - if (defined $a and defined $b) { - return $a eq $b; - } else { - if (defined $a or defined $b) { - return 0; - } else { - return 1; - } - } + $this->{$isNullable} = 0 if not exists $this->{$isNullable}; + + is( $this->{$type}, typeof IMPL::SQL::Schema::Type) or + die new IMPL::InvalidArgumentException('a type is required for the column',$this->{$name}); } -sub isEquals { - my ($a,$b) = @_; - - if (defined $a and defined $b) { - return $a == $b; - } else { - if (defined $a or defined $b) { - return 0; - } else { - return 1; - } - } -} - -sub isSame { +sub SameValue { my ($this,$other) = @_; - return ($this->{$name} eq $other->{$name} and $this->{$isNullable} == $other->{$isNullable} and isEqualsStr($this->{$defaultValue}, $other->{$defaultValue}) and $this->{$type}->isSame($other->{$type})); + return ( + $this->{$name} eq $other->{$name} + and $this->{$isNullable} == $other->{$isNullable} + and equals_s($this->{$defaultValue}, $other->{$defaultValue}) + and $this->{$type}->SameValue($other->{$type}) + ); } 1;