diff --git a/cmake_scripts/default_build_setup.cmake b/cmake_scripts/default_build_setup.cmake index 10c74a6ac..8ef6fac0b 100644 --- a/cmake_scripts/default_build_setup.cmake +++ b/cmake_scripts/default_build_setup.cmake @@ -64,3 +64,11 @@ add_custom_target(refresh_cmake_configuration cmake -E touch ${CMAKE_PARENT_LIST_FILE} # make cmake detect configuration is changed on NEXT build COMMENT "Forcing refreshing of the CMake configuration. This allows to use globbing safely." ) + +if(WIN32) + add_definitions("-std=c++17") + link_directories("$ENV{PYTHON}/libs") + set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS "TRUE") + set(Boost_USE_STATIC_RUNTIME "ON") + set(Boost_USE_STATIC_LIBS "ON") +endif() diff --git a/cpp/cpp_odbc/CMakeLists.txt b/cpp/cpp_odbc/CMakeLists.txt index e58adb288..5bb942d43 100644 --- a/cpp/cpp_odbc/CMakeLists.txt +++ b/cpp/cpp_odbc/CMakeLists.txt @@ -1,3 +1,6 @@ +find_package(Boost REQUIRED COMPONENTS locale) +include_directories(SYSTEM ${Boost_INCLUDE_DIRS}) + find_package(odbc REQUIRED) include_directories(SYSTEM ${Odbc_INCLUDE_DIR}) diff --git a/cpp/cpp_odbc/Library/src/level2/level1_connector.cpp b/cpp/cpp_odbc/Library/src/level2/level1_connector.cpp index fca4c1f95..276025f47 100644 --- a/cpp/cpp_odbc/Library/src/level2/level1_connector.cpp +++ b/cpp/cpp_odbc/Library/src/level2/level1_connector.cpp @@ -20,6 +20,8 @@ #include #include +#include + namespace impl { template @@ -430,7 +432,12 @@ column_description level1_connector::do_describe_column_wide(statement_handle co impl::throw_on_error(return_code, *this, handle); - std::string const utf8_name = std::wstring_convert, char16_t>{}.to_bytes(name); + // TODO-Simeon: throws + // throw std::invalid_argument("Simeon conversion in level1_connector"); + // TODO-Simeon: throws + + //std::string const utf8_name = std::wstring_convert, char16_t>{}.to_bytes(name); + auto const utf8_name = boost::locale::conv::utf_to_utf(static_cast(name)); return {utf8_name, data_type, size, decimal_digits, allows_nullable}; } diff --git a/cpp/turbodbc/CMakeLists.txt b/cpp/turbodbc/CMakeLists.txt index 2e41feddf..31a385f61 100644 --- a/cpp/turbodbc/CMakeLists.txt +++ b/cpp/turbodbc/CMakeLists.txt @@ -1,4 +1,4 @@ -find_package(Boost REQUIRED COMPONENTS system date_time) +find_package(Boost REQUIRED COMPONENTS system date_time locale) include_directories(SYSTEM ${Boost_INCLUDE_DIRS}) find_package(odbc REQUIRED) diff --git a/cpp/turbodbc/Library/src/connect.cpp b/cpp/turbodbc/Library/src/connect.cpp index 34002523b..7992ede1e 100644 --- a/cpp/turbodbc/Library/src/connect.cpp +++ b/cpp/turbodbc/Library/src/connect.cpp @@ -1,6 +1,8 @@ #include "turbodbc/connect.h" #include +using namespace std; + turbodbc::connection turbodbc::connect(std::string const & connection_string, options options) { auto environment = cpp_odbc::make_environment(); diff --git a/cpp/turbodbc/Library/src/cursor.cpp b/cpp/turbodbc/Library/src/cursor.cpp index 56d18a5ab..5a5883b84 100644 --- a/cpp/turbodbc/Library/src/cursor.cpp +++ b/cpp/turbodbc/Library/src/cursor.cpp @@ -14,12 +14,19 @@ #include #include +#include + namespace { std::u16string as_utf16(std::string utf8_encoded) { + // TODO-Simeon: throws + // throw std::invalid_argument("Simeon conversion in cursor"); + // TODO-Simeon: throws + // not all compilers support the new C++11 conversion facets - static std::wstring_convert, char16_t> converter; - return converter.from_bytes(utf8_encoded); + return boost::locale::conv::utf_to_utf(utf8_encoded); + //static std::wstring_convert, char16_t> converter; + //return converter.from_bytes(utf8_encoded); } } diff --git a/cpp/turbodbc_arrow/Library/src/arrow_result_set.cpp b/cpp/turbodbc_arrow/Library/src/arrow_result_set.cpp index 84ce79ae2..bcb0631d8 100644 --- a/cpp/turbodbc_arrow/Library/src/arrow_result_set.cpp +++ b/cpp/turbodbc_arrow/Library/src/arrow_result_set.cpp @@ -15,6 +15,8 @@ #include #include +#include + using arrow::default_memory_pool; using arrow::AdaptiveIntBuilder; using arrow::ArrayBuilder; @@ -127,7 +129,11 @@ Status AppendUnicodeStringsToBuilder(size_t rows_in_batch, BuilderType& builder, if (element.indicator == SQL_NULL_DATA) { ARROW_RETURN_NOT_OK(builder.AppendNullProxy()); } else { + // TODO-Simeon: throws + // throw std::invalid_argument("Simeon conversion in arrow_result_set"); + // TODO-Simeon: throws std::u16string str_u16(reinterpret_cast(element.data_pointer), element.indicator / 2); + //std::string u8string = std::wstring_convert, char16_t>{}.to_bytes(str_u16); std::string u8string = std::wstring_convert, char16_t>{}.to_bytes(str_u16); ARROW_RETURN_NOT_OK(builder.AppendProxy(u8string.data(), u8string.size())); } diff --git a/cpp/turbodbc_arrow/Library/src/set_arrow_parameters.cpp b/cpp/turbodbc_arrow/Library/src/set_arrow_parameters.cpp index 3d1e94f9d..703b6a8f0 100644 --- a/cpp/turbodbc_arrow/Library/src/set_arrow_parameters.cpp +++ b/cpp/turbodbc_arrow/Library/src/set_arrow_parameters.cpp @@ -14,6 +14,8 @@ #include #include +#include + using arrow::BooleanArray; using arrow::BinaryArray; using arrow::ChunkedArray; diff --git a/environment.yml b/environment.yml index 845019ee0..1950f28be 100644 --- a/environment.yml +++ b/environment.yml @@ -4,7 +4,7 @@ channels: dependencies: - python>=3.9 - pyarrow>=7.0,<14 - - sel(unix): unixodbc + # - sel(unix): unixodbc - c-compiler - cxx-compiler - gmock=1.10.0 diff --git a/x_read.py b/x_read.py index 544559e39..2f1678813 100644 --- a/x_read.py +++ b/x_read.py @@ -36,7 +36,7 @@ def mssql_connect_turbodbc() -> turbodbc.connection.Connection: ) -smoke() +# smoke() which = input("Which query: ") if len(sys.argv) < 2 else sys.argv[-1]