Skip to content

Commit

Permalink
SQLite does not support the "FOR UPDATE" syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
sorear committed May 14, 2014
1 parent b33fe17 commit 1309bcc
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions lib/DBR/Misc/Connection.pm
Expand Up @@ -36,6 +36,7 @@ sub selectrow_array { my $self = shift; return $self->_wrap($self->{dbh}->selec
sub disconnect { my $self = shift; return $self->_wrap($self->{dbh}->disconnect(@_)) }
sub quote { shift->{dbh}->quote(@_) }
sub quote_identifier { shift->{dbh}->quote_identifier(@_) }
sub can_lock { 1 }

sub ping {
my $self = shift;
Expand Down
2 changes: 2 additions & 0 deletions lib/DBR/Misc/Connection/SQLite.pm
Expand Up @@ -14,4 +14,6 @@ sub getSequenceValue{

}

sub can_lock { 0 }

1;
2 changes: 1 addition & 1 deletion lib/DBR/Query/Insert.pm
Expand Up @@ -87,7 +87,7 @@ sub sql{
$sql = "INSERT INTO $tables (" . join (', ', @fields) . ') values (' . join (', ', @values) . ')';

$sql .= ' WHERE ' . $self->{where}->sql( $conn ) if $self->{where};
$sql .= ' FOR UPDATE' if $self->{lock};
$sql .= ' FOR UPDATE' if $self->{lock} && $conn->can_lock;
$sql .= ' LIMIT ' . $self->{limit} if $self->{limit};

$self->_logDebug2( $sql );
Expand Down
2 changes: 1 addition & 1 deletion lib/DBR/Query/Select.pm
Expand Up @@ -48,7 +48,7 @@ sub sql{
if (@{ $self->{orderby} || [] }) {
$sql .= ' ORDER BY ' . join(', ', map { $_->sql($conn) } @{ $self->{orderby} || [] });
}
$sql .= ' FOR UPDATE' if $self->{lock};
$sql .= ' FOR UPDATE' if $self->{lock} && $conn->can_lock;
$sql .= ' LIMIT ' . $self->_limit_clause if $self->{limit} || $self->{offset};

$self->_logDebug2( $sql );
Expand Down

0 comments on commit 1309bcc

Please sign in to comment.