mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-07-07 17:04:59 +00:00
Document round trip ability (#1052)
This commit is contained in:
parent
86aa044032
commit
64eccdbba2
3 changed files with 46 additions and 1 deletions
22
README.md
22
README.md
|
@ -59,6 +59,28 @@ This crate avoids semantic analysis because it varies drastically
|
|||
between dialects and implementations. If you want to do semantic
|
||||
analysis, feel free to use this project as a base.
|
||||
|
||||
## Preserves Syntax Round Trip
|
||||
|
||||
This crate allows users to recover the original SQL text (with normalized
|
||||
whitespace and keyword capitalization), which is useful for tools that
|
||||
analyze and manipulate SQL.
|
||||
|
||||
This means that other than whitespace and the capitalization of keywords, the
|
||||
following should hold true for all SQL:
|
||||
|
||||
```rust
|
||||
// Parse SQL
|
||||
let ast = Parser::parse_sql(&GenericDialect, sql).unwrap();
|
||||
|
||||
// The original SQL text can be generated from the AST
|
||||
assert_eq!(ast[0].to_string(), sql);
|
||||
```
|
||||
|
||||
There are still some cases in this crate where different SQL with seemingly
|
||||
similar semantics are represented with the same AST. We welcome PRs to fix such
|
||||
issues and distinguish different syntaxes in the AST.
|
||||
|
||||
|
||||
## SQL compliance
|
||||
|
||||
SQL was first standardized in 1987, and revisions of the standard have been
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue