Summary
database/sql.ColumnType.DatabaseTypeName() always returns "" because the driver's Rows type does not implement the ColumnTypeDatabaseTypeName(index int) string interface.
This makes it impossible for callers to distinguish text columns (VARCHAR, WVARCHAR, etc.) from binary columns (BINARY, VARBINARY) when both arrive as []byte values.
Context
The ODBC SQL type is already available — BaseColumn.SQLType is populated by SQLDescribeCol during column setup in NewColumn(). It just needs to be exposed as a string via the database/sql optional interface.
Suggested implementation
Add to rows.go:
func (r *Rows) ColumnTypeDatabaseTypeName(index int) string {
// requires exposing SQLType from the Column interface
}
The mapping from api.SQL_* constants to names is straightforward (SQL_VARCHAR → "VARCHAR", SQL_WCHAR → "WCHAR", etc.). The Column interface would need a method to expose BaseColumn.SQLType, or the implementation could type-assert through the concrete types.
Use case
I maintain a read-only REST API for Microsoft Access databases. The ACE ODBC driver returns text fields as []byte (via SQL_C_CHAR/SQL_C_WCHAR). Without DatabaseTypeName(), there's no way to distinguish text from binary/OLE columns — both arrive as []byte. Currently working around this with a UTF-8 validity heuristic, but the proper fix is driver-level type metadata.
Summary
database/sql.ColumnType.DatabaseTypeName()always returns""because the driver'sRowstype does not implement theColumnTypeDatabaseTypeName(index int) stringinterface.This makes it impossible for callers to distinguish text columns (
VARCHAR,WVARCHAR, etc.) from binary columns (BINARY,VARBINARY) when both arrive as[]bytevalues.Context
The ODBC SQL type is already available —
BaseColumn.SQLTypeis populated bySQLDescribeColduring column setup inNewColumn(). It just needs to be exposed as a string via thedatabase/sqloptional interface.Suggested implementation
Add to
rows.go:The mapping from
api.SQL_*constants to names is straightforward (SQL_VARCHAR → "VARCHAR", SQL_WCHAR → "WCHAR", etc.). TheColumninterface would need a method to exposeBaseColumn.SQLType, or the implementation could type-assert through the concrete types.Use case
I maintain a read-only REST API for Microsoft Access databases. The ACE ODBC driver returns text fields as
[]byte(viaSQL_C_CHAR/SQL_C_WCHAR). WithoutDatabaseTypeName(), there's no way to distinguish text from binary/OLE columns — both arrive as[]byte. Currently working around this with a UTF-8 validity heuristic, but the proper fix is driver-level type metadata.