apache / apache/datafusion-sqlparser-rs
docs: ColumnOption::ForeignKey docs have wrong SQL syntax
- 主要语言
- Rust
- 星标
- 3.5k
- 派生
- 772
- 平均合并
- 4 天 9 小时
- 30 天内合并 PR
- 17
描述
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.
贡献指南
这个仓库没有索引到贡献指南
调研方向
打开链接的 docs.rs 页面,并在仓库源代码中找到 ColumnOption::ForeignKey 的文档。根据 issue 中的示例验证列约束语法,然后修正语法描述,并将较大的语法字面量单独放在一个段落中。当生成的文档描述的是不带表约束 FOREIGN KEY 前缀的有效列语法时,即表示完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- rust
- 领域
- documentation
- Issue 类型
- 文档
- 难度
- 1/5
- 预计耗时
- 1 小时以内
- 活跃度
- 停滞
- 描述清晰度
- 描述清楚
- 新手友好度
- 72/100