fix bug in qualify_objects that would add schema to relnames
[dbsrgits/DBIx-Class-Schema-Loader.git] / lib / DBIx / Class / Schema / Loader / RelBuilder.pm
index a12c035..e3475dd 100644 (file)
@@ -7,7 +7,7 @@ use Carp::Clan qw/^DBIx::Class/;
 use Lingua::EN::Inflect::Phrase ();
 use DBIx::Class::Schema::Loader::Utils 'split_name';
 
-our $VERSION = '0.07000';
+our $VERSION = '0.07001';
 
 =head1 NAME
 
@@ -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;