Skip to content

Commit fdbf64c

Browse files
authored
Merge pull request #94 from benesch/empty-create-table
Support CREATE TABLE with no columns
2 parents 2f4cd8f + b3a2a6b commit fdbf64c

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/sqlparser.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -854,7 +854,7 @@ impl Parser {
854854
fn parse_columns(&mut self) -> Result<(Vec<SQLColumnDef>, Vec<TableConstraint>), ParserError> {
855855
let mut columns = vec![];
856856
let mut constraints = vec![];
857-
if !self.consume_token(&Token::LParen) {
857+
if !self.consume_token(&Token::LParen) || self.consume_token(&Token::RParen) {
858858
return Ok((columns, constraints));
859859
}
860860

tests/sqlparser_common.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -928,6 +928,12 @@ fn parse_create_external_table() {
928928
}
929929
}
930930

931+
#[test]
932+
fn parse_create_table_empty() {
933+
// Zero-column tables are weird, but supported by at least PostgreSQL.
934+
let _ = verified_stmt("CREATE TABLE t ()");
935+
}
936+
931937
#[test]
932938
fn parse_alter_table_constraints() {
933939
check_one("CONSTRAINT address_pkey PRIMARY KEY (address_id)");

0 commit comments

Comments
 (0)