From: Peter Rabbitson Date: Thu, 29 Apr 2010 08:32:09 +0000 (+0000) Subject: Allow limit syntax change in-flight without digging into internals X-Git-Tag: v0.08122~91 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=b2c7cf7421d9564b03981c9f75b4911099831364;p=dbsrgits%2FDBIx-Class.git Allow limit syntax change in-flight without digging into internals --- diff --git a/lib/DBIx/Class/SQLAHacks.pm b/lib/DBIx/Class/SQLAHacks.pm index 5e3ab35..0669e36 100644 --- a/lib/DBIx/Class/SQLAHacks.pm +++ b/lib/DBIx/Class/SQLAHacks.pm @@ -609,7 +609,10 @@ sub _join_condition { sub limit_dialect { my $self = shift; - $self->{limit_dialect} = shift if @_; + if (@_) { + $self->{limit_dialect} = shift; + undef $self->{_cached_syntax}; + } return $self->{limit_dialect}; } diff --git a/t/sqlahacks/limit_dialects/rownumberover.t b/t/sqlahacks/limit_dialects/rownumberover.t index 2c11c58..a73e278 100644 --- a/t/sqlahacks/limit_dialects/rownumberover.t +++ b/t/sqlahacks/limit_dialects/rownumberover.t @@ -8,7 +8,6 @@ use DBIC::SqlMakerTest; my $schema = DBICTest->init_schema; -delete $schema->storage->_sql_maker->{_cached_syntax}; $schema->storage->_sql_maker->limit_dialect ('RowNumberOver'); my $rs_selectas_col = $schema->resultset ('BooksInLibrary')->search ({}, { @@ -18,10 +17,6 @@ my $rs_selectas_col = $schema->resultset ('BooksInLibrary')->search ({}, { rows => 1, }); -use Data::Dumper; -$Data::Dumper::Maxdepth = 4; -#die Dumper $rs_selectas_col->_resolved_attrs; - is_same_sql_bind( $rs_selectas_col->as_query, '( diff --git a/t/sqlahacks/limit_dialects/toplimit.t b/t/sqlahacks/limit_dialects/toplimit.t index 0f10062..1ad1cda 100644 --- a/t/sqlahacks/limit_dialects/toplimit.t +++ b/t/sqlahacks/limit_dialects/toplimit.t @@ -11,7 +11,6 @@ my $schema = DBICTest->init_schema; # Trick the sqlite DB to use Top limit emulation # We could test all of this via $sq->$op directly, # but some conditions need a $rsrc -delete $schema->storage->_sql_maker->{_cached_syntax}; $schema->storage->_sql_maker->limit_dialect ('Top'); my $rs = $schema->resultset ('BooksInLibrary')->search ({}, { prefetch => 'owner', rows => 1, offset => 3 });