Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3.2 bug in Database::prepare_select #1

Closed
sebastfr opened this issue Jun 20, 2013 · 1 comment
Closed

3.2 bug in Database::prepare_select #1

sebastfr opened this issue Jun 20, 2013 · 1 comment
Assignees
Milestone

Comments

@sebastfr
Copy link
Contributor

@sebastfr sebastfr commented Jun 20, 2013

Some parts of Stats::Handler rely on prepare_select() however that method is buggy on 3.2 (and early 3.3?) as the query "offset" and "limit" are swapped hence no records are select'ed.

Potential solution: implement that method locally (i.e. in Handler.pm).

@ghost ghost assigned sebastfr Jun 20, 2013
@sebastfr
Copy link
Contributor Author

@sebastfr sebastfr commented Jun 20, 2013

For a quick fix try that:

sub prepare_select
{
        my( $self, $sql, %options ) = @_;
        if( defined $options{limit} && length($options{limit}) )
        {
                if( defined $options{offset} && length($options{offset}) )
                {
                        $sql .= sprintf(" LIMIT %d OFFSET %d",
                                $options{offset},
                                $options{limit} );
                }
                else
                {
                        $sql .= sprintf(" LIMIT %d", $options{limit} );
                }
        }
        return $self->prepare( $sql );
}

Replace with:

sub prepare_select
{
        my( $self, $sql, %options ) = @_;
        if( defined $options{limit} && length($options{limit}) )
        {
                if( defined $options{offset} && length($options{offset}) )
                {
                        $sql .= sprintf(" LIMIT %d OFFSET %d",
                                $options{limit},
                                $options{offset} );
                }
                else
                {
                        $sql .= sprintf(" LIMIT %d", $options{limit} );
                }
        }
        return $self->prepare( $sql );
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant