add match_type attribute
[dbsrgits/SQL-Translator-2.0-ish.git] / lib / SQL / Translator.pm
index 4e6c57f..72541f9 100644 (file)
@@ -40,7 +40,8 @@ class SQL::Translator {
     has 'schema' => (
         isa => Schema,
         is => 'rw',
-        default => sub { SQL::Translator::Object::Schema->new }
+        lazy => 1,
+        default => sub { SQL::Translator::Object::Schema->new },
     );
 
     has 'parser_args' => (
@@ -57,6 +58,8 @@ class SQL::Translator {
     has 'no_comments' => (isa => Bool, is => 'rw', default => 0);
     has 'show_warnings' => (isa => Bool, is => 'rw', default => 1);
     has 'trace' => (isa => Bool, is => 'rw', default => 0);
+    has 'quote_table_names' => (isa => Bool, is => 'rw', default => 0);
+    has 'quote_field_names' => (isa => Bool, is => 'rw', default => 0);
     has 'version' => (isa => Str, is => 'rw');
     has 'filename' => (isa => Str, is => 'rw');
 
@@ -78,9 +81,14 @@ class SQL::Translator {
     method _build__producer {
         my $class = 'SQL::Translator::Producer';
         my $role = $class . '::' . $self->producer;
-    
+
         Class::MOP::load_class($class);
-        try { Class::MOP::load_class($role) } catch ($e) { warn "ERROR: $e"; $role = $class . '::SQL::' . $self->producer; Class::MOP::load_class($role) }
+        try {
+            Class::MOP::load_class($role)
+        } catch ($e) {
+            $role = $class . '::SQL::' . $self->producer;
+            Class::MOP::load_class($role)
+        }
     
         my $producer = $class->new({ translator => $self });
         $role->meta->apply($producer);
@@ -92,12 +100,13 @@ class SQL::Translator {
         if ($parser) {
             $self->_clear_parser;
             $self->parser($parser);
-            $self->schema($self->parse($data));
+            $self->parse($data);
+            $self->schema;
         } elsif ($producer) {
             $self->_clear_producer;
-            $self->schema($self->parse($data)) if $data;
+            $self->parse($data) if $data;
             $self->producer($producer);
-            return $self->produce;
+            $self->produce;
         }
     }