-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Crash when filtering entities using an unkown column name #6600
Comments
This should be a duplicate of #6597
|
@grzesiek2010 I've assigned #6597 to you as well, so the PR should just mark both issues as closed (assuming the fix does tackle both). |
To me, this is not a duplicate, as these are two distinct issues:
@lognaturel please correct me if I'm wrong. |
@grzesiek2010 yeah it sounds like they're subtly different to me from that. I still think it makes sense to just tackle them together though as the changes should be within the same area? |
Yes the fix is actually the same I just wanted to make it clear that the issues are not duplicates. |
Sorry if I'm coming across as pedantic! I want to make sure we have alignment on this because if we have misunderstandings about the expression the implementation might be wrong. The user intent is different between the two so I agree on that. But I still believe that the query shape is identical. It's entirely possible that I have a misunderstanding too so I want to outline my thinking.
To me, this wording implies that Maybe the form I shared with this pattern caused confusion because it also had calculates with expressions like
That sounds right. That part of the expression should be equivalent to
Can you say more about what that means and how it's different from how the other query is evaluated? |
Yes, the query is identical as in both cases a missing column is detected and an SQLiteException is thrown. That's because that undefined is treated as a column. However, when we fall back to JR it is treated as a value (empty string) that we compare with an answer entered for a given question.
I didn't debug JR (I only added tests) so maybe I'm wrong but I assumed that in the example you shared with me earlier: isn't that right? That's what I meant by saying that:
Again at the moment of building an SQLite query, both cases result in a missing column, and an exception is thrown but then when we fall back to JR: That's the difference. Does that make sense? |
I've just gone a bit of a journey caching up on this. There are two things that were throwing me off:
Given that, I now understand the comment "undefined should be treated as a column which doesn't exist" from @lognaturel (and the following discussion) which was messing with me, but I'm now also confused as to why this isn't a duplicate of #6597: Please correct me if I'm wrong here as I don't want to review #6601 again until I'm confident I've got this in my head properly. |
Got it about XLSForm sugar, sorry about that. I still see them as duplicate issues. As I understand it, @grzesiek2010 is making a distinction between an expression with an unknown column and a literal value vs an unknown column and a form reference. See more at #6601 (comment) |
Ok so basically so we can break it down to two kinds of related expressions that are causing problems:
Forgetting about the optimizations for a sec and just considering XPath semantics, both expressions are semantically equivalent to If that's the case, I think we can optimize these expressions - even if they're nested with an |
I agree that it would be very nice to optimize these but not critical for now. I put some thoughts on how at #6601 (comment) |
Problem description
The app crashes when filtering entities using an expression that checks if another question in a form has no answer, using
undefined
ornull
instead of an empty string. Logic like:${q0} = undefined
.Steps to reproduce the problem
Expected behavior
There should be no crash. We can't optimize such filters that reference other questions, as the SQLite queries we build for optimization rely solely on the entities database.
The text was updated successfully, but these errors were encountered: