Skip to content

Test for Merging a bidirectional list creates unnecessary UPDATE statement #1531

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

Merged

Conversation

RogerKratz
Copy link
Contributor

@RogerKratz RogerKratz commented Jan 12, 2018

Test for #1530.

* collection owns FK (inverse=false)
* Removing OrderIndex on child
* Set update/insert=false on child's parent mapping
* Set parent's list's key/parent to update=false
@RogerKratz RogerKratz changed the title Failing test for issue #1530 Green tests for issue #1530 Jan 17, 2018
@RogerKratz
Copy link
Contributor Author

Could get my tests green without any code changes, just changed the mapping. However - it was far from obvious how to get this right... Still think "normal" biref should work. Anyhow, to make this use case work, I had to change the mapping as follows...

  • collection owns FK (inverse=false)
  • Removing OrderIndex on child
  • Set update/insert=false on child's parent mapping
  • Set parent's list's key/parent to update=false <-- This took me some time to find out

Don't know if...

  • this PR/issue should be deleted
  • docs should be updated with above info
  • this PR with old, "normal" mapping should work so the bug/issue is still valid

@fredericDelaporte
Copy link
Member

Still think "normal" biref should work.

Well it works if I have understood all this well, but in a sub-optimal manner.

  • docs should be updated with above info

Why not, doc sources are in doc\reference\modules, if you see a proper way of documenting this.

  • this PR with old, "normal" mapping should work so the bug/issue is still valid

Ideally it should work in an optimal way (a single insert rather than insert then update), but if this implies too complicated code for achieving a single insert, I will not consider it is worth it. Especially since mapping with a list is not a common place thing I think, because in my experience it causes more issues than it resolves. (I have always ended up handling my indexes manually for setting their value, while using an order-by in my collection mapping for sorting according to them.)

@hazzik
Copy link
Member

hazzik commented Nov 5, 2018

Not sure what to do with this tests :(

@RogerKratz
Copy link
Contributor Author

Just delete them in their present form.
What would be really good if they were green using "normal" bidirectional mapping. So maybe keep them as failing test with "normal" mapping instead?

@fredericDelaporte
Copy link
Member

Thinking about it again, should a list mapped as inverse even be considered a "normal" thing? Handling indexes looks more as the responsibility of the list. At least, the list is always concerned by the indexes, while children may ignore them completely.

@RogerKratz
Copy link
Contributor Author

Sorry, didn't mean it was a "normal thing to do", but rather "the normal way of mapping a biref collection is using inverse=true".
That being said, feel free to just drop this PR.

@fredericDelaporte
Copy link
Member

Closing this PR should be done if #1530 is closed too without being done. I do not think it should be closed.

So I have updated this PR for including again the failing case, along with the mapping not having the issue. The failing case is marked as known bug for allowing merging this.

I have also moved the files to a folder named GH1530, as it is the preferred naming under NHSpecificTest.

@fredericDelaporte fredericDelaporte added this to the 5.2 milestone Nov 7, 2018
@fredericDelaporte fredericDelaporte changed the title Green tests for issue #1530 Test for Merging a bidirectonal list creates unecessary UPDATE statement Nov 7, 2018
@fredericDelaporte fredericDelaporte merged commit 9de4aaa into nhibernate:master Nov 8, 2018
@fredericDelaporte fredericDelaporte changed the title Test for Merging a bidirectonal list creates unecessary UPDATE statement Test for Merging a bidirectional list creates unnecessary UPDATE statement Nov 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants