comparison Lib/IMPL/SQL/Schema/Table.pm @ 271:56364d0c4b4f

+IMPL::SQL::Schema::MySQL: added basic support for MySQL
author cin
date Mon, 28 Jan 2013 02:43:14 +0400
parents dacfe7c0311a
children 4ddb27ff4a0b
comparison
equal deleted inserted replaced
270:3f59fd828d5f 271:56364d0c4b4f
33 33
34 if ($args{columns}) { 34 if ($args{columns}) {
35 die new IMPL::InvalidOperationException('A columns property should be a reference to an array') unless ref $args{columns} eq 'ARRAY'; 35 die new IMPL::InvalidOperationException('A columns property should be a reference to an array') unless ref $args{columns} eq 'ARRAY';
36 36
37 $this->InsertColumn($_) foreach @{$args{columns}}; 37 $this->InsertColumn($_) foreach @{$args{columns}};
38 }
39
40 if ($args{constraints}) {
41 die new IMPL::InvalidOperationException('A constraints property should be a reference to an array') unless ref $args{constraints} eq 'ARRAY';
42
43 $this->AddConstraint($_) foreach @{$args{constraints}};
44 } 38 }
45 } 39 }
46 40
47 sub InsertColumn { 41 sub InsertColumn {
48 my ($this,$column,$index) = @_; 42 my ($this,$column,$index) = @_;
179 my ($type,$params) = @_; 173 my ($type,$params) = @_;
180 174
181 $type = IMPL::SQL::Schema::Constraint->ResolveAlias($type) or 175 $type = IMPL::SQL::Schema::Constraint->ResolveAlias($type) or
182 die new IMPL::Exception("Can't resolve a constraint alias",$_[0]); 176 die new IMPL::Exception("Can't resolve a constraint alias",$_[0]);
183 177
178 $params = {%{$params}};
179
184 $params->{table} = $this; 180 $params->{table} = $this;
185 181
186 $this->AddConstraint($type->new(%$params)); 182 $this->AddConstraint($type->new(%$params));
187 } else { 183 } else {
188 die new IMPL::Exception("Wrong arguments number",scalar(@_)); 184 die new IMPL::Exception("Wrong arguments number",scalar(@_));