From: Peter Rabbitson Date: Mon, 25 May 2009 07:42:45 +0000 (+0000) Subject: Move the DB2 Limit syntax setting into the storage class X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=ac788c460002e58aed8877ea46154f1b0d0f3193;p=dbsrgits%2FDBIx-Class-Historic.git Move the DB2 Limit syntax setting into the storage class --- diff --git a/lib/DBIx/Class/SQLAHacks.pm b/lib/DBIx/Class/SQLAHacks.pm index 63834e3..842d277 100644 --- a/lib/DBIx/Class/SQLAHacks.pm +++ b/lib/DBIx/Class/SQLAHacks.pm @@ -5,6 +5,7 @@ use base qw/SQL::Abstract::Limit/; use strict; use warnings; use Carp::Clan qw/^DBIx::Class/; +use Scalar::Util(); sub new { my $self = shift->SUPER::new(@_); @@ -97,21 +98,9 @@ SQL # While we're at it, this should make LIMIT queries more efficient, # without digging into things too deeply -use Scalar::Util 'blessed'; sub _find_syntax { my ($self, $syntax) = @_; - - # DB2 is the only remaining DB using this. Even though we are not sure if - # RowNumberOver is still needed here (should be part of SQLA) leave the - # code in place - my $dbhname = blessed($syntax) ? $syntax->{Driver}{Name} : $syntax; - if(ref($self) && $dbhname) { - if ($dbhname eq 'DB2') { - return 'RowNumberOver'; - } - } - - $self->{_cached_syntax} ||= $self->SUPER::_find_syntax($syntax); + return $self->{_cached_syntax} ||= $self->SUPER::_find_syntax($syntax); } sub select { diff --git a/lib/DBIx/Class/Storage/DBI/DB2.pm b/lib/DBIx/Class/Storage/DBI/DB2.pm index 4b5051b..4988c06 100644 --- a/lib/DBIx/Class/Storage/DBI/DB2.pm +++ b/lib/DBIx/Class/Storage/DBI/DB2.pm @@ -20,6 +20,16 @@ sub _dbh_last_insert_id { sub datetime_parser_type { "DateTime::Format::DB2"; } +sub _sql_maker_opts { + my ( $self, $opts ) = @_; + + if ( $opts ) { + $self->{_sql_maker_opts} = { %$opts }; + } + + return { limit_dialect => 'RowNumberOver', %{$self->{_sql_maker_opts}||{}} }; +} + 1; =head1 NAME