Fix for => 'shared' on MySQL (RT#64590)
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / SQLMaker / MySQL.pm
CommitLineData
87aa29e2 1package # Hide from PAUSE
d5dedbd6 2 DBIx::Class::SQLMaker::MySQL;
87aa29e2 3
d5dedbd6 4use base qw( DBIx::Class::SQLMaker );
87aa29e2 5use Carp::Clan qw/^DBIx::Class|^SQL::Abstract/;
6
7#
8# MySQL does not understand the standard INSERT INTO $table DEFAULT VALUES
9# Adjust SQL here instead
10#
11sub insert {
12 my $self = shift;
13
14 my $table = $_[0];
cebb7cce 15 $table = $self->_quote($table);
87aa29e2 16
17 if (! $_[1] or (ref $_[1] eq 'HASH' and !keys %{$_[1]} ) ) {
18 return "INSERT INTO ${table} () VALUES ()"
19 }
20
21 return $self->SUPER::insert (@_);
22}
23
b8391c87 24# Allow STRAIGHT_JOIN's
25sub _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->SUPER::_generate_join_clause( $join_type );
33}
4e0a89e4 34
35# LOCK IN SHARE MODE
36my $for_syntax = {
37 update => 'FOR UPDATE',
38 shared => 'LOCK IN SHARE MODE'
39};
40
41sub _lock_select {
42 my ($self, $type) = @_;
43
44 my $sql = $for_syntax->{$type} || croak "Unknown SELECT .. FOR type '$type' requested";
45
46 return " $sql";
47}
48
87aa29e2 491;