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

HBX-2716 - Remove floating point types from types advertised to support precision & scale #4653

Merged
merged 1 commit into from
Feb 5, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 );
}
}
Loading