Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change of Delimiter does not work correct for SQLite #1081

Closed
stkuehnl opened this issue Aug 12, 2015 · 1 comment
Closed

Change of Delimiter does not work correct for SQLite #1081

stkuehnl opened this issue Aug 12, 2015 · 1 comment

Comments

@stkuehnl
Copy link

@stkuehnl stkuehnl commented Aug 12, 2015

I would create the following two tables in a SQLite Database by using flyway:

CREATE TABLE my_patch_level
  (
    db_id                     INTEGER PRIMARY KEY autoincrement,
    db_level                  NUMBER (3) NOT NULL ,
    db_svn                    VARCHAR2 (35) NOT NULL ,
    db_zp_beginn              DATE NOT NULL ,
    db_zp_ende                DATE
   ) ;
CREATE TABLE adr_verfahren
  (
    vrf_id   INTEGER PRIMARY KEY autoincrement ,
    vrf_knz  VARCHAR2 (3) NOT NULL ,
    vrf_name VARCHAR2 (80) ,
    vrf_zid  NUMBER (12) ,
    vrf_dm   DATE DEFAULT (datetime('now','localtime'))
  ) ;

After executing the script with flyway - there has been created only one table without any exception.
I have debug flyway. The class SQLiteSqlStatementBuilder overrides the method changeDelimiterIfNecessary. In this method flyway checks if it is necessary to change the delimiter. This is useful for database-specific stored procedures or trigger. But in my case - there is no stored procedures or trigger.
Due the column db_zp_beginn (in my first table) the following code assigned the field insideBeginEndBlock to true and the method returns null for the delimiter and flyway puts all the following statemets to the current statement.
Here the code:

    @Override
    protected Delimiter changeDelimiterIfNecessary(String line, Delimiter delimiter) {
        if (line.contains("BEGIN")) {
            insideBeginEndBlock = true;
        }

        if (line.endsWith("END;")) {
            insideBeginEndBlock = false;
        }

        if (insideBeginEndBlock) {
            return null;
        }
        return getDefaultDelimiter();
    }

The condition for setting the field insideBeginEndBlock should be fixed. There could also be a problem if I would insert a text in a column which contains begin or if I have a column such as beginners.

@axelfontaine axelfontaine added this to the Flyway 4.0 milestone Oct 28, 2015
axelfontaine added a commit to flyway/flywaydb.org that referenced this issue Oct 28, 2015
@axelfontaine
Copy link
Contributor

@axelfontaine axelfontaine commented Oct 28, 2015

Thanks for researching this! Fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.