Please see attached patch against the 0.08120 tag. Not 100% sure I got
the test in the right place though.
Mark
Index: t/71mysql.t
===================================================================
--- t/71mysql.t (revision 9034)
+++ t/71mysql.t (working copy)
@@ -192,6 +192,20 @@
[],
'overriden default join type works',
);
+
+ # Test support for straight joins too
+ $schema->storage->sql_maker->{_default_jointype} = 'straight';
+ is_same_sql_bind (
+ $rs->as_query,
+ '(
+ SELECT me.cdid, me.artist, me.title, me.year, me.genreid, me.single_track,
+ artist.artistid, artist.name, artist.rank, artist.charfield
+ FROM cd me
+ STRAIGHT_JOIN artist artist ON artist.artistid = me.artist
+ )',
+ [],
+ 'straight joins correctly supported for mysql'
+ );
}
## Can we properly deal with the null search problem?
Index: lib/DBIx/Class/SQLAHacks.pm
===================================================================
--- lib/DBIx/Class/SQLAHacks.pm (revision 9034)
+++ lib/DBIx/Class/SQLAHacks.pm (working copy)
@@ -485,6 +485,14 @@
}
}
+sub _generate_join_clause {
+ my ($self, $join_type) = @_;
+
+ return sprintf ('%s JOIN ',
+ $join_type ? ' ' . uc($join_type) : ''
+ );
+}
+
sub _recurse_from {
my ($self, $from, @join) = @_;
my @sqlf;
@@ -503,10 +511,7 @@
$join_type = $self->{_default_jointype} if not defined $join_type;
- my $join_clause = sprintf ('%s JOIN ',
- $join_type ? ' ' . uc($join_type) : ''
- );
- push @sqlf, $join_clause;
+ push @sqlf, $self->_generate_join_clause( $join_type );
if (ref $to eq 'ARRAY') {
push(@sqlf, '(', $self->_recurse_from(@$to), ')');
Index: lib/DBIx/Class/SQLAHacks/MySQL.pm
===================================================================
--- lib/DBIx/Class/SQLAHacks/MySQL.pm (revision 9034)
+++ lib/DBIx/Class/SQLAHacks/MySQL.pm (working copy)
@@ -21,4 +21,14 @@
return $self->SUPER::insert (@_);
}
+# Allow STRAIGHT_JOIN's
+sub _generate_join_clause {
+ my ($self, $join_type) = @_;
+
+ if( $join_type && $join_type =~ /^STRAIGHT\z/i ) {
+ return ' STRAIGHT_JOIN '
+ }
+
+ return $self->SUPER::_generate_join_clause( $join_type );
+}
1;