From: Moritz Onken Date: Wed, 3 Mar 2010 11:05:51 +0000 (+0000) Subject: Fix for SQLite to ignore the { for => ... } attribute X-Git-Tag: v0.08121~91 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=09cedb88933d7210c4af1b6bed5639bad24ea4c9;p=dbsrgits%2FDBIx-Class.git Fix for SQLite to ignore the { for => ... } attribute --- diff --git a/Changes b/Changes index 1ab1a7b..5a71df3 100644 --- a/Changes +++ b/Changes @@ -3,6 +3,7 @@ Revision history for DBIx::Class - Fix regression on not properly throwing when $obj->relationship is unresolvable - Add has_relationship method to row objects + - Fix for SQLite to ignore the { for => ... } attribute 0.08120 2010-02-24 08:58:00 (UTC) - Make sure possibly overwritten deployment_statements methods in diff --git a/lib/DBIx/Class/SQLAHacks/SQLite.pm b/lib/DBIx/Class/SQLAHacks/SQLite.pm new file mode 100644 index 0000000..dfc77ae --- /dev/null +++ b/lib/DBIx/Class/SQLAHacks/SQLite.pm @@ -0,0 +1,17 @@ +package # Hide from PAUSE + DBIx::Class::SQLAHacks::SQLite; + +use base qw( DBIx::Class::SQLAHacks ); +use Carp::Clan qw/^DBIx::Class|^SQL::Abstract/; + +# +# SQLite does not understand SELECT ... FOR UPDATE +# Adjust SQL here instead +# +sub select { + my $self = shift; + local $self->{_dbic_rs_attrs}{for} = undef; + return $self->SUPER::select (@_); +} + +1; diff --git a/lib/DBIx/Class/Storage/DBI/SQLite.pm b/lib/DBIx/Class/Storage/DBI/SQLite.pm index f7977bb..d096d80 100644 --- a/lib/DBIx/Class/Storage/DBI/SQLite.pm +++ b/lib/DBIx/Class/Storage/DBI/SQLite.pm @@ -10,6 +10,8 @@ use POSIX 'strftime'; use File::Copy; use File::Spec; +__PACKAGE__->sql_maker_class('DBIx::Class::SQLAHacks::SQLite'); + sub backup { my ($self, $dir) = @_; diff --git a/t/sqlahacks/sqlite.t b/t/sqlahacks/sqlite.t new file mode 100644 index 0000000..14fdc19 --- /dev/null +++ b/t/sqlahacks/sqlite.t @@ -0,0 +1,15 @@ +use strict; +use warnings; + +use Test::More; +use lib qw(t/lib); +use DBICTest; +use DBIC::SqlMakerTest; + +my $schema = DBICTest->init_schema; + +is_same_sql_bind( + $schema->resultset('Artist')->search ({}, {for => 'update'})->as_query, + "(SELECT me.artistid, me.name, me.rank, me.charfield FROM artist me)", []); + +done_testing;