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

Migrate from retrieveQuery to asQuery - object type returned from asQuery not accepted where object type returned from retrieveQuery is accepted. #226

Open
davidAtInleague opened this issue Jun 5, 2023 · 1 comment

Comments

@davidAtInleague
Copy link
Contributor

davidAtInleague commented Jun 5, 2023

quick 6.2.1

The following example demonstrates a pattern of using Quick to build some (arbitrarily complicated and reusable) where clause, and then using that clause to drive a QB whereIn.

The result of retrieveQuery has been (and remains) fine here, but using the result of asQuery throws an exception.


getInstance("QueryBuilder@qb")
	.from("some_other_table")
	// ok
	.whereIn("ID", getInstance("User").someFilterScope().retrieveQuery().reselect("ID") )

	// fails with:
	// Invalid call of the function [compileSelect],
	// first Argument [query] is of invalid type,
	// Cannot cast Object type [Component quick.models.QuickBuilder] to a value of type [QueryBuilder]
	.whereIn("ID", getInstance("User").someFilterScope().asQuery().reselect("ID") )
	.get()
@elpete
Copy link
Collaborator

elpete commented Jun 7, 2023

Ah. I see why. You are passing a QuickBuilder instance into a QueryBuilder instance. It would work if they were both QuickBuilder instances.

I’m not sure how possible it will be to support passing in a QuickBuilder to a QueryBuilder. This seems like a place where retrieveQuery is probably the right option, but I’ll keep this issue open in case inspiration strikes.

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