-
Notifications
You must be signed in to change notification settings - Fork 208
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
How to generate nested select statements #352
Comments
It looks like replacing Behaves as desired: seasonQuery := dialect.From(models.TableNames.Seasons).Select(models.SeasonColumns.ID).Where(goqu.C(models.SeasonColumns.Status).Eq(models.SeasonsStatusActive))
teamQuery := dialect.From(models.TableNames.Teams).Select(models.TeamColumns.ID).Where(goqu.C(models.TeamColumns.SeasonID).Eq(seasonQuery)) => SELECT `id` FROM `teams` WHERE (`season_id` IN (SELECT `id` FROM `seasons` WHERE (`status` = 'active'))) |
Hey @parnic, I've also recently stumbled upon this bug. I'll make the PR with a fix soon :) In short, |
@parnic I made a PR. But looks like replacing It even has this in tests:
PS. Noticed that you told the same thing about |
Apologies if this is answered somewhere, I tried searching and couldn't find anything.
If I wanted to generate a nested select statement/select subquery similar to the following:
Is that possible with goqu? I've tried something like this for the nested bits:
but using an SQLite dialect it ends up generating a query like:
where the extra
()
in the IN breaks the select from seeing multiple IDs.Is there a way to use one SelectDataset, or a derivative of it, in an In() like this?
The text was updated successfully, but these errors were encountered: