Merge pull request #94 from benesch/empty-create-table

Support CREATE TABLE with no columns
This commit is contained in:
Nikhil Benesch 2019-06-03 23:44:18 -04:00 committed by GitHub
commit fdbf64c64d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View file

@ -854,7 +854,7 @@ impl Parser {
fn parse_columns(&mut self) -> Result<(Vec<SQLColumnDef>, Vec<TableConstraint>), ParserError> {
let mut columns = 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));
}

View file

@ -928,6 +928,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]
fn parse_alter_table_constraints() {
check_one("CONSTRAINT address_pkey PRIMARY KEY (address_id)");