drogon icon indicating copy to clipboard operation
drogon copied to clipboard

[Regression] execSqlSync with string_view

Open kotori2 opened this issue 1 year ago • 4 comments

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):

  • OS: Windows 11 with MSVC 19.33.31629.0
  • Browser: -
  • Version: 1.8.0 release via vcpkg

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.

kotori2 avatar Sep 20 '22 21:09 kotori2

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

an-tao avatar Sep 21 '22 01:09 an-tao

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.

kotori2 avatar Sep 21 '22 01:09 kotori2

Which version works with string_view? 1.7.5?

an-tao avatar Sep 21 '22 02:09 an-tao

1.7.4, also installed from vcpkg

kotori2 avatar Sep 21 '22 03:09 kotori2