抑制/消除嵌套选择的 datagrip sql 重新格式化

问题描述 投票:0回答:2

在 datagrip 的 SQL 编辑器中,如果我从 sql 开始,选择像

select 
col1,
col2,
col3 
from table1

然后将其放在嵌套选择上下文中的括号中,它会重置我的所有行,即:

select
t1.*
from (
  select col1
    , col2
    , col3
  from table1
) t1

我非常讨厌这个。 我希望它的行为类似于:

select
t1.*
from 
(
select 
col1
,col2
,col3
from table1
) t1

区别在于它不会为嵌套选择重新分配行和缩进。 --我自己可以搞定。

有谁知道如何关闭嵌套选择的换行/缩进行为? 我已经搞乱了 DG 的偏好对话有一段时间了,但没有效果。 感谢您的建议!

sql datagrip nested-select
2个回答
0
投票

您可以禁用代码格式。

  • 转到文件 > 设置 > 编辑器 > 代码样式
  • 检查设置窗口底部的禁用格式设置选项。

enter image description here


0
投票

我也遇到过同样烦人的行为;我发现 DataGrip 格式化仅在子选择最后一行下的行上输入右括号时才会触发。
这是可以避免的:

SELECT t.* FROM (
SELECT
col1,
col2,
col3
FROM table1 -- > If I input the ")" at the end of the line here, no formatting occurs. */
/* If I input the ")" here (so after hitting "enter" to create a new line), formatting occurs. */

这是一种烦人的解决方法,但在我习惯之后,它对我来说效果很好。

© www.soinside.com 2019 - 2024. All rights reserved.