Open marwan38 opened 2 weeks ago
You say this is a regression - what is the latest version you saw this working in?
You say this is a regression - what is the latest version you saw this working in?
We're on version 4.13.42 of the framework I believe. Upgrading straight to 5.2
@marwan38 the example SQL ($sql = SQLSelect::create('*', '( SELECT DISTINCT "SiteTree"."ClassName" FROM "SiteTree" ) as FINAL');
) is the same in both how to reproduce and possible solution. It won't fix the issue, but maybe will give more context on what you found out so far. Perhaps should be different?
@michalkleiner
It's mentioned just above the example,.. my mistake I've updated it. An important note right below is that it's not exactly a "possible solution" but rather something I discovered which may help debug the issue.
I'm going to move that into the "additional context" section then - since that's what you're saying it is.
Module version(s) affected
5
Description
Regression within the SQLSelect class causes sub queries to be duplicated. This can be very easily reproduced in a blank silverstripe project.
How to reproduce
The regression itself:
Creating the select statement
Output
Note that the subquery is being duplicated.
Possible Solution
no response
Additional Context
I noticed that the issue cannot be reproduced when double quotations (") are left out of the query. Following the same reproduction steps WITHOUT the double quotations results in the correct output:
Output
The reproduction code is an MVP, our actual use case is a little bit more complex with additional where statements, and froms. This worked just fine in silverstripe v4. A closer reproduction would be something like
Output (Note the duplication after the aliasing "AS FINAL AS "...."):
Changing the alias to be resolved as the array index, like
resolves the same way.
Validations
silverstripe/installer
(with any code examples you've provided)