Skip to content

fix: nested relationship orderBy constraints#586

Merged
kiaking merged 5 commits into
masterfrom
bugfix/571-relations-orderBy
Mar 8, 2020
Merged

fix: nested relationship orderBy constraints#586
kiaking merged 5 commits into
masterfrom
bugfix/571-relations-orderBy

Conversation

@cuebit

@cuebit cuebit commented Mar 5, 2020

Copy link
Copy Markdown
Member

Description

Resolves #571 it is reported that nested relations do not observe any ordering constraints applied to them.

Type of PR:

  • Bugfix
  • Feature
  • Enhancement
  • Documentation
  • Other

Breaking changes:

  • No
  • Yes

Issue Recap

  • Applying orderBy constraint on nested relations is ignored and relationships are loaded in the order in which they were inserted.
  • In some cases where primary keys are integers, the ordering is unreliable because numeric object keys do not preserve the order in which the dictionary is created.

Proposed Solution

  • Use Map to generate relation indexes to make sure the ordering is preserved for numeric keys.
  • Only iterate over recursive relations if the relation query contains any order constraints to avoid expensive iterations for relations without.

@cuebit cuebit added the bug Something isn't working label Mar 5, 2020
@cuebit cuebit self-assigned this Mar 5, 2020
@codecov

codecov Bot commented Mar 5, 2020

Copy link
Copy Markdown

Codecov Report

Merging #586 into master will not change coverage by %.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##            master      #586    +/-   ##
==========================================
  Coverage   100.00%   100.00%            
==========================================
  Files           47        48     +1     
  Lines         1863      2169   +306     
  Branches       258       331    +73     
==========================================
+ Hits          1863      2169   +306     
Impacted Files Coverage Δ
src/query/Query.ts 100.00% <0.00%> (ø)
src/schema/Schema.ts 100.00% <0.00%> (ø)
src/query/processors/Normalizer.ts 100.00% <0.00%> (ø)
src/schema/IdAttribute.ts 100.00% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8b03d84...3115b9b. Read the comment docs.

@kiaking

kiaking commented Mar 8, 2020

Copy link
Copy Markdown
Member

Wonderful! Thank you so much 👍

@kiaking kiaking merged commit 42f25be into master Mar 8, 2020
@kiaking kiaking deleted the bugfix/571-relations-orderBy branch March 8, 2020 13:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Many-to-many relations orderBy constraint does not resolve

2 participants