$statement->goto_page() issue

3 views
Skip to first unread message

Sergiy Zuban

unread,
Apr 4, 2014, 3:56:05 PM4/4/14
to dbix-da...@googlegroups.com
Hi Laurent,

The following code doesn't work:

        my $statement = $join->select(
            -result_as => 'statement',
            -page_size => 10,
        );

        $statement->goto_page( 3 );

        foreach my $row ( @{ $statement->page_rows } )
        {
        }

goto_page() doesn't change OFFSET because it tries to update offset via named placeholder 'offset' in DBIx::DataModel::Statement.

  # TODO: DON'T REMEMBER why the line below was here. Keep it around for a while ...
  push @bind_args, offset => $self->{offset}  if $self->{offset};
  $self->bind(@bind_args)      if @bind_args;

SQL::Abstract::More returns regular bindings for LIMIT ? OFFSET ? rather than named one: LIMIT ?:limit OFFSET ?:offset
So there is no guaranteed way to find out which of them if for OFFSET.

As a workaround I specify ->select( -page_index => 3, ... ) and it works.

Btw, i'm getting the following warnings: Use of uninitialized value in numeric eq (==) at .../lib/perl5/DBIx/DataModel/Statement.pm line 637.

  $self->execute     unless $self->{row_num} == $self->{offset};

$self->{row_num} is undef here.

Laurent Dami

unread,
Apr 15, 2014, 11:25:50 PM4/15/14
to dbix-da...@googlegroups.com
Le 04.04.2014 21:56, Sergiy Zuban a écrit :
> Hi Laurent,
>
> The following code doesn't work:
> [ ... goto_page() ...]
Hi Sergiy,

Thanks for the report. Actually I never used this feature myself, and
you are right, it doesn't work :-(

I just added a test "paging.t" to prove that it doesn't work ; now I'll
see how to fix it.

Cheers, Laurent D.

Laurent Dami

unread,
Apr 18, 2014, 9:22:06 PM4/18/14
to dbix-da...@googlegroups.com
Le 04.04.2014 21:56, Sergiy Zuban a écrit :
> Hi Laurent,
>
> The following code doesn't work:
>
> my $statement = $join->select(
> -result_as => 'statement',
> -page_size => 10,
> );
>
> $statement->goto_page( 3 );
>
> foreach my $row ( @{ $statement->page_rows } )
> {
> }
>
>
Hi Sergiy,

While working on the ->goto_page() bug, I realize that this API doesn't
really make sense, especially since I merged your changes about
->finish(), because once a sth handle is finished it cannot be scrolled
to another offset, even if the DBMS supports scrollable cursors (like
Oracle).

Paging should be done when creating the request, with no "goto" after
that; so I'm considerint dropping methods ->goto_page(), ->shift_page(),
etc. from the API. Apparently you were the only person to use it, since
you discovered that bug after many years !

So would it be OK for you if those methods disappear? Your example code
could already be rewritten as :

my $page_rows = $join->select(
-page_size => 10,
-page_index => 3,
);

foreach my $row ( @$page_rows )
{
}

Thanks in advance,

Laurent Dami

Sergiy Zuban

unread,
Apr 20, 2014, 9:36:01 PM4/20/14
to dbix-da...@googlegroups.com

Hi Laurent,

I agree with you. It seems to be better to remove this feature and leave -page_size only

Sergiy Zuban

--

--- You received this message because you are subscribed to the Google Groups "dbix-datamodel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dbix-datamodel+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Sergiy Zuban

unread,
Apr 20, 2014, 9:38:41 PM4/20/14
to dbix-da...@googlegroups.com

I mean -page_size + -page_index

Sergiy Zuban

Laurent Dami

unread,
Apr 22, 2014, 2:21:07 AM4/22/14
to dbix-da...@googlegroups.com
Le 21.04.2014 03:36, Sergiy Zuban a écrit :
>
> Hi Laurent,
>
> I agree with you. It seems to be better to remove this feature and
> leave -page_size only
>
> Sergiy Zuban
>
>
shipped (together with the ->finish() changes) in v2.43
Reply all
Reply to author
Forward
0 new messages