Commit | Line | Data |
87aa29e2 |
1 | package # Hide from PAUSE |
d5dedbd6 |
2 | DBIx::Class::SQLMaker::MySQL; |
87aa29e2 |
3 | |
d5dedbd6 |
4 | use base qw( DBIx::Class::SQLMaker ); |
87aa29e2 |
5 | use Carp::Clan qw/^DBIx::Class|^SQL::Abstract/; |
9c1700e3 |
6 | use namespace::clean; |
87aa29e2 |
7 | |
8 | # |
9 | # MySQL does not understand the standard INSERT INTO $table DEFAULT VALUES |
10 | # Adjust SQL here instead |
11 | # |
12 | sub insert { |
13 | my $self = shift; |
14 | |
15 | my $table = $_[0]; |
cebb7cce |
16 | $table = $self->_quote($table); |
87aa29e2 |
17 | |
18 | if (! $_[1] or (ref $_[1] eq 'HASH' and !keys %{$_[1]} ) ) { |
19 | return "INSERT INTO ${table} () VALUES ()" |
20 | } |
21 | |
22 | return $self->SUPER::insert (@_); |
23 | } |
24 | |
b8391c87 |
25 | # Allow STRAIGHT_JOIN's |
26 | sub _generate_join_clause { |
27 | my ($self, $join_type) = @_; |
28 | |
29 | if( $join_type && $join_type =~ /^STRAIGHT\z/i ) { |
30 | return ' STRAIGHT_JOIN ' |
31 | } |
32 | |
33 | return $self->SUPER::_generate_join_clause( $join_type ); |
34 | } |
4e0a89e4 |
35 | |
36 | # LOCK IN SHARE MODE |
37 | my $for_syntax = { |
38 | update => 'FOR UPDATE', |
39 | shared => 'LOCK IN SHARE MODE' |
40 | }; |
41 | |
42 | sub _lock_select { |
43 | my ($self, $type) = @_; |
44 | |
45 | my $sql = $for_syntax->{$type} || croak "Unknown SELECT .. FOR type '$type' requested"; |
46 | |
47 | return " $sql"; |
48 | } |
49 | |
87aa29e2 |
50 | 1; |