release v0.11013_02
[dbsrgits/SQL-Translator.git] / lib / SQL / Translator / Schema.pm
index 6cf710c..9c190dc 100644 (file)
@@ -26,31 +26,28 @@ returns the database structure.
 
 =cut
 
-use Moo;
+use Moo 1.000003;
 use SQL::Translator::Schema::Constants;
 use SQL::Translator::Schema::Procedure;
 use SQL::Translator::Schema::Table;
 use SQL::Translator::Schema::Trigger;
 use SQL::Translator::Schema::View;
+use Sub::Quote qw(quote_sub);
 
 use SQL::Translator::Utils 'parse_list_arg';
 use Carp;
 
-with qw(
-  SQL::Translator::Schema::Role::Extra
-  SQL::Translator::Schema::Role::Error
-  SQL::Translator::Schema::Role::Compare
-);
+extends 'SQL::Translator::Schema::Object';
 
 our $VERSION = '1.59';
 
 
-has _order => (is => 'ro', default => sub { +{ map { $_ => 0 } qw/
+has _order => (is => 'ro', default => quote_sub(q{ +{ map { $_ => 0 } qw/
     table
     view
     trigger
     proc
-  /} },
+  /} }),
 );
 
 # FIXME - to be removed, together with the SQL::Translator::Schema::Graph* stuff
@@ -100,7 +97,7 @@ Returns a Graph::Directed object with the table names for nodes.
     return $g;
 }
 
-has _tables => ( is => 'ro', init_arg => undef, default => sub { +{} } );
+has _tables => ( is => 'ro', init_arg => undef, default => quote_sub(q{ +{} }) );
 
 sub add_table {
 
@@ -140,7 +137,7 @@ not be created.
     my $table_name = $table->name;
 
     if ( defined $self->_tables->{$table_name} ) {
-        return $self->error(qq[Can't create table: "$table_name" exists]);
+        return $self->error(qq[Can't use table name "$table_name": table exists]);
     }
     else {
         $self->_tables->{$table_name} = $table;
@@ -193,7 +190,7 @@ can be set to 1 to also drop all triggers on the table, default is 0.
     return $table;
 }
 
-has _procedures => ( is => 'ro', init_arg => undef, default => sub { +{} } );
+has _procedures => ( is => 'ro', init_arg => undef, default => quote_sub(q{ +{} }) );
 
 sub add_procedure {
 
@@ -279,7 +276,7 @@ object.
     return $proc;
 }
 
-has _triggers => ( is => 'ro', init_arg => undef, default => sub { +{} } );
+has _triggers => ( is => 'ro', init_arg => undef, default => quote_sub(q{ +{} }) );
 
 sub add_trigger {
 
@@ -362,7 +359,7 @@ trigger name or an C<SQL::Translator::Schema::Trigger> object.
     return $trigger;
 }
 
-has _views => ( is => 'ro', init_arg => undef, default => sub { +{} } );
+has _views => ( is => 'ro', init_arg => undef, default => quote_sub(q{ +{} }) );
 
 sub add_view {
 
@@ -451,7 +448,7 @@ Get or set the schema's database.  (optional)
 
 =cut
 
-has database => ( is => 'rw', default => sub { '' } );
+has database => ( is => 'rw', default => quote_sub(q{ '' }) );
 
 sub is_valid {
 
@@ -747,7 +744,7 @@ Get or set the schema's name.  (optional)
 
 =cut
 
-has name => ( is => 'rw', default => sub { '' } );
+has name => ( is => 'rw', default => quote_sub(q{ '' }) );
 
 =pod
 
@@ -757,13 +754,7 @@ Get the SQL::Translator instance that instantiated the parser.
 
 =cut
 
-has translator => ( is => 'rw' );
-
-sub DESTROY {
-    my $self = shift;
-    undef $_ for values %{ $self->_tables };
-    undef $_ for values %{ $self->_views };
-}
+has translator => ( is => 'rw', weak_ref => 1 );
 
 1;