DBZ-5390 Reorder relational_property definition to give priority to out_of_line_constraint

This commit is contained in:
Anisha Mohanty 2022-07-13 12:42:22 +05:30 committed by Jiri Pechanec
parent 2b78f6cfeb
commit 04941330c3
3 changed files with 28 additions and 3 deletions

View File

@ -417,6 +417,23 @@ public void shouldParseAlterTableWithoutDatatypeContextClause() throws Exception
assertThat(table.columnWithName("NAME").defaultValueExpression()).isEqualTo(Optional.of("NULL"));
}
@Test
@FixFor("DBZ-5390")
public void shouldParseCheckConstraint() throws Exception {
parser.setCurrentDatabase(PDB_NAME);
parser.setCurrentSchema("SCOTT");
String SQL = "CREATE TABLE \"SCOTT\".\"ASTERISK_TEST\" ( \"PID\" int, \"DEPT\" varchar(50), constraint \"CK_DEPT\" check(\"DEPT\" IN('IT','sales','manager')))";
parser.parse(SQL, tables);
DdlChanges changes = parser.getDdlChanges();
List<DdlParserListener.EventType> eventTypes = getEventTypesFromChanges(changes);
assertThat(eventTypes).containsExactly(DdlParserListener.EventType.CREATE_TABLE);
Table table = tables.forTable(new TableId(PDB_NAME, "SCOTT", "ASTERISK_TEST"));
assertThat(table.columns().size()).isEqualTo(2);
}
private List<DdlParserListener.EventType> getEventTypesFromChanges(DdlChanges changes) {
List<DdlParserListener.EventType> eventTypes = new ArrayList<>();
changes.getEventsByDatabase((String dbName, List<DdlParserListener.Event> events) -> {

View File

@ -1855,10 +1855,10 @@ relational_table
;
relational_property
: (column_definition
| virtual_column_definition
| out_of_line_constraint
: ( out_of_line_constraint
| out_of_line_ref_constraint
| column_definition
| virtual_column_definition
| supplemental_logging_props
)
;

View File

@ -250,6 +250,14 @@ CREATE TABLE "APPLSYS"."FND_SEC_GUIDELINES_TL"
STORAGE(INITIAL 4096 NEXT 131072 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 4 FREELIST GROUPS 4 BUFFER_POOL DEFAULT))
;
CREATE TABLE "t_ddl_0027"(
"PID" INT,
"FID" INT,
"NAME" VARCHAR(50) DEFAULT 'Tom',
"ADDRESS" VARCHAR(50) NOT NULL,
"DEPT" VARCHAR(50),
CONSTRAINT "PK_ID" PRIMARY KEY("PID"),
CONSTRAINT "CK_DEPT" CHECK ("DEPT" IN('IT', 'SALES', 'MANAGER')));
-- Create index
create index hr.name on hr.table (id,data) tablespace ts;
create unique index idx_eshp_auction_file_history_id on eshp_auction_file_history(history_id);