Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upHow to build a conditional query #455
Comments
This comment has been minimized.
|
One way to solve this is to box the query in each branch (with Marcel Müller notifications@github.com schrieb am So. 2. Okt. 2016 um
|
This comment has been minimized.
TheNeikos
commented
Oct 2, 2016
•
|
Hm, doing that gives me this error:
Adding that attribute just raises it to 256 :v Edit: Okay, adding Thanks! |
TheNeikos
closed this
Oct 2, 2016
This comment has been minimized.
|
Yeah, you're correct. You'll need to box it before the branch, but you won't need to box it again in each branch. Once it's boxed it stays boxed forever. |
This comment has been minimized.
pka
commented
Jan 27, 2018
|
After an hour or two of trying to compose a query like this, I gave up and looked through all issues finding this solution on page 15 of the closed tickets This deserves a hint in the documentation (or a more prominent one, in case it's already documented). The ability to compose queries programmatically in a readable way is a fundamental advantage of an ORM compared to raw SQL. Thanks for this great library! |
This comment has been minimized.
It is already in the docs. For example here. |
This comment has been minimized.
pka
commented
Jan 27, 2018
•
|
What about a sentence in the Getting Started guide like "In cases where you want to conditionally modify a query, use into_boxed to box the pieces of a query into a single type."? |
TheNeikos commentedOct 2, 2016
•
edited
Due to the fact that the
filtermethod returns a new type I'm unable to create a 'dynamic' query. Basically I want to do something like this:This fails to compile due to the fact that query gets typed right away and it might or might not change.
Is this something that can be addressed? I'd rather not have
N!code paths to run through.A macro would be a suitable replacement, however I am not knowledgeable enough to create it.