Skip to content

Commit 0fa6143

Browse files
committed
work on co-pilot comments
1 parent 07b9ef4 commit 0fa6143

2 files changed

Lines changed: 13 additions & 8 deletions

File tree

cpp/src/arrow/flight/sql/odbc/odbc_impl/encoding_utils.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,12 @@
3434
#define _SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING
3535

3636
#ifdef __linux__
37-
# define GET_SQWCHAR_PTR(wstring_var) (ODBC::ToSqlWCharVector(wstring_var).data())
37+
# define ODBC_INI reinterpret_cast<LPCWSTR>(u"ODBC.INI")
3838
#else
3939
// Windows and macOS
40-
# define GET_SQWCHAR_PTR(wstring_var) (wstring_var.c_str())
40+
# define ODBC_INI reinterpret_cast<LPCWSTR>(L"ODBC.INI")
4141
#endif
4242

43-
#define ODBC_INI reinterpret_cast<LPCWSTR>(GET_SQWCHAR_PTR(std::wstring(L"ODBC.INI")))
44-
4543
namespace ODBC {
4644

4745
// Return the number of bytes required for the conversion.

cpp/src/arrow/flight/sql/odbc/odbc_impl/system_dsn.cc

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ void PostError(DWORD error_code, LPWSTR error_msg) {
5959

6060
void PostArrowUtilError(arrow::Status error_status) {
6161
std::string error_msg = error_status.message();
62-
std::wstring werror_msg = arrow::util::UTF8ToWideString(error_msg).ValueOr(
63-
L"Error during utf8 to wide string conversion");
62+
CONVERT_SQLWCHAR_STR(werror_msg, error_msg);
6463

65-
PostError(ODBC_ERROR_GENERAL_ERR, const_cast<LPWSTR>(GET_SQWCHAR_PTR(werror_msg)));
64+
PostError(ODBC_ERROR_GENERAL_ERR,
65+
const_cast<LPWSTR>(reinterpret_cast<LPCWSTR>(werror_msg.c_str())));
6666
}
6767

6868
void PostLastInstallerError() {
@@ -94,7 +94,14 @@ void PostLastInstallerError() {
9494
* @return True on success and false on fail.
9595
*/
9696
bool UnregisterDsn(const std::wstring& dsn) {
97-
if (SQLRemoveDSNFromIni(GET_SQWCHAR_PTR(dsn))) {
97+
#ifdef __linux__
98+
auto dsn_vec = ODBC::ToSqlWCharVector(dsn);
99+
const SQLWCHAR* dsn_arr = dsn_vec.data();
100+
#else
101+
// Windows and macOS
102+
const SQLWCHAR* dsn_arr = dsn.c_str();
103+
#endif
104+
if (SQLRemoveDSNFromIni(dsn_arr)) {
98105
return true;
99106
}
100107

0 commit comments

Comments
 (0)