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