Skip to content

Commit

Permalink
Fixed: Fails to detect LONG VARCHAR as CLOB and LONG BINARY as BLOB (#…
Browse files Browse the repository at this point in the history
…4670)

* Fixed: Fails to detect LONG VARCHAR as CLOB and LONG BINARY as BLOB

* Blob and Clob data types tests added.

---------

Co-authored-by: Daniel Mallorga <dmallorga@liquibase.com>
  • Loading branch information
mkarg and MalloD12 committed Sep 5, 2023
1 parent 8e5075a commit e72b1fa
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,12 @@ public LiquibaseDataType fromDescription(String dataTypeDefinition, Database dat
// record additional information that is still attached to the data type name
String additionalInfo = null;
if (dataTypeName.toLowerCase(Locale.US).startsWith("bit varying")
|| dataTypeName.toLowerCase(Locale.US).startsWith("character varying")) {
// not going to do anything. Special case for postgres in our tests,
|| dataTypeName.toLowerCase(Locale.US).startsWith("character varying")
|| dataTypeName.toLowerCase(Locale.US).startsWith("long varchar")
|| dataTypeName.toLowerCase(Locale.US).startsWith("long nvarchar")
|| dataTypeName.toLowerCase(Locale.US).startsWith("long binary")
|| dataTypeName.toLowerCase(Locale.US).startsWith("long varbinary")) {
// not going to do anything. Special case for postgres and asany,
// need to better support handling these types of differences
} else {
// Heuristic: from what we now have left of the data type name, everything after the first space
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import java.util.Arrays;
import java.util.Locale;

@DataTypeInfo(name = "blob", aliases = {"longblob", "longvarbinary", "java.sql.Types.BLOB", "java.sql.Types.LONGBLOB", "java.sql.Types.LONGVARBINARY", "java.sql.Types.VARBINARY", "java.sql.Types.BINARY", "varbinary", "binary", "image", "tinyblob", "mediumblob"}, minParameters = 0, maxParameters = 1, priority = LiquibaseDataType.PRIORITY_DEFAULT)
@DataTypeInfo(name = "blob", aliases = {"longblob", "longvarbinary", "java.sql.Types.BLOB", "java.sql.Types.LONGBLOB", "java.sql.Types.LONGVARBINARY", "java.sql.Types.VARBINARY", "java.sql.Types.BINARY", "varbinary", "binary", "image", "tinyblob", "mediumblob", "long binary", "long varbinary"}, minParameters = 0, maxParameters = 1, priority = LiquibaseDataType.PRIORITY_DEFAULT)
public class BlobType extends LiquibaseDataType {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

import java.util.Locale;

@DataTypeInfo(name = "clob", aliases = {"longvarchar", "text", "longtext", "java.sql.Types.LONGVARCHAR", "java.sql.Types.CLOB", "nclob", "longnvarchar", "ntext", "java.sql.Types.LONGNVARCHAR", "java.sql.Types.NCLOB", "tinytext", "mediumtext"}, minParameters = 0, maxParameters = 0, priority = LiquibaseDataType.PRIORITY_DEFAULT)
@DataTypeInfo(name = "clob", aliases = {"longvarchar", "text", "longtext", "java.sql.Types.LONGVARCHAR", "java.sql.Types.CLOB", "nclob", "longnvarchar", "ntext", "java.sql.Types.LONGNVARCHAR", "java.sql.Types.NCLOB", "tinytext", "mediumtext", "long varchar", "long nvarchar"}, minParameters = 0, maxParameters = 0, priority = LiquibaseDataType.PRIORITY_DEFAULT)
public class ClobType extends LiquibaseDataType {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,11 @@ class DataTypeFactoryTest extends Specification {
"INT(20)" | new SybaseDatabase() | "INT" | IntType | false
"SMALLINT(20)" | new SybaseDatabase() | "SMALLINT" | SmallIntType | false
"TINYINT(20)" | new SybaseDatabase() | "TINYINT" | TinyIntType | false
"long binary" | new SybaseDatabase() | "IMAGE" | BlobType | false
"long varbinary" | new SybaseDatabase() | "IMAGE" | BlobType | false
"long varchar" | new SybaseDatabase() | "TEXT" | ClobType | false
"long nvarchar" | new SybaseDatabase() | "TEXT" | ClobType | false
"character varying" | new SybaseDatabase() | "VARCHAR" | VarcharType | false
}

@Unroll("#featureName: #object for #database")
Expand Down

0 comments on commit e72b1fa

Please sign in to comment.