sqltoast icon indicating copy to clipboard operation
sqltoast copied to clipboard

Handle explicit `<column> <data type> NULL` constraint specifier

Open jaypipes opened this issue 7 years ago • 0 comments

The NULL constraint specifier is default for the CREATE TABLE statement, however we don't support it. We only support the standard NOT NULL constraint specifier:

jaypipes@uberbox:~/src/github.com/jaypipes/sqltoast/_build$ ./sqltoaster "create table t1 (c1 int not null primary key)"
OK
statements[0]:
  <statement: CREATE TABLE
    table identifier: t1
    column definitions:
      c1 INT NOT NULL
    constraints:
      PRIMARY KEY(c1)>

(took 28831 nanoseconds)
jaypipes@uberbox:~/src/github.com/jaypipes/sqltoast/_build$ ./sqltoaster "create table t1 (id int not null primary key, name varchar(200) null)"
Syntax error.
Expected to find one of (','|')') but found keyword[NULL]
create table t1 (id int not null primary key, name varchar(200) null)
                                                               ^^^^^^
(took 61148 nanoseconds)

Should be a simple fix to ignore the NULL constraint specifier when NOT isn't present.

jaypipes avatar Feb 11 '18 14:02 jaypipes