Skip to content
This repository was archived by the owner on Aug 30, 2024. It is now read-only.

Commit 03ed54c

Browse files
Merge pull request #272 from Trivadis/bugfix/issue-265-wrong-indent
Bugfix/issue 265 wrong indent
2 parents 9cbe54e + 4be8994 commit 03ed54c

3 files changed

Lines changed: 80 additions & 4 deletions

File tree

settings/sql_developer/trivadis_custom_format.arbori

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3406,7 +3406,7 @@ r7_single_table_insert:
34063406
| [keyword) 'RETURNING'
34073407
| [keyword) 'LOG'
34083408
| [keyword) 'REJECT'
3409-
| [keyword) 'SELECT' & ![keyword^^-1) '(' & ![keyword^^^-1) '('
3409+
| [keyword) 'SELECT' & ![keyword^^-1) '(' & ![keyword^^^-1) '(' & ![keyword^^^^-1) '('
34103410
)
34113411
& insert < keyword
34123412
& parent < insert

standalone/src/test/java/com/trivadis/plsql/formatter/settings/tests/issues/Issue_264_exit_in_whenever_oserror.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,10 @@
44
import org.junit.jupiter.api.Test;
55
import org.junit.jupiter.api.TestInstance;
66

7-
import java.io.IOException;
8-
97
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
108
public class Issue_264_exit_in_whenever_oserror extends ConfiguredTestFormatter {
119
@Test
12-
public void exit_in_whenever_os_error() throws IOException {
10+
public void exit_in_whenever_os_error() {
1311
var input = """
1412
whenever sqlerror exit failure
1513
whenever oserror exit failure
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
package com.trivadis.plsql.formatter.settings.tests.issues;
2+
3+
import com.trivadis.plsql.formatter.settings.ConfiguredTestFormatter;
4+
import org.junit.jupiter.api.Test;
5+
import org.junit.jupiter.api.TestInstance;
6+
7+
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
8+
public class Issue_265_wrong_indent_in_insert extends ConfiguredTestFormatter {
9+
@Test
10+
public void insert_from_subquery() {
11+
var input = """
12+
insert into t1
13+
select object_type, count(*)
14+
from (
15+
select 'table' as object_type, table_name as object_name
16+
from user_tables
17+
union all
18+
select 'view', view_name
19+
from user_views
20+
union all
21+
select 'sequence', sequence_name
22+
from user_sequences
23+
)
24+
group by object_type;
25+
""";
26+
formatAndAssert(input);
27+
}
28+
29+
@Test
30+
public void insert_from_with_clause() {
31+
var input = """
32+
insert into t2
33+
with
34+
objects as (
35+
select 'table' as object_type, table_name as object_name
36+
from user_tables
37+
union all
38+
select 'view', view_name
39+
from user_views
40+
union all
41+
select 'sequence', sequence_name
42+
from user_sequences
43+
)
44+
select object_type, count(*)
45+
from objects
46+
group by object_type;
47+
/
48+
""";
49+
formatAndAssert(input);
50+
}
51+
52+
@Test
53+
public void insert_from_with_clause_with_subquery() {
54+
var input = """
55+
insert into t3
56+
with
57+
combined as (
58+
select object_type, count(*)
59+
from (
60+
select 'table' as object_type, table_name as object_name
61+
from user_tables
62+
union all
63+
select 'view', view_name
64+
from user_views
65+
union all
66+
select 'sequence', sequence_name
67+
from user_sequences
68+
)
69+
group by object_type
70+
)
71+
select *
72+
from combined;
73+
/
74+
""";
75+
formatAndAssert(input);
76+
}
77+
78+
}

0 commit comments

Comments
 (0)