thecodingmachine / magic-query

A very clever library to use SQL prepared statement with a variable number of parameters... and much more!
http://mouf-php.com/packages/mouf/magic-query/README.md
22 stars 14 forks source link

Issue with comma with multi FROM #76

Open ReynaldBarbeaut opened 3 years ago

ReynaldBarbeaut commented 3 years ago

Hello,

We have this example:

SELECT COUNT(B.*) FROM (SELECT tags.id FROM tags,
            (SELECT t.* FROM tags t WHERE t.id IN (0,1,2)) as childTag
            WHERE tags.lft < childTag.lft AND tags.rgt > childTag.rgt AND tags.depth = 2) as B

So we see that we are using 2 tables in the FROM and after MagicQuery it's removing the comma. Response from MQ:

SELECT 
  COUNT(  `B`.*)
FROM   (SELECT 
    `tags`.`id`
FROM     `tags`     (SELECT 
      `t`.*
FROM       `tags` `t`
WHERE             `t`.`id` IN       (      0,      1,      2)) `childTag`
WHERE     (        `tags`.`lft` <     `childTag`.`lft`)
    AND (        `tags`.`rgt` >     `childTag`.`rgt`)
    AND (        `tags`.`depth` =     2)) `B`

Do you have any solution ? Thank you.