简体   繁体   中英

This row does not contain values for that table

I'm using Drift(moor). When trying to get a sample of data using leftOuterJoin, the following situation happens: The table that I join via leftOuterJoin returns null as a value. Ie leftOuterJoin itself works correctly but values from joined table are not read and return null. As a result, I get a row where 1 or 2 columns have null values (depending on what table I join) No one with such a situation is not faced?

final rows = await (select(favoritePlaces).join(
      [
        leftOuterJoin(
            cachedPlaces, cachedPlaces.id.equalsExp(favoritePlaces.placeId)),
      ],
    )).get();

parsedExpressions

  1. Remove ".get()" from the last line.

  2. Add below lines after your code:

    final result = await rows.get();

    return result.map((resultRow) { return FavoritePlacesWithcachedPlaces( resultRow.readTable(favoritePlaces), resultRow.readTableOrNull(cachedPlaces), ); }).toList();

where FavoritePlacesWithcachedPlaces object is something like:

class FavoritePlacesWithcachedPlaces {

final FavoritePlaces favoritePlaces;
final CachedPlaces? cachedPlaces;

FavoritePlacesWithcachedPlaces (this.favoritePlaces, 
this.cachedPlaces);}

The key point is using "readTableOrNull".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM