Skip to content

RemoteMutableEdge.save(bucketName) does not support update like its counter part RemoteMutableEdge.save() #1578

Description

@rmsloan

ArcadeDB Version:

ArcadeDB Server v24.4.1

OS and JDK Version:

Linux 4.18.0-477.21.1.el8_8.x86_64 - OpenJDK 64-Bit Server VM 11.0.22 (Temurin-11.0.22+7)

Expected behavior

Expected RemoteMutableEdge.save(bucketName) to perform an sql update similarly to its counter part save()

Actual behavior

RemoteMutableEdge.save(bucketName) throws an IllegalStateException; however I believe it should do the following if (rid != null)

  • Check for bucket validity; just like MutableDocument does
  • sql update; just like its save() counterpart
MutableDocument - for comparison

  public MutableDocument save(final String bucketName) {
    dirty = true;
    if (rid != null) {
      // UPDATE
      if (rid.bucketId != database.getSchema().getBucketByName(bucketName).getFileId())
        throw new IllegalStateException("Cannot update a record in a custom bucket");

      database.updateRecord(this);
    } else
      // CREATE
      database.createRecord(this, bucketName);
    return this;
  }
RemoteMutableEdge - for comparison

  @Override
  public MutableEdge save() {
    dirty = true;
    if (rid != null)
      remoteDatabase.command("sql", "update " + rid + " content " + toJSON());
    else
      remoteDatabase.command("sql", "insert into " + getTypeName() + " content " + toJSON());
    dirty = false;
    return this;
  }
RemoteMutableEdge - Requires Fix

  @Override
  public MutableEdge save(final String bucketName) {
    dirty = true;
    if (rid != null)
      throw new IllegalStateException("Cannot update a record in a custom bucket");
    remoteDatabase.command("sql", "insert into " + getTypeName() + " bucket " + bucketName + " content " + toJSON());
    dirty = false;
    return this;
  }

Steps to reproduce

db is a RemoteDatabase

  db.transaction( () -> {
    MutableVertex elon = db.newVertex("User", "name", "Elon", "lastName", "Musk").save();
    MutableVertex steve = db.newVertex("User", "name", "Steve", "lastName", "Jobs").save();
    MutableEdge lEdge = elon.newEdge("IsFriendOf", steve, true, "since", 2010);
    lEdge.save("MyAwesomeBucket");
  });

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions