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

Placeholders in Relation callback #557

Open
arvidfm opened this issue Jun 2, 2022 · 3 comments
Open

Placeholders in Relation callback #557

arvidfm opened this issue Jun 2, 2022 · 3 comments
Labels
enhancement New feature or request stale

Comments

@arvidfm
Copy link

arvidfm commented Jun 2, 2022

It would be nice if placeholders used inside Relation callbacks resolved to the table corresponding to the relation rather than the root model, e.g.:

var card Card
db.NewSelect().Model(&card).
    Relation("Card.Deck.Collection", func(query *bun.SelectQuery) *bun.SelectQuery {
        // ?TableAlias.name should resolve to card__deck__collection.name; currently resolves to card.name
        return query.Where("?TableAlias.name = ?", collectionName)
    })

Possibly related to #154.

@vmihailenco vmihailenco added the enhancement New feature or request label Jun 3, 2022
@imraan-go
Copy link

imraan-go commented Jun 8, 2022

I think this "Where" clause should be appended after join instead of at the end of the query. More details on this issue: #554

@vmihailenco any comment on this ?

@fiftin
Copy link

fiftin commented Jun 20, 2022

@arvidfm , @vmihailenco

We need to come up with a syntax for this feature. Currently I will do like in issue description.

But I think we should replace ?TableAlias to something without ?.

Copy link

github-actions bot commented Nov 7, 2024

This issue has been automatically marked as stale because it has not had activity in the last 30 days. If there is no update within the next 7 days, this issue will be closed.

@github-actions github-actions bot added the stale label Nov 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request stale
Projects
None yet
Development

No branches or pull requests

4 participants