From 42aa63267bbad7d92bec99cedc92b5d30df2bbc2 Mon Sep 17 00:00:00 2001 From: Wesley Willard Date: Fri, 20 Mar 2020 14:03:02 -0500 Subject: [PATCH 1/3] Add Postgres to the list of databases which do not need a size argument for SMALLINT --- .../main/java/liquibase/datatype/core/SmallIntType.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/liquibase-core/src/main/java/liquibase/datatype/core/SmallIntType.java b/liquibase-core/src/main/java/liquibase/datatype/core/SmallIntType.java index ed2fbbae936..e9240e222ff 100644 --- a/liquibase-core/src/main/java/liquibase/datatype/core/SmallIntType.java +++ b/liquibase-core/src/main/java/liquibase/datatype/core/SmallIntType.java @@ -34,8 +34,11 @@ public DatabaseDataType toDatabaseDataType(Database database) { type.addAdditionalInformation(getAdditionalInformation()); return type; } - if ((database instanceof AbstractDb2Database) || (database instanceof DerbyDatabase) || (database instanceof - FirebirdDatabase) || (database instanceof InformixDatabase)) { + if ((database instanceof AbstractDb2Database) || + (database instanceof PostgresDatabase) || + (database instanceof DerbyDatabase) || + (database instanceof FirebirdDatabase) || + (database instanceof InformixDatabase)) { return new DatabaseDataType("SMALLINT"); //always smallint regardless of parameters passed } From 55bfaa0c4cb4d22e2ca90718da518db04b87efb7 Mon Sep 17 00:00:00 2001 From: Wesley Willard Date: Fri, 20 Mar 2020 16:20:58 -0500 Subject: [PATCH 2/3] Needed to move Postgres SMALLINT check to handle auto increment version check --- .../liquibase/datatype/core/SmallIntType.java | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/liquibase-core/src/main/java/liquibase/datatype/core/SmallIntType.java b/liquibase-core/src/main/java/liquibase/datatype/core/SmallIntType.java index e9240e222ff..20842a58db3 100644 --- a/liquibase-core/src/main/java/liquibase/datatype/core/SmallIntType.java +++ b/liquibase-core/src/main/java/liquibase/datatype/core/SmallIntType.java @@ -35,7 +35,6 @@ public DatabaseDataType toDatabaseDataType(Database database) { return type; } if ((database instanceof AbstractDb2Database) || - (database instanceof PostgresDatabase) || (database instanceof DerbyDatabase) || (database instanceof FirebirdDatabase) || (database instanceof InformixDatabase)) { @@ -48,16 +47,17 @@ public DatabaseDataType toDatabaseDataType(Database database) { if (database instanceof PostgresDatabase) { - if (isAutoIncrement()) { - int majorVersion = 9; - try { - majorVersion = database.getDatabaseMajorVersion(); - } catch (DatabaseException e) { - // ignore - } - if (majorVersion < 10) { - return new DatabaseDataType("SMALLSERIAL"); - } + if (! isAutoIncrement()) { + return new DatabaseDataType("SMALLINT"); //always smallint regardless of parameters passed + } + int majorVersion = 9; + try { + majorVersion = database.getDatabaseMajorVersion(); + } catch (DatabaseException e) { + // ignore + } + if (majorVersion < 10) { + return new DatabaseDataType("SMALLSERIAL"); } } From 08ca6f90b9fc44b5742ecc76fc26bf87bc0bb402 Mon Sep 17 00:00:00 2001 From: Wesley Willard Date: Mon, 23 Mar 2020 11:33:00 -0500 Subject: [PATCH 3/3] Re-worked SMALLINT fix --- .../liquibase/datatype/core/SmallIntType.java | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/liquibase-core/src/main/java/liquibase/datatype/core/SmallIntType.java b/liquibase-core/src/main/java/liquibase/datatype/core/SmallIntType.java index 20842a58db3..3cb6bede1b3 100644 --- a/liquibase-core/src/main/java/liquibase/datatype/core/SmallIntType.java +++ b/liquibase-core/src/main/java/liquibase/datatype/core/SmallIntType.java @@ -47,21 +47,20 @@ public DatabaseDataType toDatabaseDataType(Database database) { if (database instanceof PostgresDatabase) { - if (! isAutoIncrement()) { - return new DatabaseDataType("SMALLINT"); //always smallint regardless of parameters passed - } - int majorVersion = 9; - try { - majorVersion = database.getDatabaseMajorVersion(); - } catch (DatabaseException e) { - // ignore - } - if (majorVersion < 10) { - return new DatabaseDataType("SMALLSERIAL"); + if (isAutoIncrement()) { + int majorVersion = 9; + try { + majorVersion = database.getDatabaseMajorVersion(); + } catch (DatabaseException e) { + // ignore + } + if (majorVersion < 10) { + return new DatabaseDataType("SMALLSERIAL"); + } } + return new DatabaseDataType("SMALLINT"); //always smallint regardless of parameters passed } - return super.toDatabaseDataType(database); }