Support parsing constraints in CREATE TABLE

<table element> ::= ... | <table constraint definition> | ...
https://jakewheat.github.io/sql-overview/sql-2011-foundation-grammar.html#table-element-list
This commit is contained in:
Nickolay Ponomarev 2019-05-11 23:51:30 +03:00
parent c69a1881c7
commit aab0c36443
4 changed files with 123 additions and 65 deletions

View file

@ -23,12 +23,14 @@ fn parse_create_table_with_defaults() {
SQLStatement::SQLCreateTable {
name,
columns,
constraints,
external: false,
file_format: None,
location: None,
} => {
assert_eq!("public.customer", name.to_string());
assert_eq!(10, columns.len());
assert!(constraints.is_empty());
let c_name = &columns[0];
assert_eq!("customer_id", c_name.name);
@ -69,11 +71,13 @@ fn parse_create_table_from_pg_dump() {
SQLStatement::SQLCreateTable {
name,
columns,
constraints,
external: false,
file_format: None,
location: None,
} => {
assert_eq!("public.customer", name.to_string());
assert!(constraints.is_empty());
let c_customer_id = &columns[0];
assert_eq!("customer_id", c_customer_id.name);
@ -130,11 +134,13 @@ fn parse_create_table_with_inherit() {
SQLStatement::SQLCreateTable {
name,
columns,
constraints,
external: false,
file_format: None,
location: None,
} => {
assert_eq!("bazaar.settings", name.to_string());
assert!(constraints.is_empty());
let c_name = &columns[0];
assert_eq!("settings_id", c_name.name);