drogonframework / drogonframework/drogon
Unsigned numbers converted to a string as if they were signed number when executing SQL queries.
- Dominant language
- C++
- Stars
- 14.3k
- Forks
- 1.4k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 15
Description
**Describe the bug**
When executing a query in Drogon, and providing a number (of any kind), the number is then converted to a string to then execute the query.
Drogon does not take into account whether the integer is signed or unsigned, and treats it as an unsigned integer regardless.
Therefore, if the number is a `uint64_t number = 0xFFFFFFFFFFFFFFFF` Drogon will execute a query containing a `-1` instead of `18446744073709551615`.
It is also possible that a mathematical representation of the number is given in the query instead of the simple number, this is according to the Visual Studio debugger, but this might just be the way Visual Studio represents those numbers in the debugger.
Unfortunately I couldn't extract the actually executed query from Drogon for now to be sure.
**To Reproduce**
In my code, I use execSqlAsyncFuture, this should have an influence on the result
```cpp
//...
uint64_t token = 0xFFFFFFFFFFFFFFFF;
// In a real life example, the number 11257680082823560026 was used (those are randomly generated)
queryResult = dbClient->execSqlAsyncFuture("INSERT INTO Sessions (user_id, token, last_action) VALUES (?, ?, ?)",
userID, token, App::utils::datetimeToString(std::time(0)));
```
**Expected behavior**
The expected behavior is for drogon to take into account that the number might be unsigned, therefore converting to an appropriate string.
**Desktop (please complete the following information):**
- 5.10.60.1-microsoft-standard-WSL2 #\1 SMP Wed Aug 25 23:20:18 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux (Ubuntu)
The code is edited on Visual Studio 2022, but everything is compiled and run on the WSL
Contributor guide
Assessment
This issue has not been assessed yet.