Skip to content
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

feat: Support generic expressions in SET statement #574

Merged
merged 1 commit into from Aug 18, 2022

Conversation

ovr
Copy link
Contributor

@ovr ovr commented Aug 16, 2022

Hello!

MySQL allows to use any kind of expression in SetVariable statement, for example:

SET sql_mode = CONCAT(@@sql_mode, ',STRICT_TRANS_TABLES')

Thanks

@coveralls
Copy link

Pull Request Test Coverage Report for Build 2867488628

  • 32 of 32 (100.0%) changed or added relevant lines in 7 files are covered.
  • 2 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-0.005%) to 85.428%

Files with Coverage Reduction New Missed Lines %
src/parser.rs 2 83.17%
Totals Coverage Status
Change from base Build 2863782747: -0.005%
Covered Lines: 9509
Relevant Lines: 11131

💛 - Coveralls

@alamb alamb changed the title feat: Support expression in SET statement feat: Support generic expressions in SET statement Aug 18, 2022
Copy link
Collaborator

@alamb alamb left a comment

Choose a reason for hiding this comment

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

This looks great -- thanks @ovr

@@ -580,7 +580,7 @@ fn parse_select_count_wildcard() {

#[test]
fn parse_select_count_distinct() {
let sql = "SELECT COUNT(DISTINCT + x) FROM customer";
let sql = "SELECT COUNT(DISTINCT +x) FROM customer";
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah, I was confused about this for a while, but then I see that +x is actually a unary op, so it makes sense to display it as +x rather than + x 👍

@@ -754,7 +754,7 @@ fn parse_compound_expr_2() {
#[test]
fn parse_unary_math() {
use self::Expr::*;
let sql = "- a + - b";
let sql = "-a + -b";
Copy link
Collaborator

Choose a reason for hiding this comment

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

❤️

@alamb alamb merged commit 6d8aacd into sqlparser-rs:main Aug 18, 2022
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.

None yet

4 participants