From: Matt S Trout Date: Mon, 15 Oct 2012 21:20:29 +0000 (+0000) Subject: defer stability check decision to renderer's Slice role X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=f21c4459e77bf62e7a03b0a170bdc195040d56e8;p=dbsrgits%2FDBIx-Class-Historic.git defer stability check decision to renderer's Slice role --- diff --git a/lib/DBIx/Class/SQLMaker.pm b/lib/DBIx/Class/SQLMaker.pm index 94fe0f6..6dfc427 100644 --- a/lib/DBIx/Class/SQLMaker.pm +++ b/lib/DBIx/Class/SQLMaker.pm @@ -61,12 +61,6 @@ around _build_renderer_class => sub { ); }; -has limit_requires_order_by_stability_check - => (is => 'rw', default => sub { 0 }); - -has limit_enforces_order_by_stability - => (is => 'rw', default => sub { 0 }); - # for when I need a normalized l/r pair sub _quote_chars { map @@ -151,7 +145,11 @@ sub select { my %final_attrs = (%{$rs_attrs||{}}, limit => $limit, offset => $offset); - if ($offset and $self->limit_requires_order_by_stability_check) { + my %slice_stability = $self->renderer->slice_stability; + + my $stability = $slice_stability{$offset ? 'offset' : 'limit'}; + + if ($stability) { my $source = $rs_attrs->{_rsroot_rsrc}; unless ( $final_attrs{order_is_stable} @@ -161,7 +159,7 @@ sub select { @final_attrs{qw(from order_by where)} ) ) { - if ($self->limit_enforces_order_by_stability) { + if ($stability eq 'requires') { if ($self->converter->_order_by_to_dq($final_attrs{order_by})) { $self->throw_exception( 'Current limit/offset implementation requires a stable order for offset' diff --git a/t/sqlmaker/limit_dialects/fetch_first.t b/t/sqlmaker/limit_dialects/fetch_first.t index b1ba9de..b867086 100644 --- a/t/sqlmaker/limit_dialects/fetch_first.t +++ b/t/sqlmaker/limit_dialects/fetch_first.t @@ -11,8 +11,6 @@ my $schema = DBICTest->init_schema; # based on toplimit.t delete $schema->storage->_sql_maker->{_cached_syntax}; $schema->storage->_sql_maker->limit_dialect('FetchFirst'); -$schema->storage->_sql_maker->limit_requires_order_by_stability_check(1); -$schema->storage->_sql_maker->limit_enforces_order_by_stability(1); my $books_45_and_owners = $schema->resultset ('BooksInLibrary')->search ({}, { prefetch => 'owner', rows => 2, offset => 3, diff --git a/t/sqlmaker/limit_dialects/rownum.t b/t/sqlmaker/limit_dialects/rownum.t index 9cf263c..08a7631 100644 --- a/t/sqlmaker/limit_dialects/rownum.t +++ b/t/sqlmaker/limit_dialects/rownum.t @@ -18,8 +18,6 @@ my $schema = DBICTest->init_schema; $schema->storage->_sql_maker->limit_dialect('RowNum'); -$schema->storage->_sql_maker->limit_requires_order_by_stability_check(1); - my $rs = $schema->resultset ('CD')->search({ id => 1 }); my $where_bind = [ { dbic_colname => 'id' }, 1 ]; diff --git a/t/sqlmaker/limit_dialects/toplimit.t b/t/sqlmaker/limit_dialects/toplimit.t index 3a80605..a4e7836 100644 --- a/t/sqlmaker/limit_dialects/toplimit.t +++ b/t/sqlmaker/limit_dialects/toplimit.t @@ -12,8 +12,6 @@ my $schema = DBICTest->init_schema; # We could test all of this via $sq->$op directly, # but some conditions need a $rsrc $schema->storage->_sql_maker->limit_dialect('Top'); -$schema->storage->_sql_maker->limit_requires_order_by_stability_check(1); -$schema->storage->_sql_maker->limit_enforces_order_by_stability(1); my $books_45_and_owners = $schema->resultset ('BooksInLibrary')->search ({}, { prefetch => 'owner', rows => 2, offset => 3,