Skip to content

Commit 5d87dc5

Browse files
authored
Merge pull request wankdanker#85 from markdirish/2.3.0-date-time-size
2.3.0 date time size
2 parents 60aa6e4 + a028006 commit 5d87dc5

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

src/odbc_connection.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2032,6 +2032,22 @@ SQLRETURN ODBCConnection::BindColumns(QueryData *data) {
20322032
DEBUG_PRINTF("[SQLHENV: %p][SQLHDBC: %p][SQLHSTMT: %p] ODBCConnection::BindColumns(): SQLDescribeCol FAILED: SQLRETURN = %d\n", this->hENV, this->hDBC, data->hSTMT, data->sqlReturnCode);
20332033
return data->sqlReturnCode;
20342034
}
2035+
2036+
// ensuring ColumnSize values are valid according to ODBC docs
2037+
if (column->DataType == SQL_TYPE_DATE && column->ColumnSize < 10) {
2038+
// ODBC docs say this should be 10, but some drivers have bugs that
2039+
// return invalid values. eg. 4D
2040+
// Ensure that it is a minimum of 10.
2041+
column->ColumnSize = 10;
2042+
}
2043+
2044+
if (column->DataType == SQL_TYPE_TIME && column->ColumnSize < 8) {
2045+
// ODBC docs say this should be 8, but some drivers have bugs that
2046+
// return invalid values. eg. 4D
2047+
// Ensure that it is a minimum of 8.
2048+
column->ColumnSize = 8;
2049+
}
2050+
20352051
DEBUG_PRINTF("[SQLHENV: %p][SQLHDBC: %p][SQLHSTMT: %p] ODBCConnection::BindColumns(): SQLDescribeCol passed: ColumnName = %s, NameLength = %d, DataType = %d, ColumnSize = %lu, DecimalDigits = %d, Nullable = %d\n", this->hENV, this->hDBC, data->hSTMT, column->ColumnName, column->NameLength, column->DataType, column->ColumnSize, column->DecimalDigits, column->Nullable);
20362052
// bind depending on the column
20372053
switch(column->DataType) {

0 commit comments

Comments
 (0)