Skip to content

Select operator does not work as expected with one-to-many relationships #159

Closed
@sadu99

Description

@sadu99

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions