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

Allow passing a pop.Model directly #592

Open
zepatrik opened this issue Sep 17, 2020 · 0 comments
Open

Allow passing a pop.Model directly #592

zepatrik opened this issue Sep 17, 2020 · 0 comments
Labels
proposal A suggestion for a change, feature, enhancement, etc s: triage Some tests need to be run to confirm the issue
Milestone

Comments

@zepatrik
Copy link
Contributor

zepatrik commented Sep 17, 2020

Description

I was surprised to figure out I could not pass a pop.Model as the destination. It would be nice to be able to pass that directly and use my own AS name. Here is an example of what I'd like to do:

c.Where("r.subject = ? AND r.skip=FALSE", subject).
   	Where("h.error='{}'").
   	Join("hydra_oauth2_consent_request AS r", "h.challenge = r.challenge").
   	Order("h.requested_at DESC").
   	All(&pop.Model{
   			Value: &rs,
   			As: "h",
   	})

Instead I have to do something like

tn := consent.HandledConsentRequest{}.TableName()

c.Where("r.subject = ? AND r.skip=FALSE", subject).
		Where(fmt.Sprintf("%s.error='{}'", tn)).
		Join("hydra_oauth2_consent_request AS r", fmt.Sprintf("%s.challenge = r.challenge", tn)).
		Order(fmt.Sprintf("%s.requested_at DESC", tn)).
		All(&rs)

I think it is quite easy to implement and can reduce the complexity of writing long queries like the one above.

Expected Behavior

Customize AS through passing a pop.Model.

Actual Behavior

Does not work.

@sio4 sio4 added proposal A suggestion for a change, feature, enhancement, etc s: triage Some tests need to be run to confirm the issue labels Sep 20, 2022
@sio4 sio4 added this to the Backlog milestone Sep 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
proposal A suggestion for a change, feature, enhancement, etc s: triage Some tests need to be run to confirm the issue
Projects
None yet
Development

No branches or pull requests

2 participants