Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -776,7 +776,7 @@ void ODBCStatement::getColumnCount(SQLSMALLINT* columnCountPtr) {
// error
return;
}
size_t columnCount = m_currentArd->GetRecords().size();
Comment thread
rscales marked this conversation as resolved.
size_t columnCount = m_ird->GetRecords().size();
*columnCountPtr = static_cast<SQLSMALLINT>(columnCount);
}

Expand Down
46 changes: 46 additions & 0 deletions cpp/src/arrow/flight/sql/odbc/tests/statement_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2400,4 +2400,50 @@ TYPED_TEST(FlightSQLODBCTestBase, TestSQLNativeSqlReturnsErrorOnBadInputs) {
this->disconnect();
}

TEST_F(FlightSQLODBCMockTestBase, SQLNumResultColsReturnsColumnsOnSelect) {
this->connect();
this->CreateTestTables();

SQLSMALLINT columnCount = 0;
SQLSMALLINT expectedValue = 3;
SQLWCHAR sqlQuery[] = L"SELECT * FROM TestTable LIMIT 1;";
SQLINTEGER queryLength = static_cast<SQLINTEGER>(wcslen(sqlQuery));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to SQLRowCount, let's run the test on both remote and mock server


SQLRETURN ret = SQLExecDirect(this->stmt, sqlQuery, queryLength);

EXPECT_EQ(ret, SQL_SUCCESS);

ret = SQLFetch(this->stmt);

EXPECT_EQ(ret, SQL_SUCCESS);

CheckIntColumn(this->stmt, 1, 1);
CheckStringColumnW(this->stmt, 2, L"One");
CheckIntColumn(this->stmt, 3, 1);

ret = SQLNumResultCols(this->stmt, &columnCount);

EXPECT_EQ(ret, SQL_SUCCESS);

EXPECT_EQ(columnCount, expectedValue);

this->disconnect();
}

TYPED_TEST(FlightSQLODBCTestBase, SQLNumResultColsFunctionSequenceErrorOnNoQuery) {
this->connect();

SQLSMALLINT columnCount = 0;
SQLSMALLINT expectedValue = 0;

SQLRETURN ret = SQLNumResultCols(this->stmt, &columnCount);
Comment thread
rscales marked this conversation as resolved.

EXPECT_EQ(ret, SQL_ERROR);
VerifyOdbcErrorState(SQL_HANDLE_STMT, this->stmt, error_state_HY010);

EXPECT_EQ(columnCount, expectedValue);

this->disconnect();
}

} // namespace arrow::flight::sql::odbc