mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-09-27 07:59:11 +00:00
Improve error messages in parse_create()
By not swallowing the Err from parse_data_type(). Also switch to `match` to enable parsing table-level constraints in this loop later.
This commit is contained in:
parent
a0f625b949
commit
346d1ff2e4
1 changed files with 9 additions and 9 deletions
|
@ -552,8 +552,9 @@ impl Parser {
|
||||||
let mut columns = vec![];
|
let mut columns = vec![];
|
||||||
if self.consume_token(&Token::LParen) {
|
if self.consume_token(&Token::LParen) {
|
||||||
loop {
|
loop {
|
||||||
if let Some(Token::SQLWord(column_name)) = self.next_token() {
|
match self.next_token() {
|
||||||
if let Ok(data_type) = self.parse_data_type() {
|
Some(Token::SQLWord(column_name)) => {
|
||||||
|
let data_type = self.parse_data_type()?;
|
||||||
let is_primary = self.parse_keywords(vec!["PRIMARY", "KEY"]);
|
let is_primary = self.parse_keywords(vec!["PRIMARY", "KEY"]);
|
||||||
let is_unique = self.parse_keyword("UNIQUE");
|
let is_unique = self.parse_keyword("UNIQUE");
|
||||||
let default = if self.parse_keyword("DEFAULT") {
|
let default = if self.parse_keyword("DEFAULT") {
|
||||||
|
@ -590,14 +591,13 @@ impl Parser {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
unexpected => {
|
||||||
return parser_err!(format!(
|
return parser_err!(format!(
|
||||||
"Error parsing data type in column definition near: {:?}",
|
"Expected column name, got {:?}",
|
||||||
self.peek_token()
|
unexpected
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
return parser_err!("Error parsing column name");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue