Support parsing dates, times, and timestamps as strings

This commit is contained in:
Nikhil Benesch 2019-05-30 14:46:37 -04:00
parent 11fc833433
commit ed3ed26bb1
No known key found for this signature in database
GPG key ID: F7386C5DEADABA7F
3 changed files with 44 additions and 0 deletions

View file

@ -192,12 +192,17 @@ impl Parser {
}
"CASE" => self.parse_case_expression(),
"CAST" => self.parse_cast_expression(),
"DATE" => Ok(ASTNode::SQLValue(Value::Date(self.parse_literal_string()?))),
"EXISTS" => self.parse_exists_expression(),
"EXTRACT" => self.parse_extract_expression(),
"NOT" => Ok(ASTNode::SQLUnary {
operator: SQLOperator::Not,
expr: Box::new(self.parse_subexpr(Self::UNARY_NOT_PREC)?),
}),
"TIME" => Ok(ASTNode::SQLValue(Value::Time(self.parse_literal_string()?))),
"TIMESTAMP" => Ok(ASTNode::SQLValue(Value::Timestamp(
self.parse_literal_string()?,
))),
// Here `w` is a word, check if it's a part of a multi-part
// identifier, a function call, or a simple identifier:
_ => match self.peek_token() {