apache / apache/datafusion-sqlparser-rs
docs: ColumnOption::ForeignKey docs have wrong SQL syntax
- Dominant language
- Rust
- Stars
- 3.5k
- Forks
- 772
- Avg merge
- 4d 9h
- Merged PRs (30d)
- 17
Description
https://docs.rs/sqlparser/0.55.0/sqlparser/ast/enum.ColumnOption.html#variant.ForeignKey
says
> A referential integrity constraint (`[FOREIGN KEY REFERENCES () { [ON DELETE ] [ON UPDATE ] | [ON UPDATE ] [ON DELETE ] } []`).
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.
Contributor guide
No contributing guide indexed for this repository
Research direction
Open the linked docs.rs page and locate the ColumnOption::ForeignKey documentation in the repository source. Verify the column-constraint syntax against the examples in the issue, then correct the syntax description and place the large syntax literal in its own paragraph. Done means the generated documentation describes valid column syntax without the table-constraint FOREIGN KEY prefix.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 72/100