Skip to content

Join statement just ignored in Dart API #2668

Answered by simolus3
nesmrtelny asked this question in Q&A
Discussion options

You must be logged in to vote

Unlike methods like where that mutate the single-table query, join returns a new object. This is required because we can't have callback-like APIs for WHEREs on joins, so the interface of the statement is slightly different after adding the join.

So you can fix the snippet by storing the result of join in a new variable:

    final joined = tasksQuery.join([
      innerJoin(database.peopleTasks, database.peopleTasks.taskId.equalsExp(database.tasks.id)),
    ]).where(
      database.peopleTasks.personId.equals(personId),
    );

    joined.limit(tasksLimit);

    final rows = await joined.get();

For each row in rows, you can get the todo item with readTable(database.tasks) and the associate…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@nesmrtelny
Comment options

Answer selected by nesmrtelny
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants