Merge 'connected_schema_leak' into 'trunk'
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / Storage / DBI.pm
index 22477fe..2939f4a 100644 (file)
@@ -2521,15 +2521,19 @@ sub lag_behind_master {
 L<DBIx::Class> uses L<DBIx::Class::Relationship> names as table aliases in
 queries.
 
-This hook is to allow specific C<Storage> drivers to change the way these
-aliases are named.
+This hook is to allow specific L<DBIx::Class::Storage> drivers to change the
+way these aliases are named.
+
+The default behavior is C<"$relname_$join_count" if $join_count > 1>, otherwise
+C<"$relname">.
 
 =cut
 
 sub relname_to_table_alias {
   my ($self, $relname, $join_count) = @_;
 
-  my $alias = ($join_count > 1 ? join('_', $relname, $join_count) : $relname);
+  my $alias = ($join_count && $join_count > 1 ?
+    join('_', $relname, $join_count) : $relname);
 
   return $alias;
 }