Skip to content

Commit

Permalink
HBX-2716 - Remove floating point types from types advertised to suppo…
Browse files Browse the repository at this point in the history
…rt precision & scale

Signed-off-by: Koen Aers <koen.aers@gmail.com>
  • Loading branch information
adferrand authored and koentsje committed Feb 5, 2024
1 parent 73e0078 commit ec38d91
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,12 @@ public static void processBasicColumns(
if(JdbcToHibernateTypeHelper.typeHasLength(sqlType) ) {
column.setLength(size);
}
if(JdbcToHibernateTypeHelper.typeHasScaleAndPrecision(sqlType) ) {
if(JdbcToHibernateTypeHelper.typeHasPrecision(sqlType) ) {
column.setPrecision(size);
}
}
if(intBounds(decimalDigits) ) {
if(JdbcToHibernateTypeHelper.typeHasScaleAndPrecision(sqlType) ) {
if(JdbcToHibernateTypeHelper.typeHasScale(sqlType) ) {
column.setScale(decimalDigits);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,17 +183,25 @@ public static String getJDBCTypeName(int value) {
* @throws SQLException
*/

// scale and precision have numeric column
public static boolean typeHasScaleAndPrecision(int sqlType) {
return (sqlType == Types.DECIMAL || sqlType == Types.NUMERIC
|| sqlType == Types.REAL || sqlType == Types.FLOAT || sqlType == Types.DOUBLE);
}

// length is for string column
public static boolean typeHasLength(int sqlType) {
return (sqlType == Types.CHAR || sqlType == Types.DATE
|| sqlType == Types.LONGVARCHAR || sqlType == Types.TIME || sqlType == Types.TIMESTAMP
|| sqlType == Types.VARCHAR );
}
}
// scale is for non floating point numeric columns
public static boolean typeHasScale(int sqlType) {
return (sqlType == Types.DECIMAL || sqlType == Types.NUMERIC);
}

// precision is for numeric columns
public static boolean typeHasPrecision(int sqlType) {
return (sqlType == Types.DECIMAL || sqlType == Types.NUMERIC
|| sqlType == Types.REAL || sqlType == Types.FLOAT || sqlType == Types.DOUBLE);
}

public static boolean typeHasScaleAndPrecision(int sqlType) {
return typeHasScale(sqlType) && typeHasPrecision(sqlType);
}

// length is for string columns
public static boolean typeHasLength(int sqlType) {
return (sqlType == Types.CHAR || sqlType == Types.DATE
|| sqlType == Types.LONGVARCHAR || sqlType == Types.TIME || sqlType == Types.TIMESTAMP
|| sqlType == Types.VARCHAR );
}
}

0 comments on commit ec38d91

Please sign in to comment.