Skip to content

Rename ASTNode to Expr #119

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 20, 2019
Merged

Rename ASTNode to Expr #119

merged 1 commit into from
Jun 20, 2019

Conversation

benesch
Copy link
Contributor

@benesch benesch commented Jun 18, 2019

The ASTNode enum was confusingly named. In the past, the name made
sense, as the enum contained nearly all of the nodes in the AST, but
over time, pieces have been split into different structs, like
SQLStatement and SQLQuery. The ASTNode enum now contains only contains
expression nodes, so Expr is a better name.

Extracted from #105.

@coveralls
Copy link

Pull Request Test Coverage Report for Build 360

  • 213 of 213 (100.0%) changed or added relevant lines in 8 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at ?%

Totals Coverage Status
Change from base Build 358: 0.0%
Covered Lines:
Relevant Lines: 0

💛 - Coveralls

@coveralls
Copy link

coveralls commented Jun 18, 2019

Pull Request Test Coverage Report for Build 365

  • 226 of 229 (98.69%) changed or added relevant lines in 8 files are covered.
  • 2 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-0.05%) to 92.174%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/test_utils.rs 3 4 75.0%
tests/sqlparser_common.rs 107 109 98.17%
Files with Coverage Reduction New Missed Lines %
tests/sqlparser_common.rs 2 90.95%
Totals Coverage Status
Change from base Build 358: -0.05%
Covered Lines: 318
Relevant Lines: 345

💛 - Coveralls

Copy link
Contributor

@nickolay nickolay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks for doing this!

@@ -177,9 +177,9 @@ impl ToString for Cte {
#[derive(Debug, Clone, PartialEq, Hash)]
pub enum SQLSelectItem {
/// Any expression, not followed by `[ AS ] alias`
UnnamedExpression(ASTNode),
UnnamedExpression(Expr),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we keep UnnamedExpression and ExpressionWithAlias or rename them to use Expr? Same for parse_.._expression() methods.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, good idea! Done.

},
/// Unary operation e.g. `NOT foo`
SQLUnaryOp {
op: SQLUnaryOperator,
expr: Box<ASTNode>,
expr: Box<Expr>,
},
/// CAST an expression to a different data type e.g. `CAST(foo AS VARCHAR(123))`
SQLCast {
Copy link
Contributor

@nickolay nickolay Jun 18, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My version of cargo fmt reformats this (and a few others) on one line. I wonder why CI doesn't catch it..

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What version of the Rust toolchain are you using? Perhaps the formatting here is different in different versions.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Never mind. I think something's broken in CI.

The ASTNode enum was confusingly named. In the past, the name made
sense, as the enum contained nearly all of the nodes in the AST, but
over time, pieces have been split into different structs, like
SQLStatement and SQLQuery. The ASTNode enum now contains only contains
expression nodes, so Expr is a better name.

Also rename the UnnamedExpression and ExpressionWithAlias variants
of SQLSelectItem to UnnamedExpr and ExprWithAlias, respectively, to
match the new shorthand for the word "expression".
@nickolay
Copy link
Contributor

This looks ready to merge to me!

@benesch benesch merged commit 5b23ad1 into master Jun 20, 2019
@benesch benesch deleted the astnode-expr branch June 20, 2019 01:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants