leftJoin<Tb> method

TupleJoinQuerySource<TDao, Tb?> leftJoin<Tb>(
  1. DataBean<Tb> other, {
  2. Filter? filter,
})

Create JoinedQuerySource where this DataBean is used as main source.

This will create a left join. (Return value for other will be nullable)

When mainField and otherField are null, the only ForeignKey of this is used as mainField and the corresponding PrimaryKey of other is used as otherField. If this bean has multiple ForeignKeys to other, this throws a PersistenceException.

Implementation

TupleJoinQuerySource<TDao, Tb?> leftJoin<Tb>(DataBean<Tb> other,
    {Filter? filter}) {
  if (filter == null) {
    final foreignField = fields
        .whereType<ForeignKey>()
        .firstOrNullWhere((f) => other.fields.contains(f.foreignPrimaryKey));
    final mainField = foreignField;
    final otherField = foreignField?.foreignPrimaryKey;
    filter = mainField?.equals(otherField);
  }

  if (filter == null) {
    throw PersistenceException(
        'Could not autodetect join relation between "$runtimeType" and "${other.runtimeType}".');
  }

  return TupleJoinQuerySource<TDao, Tb?>(this, BeanJoin(other, filter));
}