[Dbix-class] Fix for problem with create_ddl_dir

Carl Vincent C.A.Vincent at newcastle.ac.uk
Wed Feb 28 17:25:36 GMT 2007


Hi,

I know it's marked EXPERIMENTAL, but I've been brave and had a go with
the deploy stuff in DBIx::Class::Schema.

Works fine for me for SQLite which helps me no end with tests. It's a
bit less reliable with MySQL.

I hit a problem with long package names:

If your schema class is "Company::Project::Schema"
$schema->create_ddl_dir produces sql in a file named
"Company-Project::Schema-0.01-SQLite.sql"

Those colons upset my Fedora Core 6 box, and completely foxed my windows
box!

I've made a fix to the regexp that creates the filename:

$ svn diff lib/DBIx/Class/Schema.pm 
Index: lib/DBIx/Class/Schema.pm
===================================================================
--- lib/DBIx/Class/Schema.pm    (revision 3105)
+++ lib/DBIx/Class/Schema.pm    (working copy)
@@ -788,7 +788,7 @@
     my ($self, $type, $dir, $version) = @_;
 
     my $filename = ref($self);
-    $filename =~ s/::/-/;
+    $filename =~ s/::/-/g;
     $filename = "$dir$filename-$version-$type.sql";
 
     return $filename;



I'm taking the cowards line with respect to the tests - there doesn't
seem to be any for the deploy code... If I'm mistaken I'll look at
updating tests if someone points me the right way.

Cheers

Carl (IRC: CaptainCarlos)

-- 
     -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
     Carl Vincent             http://www.netskills.ac.uk/ (URL)
     Systems Manager                       0191 222 5003 (voice)
     Netskills, Newcastle University       0191 222 5001  (fax)
     Training  -  Accreditation  -  Consultancy  -  Development



More information about the Dbix-class mailing list