From: Arthur Axel 'fREW' Schmidt Date: Wed, 5 May 2010 05:04:10 +0000 (-0500) Subject: rename sqltargs to sql_translator_args X-Git-Tag: v0.001000_06~6 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=02a7b8ac7ff6775fa47f26d22a825d024637a1a6;p=dbsrgits%2FDBIx-Class-DeploymentHandler.git rename sqltargs to sql_translator_args --- diff --git a/lib/DBIx/Class/DeploymentHandler.pm b/lib/DBIx/Class/DeploymentHandler.pm index 1fd2038..2a37231 100644 --- a/lib/DBIx/Class/DeploymentHandler.pm +++ b/lib/DBIx/Class/DeploymentHandler.pm @@ -47,9 +47,9 @@ __END__ my $s = My::Schema->connect(...); my $dh = DH->new({ - schema => $s, - databases => 'SQLite', - sqltargs => { add_drop_table => 0 }, + schema => $s, + databases => 'SQLite', + sql_translator_args => { add_drop_table => 0 }, }); $dh->prepare_install; @@ -62,9 +62,9 @@ or for upgrades: my $s = My::Schema->connect(...); my $dh = DH->new({ - schema => $s, - databases => 'SQLite', - sqltargs => { add_drop_table => 0 }, + schema => $s, + databases => 'SQLite', + sql_translator_args => { add_drop_table => 0 }, }); $dh->prepare_upgrade(1, 2); diff --git a/lib/DBIx/Class/DeploymentHandler/DeployMethod/SQL/Translator.pm b/lib/DBIx/Class/DeploymentHandler/DeployMethod/SQL/Translator.pm index 101ae2e..5f6d7c5 100644 --- a/lib/DBIx/Class/DeploymentHandler/DeployMethod/SQL/Translator.pm +++ b/lib/DBIx/Class/DeploymentHandler/DeployMethod/SQL/Translator.pm @@ -36,7 +36,7 @@ method _build_storage { $s } -has sqltargs => ( +has sql_translator_args => ( isa => 'HashRef', is => 'ro', default => sub { {} }, @@ -200,7 +200,7 @@ sub deploy { sub _prepare_install { my $self = shift; - my $sqltargs = { %{$self->sqltargs}, %{shift @_} }; + my $sqltargs = { %{$self->sql_translator_args}, %{shift @_} }; my $to_file = shift; my $schema = $self->schema; my $databases = $self->databases; @@ -296,7 +296,7 @@ method _prepare_changegrade($from_version, $to_version, $version_set, $direction my $schema = $self->schema; my $databases = $self->databases; my $dir = $self->upgrade_directory; - my $sqltargs = $self->sqltargs; + my $sqltargs = $self->sql_translator_args; my $schema_version = $self->schema_version; @@ -545,10 +545,9 @@ and generate the DDL. The L that is I used to talk to the database and generate the DDL. This is automatically created with L. -=attr sqltargs +=attr sql_translator_args -TODO -# rename +The arguments that get passed to L when it's used. =attr upgrade_directory diff --git a/lib/DBIx/Class/DeploymentHandler/Deprecated/WithDeprecatedSqltDeployMethod.pm b/lib/DBIx/Class/DeploymentHandler/Deprecated/WithDeprecatedSqltDeployMethod.pm index 05d4825..55157b2 100644 --- a/lib/DBIx/Class/DeploymentHandler/Deprecated/WithDeprecatedSqltDeployMethod.pm +++ b/lib/DBIx/Class/DeploymentHandler/Deprecated/WithDeprecatedSqltDeployMethod.pm @@ -26,7 +26,7 @@ has databases => ( default => sub { [qw( MySQL SQLite PostgreSQL )] }, ); -has sqltargs => ( +has sql_translator_args => ( isa => 'HashRef', is => 'ro', default => sub { {} }, @@ -35,10 +35,10 @@ has sqltargs => ( sub _build_deploy_method { my $self = shift; DBIx::Class::DeploymentHandler::DeployMethod::SQL::Translator::Deprecated->new({ - schema => $self->schema, - databases => $self->databases, - upgrade_directory => $self->upgrade_directory, - sqltargs => $self->sqltargs, + schema => $self->schema, + databases => $self->databases, + upgrade_directory => $self->upgrade_directory, + sql_translator_args => $self->sql_translator_args, }); } diff --git a/lib/DBIx/Class/DeploymentHandler/WithSqltDeployMethod.pm b/lib/DBIx/Class/DeploymentHandler/WithSqltDeployMethod.pm index 8b3f5cc..80fbf77 100644 --- a/lib/DBIx/Class/DeploymentHandler/WithSqltDeployMethod.pm +++ b/lib/DBIx/Class/DeploymentHandler/WithSqltDeployMethod.pm @@ -26,7 +26,7 @@ has databases => ( default => sub { [qw( MySQL SQLite PostgreSQL )] }, ); -has sqltargs => ( +has sql_translator_args => ( isa => 'HashRef', is => 'ro', default => sub { {} }, @@ -35,10 +35,10 @@ has sqltargs => ( sub _build_deploy_method { my $self = shift; my $args = { - schema => $self->schema, - databases => $self->databases, - upgrade_directory => $self->upgrade_directory, - sqltargs => $self->sqltargs, + schema => $self->schema, + databases => $self->databases, + upgrade_directory => $self->upgrade_directory, + sql_translator_args => $self->sql_translator_args, }; $args->{schema_version} = $self->schema_version if $self->has_schema_version; diff --git a/t/02-instantiation.t b/t/02-instantiation.t index 5173da8..00cb75b 100644 --- a/t/02-instantiation.t +++ b/t/02-instantiation.t @@ -27,7 +27,7 @@ VERSION1: { upgrade_directory => $sql_dir, schema => $s, databases => 'SQLite', - sqltargs => { add_drop_table => 0 }, + sql_translator_args => { add_drop_table => 0 }, }); ok($handler, 'DBIx::Class::DeploymentHandler w/1 instantiates correctly'); diff --git a/t/03-deprecated.t b/t/03-deprecated.t index 5eb19d3..f9bd021 100644 --- a/t/03-deprecated.t +++ b/t/03-deprecated.t @@ -26,7 +26,7 @@ VERSION1: { upgrade_directory => $sql_dir, schema => $s, databases => 'SQLite', - sqltargs => { add_drop_table => 0 }, + sql_translator_args => { add_drop_table => 0 }, }); ok($handler, 'DBIx::Class::DeploymentHandler w/1.0 instantiates correctly'); diff --git a/t/deploy_methods/sql_translator.t b/t/deploy_methods/sql_translator.t index 1020f25..21a0197 100644 --- a/t/deploy_methods/sql_translator.t +++ b/t/deploy_methods/sql_translator.t @@ -22,7 +22,7 @@ VERSION1: { schema => $s, upgrade_directory => $sql_dir, databases => ['SQLite'], - sqltargs => { add_drop_table => 0 }, + sql_translator_args => { add_drop_table => 0 }, }); ok( $dm, 'DBIC::DH::DM::SQL::Translator gets instantiated correctly' ); @@ -77,7 +77,7 @@ VERSION2: { schema => $s, upgrade_directory => $sql_dir, databases => ['SQLite'], - sqltargs => { add_drop_table => 0 }, + sql_translator_args => { add_drop_table => 0 }, txn_wrap => 1, }); @@ -172,7 +172,7 @@ VERSION3: { schema => $s, upgrade_directory => $sql_dir, databases => ['SQLite'], - sqltargs => { add_drop_table => 0 }, + sql_translator_args => { add_drop_table => 0 }, txn_wrap => 0, }); diff --git a/t/deploy_methods/sql_translator_deprecated.t b/t/deploy_methods/sql_translator_deprecated.t index 1342a5f..e3c0a91 100644 --- a/t/deploy_methods/sql_translator_deprecated.t +++ b/t/deploy_methods/sql_translator_deprecated.t @@ -23,7 +23,7 @@ VERSION1: { schema => $s, upgrade_directory => $sql_dir, databases => ['SQLite'], - sqltargs => { add_drop_table => 0 }, + sql_translator_args => { add_drop_table => 0 }, }); ok( $dm, 'DBIC::DH::DM::SQLT::Deprecated gets instantiated correctly' ); diff --git a/t/version_storages/standard.t b/t/version_storages/standard.t index f714b6d..d3d3ff7 100644 --- a/t/version_storages/standard.t +++ b/t/version_storages/standard.t @@ -17,25 +17,25 @@ my $sql_dir = 't/sql'; my $s = DBICVersion::Schema->connect(@connection); { - my $warning; - local $SIG{__WARN__} = sub {$warning = shift}; - my $t = DBICVersion::Schema->connect('frewfrew', '', ''); - like( $warning, qr/Your DB is currently unversioned. Please call upgrade on your schema to sync the DB/, 'warning when database is unversioned'); + my $warning; + local $SIG{__WARN__} = sub {$warning = shift}; + my $t = DBICVersion::Schema->connect('frewfrew', '', ''); + like( $warning, qr/Your DB is currently unversioned. Please call upgrade on your schema to sync the DB/, 'warning when database is unversioned'); } DBICDHTest::ready; my $dm = Translator->new({ - schema => $s, - upgrade_directory => $sql_dir, - databases => ['SQLite'], - sqltargs => { add_drop_table => 0 }, + schema => $s, + upgrade_directory => $sql_dir, + databases => ['SQLite'], + sql_translator_args => { add_drop_table => 0 }, }); my $vs = Standard->new({ schema => $s }); $dm->prepare_resultsource_install( - $vs->version_rs->result_source + $vs->version_rs->result_source ); ok( $vs, 'DBIC::DH::VersionStorage::Standard instantiates correctly' ); @@ -43,44 +43,44 @@ ok( $vs, 'DBIC::DH::VersionStorage::Standard instantiates correctly' ); ok( !$vs->version_storage_is_installed, 'VersionStorage is not yet installed' ); $dm->install_resultsource( - $vs->version_rs->result_source, - '1.0', + $vs->version_rs->result_source, + '1.0', ); ok( $vs->version_storage_is_installed, 'VersionStorage is now installed' ); $vs->add_database_version({ - version => '1.0', + version => '1.0', }); ok( - eq_array( - [ $vs->version_rs->search(undef, {order_by => 'id'})->get_column('version')->all], - [ '1.0' ], - ), - 'initial version works correctly' + eq_array( + [ $vs->version_rs->search(undef, {order_by => 'id'})->get_column('version')->all], + [ '1.0' ], + ), + 'initial version works correctly' ); is( $vs->database_version, '1.0', 'database version is 1.0'); $vs->add_database_version({ - version => '2.0', + version => '2.0', }); is( $vs->database_version, '2.0', 'database version is 2.0'); ok( - eq_array( - [ $vs->version_rs->search(undef, {order_by => 'id'})->get_column('version')->all], - [ '1.0', '2.0', ], - ), - 'adding another version works correctly' + eq_array( + [ $vs->version_rs->search(undef, {order_by => 'id'})->get_column('version')->all], + [ '1.0', '2.0', ], + ), + 'adding another version works correctly' ); { - my $warning; - local $SIG{__WARN__} = sub {$warning = shift}; - my $u = DBICVersion::Schema->connect($db, '', ''); - like( $warning, qr/Versions out of sync. This is 1.0, your database contains version 2.0, please call upgrade on your Schema./, 'warning when database/schema mismatch'); + my $warning; + local $SIG{__WARN__} = sub {$warning = shift}; + my $u = DBICVersion::Schema->connect($db, '', ''); + like( $warning, qr/Versions out of sync. This is 1.0, your database contains version 2.0, please call upgrade on your Schema./, 'warning when database/schema mismatch'); }