babelfish-for-postgresql / babelfish_compass

Babelfish Compass: compatibility assessment tool for Babelfish for PostgreSQL
Apache License 2.0
108 stars 21 forks source link

Fix column_constraint parser rule for accepting empty column list #32

Closed 3manuek closed 2 years ago

3manuek commented 2 years ago

Description

SQL Server DDL definition accepts the following pattern:

REFERENCES referenced_table_name [ ( ref_column ) ]

There is a related babelfish_extensions' issue and it has a pending PR.

Proposed patch:

diff --git a/src/main/parser/TSQLParser.g4 b/src/main/parser/TSQLParser.g4
index b2fa036..741e06b 100644
--- a/src/main/parser/TSQLParser.g4
+++ b/src/main/parser/TSQLParser.g4
@@ -3225,7 +3225,7 @@ column_constraint
     :(CONSTRAINT constraint=id)?
       ((PRIMARY KEY | UNIQUE) clustered? with_index_options?
       | CHECK for_replication? LR_BRACKET search_condition RR_BRACKET
-      | (FOREIGN KEY)? REFERENCES table_name LR_BRACKET pk = column_name_list RR_BRACKET (on_update | on_delete)*  for_replication?
+      | (FOREIGN KEY)? REFERENCES table_name (LR_BRACKET pk = column_name_list RR_BRACKET)? (on_update | on_delete)*  for_replication?
       | DEFAULT expression
       | null_notnull
       | WITH VALUES 
3manuek commented 2 years ago

@nasbyj -- could you grant me access to create/push branches and Issue Management?

robverschoor commented 2 years ago

This fix is already scheduled to be included for the next release of Compass