Skip to content

Develop utility getters for ODBC APIs#136

Merged
alinaliBQ merged 7 commits intoapache-odbcfrom
getter-tests
Nov 7, 2025
Merged

Develop utility getters for ODBC APIs#136
alinaliBQ merged 7 commits intoapache-odbcfrom
getter-tests

Conversation

@alinaliBQ
Copy link
Copy Markdown

@alinaliBQ alinaliBQ commented Nov 6, 2025

create utility getters and then using standard GTest assertions, instead of making a function for every combination of data type and comparator.
Added getters for:
SQLGetStmtAttr
SQLGetInfo
SQLColAttribute / SQLColAttributes (with s at the end)

Removed disabled tests for SQLGetInfo

Need to verify the development with community
Types added:
- SQLUSMALLINT
- SQLUINTEGER
- SQLULEN
- SQLWCHAR

Prototype `TestSQLGetInfoNullCollation` test
@alinaliBQ alinaliBQ force-pushed the getter-tests branch 2 times, most recently from a5b5cf1 to d071319 Compare November 6, 2025 23:56
- string getter
- number getter

Plus renaming tests

SQLColAttribute prototype `TestSQLColAttributeBasetable_name`
@alinaliBQ alinaliBQ marked this pull request as ready for review November 7, 2025 00:21
void CheckSQLColAttributeString(SQLHSTMT stmt, const std::wstring& wsql, SQLUSMALLINT idx,
SQLUSMALLINT field_identifier,
const std::wstring& expected_attr_string) {
void getSQLColAttributeString(SQLHSTMT stmt, const std::wstring& wsql, SQLUSMALLINT idx,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

PascalCase for function names.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Good catch thanks! Fixed

void CheckSQLColAttributesString(SQLHSTMT stmt, const std::wstring& wsql,
SQLUSMALLINT idx, SQLUSMALLINT field_identifier,
const std::wstring& expected_attr_string) {
void getSQLColAttributesString(SQLHSTMT stmt, const std::wstring& wsql, SQLUSMALLINT idx,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

likewise.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

fixed

CheckSQLColAttributeNumeric(this->stmt, wsql, 1, SQL_DESC_CASE_SENSITIVE, SQL_FALSE);
SQLLEN value;
getSQLColAttributeNumeric(this->stmt, wsql, 1, SQL_DESC_CASE_SENSITIVE, &value);
ASSERT_EQ(SQL_FALSE, value);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Before we had the assertion with the expected value inside CheckSQLColAttributeNumeric() and now it's pulled out. Any particular reason for that? Perhaps it's still worth having a utility function that handles the assertion?

Likewise for all the other spots where this is happening.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I'm pulling out the assertions due to community comment from David: apache#47762 (comment)

@alinaliBQ alinaliBQ closed this Nov 7, 2025
@alinaliBQ alinaliBQ reopened this Nov 7, 2025
@alinaliBQ alinaliBQ closed this Nov 7, 2025
@alinaliBQ alinaliBQ reopened this Nov 7, 2025
Copy link
Copy Markdown
Author

@alinaliBQ alinaliBQ left a comment

Choose a reason for hiding this comment

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

Addressed comments from Justin

void CheckSQLColAttributeString(SQLHSTMT stmt, const std::wstring& wsql, SQLUSMALLINT idx,
SQLUSMALLINT field_identifier,
const std::wstring& expected_attr_string) {
void getSQLColAttributeString(SQLHSTMT stmt, const std::wstring& wsql, SQLUSMALLINT idx,
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Good catch thanks! Fixed

void CheckSQLColAttributesString(SQLHSTMT stmt, const std::wstring& wsql,
SQLUSMALLINT idx, SQLUSMALLINT field_identifier,
const std::wstring& expected_attr_string) {
void getSQLColAttributesString(SQLHSTMT stmt, const std::wstring& wsql, SQLUSMALLINT idx,
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

fixed

SQLUSMALLINT idx, SQLUSMALLINT field_identifier,
SQLLEN expected_attr_numeric) {
// Execute query and check ODBC 2.0 API SQLColAttributes numeric attribute
void getSQLColAttributeNumeric(SQLHSTMT stmt, const std::wstring& wsql, SQLUSMALLINT idx,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Still needs to be updated to PascalCase.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

yes, I missed it, my bad. It is fixed

ASSERT_EQ(SQL_SUCCESS, SQLColAttribute(stmt, idx, field_identifier, 0, 0, 0, value));
}

void getSQLColAttributesNumeric(SQLHSTMT stmt, const std::wstring& wsql, SQLUSMALLINT idx,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Likewise

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

fixed, ty

@alinaliBQ alinaliBQ merged commit e495122 into apache-odbc Nov 7, 2025
21 of 24 checks passed
@alinaliBQ alinaliBQ deleted the getter-tests branch November 7, 2025 21:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants