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

Commit

Permalink
Merge pull request #128 from Trivadis/feature/issue-126-view-column-list
Browse files Browse the repository at this point in the history
Feature/issue 126 view column list
  • Loading branch information
PhilippSalvisberg authored Aug 1, 2021
2 parents 5766092 + 560604a commit 90b89b6
Show file tree
Hide file tree
Showing 2 changed files with 191 additions and 0 deletions.
8 changes: 8 additions & 0 deletions settings/sql_developer/trivadis_custom_format_phase2.arbori
Original file line number Diff line number Diff line change
Expand Up @@ -740,6 +740,7 @@ a15_various:
| [node) subquery & [node^) multi_table_insert
| [node) prm_spec & [node-1) ','
| [node) subprg_property
| [node) ')' & [node^) create_view#[114,130)
;

a15_is_or_as:
Expand All @@ -749,9 +750,16 @@ a15_is_or_as:
& node-1 = prop^
;

a15_view_column_alias:
[parent) create_view#[114,130)
& [node) alias_in_out_constraints
& parent < node
;

a15_line_break_before:
a15_various
| a15_is_or_as
| a15_view_column_alias
-> {
var node = tuple.get("node");
if (getIndent(node.from).indexOf("\n") == -1) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
package com.trivadis.plsql.formatter.settings.tests.issues;

import com.trivadis.plsql.formatter.settings.ConfiguredTestFormatter;
import oracle.dbtools.app.Format;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import java.io.IOException;

public class Issue_126_create_view_column_list extends ConfiguredTestFormatter {

@BeforeEach
public void setup() {
getFormatter().options.put("identSpaces", 2);
getFormatter().options.put("idCase", Format.Case.lower);
}

@Test
public void dbms_metadata_view() throws IOException {
getFormatter().options.put(getFormatter().spaceAfterCommas, false);
var input = """
CREATE OR REPLACE FORCE EDITIONABLE VIEW "COVID_COVPN"."DUAL_V" ("DUMMY1", "DUMMY2", "DUMMY3", "DUMMY4", "DUMMY5", "DUMMY6", "DUMMY7", "DUMMY8", "DUMMY9", "DUMMY10", "DUMMY11", "DUMMY12", "DUMMY13", "DUMMY14", "DUMMY15", "DUMMY16", "DUMMY17", "DUMMY18", "DUMMY19", "DUMMY20", "DUMMY21", "DUMMY22", "DUMMY23", "DUMMY24", "DUMMY25", "DUMMY26", "DUMMY27", "DUMMY28", "DUMMY29", "DUMMY30", "DUMMY31", "DUMMY32", "DUMMY33", "DUMMY34", "DUMMY35", "DUMMY36", "DUMMY37", "DUMMY38", "DUMMY39", "DUMMY40", "DUMMY41", "DUMMY42", "DUMMY43", "DUMMY44", "DUMMY45", "DUMMY46", "DUMMY47", "DUMMY48", "DUMMY49", "DUMMY50") AS\s
select dummy dummy1,
dummy dummy2,
dummy dummy3,
dummy dummy4,
dummy dummy5,
dummy dummy6,
dummy dummy7,
dummy dummy8,
dummy dummy9,
dummy dummy10,
dummy dummy11,
dummy dummy12,
dummy dummy13,
dummy dummy14,
dummy dummy15,
dummy dummy16,
dummy dummy17,
dummy dummy18,
dummy dummy19,
dummy dummy20,
dummy dummy21,
dummy dummy22,
dummy dummy23,
dummy dummy24,
dummy dummy25,
dummy dummy26,
dummy dummy27,
dummy dummy28,
dummy dummy29,
dummy dummy30,
dummy dummy31,
dummy dummy32,
dummy dummy33,
dummy dummy34,
dummy dummy35,
dummy dummy36,
dummy dummy37,
dummy dummy38,
dummy dummy39,
dummy dummy40,
dummy dummy41,
dummy dummy42,
dummy dummy43,
dummy dummy44,
dummy dummy45,
dummy dummy46,
dummy dummy47,
dummy dummy48,
dummy dummy49,
dummy dummy50
from dual;
""";
var expected = """
create or replace force editionable view "COVID_COVPN"."DUAL_V" (
"DUMMY1",
"DUMMY2",
"DUMMY3",
"DUMMY4",
"DUMMY5",
"DUMMY6",
"DUMMY7",
"DUMMY8",
"DUMMY9",
"DUMMY10",
"DUMMY11",
"DUMMY12",
"DUMMY13",
"DUMMY14",
"DUMMY15",
"DUMMY16",
"DUMMY17",
"DUMMY18",
"DUMMY19",
"DUMMY20",
"DUMMY21",
"DUMMY22",
"DUMMY23",
"DUMMY24",
"DUMMY25",
"DUMMY26",
"DUMMY27",
"DUMMY28",
"DUMMY29",
"DUMMY30",
"DUMMY31",
"DUMMY32",
"DUMMY33",
"DUMMY34",
"DUMMY35",
"DUMMY36",
"DUMMY37",
"DUMMY38",
"DUMMY39",
"DUMMY40",
"DUMMY41",
"DUMMY42",
"DUMMY43",
"DUMMY44",
"DUMMY45",
"DUMMY46",
"DUMMY47",
"DUMMY48",
"DUMMY49",
"DUMMY50"
) as
select dummy dummy1,
dummy dummy2,
dummy dummy3,
dummy dummy4,
dummy dummy5,
dummy dummy6,
dummy dummy7,
dummy dummy8,
dummy dummy9,
dummy dummy10,
dummy dummy11,
dummy dummy12,
dummy dummy13,
dummy dummy14,
dummy dummy15,
dummy dummy16,
dummy dummy17,
dummy dummy18,
dummy dummy19,
dummy dummy20,
dummy dummy21,
dummy dummy22,
dummy dummy23,
dummy dummy24,
dummy dummy25,
dummy dummy26,
dummy dummy27,
dummy dummy28,
dummy dummy29,
dummy dummy30,
dummy dummy31,
dummy dummy32,
dummy dummy33,
dummy dummy34,
dummy dummy35,
dummy dummy36,
dummy dummy37,
dummy dummy38,
dummy dummy39,
dummy dummy40,
dummy dummy41,
dummy dummy42,
dummy dummy43,
dummy dummy44,
dummy dummy45,
dummy dummy46,
dummy dummy47,
dummy dummy48,
dummy dummy49,
dummy dummy50
from dual;
""";
var actual = formatter.format(input);
assertEquals(expected, actual);
}
}

0 comments on commit 90b89b6

Please sign in to comment.