drogonframework / drogonframework/drogon

Compilation errors related to the SqlBinder class and lambda functions passed to execSqlAsync

Open
#1,896 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
14.3k
Forks
1.4k
Avg merge
1d 12h
Merged PRs (30d)
15

Description

Description of the Problem:
I am using Drogon's ORM to interact with a MariaDB database. The application involves creating and retrieving Event objects from the database. However, I am facing compilation errors primarily in the EventRepository class, particularly in the insertEvent and getEventById methods. These methods use the execSqlAsync function to execute SQL queries asynchronously.

Errors:
The compilation errors are mostly related to the SqlBinder class and lambda functions passed to execSqlAsync. Here are some of the error messages:

Error related to conversion in SqlBinder.h: cannot convert '(lambda)' to 'uint16_t' without a conversion operator
Errors in FunctionTraits.h about std::remove_reference::type not being a class, namespace, or enumeration.
Incomplete definition errors in SqlBinder and FunctionTraits.

Code Snippets:
Here are the key parts of my code:

void EventRepository::insertEvent(const Playfuse::models::Event& event, std::function callback) {
std::string query = "INSERT INTO events (...) VALUES (?, ?, ?, ?, ?, ?, ?, ?)";
dbClient_->execSqlAsync(query, event.getCreatorID(), ..., [callback](const drogon::orm::Result& result) {
// ...
}, [callback](const drogon::orm::DrogonDbException& e) {
// ...
});
}

void EventRepository::getEventById(int eventID, std::function callback) {
std::string query = "SELECT ... FROM events WHERE EventID = ?";
dbClient_->execSqlAsync(query, eventID, ...);
}

I suspect the issue might be related to how I'm passing arguments or lambda functions to `execSqlAsync`. The application compiles when I comment out the event values in these methods.

Any insights into what might be causing these errors and how to fix them would be greatly appreciated. Thank you in advance for your help!

Best regards,

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the compilation failure in EventRepository::insertEvent and getEventById with the event values enabled, then inspect SqlBinder.h and FunctionTraits.h along the execSqlAsync overload used. Compare the lambda and argument forms with the documented or existing execSqlAsync usage in the repository. Done means the affected methods compile without the reported SqlBinder and FunctionTraits errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, sql
Domain
databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.