datanucleus / datanucleus-rdbms

DataNucleus support for persistence to RDBMS Datastores
30 stars 67 forks source link

Remove column mapping to JDBC type FLOAT for SQL Server #451

Closed nscuro closed 2 years ago

nscuro commented 2 years ago

The JDBC driver does not provide this type. According to https://learn.microsoft.com/en-us/sql/connect/jdbc/using-basic-data-types?view=sql-server-ver16, the SQL type FLOAT is mapped to the JDBC type DOUBLE.

dbinfo output of the schema tool is provided for the last three major versions of the JDBC driver.

This addressed #304

andyjefferson commented 2 years ago

Thx for the PR. No real issue with this fix, but why not go one step further ... add support for JDBC FLOAT if it isn't provided by the JDBC Driver. You do this by adding an entry for Types.FLOAT in the initialiseTypes method, map it to sqlType of "float", and then you can have entries for the different Java types to allow people to specify it as JDBC type = float

nscuro commented 2 years ago

Sure, I can give that a go.

I see there is already an "artificial" mapping for DOUBLE:

https://github.com/datanucleus/datanucleus-rdbms/blob/fcc9722391b7ae9f50f48fad9736bfdef75be77a/src/main/java/org/datanucleus/store/rdbms/adapter/SQLServerAdapter.java#L177-L179

It seems like the mapping would be identical for FLOAT, so just adding

addSQLTypeForJDBCType(handler, mconn, (short)Types.FLOAT, sqlType, true);

below the above snippet should do the trick?

nscuro commented 2 years ago

Thanks for merging @andyjefferson!

Do you have a rough idea of when 6.0.2 will be released? :) I'm eagerly waiting for #449 to be shipped, as the corresponding bug prevents our users with SQL server from running our project.

andyjefferson commented 2 years ago

Since only datanucleus-core and datanucleus-rdbms to release (so a plugin release, rather than accessplatform), maybe some time in the next week