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

Support limit queries with Dataloader.Ecto #93

Merged
merged 13 commits into from
Jul 3, 2020

Commits on Jun 20, 2020

  1. Load rows for limit/offset queries with lateral join

    Queries that do not rely on limit/offset continue to use
    the existing approach, where a simple where clause is added
    to the query.
    
    Complex queries are converted into a lateral subquery.
    The outer query contains the inputs.
    Ideally the query would use `unnest` or a similar function
    to efficiently load an array of values into a query, but
    Ecto doesn't offer such functionality in a portable way.
    
    The workaround here is to run a distinct query that selects
    the column from the queryable where the value is any of the
    inputs.
    mbuhot committed Jun 20, 2020
    Configuration menu
    Copy the full SHA
    7403234 View commit details
    Browse the repository at this point in the history

Commits on Jun 23, 2020

  1. Configuration menu
    Copy the full SHA
    9f62347 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    8bd12da View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    1b6daf3 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    8aa9276 View commit details
    Browse the repository at this point in the history
  5. Fix User -> Score relationship to be via post, not leaderboard

    When associating via leaderboard, all users are associated with all scores.
    It makes for a better test to only see that users scores.
    mbuhot committed Jun 23, 2020
    Configuration menu
    Copy the full SHA
    f87ad4d View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    ac82f0c View commit details
    Browse the repository at this point in the history
  7. Simplify limit tests

    mbuhot committed Jun 23, 2020
    Configuration menu
    Copy the full SHA
    6e8b2c1 View commit details
    Browse the repository at this point in the history

Commits on Jun 27, 2020

  1. Fix duplicate records from lateral preload

    This can happen when there is a through association like
    A -has many-> B -belongs to-> C
    
    When loading the A -> C association using a join, duplicate entries for C
    were being returned.
    
    The fix is to throw a distinct() on the inner query.
    There may be a more elegant approach to detecting when
    the distinct is necessary, but at least the results are correct now.
    mbuhot committed Jun 27, 2020
    Configuration menu
    Copy the full SHA
    f21029e View commit details
    Browse the repository at this point in the history
  2. Only distinct lateral preload when required

    When A HasMany B and B BelongsTo C, then A can have the same C multiple times.
    A ManyToMany association is similar.
    mbuhot committed Jun 27, 2020
    Configuration menu
    Copy the full SHA
    7710588 View commit details
    Browse the repository at this point in the history

Commits on Jun 28, 2020

  1. Configuration menu
    Copy the full SHA
    9bd760d View commit details
    Browse the repository at this point in the history
  2. Add support for loading assoc when user query contains limits and joins

    This unfortunately required a significant duplication of the
    build_preload_query code.
    
    When the users query contains joins, the first join from the users
    query to an association must target the first source in the query,
    not the last one.
    mbuhot committed Jun 28, 2020
    Configuration menu
    Copy the full SHA
    6cd72f2 View commit details
    Browse the repository at this point in the history

Commits on Jul 2, 2020

  1. Configuration menu
    Copy the full SHA
    55bfed4 View commit details
    Browse the repository at this point in the history