You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Mysql and MariaDB don't support incrementBy in a way how other platforms do. They have auto_increment_offset var set globally or per session, but not for particular table.
For H2 and HyperSQL databases generated queries are not correct
run liquibase updateSql against mentioned DBs
observe generated SQL
Actual Behavior
Generated SQL for :
For Mysql and MariaDB, nothing about incrementBy may be confusing if user rely on incrementBy but didn't check generated SQL and expect it to be working
CREATE TABLE lbcat.autoincrement_test (intColumn INT NOT NULL, dateColumn date NULL, CONSTRAINT PK_AUTOINCREMENT_TEST PRIMARY KEY (intColumn))
ALTER TABLE lbcat.autoincrement_test MODIFY intColumn INT AUTO_INCREMENT
ALTER TABLE lbcat.autoincrement_test AUTO_INCREMENT=100
For H2
CREATE TABLE PUBLIC.autoincrement_test (intColumn INT NOT NULL, dateColumn date, CONSTRAINT PK_AUTOINCREMENT_TEST PRIMARY KEY (intColumn))
ALTER TABLE PUBLIC.autoincrement_test ALTER COLUMN intColumn int GENERATED BY DEFAULT AS IDENTITY (100, 2)
failing with Syntax error in SQL statement "ALTER TABLE PUBLIC.autoincrement_test ALTER COLUMN intColumn int GENERATED BY DEFAULT AS IDENTITY ([*]100, 2)"; expected "START, RESTART, INCREMENT, MINVALUE, MAXVALUE, CYCLE, NO, EXHAUSTED, CACHE, NOMINVALUE, NOMAXVALUE, NOCYCLE, NOCACHE, )";
For HyperSQL
ALTER TABLE PUBLIC.autoincrement_test ALTER COLUMN intColumn int GENERATED BY DEFAULT AS IDENTITY (START WITH 100, INCREMENT BY 2)
failing with Reason: liquibase.exception.DatabaseException: unexpected token: , required: ) [Failed SQL: (-5581) ALTER TABLE PUBLIC.autoincrement_test ALTER COLUMN intColumn int GENERATED BY DEFAULT AS IDENTITY (START WITH 100, INCREMENT BY 2)]
Fix query for HyperSQL to remove comma, query like ALTER TABLE PUBLIC.autoincrement_test ALTER COLUMN intColumn int GENERATED BY DEFAULT AS IDENTITY (START WITH 100 INCREMENT BY 2) works fine
Additional Context
discovered in test-harness
The text was updated successfully, but these errors were encountered:
Environment
Liquibase Version: 4.10
Liquibase Integration & Version: -
Liquibase Extension(s) & Version: -
Database Vendor & Version: Mysql, MariaDB, HyperSQL, H2
Operating System Type & Version: windows 10
Description
Mysql and MariaDB don't support
incrementBy
in a way how other platforms do. They haveauto_increment_offset
var set globally or per session, but not for particular table.For H2 and HyperSQL databases generated queries are not correct
Steps To Reproduce
create xml changeLog file with next changesets
run
liquibase updateSql
against mentioned DBsobserve generated SQL
Actual Behavior
Generated SQL for :
incrementBy
may be confusing if user rely onincrementBy
but didn't check generated SQL and expect it to be workingfailing with
Syntax error in SQL statement "ALTER TABLE PUBLIC.autoincrement_test ALTER COLUMN intColumn int GENERATED BY DEFAULT AS IDENTITY ([*]100, 2)"; expected "START, RESTART, INCREMENT, MINVALUE, MAXVALUE, CYCLE, NO, EXHAUSTED, CACHE, NOMINVALUE, NOMAXVALUE, NOCYCLE, NOCACHE, )";
failing with
Reason: liquibase.exception.DatabaseException: unexpected token: , required: ) [Failed SQL: (-5581) ALTER TABLE PUBLIC.autoincrement_test ALTER COLUMN intColumn int GENERATED BY DEFAULT AS IDENTITY (START WITH 100, INCREMENT BY 2)]
Expected/Desired Behavior
incrementBy
for Mysql and MariaDB indicate that in https://docs.liquibase.com/change-types/add-auto-increment.html as not supported and throw validation error for this attribute in changeset. Fix if there is a way.ALTER TABLE PUBLIC.autoincrement_test ALTER COLUMN intColumn int GENERATED BY DEFAULT AS IDENTITY (START WITH 100 INCREMENT BY 2)
works fineAdditional Context
discovered in test-harness
The text was updated successfully, but these errors were encountered: