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

Don't change MSSQL query if no limit or offset is set #4870

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions libraries/joomla/database/query/sqlsrv.php
Expand Up @@ -260,6 +260,11 @@ public function dateAdd($date, $interval, $datePart)
*/
public function processLimit($query, $limit, $offset = 0)
{
if (!$limit && !$offset)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Bakual Shouldn't we do the same here as in other drivers:

if ($limit > 0 && $offset > 0)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In other places we have the code to apply the limit within the if clause.
I went the other way around and bail out if the checks are not successful. I prefer this way in this case because the actual code has another if clause and is quite a few lines long.
I think it's easier to read this way.
Also PostgreSQL has yet another way

        if ($limit > 0)
        {
            $query .= ' LIMIT ' . $limit;
        }

        if ($offset > 0)
        {
            $query .= ' OFFSET ' . $offset;
        }

So there is not really a standard anyway 😄

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is probably dependent on the database type on how to handle these values.

{
return $query;
}

$start = $offset + 1;
$end = $offset + $limit;

Expand Down