tv42 opened a new issue, #1761:
URL: https://github.com/apache/datafusion-sqlparser-rs/issues/1761

   
https://docs.rs/sqlparser/0.55.0/sqlparser/ast/enum.ColumnOption.html#variant.ForeignKey
   
   says
   
   > A referential integrity constraint (`[FOREIGN KEY REFERENCES 
<foreign_table> (<referred_columns>) { [ON DELETE <referential_action>] [ON 
UPDATE <referential_action>] |   [ON UPDATE <referential_action>] [ON DELETE 
<referential_action>] } [<constraint_characteristics>]`).
   
   I believe the `FOREIGN KEY (name) REFERENCES` syntax is only for table 
constraints. That's why it has to say which source columns it talks about!
   
   I believe the syntax for column constraints is just `col_name REFERENCES 
othertable (othercolumn)`.
   
   As far as I can tell, the sqlparser-rs is already correct. For example, this 
won't parse:
   
   ```sql
   -- wrong
   CREATE TABLE myschema.mytable (
     mycolumn BIGINT NOT NULL,
     PRIMARY KEY(mycolumn),
     bar BIGINT FOREIGN KEY REFERENCES foo (bar));
   ```
   
   This does:
   
   ```sql
   -- good
   CREATE TABLE myschema.mytable (
     mycolumn BIGINT NOT NULL,
     PRIMARY KEY(mycolumn),
     bar BIGINT REFERENCES foo (bar));
   ```
   
   While we're at it, that big syntax literal should live in its own paragraph.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org
For additional commands, e-mail: github-h...@datafusion.apache.org

Reply via email to