Conversation
Signed-off-by: Guan-Ming (Wesley) Chiu <105915352+guan404ming@users.noreply.github.com>
|
Hi @iffyio I would like modify the PR title to |
THROW statement
|
Done! |
|
Thanks! Please let me know if there is anything could be better in this pr, thanks! |
| Throw { | ||
| /// Error number expression. | ||
| error_number: Option<Box<Expr>>, | ||
| /// Error message expression. | ||
| message: Option<Box<Expr>>, | ||
| /// State expression. | ||
| state: Option<Box<Expr>>, | ||
| }, |
There was a problem hiding this comment.
we're slowly moving away from this representation over to having all statements wrapped in a named struct. As a result, can we do something like this instead?
struct Throw { ... }
Statement::Throw(Throw)See the RAISE statement for an example
There was a problem hiding this comment.
Thanks for your information. I just update with wrapped named struct.
| Keyword::RELEASE => self.parse_release(), | ||
| Keyword::COMMIT => self.parse_commit(), | ||
| Keyword::RAISERROR => Ok(self.parse_raiserror()?), | ||
| Keyword::THROW => Ok(self.parse_throw()?), |
There was a problem hiding this comment.
| Keyword::THROW => Ok(self.parse_throw()?), | |
| Keyword::THROW => { | |
| self.prev_token(); | |
| self.parse_throw().map(Into::into) | |
| }, |
see RAISE for an example. we're moving to have the statement parsing functions return the actual struct instead of a Statement enum variant. Also it would be ideal that the parse_throw is a standalone function (able to parse a THROW statement) so we rewind the token before invoking it
| if self.peek_token_ref().token == Token::SemiColon | ||
| || self.peek_token_ref().token == Token::EOF | ||
| { | ||
| return Ok(Statement::Throw { | ||
| error_number: None, | ||
| message: None, | ||
| state: None, | ||
| }); | ||
| } |
There was a problem hiding this comment.
| if self.peek_token_ref().token == Token::SemiColon | |
| || self.peek_token_ref().token == Token::EOF | |
| { | |
| return Ok(Statement::Throw { | |
| error_number: None, | |
| message: None, | |
| state: None, | |
| }); | |
| } |
I think we can skip this logic, it would be expected for the function to return an error if the input is empty (per the previous comment about making this function stand-alone)
There was a problem hiding this comment.
Ok, that makes sense to me. Just moved~
Co-Authored-By: Ifeanyi Ubah <7816405+iffyio@users.noreply.github.com>
f184eff to
4c18f7a
Compare
iffyio
left a comment
There was a problem hiding this comment.
LGTM! Thanks @guan404ming!
Signed-off-by: Guan-Ming (Wesley) Chiu <105915352+guan404ming@users.noreply.github.com> Co-authored-by: Ifeanyi Ubah <7816405+iffyio@users.noreply.github.com>
Why
The MSSQL THROW statement was missing from the sqlparser, preventing parsing of T-SQL error handling code.
How