Nathalie
Nathalie

Reputation: 655

Flutter Drift : update from another table with join

Is it possible to write with Drift syntax an update like

update edge_table set status = tb2.status from asset_table as tb2 where asset_id=tb2.id

I was thinking of something like this but i can't finbd the right syntax :

Future<void> updateEdgeStatusFromAssets() async {
  // Requête de jointure entre SkiEdge et SkiAsset
  final query = _database.update(_database.skiEdgeTable).write(
    _database.select(_database.skiAssetTable).join([
      innerJoin(
        _database.skiEdgeTable,
        _database.skiEdgeTable.assetId.equalsExp(_database.skiAssetTable.id),
      ),
    ]),
    updateColumns: {
      _database.skiEdgeTable.status: _database.skiAssetTable.status,
    },
  );

  await query;
}

Upvotes: 0

Views: 33

Answers (0)

Related Questions