Skip to content

Commit

Permalink
0005525: allow cast to additional types in Postgres (#188)
Browse files Browse the repository at this point in the history
  • Loading branch information
clloydaccanto committed Oct 14, 2022
1 parent e03c2fe commit ff0a9be
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions symmetric-db/src/main/java/org/jumpmind/db/model/TypeMap.java
Expand Up @@ -132,6 +132,9 @@ public abstract class TypeMap {
public static final String JSONB = "JSONB";
public static final String JSON = "JSON";
public static final String INET = "INET";
public static final String CIDR = "CIDR";
public static final String MACADDR = "MACADDR";
public static final String MACADDR8 = "MACADDR8";
/** Maps type names to the corresponding {@link java.sql.Types} constants. */
private static HashMap<String, Integer> _typeNameToTypeCode = new HashMap<String, Integer>();
/** Maps {@link java.sql.Types} type code constants to the corresponding type names. */
Expand Down
Expand Up @@ -163,6 +163,12 @@ private String getTypeToCast(Column column) {
typeToCast = "json";
} else if (column.getJdbcTypeName() != null && column.getJdbcTypeName().toUpperCase().contains(TypeMap.INET)) {
typeToCast = "inet";
} else if (column.getJdbcTypeName() != null && column.getJdbcTypeName().toUpperCase().contains(TypeMap.CIDR)) {
typeToCast = "cidr";
} else if (column.getJdbcTypeName() != null && column.getJdbcTypeName().toUpperCase().contains(TypeMap.MACADDR8)) {
typeToCast = "macaddr8";
} else if (column.getJdbcTypeName() != null && column.getJdbcTypeName().toUpperCase().contains(TypeMap.MACADDR)) {
typeToCast = "macaddr";
}
if (typeToCast != null && column.getMappedType() != null && column.getMappedType().equals(TypeMap.ARRAY)) {
typeToCast = typeToCast + "[]";
Expand Down

0 comments on commit ff0a9be

Please sign in to comment.