SQL Formatting : Join with parentheses not formatted

in : Editor > Code Style > SQL,  I enable New line before "Join expression" and disable it for "Join Condition", this seems to work when I'm writing my View SQL for the first time , but when I try to edit it MySQL decompile it and add a lot of parentheses and the formatting stops working.

could you please make it work also with parentheses added ?

3 comments
Avatar
Vladimir Luchansky
Comment actions Permalink

Hello,

Could you share a code sample that would help to reproduce the issue please?

0
Comment actions Permalink

# please see the code below

CREATE TABLE table1 (
id1 INT,
val1 VARCHAR(255),
date1 TIMESTAMP
);


CREATE TABLE table2 (
id2 INT,
val2 VARCHAR(255),
date2 TIMESTAMP
);


CREATE TABLE table3 (
id3 INT,
val3 VARCHAR(255),
date3 TIMESTAMP
);
# after formatting the view is like :
CREATE VIEW view1 AS
SELECT
t1.*
FROM table1 t1 LEFT JOIN table2 t2 ON t1.id1 = t2.id2
LEFT JOIN table3 t3 ON t3.id3 = t1.id1
LEFT JOIN table1 t11 ON t11.id1 = t1.id1;

#to edit the view
SHOW CREATE VIEW view1;

# after formatting I get :
CREATE ALGORITHM = UNDEFINED
DEFINER =`root`@`%`
SQL SECURITY DEFINER VIEW `view1` AS
SELECT
`t1`.`id1` AS `id1`,
`t1`.`val1` AS `val1`,
`t1`.`date1` AS `date1`
FROM (((`table1` `t1` LEFT JOIN `table2` `t2` ON ((`t1`.`id1` = `t2`.`id2`))) LEFT JOIN `table3` `t3`
ON ((`t3`.`id3` = `t1`.`id1`))) LEFT JOIN `table1` `t11` ON ((`t11`.`id1` = `t1`.`id1`)))
# no new line befor Left join

0
Avatar
Vladimir Luchansky
Comment actions Permalink

Thanks! Looks like this part has been reworked for upcoming 2018.2 version. Could you, please, download and install the latest Early Access Program build from Toolbox app (https://www.jetbrains.com/toolbox/app/) or from https://www.jetbrains.com/phpstorm/eap/ and check if the described issues are still present there?

0

Please sign in to leave a comment.