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

Why do we detach the table children from the toplevel family? #524

Closed
open-dynaMIX opened this issue Jun 24, 2019 · 7 comments
Closed

Why do we detach the table children from the toplevel family? #524

open-dynaMIX opened this issue Jun 24, 2019 · 7 comments

Comments

@open-dynaMIX
Copy link
Member

Out of context for this PR, but why do we detach the table children from the toplevel family? This doesn't make any sense IMHO, and puts rocks in our path when fetching the document for validation etc

Originally posted by @winged in #505

@czosel
Copy link
Contributor

czosel commented Jun 24, 2019

/cc @sliverc

@czosel
Copy link
Contributor

czosel commented Jun 24, 2019

Related: #212 (comment)

@czosel
Copy link
Contributor

czosel commented Jun 24, 2019

From what I gathered until now, table rows should always have the same family ID as the root document (in fact, table questions were the reason document families were introduced in the first place). The fact that table rows can have different family IDs seems to be a bug.
I just tested this locally and for me the first row had the right family ID, while the second didn't.

Concerning the question "Why do we detach in the first place?" - Could it be that this is a security measure in case the root document reference is changed in update?

@winged
Copy link
Contributor

winged commented Jun 24, 2019

OK with some more analysis, I think I know why this is done:

The detaching happens so the code is correct in any update case, even when the containing document changes. So the behaviour is this:

  1. detach (by deleting AnswerDocument objects)
  2. save answer (possibly including moving to another document)
  3. reattach by recreating AnswerDocuments

So my original note is wrong, even if the code looks like it.

@sliverc please confirm if my assumption is correct.

In any case, I think it may be worth it to only do the detach-reatach circus if actually needed, just to improve performance a bit. Especially since we won't be able to do bulk updates anymore when #522 lands

@sliverc
Copy link
Member

sliverc commented Jun 25, 2019

@winged
As far as I remember the main reason was that the user interface can already start pre-saving answers before it actually has to add a row to the table. Otherwise it would have to add a table row already before it has all answers which might lead to ghost rows for the user.

I think @anehx and I designed this together and he might have some more feedback on it. If it causes problems this can be rethought though.

@czosel
Copy link
Contributor

czosel commented Jun 26, 2019

👍 That's also how we ended up implementing it - thanks for the affirmation 🙂

@sliverc
Copy link
Member

sliverc commented Jul 29, 2019

@open-dynaMIX Can this be closed or is there still something unclear?

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

4 participants