fixup INNER use for mysql 3
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / SQLMaker / MySQL.pm
1 package # Hide from PAUSE
2   DBIx::Class::SQLMaker::MySQL;
3
4 use Moo;
5 use namespace::clean;
6
7 extends 'DBIx::Class::SQLMaker';
8
9 has needs_inner_join => (is => 'rw', trigger => sub { shift->clear_renderer });
10
11 sub _build_converter_class {
12   Module::Runtime::use_module('DBIx::Class::SQLMaker::Converter::MySQL');
13 }
14
15 sub _build_base_renderer_class {
16   Module::Runtime::use_module('Data::Query::Renderer::SQL::MySQL');
17 }
18
19 around _renderer_args => sub {
20   my ($orig, $self) = (shift, shift);
21   +{ %{$self->$orig(@_)}, needs_inner_join => $self->needs_inner_join };
22 };
23
24 # Allow STRAIGHT_JOIN's
25 sub _generate_join_clause {
26     my ($self, $join_type) = @_;
27
28     if( $join_type && $join_type =~ /^STRAIGHT\z/i ) {
29         return ' STRAIGHT_JOIN '
30     }
31
32     return $self->next::method($join_type);
33 }
34
35 # LOCK IN SHARE MODE
36 my $for_syntax = {
37    update => 'FOR UPDATE',
38    shared => 'LOCK IN SHARE MODE'
39 };
40
41 sub _lock_select {
42    my ($self, $type) = @_;
43
44    my $sql = $for_syntax->{$type}
45     || $self->throw_exception("Unknown SELECT .. FOR type '$type' requested");
46
47    return " $sql";
48 }
49
50 1;