-
Notifications
You must be signed in to change notification settings - Fork 44
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
fix: Order by subtype without selecting the join child #810
fix: Order by subtype without selecting the join child #810
Conversation
e94f1bf
to
e0c9d12
Compare
e0c9d12
to
a1720f3
Compare
Codecov Report
@@ Coverage Diff @@
## develop #810 +/- ##
===========================================
+ Coverage 59.64% 59.68% +0.03%
===========================================
Files 155 155
Lines 17294 17300 +6
===========================================
+ Hits 10315 10325 +10
Misses 6047 6047
+ Partials 932 928 -4
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this needs more tests, sorry. Glad you are finding your way about the mapper file though :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM as long as Andy's concerns related to tests are addressed.
Was this only a problem with query {
user(filter: {author: {age: {_gt: 54}}}) {
name
}
} |
Filter was affected a while ago, maybe pre 0.3.0. Cheers for mentioning the aggregate sort too - it looks like this branch doesn't handle that. new todo: Add tests for sort within aggregate e.g. _sum(childA: {field: childAField, order: {childB: {childBField: ASC}}}) |
78a60ce
to
89fbc26
Compare
@AndrewSisley Have added some more tests according to your suggestion. Found a bug, so the implementation has changed slightly (mostly wasn't setting the child mapping's index properly). I would pay attention to these three one-to-many cases you suggested and see if they are met (as these weren't correct queries I have tried my best to test as close as valid queries to these I could + their opposite direction order counterparts), if there is a way to properly add filter to these LMK: These 6 can be found in
|
Thanks Shahzad, testing is much better but I can still see no tests that cover what I am most concerned about (probably my fault for giving you broken test cases over discord). There seems to be no tests that the correct field will be used (prod code just takes the first). For example the below query with a nested one-many (publishers have many authors, authors have many books).
and
and
Aggregates are important to test separately as they have different codeblocks that deal with adding their dependencies. You could probably add more tests similar to these that include aggregate filters, to make sure that the filter isnt hiding any bugs in the order logic (by filtering out the expected results) - maybe something similar to the last example there, but one test where It is important that the order blocks contain child objects (or group, which would also be good to test), properties on the host object are unaffected by your prod code changes and so aren't worth worrying about. Hope you can see what I'm driving at here, give me a shout if you have any questions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.
Thanks for these test cases, you are correct the prod code at the moment takes the first field if it's a related field (as I wasn't sure if it actually gets put into Does the deeply nested one-many case work for normal query (with selections) before this PR? I can check this shortly after standup today if you aren't sure. If it does then happy to test these and make it work in this PR. If not I think we might be stepping outside of the scope of this PR, and combining multiple tasks that should be separate issues, which is why #833 was made. #588 was only about this panicking (that aspect is resolved now, right? lmk if it isn't):
|
I am not a fan of replacing a panic with us returning incorrect values, I would probably prefer the panic |
100% but where are we returning incorrect values for the test that panicked before? I feel like there are probably X different places that might be panicking or returning incorrect values in develop right now (hidden). We can tackle all those in separate issues rather than one ticket. However as mentioned in the previous message I will see if the deeply nested one to many case works after #827 was merged and if I can produce a normal example of order being used deeply like this: |
The cases I provided will likely be providing incorrect values, as they may be basing their results off the wrong underlying field (e.g. returning the top author, instead of the bottom). For the use-cases I have had in the past (pre-source), a panic would be much much prefered/cheaper than incorrect results. |
If those incorrect values aren't other panics or non-related errors, then as I mentioned I am happy to incorporate them.
No contradiction here. I am quite okay with this behavior especially when there might be a chance of incorrect write. |
89fbc26
to
f0650a3
Compare
As discussed on discord (@AndrewSisley and thanks for helping me navigate these order tests) I have modified your original requested tests from these:
To these 3 counterparts:
The findings were that these all panic, hence No Incorrect Values are seen. As these test cases panicked before this PR, and after changes introduced in this PR, this would fall under what I described previously as:
In other words, separate issues to be tackled after this PR. If you have any other hunches or suggestions to create incorrect values as you mentioned perhaps using inner |
ed6fa0c
to
f3af688
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have some more todos for you sorry, a couple on the tests, and then I reviewed the prod code which I had mostly skipped before.
a913ae1
to
9d07d59
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cheers Shahzad - bit of a tricky area to give someone new to mapper maybe at the end of a release. Thanks for all the effort RE testing, approving now assuming you sort out the prod code/tested-panics soon after the release :)
9d07d59
to
60c70ba
Compare
Cheers @AndrewSisley appreciate you bearing with me and helping me navigate the mapper, also for making me explore these aggregate and orderby test cases to get a better idea of what's happening under the hood. Indeed will try my best to resolve these panics in v0.4. There is an umbrella ticket (#833) that can expand into multiple tickets when these are investigated a bit more. |
Add another test that wasn't panicking and check that the results are providing the correct values.
60c70ba
to
ce2ab3a
Compare
1) Resolves sourcenetwork#588 2) Description - Fix: Bug that caused panic when result was ordered by the subtype / relation / join field and there were no corresponding child fields requested (from that joined type). - Test: Added test to ensure the query now returns valid results without panicing. - Test: Added ton more tests according to code review suggestions. 3) Limitations - Some tests were added to document panics which will be resolved outside this PR in sourcenetwork#833. - Found bug sourcenetwork#826 as part of this PR. - Found bug sourcenetwork#827 (fixed already).
Relevant issue(s)
Resolves #588
Description
Limitations
Tasks
How has this been tested?
CI, Local
Specify the platform(s) on which this was tested: