You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Selecting data by the Select-Class and AbstractTableGateway::selectWith returns data like you didn't use DISTINCT.
Current behavior
I have a query which performs differently on MySQL and MSSQL. When executing the query on MySQL, everything works as expected, but for MSSQL, it behaves as if I didn't enter the DISTINCT keyword.
How to reproduce
Here is my Select I'm building, with the input parameter $userid
When I output the query with $select->getSqlString($this->surveySetTable->getAdapter()->getPlatform()), this looks fine. The query also works correctly on both SQL versions when I copy it:
For MSSQL this is:
SELECT DISTINCT [survey_set].[id] AS [id], [survey_set].[name] AS [name]
FROM [survey_set]
INNER JOIN [survey] AS [s] ON [s].[survey_set_id] = [id]
INNER JOIN [course] AS [c] ON [c].[courseid] = [s].[courseid]
INNER JOIN [subunit_to_admin] AS [sta] ON [sta].[subunitid] = [c].[subunitid]
WHERE [sta].[userid] = '210'
And for MySQL it is:
SELECT DISTINCT `survey_set`.`id` AS `id`, `survey_set`.`name` AS `name`
FROM `survey_set`
INNER JOIN `survey` AS `s` ON `s`.`survey_set_id` = `id`
INNER JOIN `course` AS `c` ON `c`.`courseid` = `s`.`courseid`
INNER JOIN `subunit_to_admin` AS `sta` ON `sta`.`subunitid` = `c`.`subunitid`
WHERE `sta`.`userid` = '210'
The relation survey_set to survey is 0..1 to 1..n. So a survey_set can be in multiple survey entries. Some surveys can be in no set (they are null then). The other joins might not be relevant, I guess any 1..n relation would bring a similar result.
For MSSQL, I have 9 sets in 69 surveys and I get 69 results instead of 9, which I get when I execeute the query manually in MSSQL.
For MySQL, I got 23 sets in 189 surveys and I got 23 results, which is the same as the SQL query gives me.
Based on the SQL-String, you can also tell that the select does consider and receive this value, but it seems to be ignored at execution. This also make me think that I am not using it wrong.
Expected behavior
I want the result of "selectWith($select)" to be the same as the DB-query that the $select-Query returns.
The text was updated successfully, but these errors were encountered:
Bug Report
Summary
Selecting data by the
Select
-Class andAbstractTableGateway::selectWith
returns data like you didn't use DISTINCT.Current behavior
I have a query which performs differently on MySQL and MSSQL. When executing the query on MySQL, everything works as expected, but for MSSQL, it behaves as if I didn't enter the DISTINCT keyword.
How to reproduce
Here is my Select I'm building, with the input parameter
$userid
When I output the query with
$select->getSqlString($this->surveySetTable->getAdapter()->getPlatform())
, this looks fine. The query also works correctly on both SQL versions when I copy it:For MSSQL this is:
And for MySQL it is:
The relation survey_set to survey is 0..1 to 1..n. So a survey_set can be in multiple survey entries. Some surveys can be in no set (they are null then). The other joins might not be relevant, I guess any 1..n relation would bring a similar result.
For MSSQL, I have 9 sets in 69 surveys and I get 69 results instead of 9, which I get when I execeute the query manually in MSSQL.
For MySQL, I got 23 sets in 189 surveys and I got 23 results, which is the same as the SQL query gives me.
Based on the SQL-String, you can also tell that the select does consider and receive this value, but it seems to be ignored at execution. This also make me think that I am not using it wrong.
Expected behavior
I want the result of "selectWith($select)" to be the same as the DB-query that the $select-Query returns.
The text was updated successfully, but these errors were encountered: