Skip to content

Commit b653859

Browse files
authored
Merge pull request #126 from nickolay/pr/renames-comments
Update comments after the renaming done in PR #105
2 parents cdba436 + 7d4b488 commit b653859

File tree

8 files changed

+26
-26
lines changed

8 files changed

+26
-26
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,17 @@ let sql = "SELECT a, b, 123, myfunc(b) \
2020
WHERE a > b AND b < 100 \
2121
ORDER BY a DESC, b";
2222

23-
let dialect = GenericSqlDialect{}; // or AnsiSqlDialect, or your own dialect ...
23+
let dialect = GenericDialect {}; // or AnsiDialect, or your own dialect ...
2424

25-
let ast = Parser::parse_sql(&dialect,sql.to_string()).unwrap();
25+
let ast = Parser::parse_sql(&dialect, sql.to_string()).unwrap();
2626

2727
println!("AST: {:?}", ast);
2828
```
2929

3030
This outputs
3131

3232
```rust
33-
AST: [SQLSelect(SQLQuery { ctes: [], body: Select(SQLSelect { distinct: false, projection: [UnnamedExpression(SQLIdentifier("a")), UnnamedExpression(SQLIdentifier("b")), UnnamedExpression(SQLValue(Long(123))), UnnamedExpression(SQLFunction { name: SQLObjectName(["myfunc"]), args: [SQLIdentifier("b")], over: None })], relation: Some(Table { name: SQLObjectName(["table_1"]), alias: None }), joins: [], selection: Some(SQLBinaryExpr { left: SQLBinaryExpr { left: SQLIdentifier("a"), op: Gt, right: SQLIdentifier("b") }, op: And, right: SQLBinaryExpr { left: SQLIdentifier("b"), op: Lt, right: SQLValue(Long(100)) } }), group_by: None, having: None }), order_by: Some([SQLOrderByExpr { expr: SQLIdentifier("a"), asc: Some(false) }, SQLOrderByExpr { expr: SQLIdentifier("b"), asc: None }]), limit: None })]
33+
AST: [Query(Query { ctes: [], body: Select(Select { distinct: false, projection: [UnnamedExpr(Identifier("a")), UnnamedExpr(Identifier("b")), UnnamedExpr(Value(Long(123))), UnnamedExpr(Function(Function { name: ObjectName(["myfunc"]), args: [Identifier("b")], over: None, distinct: false }))], from: [TableWithJoins { relation: Table { name: ObjectName(["table_1"]), alias: None, args: [], with_hints: [] }, joins: [] }], selection: Some(BinaryOp { left: BinaryOp { left: Identifier("a"), op: Gt, right: Identifier("b") }, op: And, right: BinaryOp { left: Identifier("b"), op: Lt, right: Value(Long(100)) } }), group_by: [], having: None }), order_by: [OrderByExpr { expr: Identifier("a"), asc: Some(false) }, OrderByExpr { expr: Identifier("b"), asc: None }], limit: None, offset: None, fetch: None })]
3434
```
3535

3636
## Design

src/ast/ddl.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
//! AST types specific to CREATE/ALTER variants of `SQLStatement`
1+
//! AST types specific to CREATE/ALTER variants of [Statement]
22
//! (commonly referred to as Data Definition Language, or DDL)
33
use super::{DataType, Expr, Ident, ObjectName};
44

5-
/// An `ALTER TABLE` (`SQLStatement::SQLAlterTable`) operation
5+
/// An `ALTER TABLE` (`Statement::AlterTable`) operation
66
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
77
pub enum AlterTableOperation {
88
/// `ADD <table_constraint>`

src/ast/mod.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,14 @@ pub enum Expr {
5757
/// Identifier e.g. table name or column name
5858
Identifier(Ident),
5959
/// Unqualified wildcard (`*`). SQL allows this in limited contexts, such as:
60-
/// - right after `SELECT` (which is represented as a [SQLSelectItem::Wildcard] instead)
60+
/// - right after `SELECT` (which is represented as a [SelectItem::Wildcard] instead)
6161
/// - or as part of an aggregate function, e.g. `COUNT(*)`,
6262
///
6363
/// ...but we currently also accept it in contexts where it doesn't make
6464
/// sense, such as `* + *`
6565
Wildcard,
6666
/// Qualified wildcard, e.g. `alias.*` or `schema.table.*`.
67-
/// (Same caveats apply to SQLQualifiedWildcard as to SQLWildcard.)
67+
/// (Same caveats apply to `QualifiedWildcard` as to `Wildcard`.)
6868
QualifiedWildcard(Vec<Ident>),
6969
/// Multi-part identifier, e.g. `table_alias.column` or `schema.table.col`
7070
CompoundIdentifier(Vec<Ident>),
@@ -115,7 +115,7 @@ pub enum Expr {
115115
},
116116
/// Nested expression e.g. `(foo > bar)` or `(1)`
117117
Nested(Box<Expr>),
118-
/// SQLValue
118+
/// A literal value, such as string, number, date or NULL
119119
Value(Value),
120120
/// Scalar function call e.g. `LEFT(foo, 5)`
121121
Function(Function),
@@ -320,12 +320,12 @@ impl FromStr for WindowFrameUnits {
320320

321321
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
322322
pub enum WindowFrameBound {
323-
/// "CURRENT ROW"
323+
/// `CURRENT ROW`
324324
CurrentRow,
325-
/// "<N> PRECEDING" or "UNBOUNDED PRECEDING"
325+
/// `<N> PRECEDING` or `UNBOUNDED PRECEDING`
326326
Preceding(Option<u64>),
327-
/// "<N> FOLLOWING" or "UNBOUNDED FOLLOWING". This can only appear in
328-
/// SQLWindowFrame::end_bound.
327+
/// `<N> FOLLOWING` or `UNBOUNDED FOLLOWING`. This can only appear in
328+
/// [WindowFrame::end_bound].
329329
Following(Option<u64>),
330330
}
331331

@@ -610,7 +610,7 @@ impl ToString for Assignment {
610610
}
611611
}
612612

613-
/// SQL function
613+
/// A function call
614614
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
615615
pub struct Function {
616616
pub name: ObjectName,

src/dialect/keywords.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
///! This module defines
1414
/// 1) a list of constants for every keyword that
15-
/// can appear in SQLWord::keyword:
15+
/// can appear in [Word::keyword]:
1616
/// pub const KEYWORD = "KEYWORD"
1717
/// 2) an `ALL_KEYWORDS` array with every keyword in it
1818
/// This is not a list of *reserved* keywords: some of these can be

src/dialect/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pub trait Dialect: Debug {
2828
/// implementation, accepting "double quoted" ids is both ANSI-compliant
2929
/// and appropriate for most dialects (with the notable exception of
3030
/// MySQL, MS SQL, and sqlite). You can accept one of characters listed
31-
/// in `SQLWord::matching_end_quote()` here
31+
/// in `Word::matching_end_quote` here
3232
fn is_delimited_identifier_start(&self, ch: char) -> bool {
3333
ch == '"'
3434
}

src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@
1414
//!
1515
//! Example code:
1616
//!
17-
//! This crate provides an ANSI:SQL 2011 lexer and parser that can parsed SQL into an Abstract
18-
//! Syntax Tree (AST).
17+
//! This crate provides an ANSI:SQL 2011 lexer and parser that can parse SQL
18+
//! into an Abstract Syntax Tree (AST).
1919
//!
2020
//! ```
2121
//! use sqlparser::dialect::GenericDialect;
2222
//! use sqlparser::parser::Parser;
2323
//!
24-
//! let dialect = GenericDialect {}; // or AnsiSqlDialect
24+
//! let dialect = GenericDialect {}; // or AnsiDialect
2525
//!
2626
//! let sql = "SELECT a, b, 123, myfunc(b) \
2727
//! FROM table_1 \

src/parser.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ impl Parser {
225225
}
226226
_ => Ok(Expr::Identifier(w.as_ident())),
227227
},
228-
}, // End of Token::SQLWord
228+
}, // End of Token::Word
229229
Token::Mult => Ok(Expr::Wildcard),
230230
tok @ Token::Minus | tok @ Token::Plus => {
231231
let op = if tok == Token::Plus {
@@ -1697,7 +1697,7 @@ impl Parser {
16971697
// ^ ^ ^ ^
16981698
// | | | |
16991699
// | | | |
1700-
// | | | (4) belongs to a SQLSetExpr::Query inside the subquery
1700+
// | | | (4) belongs to a SetExpr::Query inside the subquery
17011701
// | | (3) starts a derived table (subquery)
17021702
// | (2) starts a nested join
17031703
// (1) an additional set of parens around a nested join
@@ -1882,7 +1882,7 @@ impl Parser {
18821882
Ok(projections)
18831883
}
18841884

1885-
/// Parse a comma-delimited list of SQL ORDER BY expressions
1885+
/// Parse a comma-delimited list of ORDER BY expressions
18861886
pub fn parse_order_by_expr_list(&mut self) -> Result<Vec<OrderByExpr>, ParserError> {
18871887
let mut expr_list: Vec<OrderByExpr> = vec![];
18881888
loop {

src/test_utils.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,27 +77,27 @@ impl TestedDialects {
7777
only_statement
7878
}
7979

80-
/// Ensures that `sql` parses as a single SQLStatement, and is not modified
80+
/// Ensures that `sql` parses as a single [Statement], and is not modified
8181
/// after a serialization round-trip.
8282
pub fn verified_stmt(&self, query: &str) -> Statement {
8383
self.one_statement_parses_to(query, query)
8484
}
8585

86-
/// Ensures that `sql` parses as a single SQLQuery, and is not modified
86+
/// Ensures that `sql` parses as a single [Query], and is not modified
8787
/// after a serialization round-trip.
8888
pub fn verified_query(&self, sql: &str) -> Query {
8989
match self.verified_stmt(sql) {
9090
Statement::Query(query) => *query,
91-
_ => panic!("Expected SQLQuery"),
91+
_ => panic!("Expected Query"),
9292
}
9393
}
9494

95-
/// Ensures that `sql` parses as a single SQLSelect, and is not modified
95+
/// Ensures that `sql` parses as a single [Select], and is not modified
9696
/// after a serialization round-trip.
9797
pub fn verified_only_select(&self, query: &str) -> Select {
9898
match self.verified_query(query).body {
9999
SetExpr::Select(s) => *s,
100-
_ => panic!("Expected SQLSetExpr::Select"),
100+
_ => panic!("Expected SetExpr::Select"),
101101
}
102102
}
103103

0 commit comments

Comments
 (0)