-
Notifications
You must be signed in to change notification settings - Fork 107
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
Indirect reference to repeat count doesn't update as repeat instances are added #584
Comments
I did quick debugging sessions on v2.17.0 vs master and got to the call on |
Hi @lognaturel! The master...lognaturel:v2.17.0-with-testingdiff-4c309f85e6172ad03a5c4590307ea6b4R105 link doesn't show anything... Did you rebase? It would be great if you can provide or point me in the right direction to a form that reproduces the issue. I could take a look at this during the weekend. |
Thanks and sorry! master...lognaturel:v2.17.0-with-testing. The test is in I did a little more exploration yesterday here are some things I've found interesting:
|
Gosh, this is hard! Starting to look at this now. The good news (I guess) is that we can always bring back the old |
OK, in master I'm getting this in the first set of assertions:
Are we on the same page? |
Changing the assertion to: range(0, 5).forEach(n -> assertThat(scenario.answerOf("/data/repeat[" + n + "]/inner-count"), is(intAnswer(n+1)))); (Notice the Makes it pass, which means that the inner-count calculate is being executed once each time a new repeat is created. The problem is that previous repeats aren't recalculated. I'd swear we explored this issue before... |
How would this be different than the |
Well, it turns out that reverting the See: https://github.com/ggalmazor/javarosa/commit/eb8ade55ea635a31f5045f8b5fe17e8a974d3a6c |
I mentioned above that on bind("/data/count").type("int").calculate("count(/data/repeat)"),
bind("/data/repeat/inner-count").type("int").calculate("count(/data/repeat)")) However, this does not: bind("/data/count").type("int").calculate("4*4"),
bind("/data/repeat/inner-count").type("int").calculate("count(/data/repeat)")) It looks like in the first case the reference to If I use I'm keeping master...lognaturel:issue-584 up to date with interesting tests. |
Edit: always considering the generic ref results in a huge performance regression:
When @ggalmazor and I touched base earlier, we agreed I'd pursue always considering the generic reference and he'd pursue bringing back === As I noted above, replacing @Test
public void onRepeatAdd_calculationsInRepeat_withoutReferenceToRepeat_areOnlyCalculatedForNewInstance() throws IOException {
Scenario scenario = Scenario.init("Count outside repeat used inside", html(
head(
title("Count outside repeat used inside"),
model(
mainInstance(t("data id=\"outside-used-inside\"",
t("repeat jr:template=\"\"",
t("inner-calc")
))),
bind("/data/repeat/inner-calc").type("int").calculate("4*4")),
body(
repeat("/data/repeat",
input("/data/repeat/inner-calc")
)
)))).onDagEvent(dagEvents::add);
dagEvents.clear();
range(0, 5).forEach(n -> {
scenario.next();
scenario.createNewRepeat();
assertThat(scenario.answerOf("/data/repeat[" + n + "]/inner-calc"), CoreMatchers.is(intAnswer(16)));
scenario.next();
});
range(0, 5).forEach(n -> assertThat(scenario.answerOf("/data/repeat[" + n + "]/inner-calc"), CoreMatchers.is(intAnswer(16))));
dagEvents.forEach(event -> System.out.println(event.getDisplayMessage()));
} I also replaced all the logic in
and confirmed that all the delete-based tests get the expected results (with different DAG events). |
I've spent some more time with the original The reason always genericizing the
I believe the firedAnchors approach only handled the first case. I wrote up a quick solution to address the first two: master...lognaturel:issue-584. The third case is trickier because it requires looking at the triggerable expression. Since it has never worked and no one seems to have missed it, I don’t plan to explore it further for now. I ran the I have some more tests I want to write but I wanted to give a quick update. |
On v2.17.0, if there's a calculate with a call on count(repeat) outside of that repeat and then a reference to that calculate inside the repeat, the reference inside the repeat is updated as the repeat count changes when repeat instances are added or removed. See master...lognaturel:v2.17.0-with-testing#diff-4c309f85e6172ad03a5c4590307ea6b4R105 for a branch that runs that test on v2.17.0. The same test fails on
master
.CC @ggalmazor would be great to get your take on this when you have some cycles.
The text was updated successfully, but these errors were encountered: