sqlite_orm icon indicating copy to clipboard operation
sqlite_orm copied to clipboard

Select distinct with return struct results in extra parenthesis

Open sujessie opened this issue 1 year ago • 2 comments

Using select distinct with a return struct generates a statement that includes parenthesis around the columns, resulting in an error. Without distinct, there are no extra parenthesis generated.

Example:

struct User
{
    uint32_t id;
    std::string name;
};

constexpr auto userStruct = sqlite_orm::struct_<User>(&User::id, &User::name);
auto const selectDistinct = sqlite_orm::distinct(userStruct);
auto statement = sqlite_orm::select(selectDistinct);

auto str = storage->dump(statement);

Resulting SQLite statement: SELECT DISTINCT(("Users"."id", "Users"."name")) FROM "Users"

Error: row value misused: SQL logic error

Without distinct: SELECT "User"."id", "User"."name" FROM "Users"

sujessie avatar Aug 02 '24 20:08 sujessie

I can also repro this. @trueqbit / @fnc12

trevornagy avatar Aug 02 '24 23:08 trevornagy

I'll look into it soon after v1.9 release is done

fnc12 avatar Aug 07 '24 05:08 fnc12