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
Conversation
According to me the issue is that the limit is applied while there is no need:
This is independent of MSSQL, it applies to MySQL and PostgreSQL as well. Don't mind that the function returns when both are not set. But that doesn't stop the errors on #__session deleting 1 row ! As explained in #4869 the update from J336 when set to test fails. |
I'm not aware of any issues like this in MySQL and PostgreSQL. And judging from code, there should be any issues since they have a similar check already in their
That may be a different issue. I don't know how you have to apply limits to a DELETE on MSSQL. Maybe the |
I thought the purpose of Joomla was to be independent of RDBMS. That means you need to do the right thing for all, not just one!. Calling routines when they shouldn't is still wrong. It doesn't make it right when it doesn't give problems in certain situations. Just because PHP and MySQL allows sloppy programming, it doesn't means you should do it! |
Just to be clear: This PR just adds a behavior to MSSQL which is already present in PostgreSQL and MySQL query classes. |
finnaly this bug gonna get fixed. |
@@ -260,6 +260,11 @@ public function dateAdd($date, $interval, $datePart) | |||
*/ | |||
public function processLimit($query, $limit, $offset = 0) | |||
{ | |||
if (!$limit && !$offset) |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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 😄
There was a problem hiding this comment.
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.
Closing as fixed with #5293 |
Issue
Currently, MSSQL creates an error for each database query where no limit is set. Like for inserts, updates and the like.
See #3602 and #4869 for the issue reports.
Solution
Add a check to the sqlsrv query class in the
processLimit()
method. Similar to what we already do in MySQL and PostgreSQL.Testing
@sovainfo can you explain how to reproduce the issue? As far as I understood one sees that on first page after updating?