mito icon indicating copy to clipboard operation
mito copied to clipboard

Function parse-statements unable to separate statements in some cases

Open svetlyak40wt opened this issue 4 years ago • 0 comments

Here is the minimal example to reproduce this issue:

CL-USER> (length (mito.migration.sql-parse::parse-statements
                      "
CREATE TABLE test_dist (id INTEGER, quicklisp_version TEXT NOT NULL DEFAULT '');

CREATE TABLE any_other_table_o_more (id INTEGER);

INSERT INTO test_dist (id, quicklisp_version) VALUES (0, 'some version');
"))
1

Expected value is 3.

However, when I replace '' default value with NULL, everything works!

CL-USER> (length (mito.migration.sql-parse::parse-statements
                      "
CREATE TABLE test_dist (id INTEGER, quicklisp_version TEXT NOT NULL DEFAULT NULL);

CREATE TABLE any_other_table_o_more (id INTEGER);

INSERT INTO test_dist (id, quicklisp_version) VALUES (0, 'some version');
"))
3

Also works with nonempty default string:

(length (mito.migration.sql-parse::parse-statements
                      "
CREATE TABLE test_dist (id INTEGER, quicklisp_version TEXT NOT NULL DEFAULT 'blah');

CREATE TABLE any_other_table_o_more (id INTEGER);

INSERT INTO test_dist (id, quicklisp_version) VALUES (0, 'some version');
"))
3

Tested on the latest Mito from the repository. Commit c51e6476ee518ceb554516a010406a20b658b908.

svetlyak40wt avatar Jan 04 '21 17:01 svetlyak40wt