You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "tv42 (via GitHub)" <gi...@apache.org> on 2025/03/10 02:14:42 UTC

[I] docs: ColumnOption::ForeignKey docs have wrong SQL syntax [datafusion-sqlparser-rs]

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-unsubscribe@datafusion.apache.org.apache.org

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


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


Re: [I] docs: ColumnOption::ForeignKey docs have wrong SQL syntax [datafusion-sqlparser-rs]

Posted by "LucaCappelletti94 (via GitHub)" <gi...@apache.org>.
LucaCappelletti94 commented on issue #1761:
URL: https://github.com/apache/datafusion-sqlparser-rs/issues/1761#issuecomment-5792208925

   Completed by #2062.


-- 
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-unsubscribe@datafusion.apache.org

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


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


Re: [I] docs: ColumnOption::ForeignKey docs have wrong SQL syntax [datafusion-sqlparser-rs]

Posted by "LucaCappelletti94 (via GitHub)" <gi...@apache.org>.
LucaCappelletti94 closed issue #1761: docs: ColumnOption::ForeignKey docs have wrong SQL syntax
URL: https://github.com/apache/datafusion-sqlparser-rs/issues/1761


-- 
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-unsubscribe@datafusion.apache.org

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


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