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

Fix SQL generation when having a column defined with startWith and incrementBy in Postgres #5629

Merged
merged 1 commit into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -469,4 +469,11 @@
<renameSequence oldSequenceName="serial_sequence_test_id_seq" newSequenceName="new_test_id_seq"/>
</changeSet>

<changeSet author="mallod" id="test-column-def-with-autoincrement-and-startWith"
logicalFilePath="empty">
<createTable tableName="test_col_def_autoIncrement_and_startWith">
<column name="id" type="integer" autoIncrement="true" startWith="100" incrementBy="5"/>
</createTable>
</changeSet>

</databaseChangeLog>
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,12 @@ public String getAutoIncrementClause(final BigInteger startWith, final BigIntege

if (generateIncrementBy) {
if (generateStartWith) {
autoIncrementClause += ", ";
if(!(this instanceof PostgresDatabase)) {
autoIncrementClause += ", ";
}
else {
autoIncrementClause += " ";
}

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -878,7 +878,7 @@ public void testAutoIncrementStartWithIncrementByPostgresDatabase() throws Excep
assertEquals("CREATE TABLE SCHEMA_NAME.TABLE_NAME (COLUMN1_NAME BIGSERIAL)", generatedSql[0].toSql());
conn.setDatabaseMajorVersion(10);
generatedSql = this.generatorUnderTest.generateSql(statement, database, null);
assertEquals("CREATE TABLE SCHEMA_NAME.TABLE_NAME (COLUMN1_NAME BIGINT GENERATED BY DEFAULT AS IDENTITY (START WITH 0, INCREMENT BY 10))", generatedSql[0].toSql());
assertEquals("CREATE TABLE SCHEMA_NAME.TABLE_NAME (COLUMN1_NAME BIGINT GENERATED BY DEFAULT AS IDENTITY (START WITH 0 INCREMENT BY 10))", generatedSql[0].toSql());
conn.setDatabaseMajorVersion(saveMajorVersion);
}
}
Expand Down