drogonframework / drogonframework/drogon

[Regression] execSqlSync with string_view

Open
#1,389 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
14.3k
Forks
1.4k
Avg merge
1d 13h
Merged PRs (30d)
14

Description

**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 <<(T)”的引用
with
[
T=std::string_view &
]
E:\link\code\REDACTED\models\REDACTED.cpp(158): note: 查看对正在编译的函数 模板 实例化“const drogon::orm::Result drogon::orm::DbClient::execSqlSync(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.
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.