From: Ash Berlin Date: Mon, 17 Mar 2008 21:46:07 +0000 (+0000) Subject: Fix is_deferrable and respcet sqltargs properly X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=45f1a484fec2dc2cae461c37af1a597d580ed8e8;p=dbsrgits%2FDBIx-Class-Historic.git Fix is_deferrable and respcet sqltargs properly --- diff --git a/Changes b/Changes index 0d95297..8a6f06e 100644 --- a/Changes +++ b/Changes @@ -4,6 +4,7 @@ Revision history for DBIx::Class parser (Anders Nor Berle) - Refactored DBIx::Class::Schema::Versioned - Syntax errors from resultset components are now reported correctly + - sqltargs respected correctly in deploy et al. 0.08010 2008-03-01 10:30 - Fix t/94versioning.t so it passes with latest SQL::Translator diff --git a/lib/DBIx/Class/Storage/DBI.pm b/lib/DBIx/Class/Storage/DBI.pm index d39ec5d..4f3416c 100644 --- a/lib/DBIx/Class/Storage/DBI.pm +++ b/lib/DBIx/Class/Storage/DBI.pm @@ -1353,9 +1353,7 @@ sub create_ddl_dir . $self->_check_sqlt_message . q{'}) if !$self->_check_sqlt_version; - my $sqlt = SQL::Translator->new({ - add_drop_table => 1, - }); + my $sqlt = SQL::Translator->new( $sqltargs ); $sqlt->parser('SQL::Translator::Parser::DBIx::Class'); my $sqlt_schema = $sqlt->translate({ data => $schema }) or die $sqlt->error; @@ -1410,10 +1408,11 @@ sub create_ddl_dir my $source_schema; { - my $t = SQL::Translator->new; + my $t = SQL::Translator->new($sqltargs); $t->debug( 0 ); $t->trace( 0 ); $t->parser( $db ) or die $t->error; + $t = $self->configure_sqlt($t, $db); my $out = $t->translate( $prefilename ) or die $t->error; $source_schema = $t->schema; unless ( $source_schema->name ) { @@ -1427,10 +1426,11 @@ sub create_ddl_dir my $dest_schema = $sqlt_schema; unless ( "SQL::Translator::Producer::$db"->can('preprocess_schema') ) { - my $t = SQL::Translator->new; + my $t = SQL::Translator->new($sqltargs); $t->debug( 0 ); $t->trace( 0 ); $t->parser( $db ) or die $t->error; + $t = $self->configure_sqlt($t, $db); my $out = $t->translate( $filename ) or die $t->error; $dest_schema = $t->schema; $dest_schema->name( $filename ) @@ -1439,7 +1439,7 @@ sub create_ddl_dir my $diff = SQL::Translator::Diff::schema_diff($source_schema, $db, $dest_schema, $db, - {} + $sqltargs ); if(!open $file, ">$difffile") { diff --git a/lib/SQL/Translator/Parser/DBIx/Class.pm b/lib/SQL/Translator/Parser/DBIx/Class.pm index 542387b..94b241e 100644 --- a/lib/SQL/Translator/Parser/DBIx/Class.pm +++ b/lib/SQL/Translator/Parser/DBIx/Class.pm @@ -153,7 +153,7 @@ sub parse { $on_update = $otherrelationship->{'attrs'}->{cascade_copy} ? 'CASCADE' : ''; } - my $is_deferrable = $rel_info->{attrs}{is_deferrable} || 0; + my $is_deferrable = $rel_info->{attrs}{is_deferrable}; # Make sure we dont create the same foreign key constraint twice my $key_test = join("\x00", @keys); @@ -185,7 +185,7 @@ sub parse { reference_table => $rel_table, on_delete => $on_delete, on_update => $on_update, - deferrable => $is_deferrable, + defined $is_deferrable ? ( deferrable => $is_deferrable ) : (), ); my $index = $table->add_index(