[Bast-commits] r7344 - in DBIx-Class/0.08/trunk:
lib/DBIx/Class/Storage t t/lib
ribasushi at dev.catalyst.perl.org
ribasushi at dev.catalyst.perl.org
Thu Aug 20 05:50:49 GMT 2009
Author: ribasushi
Date: 2009-08-20 05:50:49 +0000 (Thu, 20 Aug 2009)
New Revision: 7344
Modified:
DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI.pm
DBIx-Class/0.08/trunk/t/86sqlt.t
DBIx-Class/0.08/trunk/t/lib/sqlite.sql
Log:
Fix a weird-ass sqlt invocation in deployment_statements()
Modified: DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI.pm
===================================================================
--- DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI.pm 2009-08-19 19:44:48 UTC (rev 7343)
+++ DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI.pm 2009-08-20 05:50:49 UTC (rev 7344)
@@ -2303,18 +2303,18 @@
. $self->_check_sqlt_message . q{'})
if !$self->_check_sqlt_version;
- require SQL::Translator::Parser::DBIx::Class;
- eval qq{use SQL::Translator::Producer::${type}};
- $self->throw_exception($@) if $@;
-
# sources needs to be a parser arg, but for simplicty allow at top level
# coming in
$sqltargs->{parser_args}{sources} = delete $sqltargs->{sources}
if exists $sqltargs->{sources};
- my $tr = SQL::Translator->new(%$sqltargs);
- SQL::Translator::Parser::DBIx::Class::parse( $tr, $schema );
- return "SQL::Translator::Producer::${type}"->can('produce')->($tr);
+ my $tr = SQL::Translator->new(
+ producer => "SQL::Translator::Producer::${type}",
+ %$sqltargs,
+ parser => 'SQL::Translator::Parser::DBIx::Class',
+ data => $schema,
+ );
+ return $tr->translate;
}
sub deploy {
Modified: DBIx-Class/0.08/trunk/t/86sqlt.t
===================================================================
--- DBIx-Class/0.08/trunk/t/86sqlt.t 2009-08-19 19:44:48 UTC (rev 7343)
+++ DBIx-Class/0.08/trunk/t/86sqlt.t 2009-08-20 05:50:49 UTC (rev 7344)
@@ -8,10 +8,30 @@
eval "use SQL::Translator";
plan skip_all => 'SQL::Translator required' if $@;
-my $schema = DBICTest->init_schema;
+my $schema = DBICTest->init_schema (no_deploy => 1);
-plan tests => 133;
+# replace the sqlt calback with a custom version ading an index
+$schema->source('Track')->sqlt_deploy_callback(sub {
+ my ($self, $sqlt_table) = @_;
+ is (
+ $sqlt_table->schema->translator->producer_type,
+ join ('::', 'SQL::Translator::Producer', $schema->storage->sqlt_type),
+ 'Production type passed to translator object',
+ );
+
+ if ($schema->storage->sqlt_type eq 'SQLite' ) {
+ $sqlt_table->add_index( name => 'track_title', fields => ['title'] )
+ or die $sqlt_table->error;
+ }
+
+ $self->default_sqlt_deploy_hook($sqlt_table);
+});
+
+$schema->deploy; # do not remove, this fires the is() test in the callback above
+
+
+
my $translator = SQL::Translator->new(
parser_args => {
'DBIx::Schema' => $schema,
@@ -26,17 +46,7 @@
my $relinfo = $schema->source('Artist')->relationship_info ('cds');
local $relinfo->{attrs}{on_delete} = 'restrict';
- $schema->source('Track')->sqlt_deploy_callback(sub {
- my ($self, $sqlt_table) = @_;
- if ($schema->storage->sqlt_type eq 'SQLite' ) {
- $sqlt_table->add_index( name => 'track_title', fields => ['title'] )
- or die $sqlt_table->error;
- }
-
- $self->default_sqlt_deploy_hook($sqlt_table);
- });
-
$translator->parser('SQL::Translator::Parser::DBIx::Class');
$translator->producer('SQLite');
@@ -45,6 +55,7 @@
ok($output, "SQLT produced someoutput")
or diag($translator->error);
+
like (
$warn,
qr/SQLT attribute .+? was supplied for relationship .+? which does not appear to be a foreign constraint/,
@@ -443,3 +454,5 @@
is( $got->name, $expected->{name},
"name parameter correct for `$desc'" );
}
+
+done_testing;
Modified: DBIx-Class/0.08/trunk/t/lib/sqlite.sql
===================================================================
--- DBIx-Class/0.08/trunk/t/lib/sqlite.sql 2009-08-19 19:44:48 UTC (rev 7343)
+++ DBIx-Class/0.08/trunk/t/lib/sqlite.sql 2009-08-20 05:50:49 UTC (rev 7344)
@@ -1,6 +1,6 @@
--
-- Created by SQL::Translator::Producer::SQLite
--- Created on Wed Aug 12 16:10:43 2009
+-- Created on Thu Aug 20 07:47:13 2009
--
@@ -16,6 +16,8 @@
charfield char(10)
);
+CREATE INDEX artist_name_hookidx ON artist (name);
+
--
-- Table: bindtype_test
--
More information about the Bast-commits
mailing list