Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Select distinct with return struct results in extra parenthesis #1341

Open
sujessie opened this issue Aug 2, 2024 · 2 comments
Open

Select distinct with return struct results in extra parenthesis #1341

sujessie opened this issue Aug 2, 2024 · 2 comments

Comments

@sujessie
Copy link

sujessie commented Aug 2, 2024

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"

@trevornagy
Copy link

I can also repro this. @trueqbit / @fnc12

@fnc12
Copy link
Owner

fnc12 commented Aug 7, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants