drogonframework / drogon

Drogon: A C++14/17/20 based HTTP web application framework running on Linux/macOS/Unix/Windows
MIT License
11.52k stars 1.1k forks source link

[Regression] execSqlSync with string_view #1389

Open kotori2 opened 2 years ago

kotori2 commented 2 years ago

Describe the bug In the previous version, execSqlSync can be used with string_view, but it is broken now.

To Reproduce

    std::string s;
    std::string_view sv(s);
    drogon::TransactionPtr trans;
    trans->execSqlSync("ANYTHING", sv);

Expected behavior No compilation error.

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

Additional context

E:\link\code\REDACTED\cmake-build-debug\vcpkg_installed\x64-windows\include\drogon/orm/SqlBinder.h(377): error C2664: “u_short htons(u_short)”: 无法将参数 1 从“std::string_view”转换为“u_short”
E:\link\code\REDACTED\cmake-build-debug\vcpkg_installed\x64-windows\include\drogon/orm/SqlBinder.h(377): note: 没有可用于执行该转换的用户定义的转换运算符,或者无法调用该运算符
C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\um\winsock2.h(1813): note: 参见“htons”的声明
E:\link\code\REDACTED\cmake-build-debug\vcpkg_installed\x64-windows\include\drogon/orm/DbClient.h(189): note: 查看对正在编译的函数 模板 实例化“drogon::orm::internal::SqlBinder &drogon::orm::internal::SqlBinder::operator <<<std::string_view&>(T)”的引用
        with
        [
            T=std::string_view &
        ]
E:\link\code\REDACTED\models\REDACTED.cpp(158): note: 查看对正在编译的函数 模板 实例化“const drogon::orm::Result drogon::orm::DbClient::execSqlSync<std::string_view&>(const std::string &,std::string_view &) noexcept(false)”的引用
E:\link\code\REDACTED\cmake-build-debug\vcpkg_installed\x64-windows\include\drogon/orm/SqlBinder.h(380): error C2664: “u_long htonl(u_long)”: 无法将参数 1 从“std::string_view”转换为“u_long”
E:\link\code\REDACTED\cmake-build-debug\vcpkg_installed\x64-windows\include\drogon/orm/SqlBinder.h(380): note: 没有可用于执行该转换的用户定义的转换运算符,或者无法调用该运算符
C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\um\winsock2.h(1796): note: 参见“htonl”的声明
E:\link\code\REDACTED\cmake-build-debug\vcpkg_installed\x64-windows\include\drogon/orm/SqlBinder.h(384): error C2664: “unsigned __int64 htonll(unsigned __int64)”: 无法将参数 1 从“std::string_view”转换为“unsigned __int64”
E:\link\code\REDACTED\cmake-build-debug\vcpkg_installed\x64-windows\include\drogon/orm/SqlBinder.h(384): note: 没有可用于执行该转换的用户定义的转换运算符,或者无法调用该运算符
C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\um\winsock2.h(1887): note: 参见“htonll”的声明
ninja: build stopped: subcommand failed.
an-tao commented 2 years ago

please use string_view instead of std::string_view, maybe the boost::string_view is used in your enviroment.

kotori2 commented 2 years ago

please use string_view instead of std::string_view, maybe the boost::string_view is used in your enviroment.

It makes no difference. string_view (without namespace) seems to be defined by MSVC. Additionally I'm not using any boost things in my code.

an-tao commented 2 years ago

Which version works with string_view? 1.7.5?

kotori2 commented 2 years ago

1.7.4, also installed from vcpkg