Skip to content

Commit

Permalink
fix col size for string columns
Browse files Browse the repository at this point in the history
  • Loading branch information
artpaul committed Sep 13, 2017
1 parent 526c4a4 commit d3d9f65
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions driver/odbc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ SQLColAttribute(HSTMT statement_handle, SQLUSMALLINT column_number, SQLUSMALLINT
num_value = statement.result.getNumColumns();
break;
case SQL_DESC_DISPLAY_SIZE:
// TODO (artpaul) https://docs.microsoft.com/en-us/sql/odbc/reference/appendixes/display-size
num_value = column_info.display_size;
break;
case SQL_DESC_FIXED_PREC_SCALE:
Expand All @@ -212,15 +213,15 @@ SQLColAttribute(HSTMT statement_handle, SQLUSMALLINT column_number, SQLUSMALLINT
str_value = column_info.name;
break;
case SQL_DESC_LENGTH:
if (type_info.sql_type == SQL_VARCHAR)
if (type_info.IsStringType())
{
if (column_info.fixed_size)
{
num_value = column_info.fixed_size;
}
else
{
num_value = type_info.octet_length;
num_value = column_info.display_size;
}
}
break;
Expand All @@ -242,7 +243,7 @@ SQLColAttribute(HSTMT statement_handle, SQLUSMALLINT column_number, SQLUSMALLINT
if (column_info.fixed_size)
num_value = column_info.fixed_size * SIZEOF_CHAR;
else
num_value = type_info.octet_length * SIZEOF_CHAR;
num_value = column_info.display_size * SIZEOF_CHAR;
}
else
{
Expand Down

0 comments on commit d3d9f65

Please sign in to comment.