update method

Future<void> update(
  1. FieldData fieldData,
  2. WhereData whereData
)

Implementation

Future<void> update(FieldData fieldData, WhereData whereData) async {
  if (!initialized) throw ArgumentError(C_MUST_INIT);
  String sql = sqlCommands.update(fieldData, whereData);
  print(sql);
  if (whereData.whereStructList.length == 0)
    throw IllegalStateException(
        "TableData must contain WhereData for update");

  try {
    var affectedRows = await transaction.getConnection().updateQuery(sql);
    if (affectedRows == 0)
      throw SqlException(SqlExceptionEnum.FAILED_UPDATE,
          sql: sql, json: fieldData.toJson());
  } on SqlException catch (e) {
    throw SqlException(e.sqlExceptionEnum,
        cause: e.cause, sql: sql, json: fieldData.toJson());
  }
}