Property not read and causing exception

I am having an issue when using a property in yaml.

The following was defined in the yaml

  - property:
      name: datetime
      value: timestamp
      dbms: oracle,h2
  - property:
      name: datetime
      value: datetime
      dbms: mssql
  - property:
      name: datetime
      value: TIMESTAMP WITHOUT TIME ZONE
      dbms: postgresql

When using it in a changeset, liquibase gives the following error

              - column:
                  remarks: Date created
                  name: CREATED_DATE
                  type: ${datetime)

If I change it to hard code the time for postgres, it ran ok

Caused by: liquibase.exception.LiquibaseException: java.lang.ArrayIndexOutOfBoundsException: Index 1 out of bounds for length 1
	at liquibase.changelog.ChangeLogIterator.run(ChangeLogIterator.java:124) ~[liquibase-core-4.5.0.jar:?]
	at liquibase.changelog.DatabaseChangeLog.validate(DatabaseChangeLog.java:292) ~[liquibase-core-4.5.0.jar:?]
	at liquibase.Liquibase.lambda$update$1(Liquibase.java:231) ~[liquibase-core-4.5.0.jar:?]
	at liquibase.Scope.lambda$child$0(Scope.java:177) ~[liquibase-core-4.5.0.jar:?]
	at liquibase.Scope.child(Scope.java:186) ~[liquibase-core-4.5.0.jar:?]
	at liquibase.Scope.child(Scope.java:176) ~[liquibase-core-4.5.0.jar:?]
	at liquibase.Scope.child(Scope.java:155) ~[liquibase-core-4.5.0.jar:?]
	at liquibase.Liquibase.runInScope(Liquibase.java:2404) ~[liquibase-core-4.5.0.jar:?]
	at liquibase.Liquibase.update(Liquibase.java:211) ~[liquibase-core-4.5.0.jar:?]
	at liquibase.Liquibase.update(Liquibase.java:197) ~[liquibase-core-4.5.0.jar:?]
	at liquibase.integration.spring.SpringLiquibase.performUpdate(SpringLiquibase.java:314) ~[liquibase-core-4.5.0.jar:?]
	at liquibase.integration.spring.SpringLiquibase.afterPropertiesSet(SpringLiquibase.java:269) ~[liquibase-core-4.5.0.jar:?]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1863) ~[spring-beans-5.3.13.jar:5.3.13]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1800) ~[spring-beans-5.3.13.jar:5.3.13]
	... 18 more

Hello, @tom2011!

It’s unclear from your post what the question is. Can you please clarify?

Thanks,
Tabby

@tom2011 if this is still valid (otherwise, might help the next person who encounters similar issue(s)), these might be two potential root causes of the error here:

  • the name of the property is datetime, which on some RDBMSs it is a reserved syntax keyword. I would choose a different name for the property, for being “safe” no matter what. Go with col_type, dt_col_type, CREATED_DATE_TYPE or even RDBMS.datetime (yes, that should work too, having a dot in the name).
  • the value of the PostgreSQL case (TIMESTAMP WITHOUT TIME ZONE) might also cause the error. You could try wrapping that TIMESTAMP WITHOUT TIME ZONE value in " and see if this resolves the issue. Actually, why not use just TIMESTAMP (as the two are equivalent)?

Hope this helps,
Eduard