 |
SoftTree Technologies
Technical Support Forums
|
|
Author |
Message |
gemisigo
Joined: 11 Mar 2010 Posts: 2165
|
|
[11.3.279 Pro] - Formatting anomaly (MariaDB) |
|
I've got the following tables for example:
 |
 |
CREATE TABLE `table_with_arbitrarily_long_name`(
`id` int
,`column_1` int
,`column_2` int
,`column_3` int);
CREATE TABLE `another_table_with_arbitrarily_long_name`(
`id` int
,`id_a` int
,`column_1` int
,`column_2` int
,`column_3` int);
|
Using those two tables and the formatting rule for SELECT statements
 |
 |
SELECT ... AS ...
,... = ...
INTO ...
,...
FROM ... AS ...
,...
JOIN ...
ON ... = ...
AND ...
WHERE ... = ...
AND ...
OR ...
GROUP BY ...
,...
HAVING ...
,...
ORDER BY ...
,...
LIMIT ...;
|
I formatted this statement below:
 |
 |
SELECT a.`column_1` AS c1, a.`column_2` AS c2, a.`column_3` AS c3
FROM `table_with_arbitrarily_long_name` AS a INNER JOIN `another_table_with_arbitrarily_long_name` AS b ON b.`id_a` = a.`id`;
|
The result was exactly as expected, the different parts of the statement, including the aliases aligned properly.
 |
 |
SELECT a.`column_1` AS c1
,a.`column_2` AS c2
,a.`column_3` AS c3
FROM `table_with_arbitrarily_long_name` AS a
INNER JOIN `another_table_with_arbitrarily_long_name` AS b
ON b.`id_a` = a.`id`;
|
But when I throw an additional INTO part into the party (puntended), the alias alignment suddenly falls apart and this
 |
 |
SELECT a.`column_1` AS c1, a.`column_2` AS c2, a.`column_3` AS c3
INTO @a ,@b ,@c
FROM `table_with_arbitrarily_long_name` AS a INNER JOIN `another_table_with_arbitrarily_long_name` AS b ON b.`id_a` = a.`id`;
|
becomes this
 |
 |
SELECT a.`column_1` AS c1
,a.`column_2` AS c2
,a.`column_3` AS c3
INTO @a
,@b
,@c
FROM `table_with_arbitrarily_long_name` AS a
INNER JOIN `another_table_with_arbitrarily_long_name` AS b
ON b.`id_a` = a.`id`;
|
The aliases for the columns are still aligned, though only among themselves. Furthermore, they are unnecessary anyway and can be removed. But the aliases for the tables no longer align, neither with the aliases for the columns, nor with each other.
|
|
Thu Sep 24, 2020 8:48 am |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7948
|
|
|
|
Do you have separate formatting rules for INTO or INSERT INTO or something similar? Is INTO clause referenced in the formatting rule for SELECT? It looks like the formatter assumes based on the keyword pattern that there are 2 statements not one, that INTO clause is part of a next statement.
|
|
Sun Sep 27, 2020 8:53 am |
|
 |
gemisigo
Joined: 11 Mar 2010 Posts: 2165
|
|
|
|
No, I haven't got any formatting rules for INTO and the one for INSERT is very simple (without including keyword INTO):
 |
 |
INSERT ...(..., ...)
|
The INTO clause is indeed referenced in the formatting rule for SELECT (see code example #2 line 3 in the first post). Furthermore, as all the lines below the SELECT statement are indented as the formatting rule says they should be. I guess if SA thought INTO was a separate statement, it would be at the same indentation level as the SELECT statement was.
|
|
Sun Sep 27, 2020 4:53 pm |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7948
|
|
|
|
I'm sorry I'm unable to suggest how to fix that. I've tried a couple of things but they unfortunately don't help. I'm going to log support case to get some assistance with this issue.
|
|
Mon Sep 28, 2020 2:05 am |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|