未验证 提交 4146dc32 编写于 作者: S Serge Rider 提交者: GitHub

Merge pull request #11968 from dbeaver/conditionIndentTest#11063

#11063 add test case for conditions formatting
......@@ -265,6 +265,29 @@ public class SQLFormatterTokenizedTest {
assertEquals(expectedString, formattedString);
}
@Test
public void shouldDoDefaultFormatForStatementWidthManyConditionsAndAddIndentForFirstConditionInExpressionInsideBrackets() {
//given
String inputString = "SELECT * FROM table_name WHERE lname = 'Ivanov' AND (fname = 'Ivan' OR fname = 'Alex' OR fname = 'Ted' OR (1 = 1 AND 2 = 2));"; //#11063
String expectedString = "SELECT" + lineBreak +
"\t*" + lineBreak +
"FROM" + lineBreak +
"\ttable_name" + lineBreak +
"WHERE" + lineBreak +
"\tlname = 'Ivanov'" + lineBreak +
"\tAND (fname = 'Ivan'" + lineBreak +
"\t\tOR fname = 'Alex'" + lineBreak +
"\t\tOR fname = 'Ted'" + lineBreak +
"\t\tOR (1 = 1" + lineBreak +
"\t\t\tAND 2 = 2));";
//when
String formattedString = formatter.format(inputString, configuration);
//then
assertEquals(expectedString, formattedString);
}
private String getExpectedStringWithLineBreakBeforeBraces() {
StringBuilder sb = new StringBuilder();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册