Work around a SQL Server JDBC driver problem by manually coercing JDBC
DatabaseMetaData.getColumns() data types
This commit is contained in:
parent
e0b5fa2d66
commit
020e1958a4
@ -38,6 +38,7 @@ package org.jooq.impl;
|
||||
import static org.jooq.impl.SQLDataType.BLOB;
|
||||
import static org.jooq.impl.SQLDataType.CLOB;
|
||||
import static org.jooq.impl.SQLDataType.NCLOB;
|
||||
import static org.jooq.tools.reflect.Reflect.wrapper;
|
||||
|
||||
import java.lang.reflect.Array;
|
||||
import java.math.BigDecimal;
|
||||
@ -596,6 +597,9 @@ public class DefaultDataType<T> implements DataType<T> {
|
||||
|
||||
public static <T> DataType<T> getDataType(SQLDialect dialect, Class<T> type) {
|
||||
|
||||
// Treat primitive types the same way as their respective wrapper types
|
||||
type = (Class<T>) wrapper(type);
|
||||
|
||||
// Recurse for arrays
|
||||
if (byte[].class != type && type.isArray()) {
|
||||
return (DataType<T>) getDataType(dialect, type.getComponentType()).getArrayDataType();
|
||||
|
||||
@ -179,7 +179,23 @@ class MetaImpl implements Meta {
|
||||
|
||||
try {
|
||||
columnCache = executor
|
||||
.fetch(meta().getColumns(null, getName(), "%", "%"))
|
||||
.fetch(
|
||||
meta().getColumns(null, getName(), "%", "%"),
|
||||
|
||||
// Work around a bug in the SQL Server JDBC driver by
|
||||
// coercing data types to the expected types
|
||||
// The bug was reported here:
|
||||
// https://connect.microsoft.com/SQLServer/feedback/details/775425/jdbc-4-0-databasemetadata-getcolumns-returns-a-resultset-whose-resultsetmetadata-is-inconsistent
|
||||
String.class, // TABLE_CAT
|
||||
String.class, // TABLE_SCHEM
|
||||
String.class, // TABLE_NAME
|
||||
String.class, // COLUMN_NAME
|
||||
int.class, // DATA_TYPE
|
||||
String.class, // TYPE_NAME
|
||||
int.class, // COLUMN_SIZE
|
||||
String.class, // BUFFER_LENGTH
|
||||
int.class // DECIMAL_DIGITS
|
||||
)
|
||||
.intoGroups(fieldByName(String.class, "TABLE_NAME"));
|
||||
|
||||
List<Table<?>> result = new ArrayList<Table<?>>();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user