Add column with foreign key throws NPE

Description

Running a migration with an <addColumn> that includes a foreign key in the constraints is throwing a NPE.

Attached a sample migration, below is the stacktrace I'm getting. If I move the foreign key to be added with addForeignKey everything works, but it's just more typing...

Caused by: java.lang.NullPointerException: null
at java.util.regex.Matcher.getTextLength(Matcher.java:1234)
at java.util.regex.Matcher.reset(Matcher.java:308)
at java.util.regex.Matcher.<init>(Matcher.java:228)
at java.util.regex.Pattern.matcher(Pattern.java:1088)
at liquibase.sqlgenerator.core.AddColumnGenerator.addForeignKeyStatements(AddColumnGenerator.java:103)
at liquibase.sqlgenerator.core.AddColumnGeneratorDefaultClauseBeforeNotNull.generateSql(AddColumnGeneratorDefaultClauseBeforeNotNull.java:88)
at liquibase.sqlgenerator.core.AddColumnGeneratorDefaultClauseBeforeNotNull.generateSql(AddColumnGeneratorDefaultClauseBeforeNotNull.java:27)
at liquibase.sqlgenerator.SqlGeneratorChain.generateSql(SqlGeneratorChain.java:30)
at liquibase.sqlgenerator.SqlGeneratorFactory.generateSql(SqlGeneratorFactory.java:198)
at liquibase.executor.AbstractExecutor.applyVisitors(AbstractExecutor.java:22)
at liquibase.executor.jvm.JdbcExecutor.access$000(JdbcExecutor.java:30)
at liquibase.executor.jvm.JdbcExecutor$1ExecuteStatementCallback.doInStatement(JdbcExecutor.java:80)
at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:50)
at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:103)
at liquibase.database.AbstractJdbcDatabase.execute(AbstractJdbcDatabase.java:1513)
at liquibase.database.AbstractJdbcDatabase.executeStatements(AbstractJdbcDatabase.java:1496)
at liquibase.changelog.ChangeSet.execute(ChangeSet.java:343)
at liquibase.changelog.visitor.UpdateVisitor.visit(UpdateVisitor.java:40)
at liquibase.changelog.ChangeLogIterator.run(ChangeLogIterator.java:64)
at liquibase.Liquibase.update(Liquibase.java:137)
at liquibase.integration.spring.SpringLiquibase.performUpdate(SpringLiquibase.java:324)
at liquibase.integration.spring.SpringLiquibase.afterPropertiesSet(SpringLiquibase.java:291)

Environment

OS X 10.8
java version "1.7.0_40"
Java(TM) SE Runtime Environment (build 1.7.0_40-b40)
Java HotSpot(TM) 64-Bit Server VM (build 24.0-b55, mixed mode)
Spring 3.2.4

Activity

Show:
Per Abich
December 3, 2013, 2:59 PM

Try this:

Per Abich
December 3, 2013, 3:02 PM

I guess the documentation is a little unclear on this and the tag names really don't make it clearer... I guess it should rather be either or, not one variant throwing a NPE...

Nathan Voxland
December 5, 2013, 2:43 PM

Fixed addColumn to respect referencedTableName and referencedColumnNames attributes

Łukasz Pogorzelski
September 24, 2014, 9:41 AM

Version 3.0.4 is affected too.

Fixed

Reporter

Nick Stuart

Fix versions

Affects versions

Priority

Major