fix bug in qualify_objects that would add schema to relnames
Rafael Kitover [Thu, 10 Jun 2010 05:29:34 +0000 (01:29 -0400)]
Changes
lib/DBIx/Class/Schema/Loader/RelBuilder.pm
lib/DBIx/Class/Schema/Loader/RelBuilder/Compat/v0_06.pm
t/23dumpmore.t

diff --git a/Changes b/Changes
index 353d295..a2ae8a1 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,5 +1,8 @@
 Revision history for Perl extension DBIx::Class::Schema::Loader
 
+        - fix bug in qualify_objects that would add schema to relnames
+        - better type info for Informix, except for DATETIME precision and
+          INTERVAL support
         - better type info for DB2
         - fix some newly-introduced test bugs
 
index a0de181..e3475dd 100644 (file)
@@ -213,9 +213,26 @@ sub _remote_attrs {
     return $attrs;
 }
 
+sub _sanitize_name {
+    my ($self, $name) = @_;
+
+    if (ref $name) {
+        # scalar ref for weird table name (like one containing a '.')
+        ($name = $$name) =~ s/\W+/_/g;
+    }
+    else {
+        # remove 'schema.' prefix if any
+        $name =~ s/^[^.]+\.//;
+    }
+
+    return $name;
+}
+
 sub _normalize_name {
     my ($self, $name) = @_;
 
+    $name = $self->_sanitize_name($name);
+
     my @words = split_name $name;
 
     return join '_', map lc, @words;
index 92a96c5..d0bfb78 100644 (file)
@@ -12,6 +12,8 @@ our $VERSION = '0.07001';
 sub _normalize_name {
     my ($self, $name) = @_;
 
+    $name = $self->_sanitize_name($name);
+
     return lc $name;
 }
 
index c02c279..ea5fd6b 100644 (file)
@@ -368,6 +368,8 @@ do_dump_test(
     regexes => {
         'Result/Foo' => [
             qr/^\Q__PACKAGE__->table("foo_schema.foo");\E/m,
+            # the has_many relname should not have the schema in it!
+            qr/^__PACKAGE__->has_many\(\n  "bars"/m,
         ],
     },
 );