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

relationship constraints don't propagate through HasManyThrough #241

Open
davidAtInleague opened this issue Dec 13, 2023 · 1 comment
Open

Comments

@davidAtInleague
Copy link
Contributor

davidAtInleague commented Dec 13, 2023

Constraints that are applied through a hasMany are not applied when that hasMany is used as part of a hasManyThrough.

Minimal repro as follows.

component /*Foo*/ extends="quick.models.BaseEntity" accessors=true {
	function a_() {
	        // we expect this to fail, when run, because someJunkColumn is not a valid column name in the db
		return hasMany( relationName = "a_", localKey = "x", foreignKey = "x" ).whereRaw("[someJunkColumn] = 999");
	}
	function a() {
		return hasManyThrough( [ "a_", "alike" ] )
	}
}

getInstance("Foo").with("a_").firstOrFail() // as expected, a database error: invalid column [someJunkColumn]
getInstance("Foo").with("a").firstOrFail() // no error, because additional constraints on a_ aren't applied

quick 6.2.0, quick 7.2.0

@elpete
Copy link
Collaborator

elpete commented May 31, 2024

hasManyThrough has changed a lot from Quick 8 on. Can you test if this is still a problem on Quick 8+?

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