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

feat(relations): support macro ?TableAlias in relation callback #585

Closed
wants to merge 3 commits into from
Closed

feat(relations): support macro ?TableAlias in relation callback #585

wants to merge 3 commits into from

Conversation

fiftin
Copy link

@fiftin fiftin commented Jun 20, 2022

Relates to #557

Add ability to use macro ?TableAlias to substitution related table alias.

Example:

var card Card
db.NewSelect().Model(&card).
    Relation("Card.Deck.Collection", func(query *bun.SelectQuery) *bun.SelectQuery {
        return query.Where("?TableAlias.name = ?", collectionName)
    })

@vmihailenco
Copy link
Member

Thanks for the effort, but we need to find a solution that does not involve using regexps. I guess we need to bind the fmter to use the right model when appending relations...

@fiftin
Copy link
Author

fiftin commented Jun 27, 2022

@vmihailenco Fixed

@fiftin
Copy link
Author

fiftin commented Jul 11, 2022

Hi @vmihailenco Please check the PR.

@fiftin fiftin closed this Aug 1, 2022
@vmihailenco
Copy link
Member

Hi @fiftin,

I still have plans to look at this when time allows. Sorry for the delay.

@vmihailenco vmihailenco reopened this Aug 1, 2022
@fiftin
Copy link
Author

fiftin commented Aug 2, 2022

I created this PR for MTS contest only, contest finished. Thank you. I don't want you to merge the PR and use the code.

@fiftin fiftin closed this Aug 2, 2022
@fiftin fiftin deleted the table_alias branch August 2, 2022 16:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants