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 operator does not work as expected with one-to-many relationships #159

Closed
sadu99 opened this issue Jun 12, 2017 · 4 comments
Closed

Comments

@sadu99
Copy link

sadu99 commented Jun 12, 2017

What version of SQLBoiler are you using?

SQLBoiler v2.4.0

Issue

Certain columns can be currently selected using the qm.select() operator. However, when querying one-to-many relationships, all columns are selected regardless of the fields passed-in using the qm.select() operator.

If this happened at runtime what code produced the issue?

The following code can be found in the generated models that causes this issue:

	queryMods := []qm.QueryMod{
		qm.Select("\"a\".*"),
	}

	if len(mods) != 0 {
		queryMods = append(queryMods, mods...)
	}

As seen above, a.* is added to the QueryMod slice regardless of the passed-in mods.

Possible Fix

The generated models could contain the following code to make this work:

        queryMods := []qm.QueryMod{}
	if len(mods) != 0 {
		queryMods = append(queryMods, mods...)
	} else {
		queryMods = append(queryMods, qm.Select("\"a\".*"))
	}

Please let me know if the above is sufficient to understand the issue.

@aarondl
Copy link
Member

aarondl commented Jun 15, 2017

Fixed on dev branch. Thanks for the report.

@sadu99
Copy link
Author

sadu99 commented Jun 15, 2017

Thanks for the quick response @aarondl I have tested on dev branch and confirmed the issue is fixed 😄 When will a release be made?

@aarondl
Copy link
Member

aarondl commented Jun 17, 2017

@sadu99 Released :)

@sadu99
Copy link
Author

sadu99 commented Jun 19, 2017

@aarondl Thank you!

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

No branches or pull requests

2 participants