mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-09-06 14:10:32 +00:00
Support CREATE TABLE with no columns
This is weird, but supported by PostgreSQL.
This commit is contained in:
parent
2308c1c6f7
commit
b3a2a6be48
2 changed files with 7 additions and 1 deletions
|
@ -833,7 +833,7 @@ impl Parser {
|
||||||
fn parse_columns(&mut self) -> Result<(Vec<SQLColumnDef>, Vec<TableConstraint>), ParserError> {
|
fn parse_columns(&mut self) -> Result<(Vec<SQLColumnDef>, Vec<TableConstraint>), ParserError> {
|
||||||
let mut columns = vec![];
|
let mut columns = vec![];
|
||||||
let mut constraints = vec![];
|
let mut constraints = vec![];
|
||||||
if !self.consume_token(&Token::LParen) {
|
if !self.consume_token(&Token::LParen) || self.consume_token(&Token::RParen) {
|
||||||
return Ok((columns, constraints));
|
return Ok((columns, constraints));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -820,6 +820,12 @@ fn parse_create_external_table() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn parse_create_table_empty() {
|
||||||
|
// Zero-column tables are weird, but supported by at least PostgreSQL.
|
||||||
|
let _ = verified_stmt("CREATE TABLE t ()");
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn parse_alter_table_constraints() {
|
fn parse_alter_table_constraints() {
|
||||||
check_one("CONSTRAINT address_pkey PRIMARY KEY (address_id)");
|
check_one("CONSTRAINT address_pkey PRIMARY KEY (address_id)");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue