diff Lib/IMPL/SQL/Schema/Traits/mysql.pm @ 44:32d2350fccf9

ORM *Minor fixes *Working tarnsform to sql *Fixes to the sql traits
author Sergey
date Mon, 11 Jan 2010 01:42:00 +0300
parents 56cef8e3cda6
children 16ada169ca75
line wrap: on
line diff
--- a/Lib/IMPL/SQL/Schema/Traits/mysql.pm	Thu Jan 07 15:41:49 2010 +0300
+++ b/Lib/IMPL/SQL/Schema/Traits/mysql.pm	Mon Jan 11 01:42:00 2010 +0300
@@ -5,7 +5,7 @@
 use IMPL::Class::Property::Direct;
 
 BEGIN {
-    public _direct property SqlBatch => prop_none;
+    public _direct property SqlBatch => prop_all;
 }
 
 sub formatTypeNameInteger {
@@ -235,7 +235,7 @@
     my @sql;
     
     # table body
-    push @sql, map { formatColumn($_,$level+1) } $table->Columns ;
+    push @sql, map { formatColumn($_,$level+1) } @{$table->Columns} ;
     if ($options{'skip_foreign_keys'}) {
         push @sql, map { formatConstraint($_,$level+1) } grep {not UNIVERSAL::isa($_,'IMPL::SQL::Schema::Constraint::ForeignKey')} values %{$table->Constraints};
     } else {
@@ -303,7 +303,7 @@
     my ($constraint,$level) = @_;
     
     my $name = quote_names($constraint->Name);
-    my $columns = join(',',map quote_names($_->Name),$constraint->Columns);
+    my $columns = join(',',map quote_names($_->Name),@{$constraint->Columns});
     
     if (ref $constraint eq 'IMPL::SQL::Schema::Constraint::PrimaryKey') {
         return "\t"x$level."PRIMARY KEY ($columns)";
@@ -321,13 +321,13 @@
     my ($constraint,$level) = @_;
     
     my $name = quote_names($constraint->Name);
-    my $columns = join(',',map quote_names($_->Name),$constraint->Columns);
+    my $columns = join(',',map quote_names($_->Name),@{$constraint->Columns});
     
     not $constraint->OnDelete or grep { uc $constraint->OnDelete eq $_ } ('RESTRICT','CASCADE','SET NULL','NO ACTION','SET DEFAULT') or die new IMPL::Exception('Invalid ON DELETE reference',$constraint->OnDelete);
     not $constraint->OnUpdate or grep { uc $constraint->OnUpdate eq $_ } ('RESTRICT','CASCADE','SET NULL','NO ACTION','SET DEFAULT') or die new IMPL::Exception('Invalid ON UPDATE reference',$constraint->OnUpdate);
     
     my $refname = quote_names($constraint->ReferencedPrimaryKey->Table->Name);
-    my $refcolumns = join(',',map quote_names($_->Name),$constraint->ReferencedPrimaryKey->Columns);
+    my $refcolumns = join(',',map quote_names($_->Name),@{$constraint->ReferencedPrimaryKey->Columns});
     return (
         "\t"x$level.
         "CONSTRAINT $name FOREIGN KEY $name ($columns) REFERENCES $refname ($refcolumns)".
@@ -461,7 +461,7 @@
 sub Sql {
     my ($this) = @_;
     if (wantarray) {
-        $this->SqlBatch;
+        @{$this->SqlBatch || []};
     } else {
         return join("\n",$this->SqlBatch);
     }
@@ -477,12 +477,13 @@
     public _direct property PendingConstraints => prop_none;
 }
 
-sub CTOR {
-    my ($this,%args) = @_;
-    
-    $args{'Handler'} = new IMPL::SQL::Schema::Traits::mysql::Handler;
-    $this->SUPER::CTOR(%args);
-}
+our %CTOR = (
+    'IMPL::SQL::Schema::Traits' => sub {
+        my %args = @_;
+        $args{'Handler'} = new IMPL::SQL::Schema::Traits::mysql::Handler;
+        %args;
+    }
+);
 
 sub DropConstraint {
     my ($this,$constraint) = @_;