Skip to content

Commit

Permalink
Fixes #8949
Browse files Browse the repository at this point in the history
  • Loading branch information
wolf4ood committed Jul 9, 2019
1 parent 55820bb commit 171cadf
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.orientechnologies.orient.client.remote.message;

import com.orientechnologies.orient.core.db.document.ODatabaseDocumentRemote;
import com.orientechnologies.orient.core.record.ORecord;
import com.orientechnologies.orient.core.sql.executor.OExecutionPlan;
import com.orientechnologies.orient.core.sql.executor.OResult;
import com.orientechnologies.orient.core.sql.executor.OResultInternal;
Expand Down Expand Up @@ -63,7 +64,16 @@ public OResult next() {
if (currentPage.isEmpty()) {
throw new IllegalStateException();
}
return currentPage.remove(0);
OResultInternal internal = currentPage.remove(0);

if (internal.isRecord() && db.getTransaction().isActive()) {
ORecord record = db.getTransaction().getRecord(internal.getRecord().get().getIdentity());
if (record != null) {
internal = new OResultInternal(record);
}
}
return internal;

}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@
import com.orientechnologies.orient.core.db.document.ODatabaseDocument;
import com.orientechnologies.orient.core.exception.ODatabaseException;
import com.orientechnologies.orient.core.metadata.schema.OType;
import com.orientechnologies.orient.core.record.ORecord;
import com.orientechnologies.orient.core.record.OVertex;
import com.orientechnologies.orient.core.record.impl.ODocument;
import com.orientechnologies.orient.core.sql.executor.OResult;
import com.orientechnologies.orient.core.sql.executor.OResultSet;
import com.orientechnologies.orient.server.OClientConnection;
import com.orientechnologies.orient.server.OServer;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;

Expand Down Expand Up @@ -215,6 +218,25 @@ public void testQueryEmbeddedMap() {
assertEquals(((Map<String, OResult>) item.getProperty("map")).get("key").getProperty("one"), "value");
}

@Test
public void testCommandWithTX() {

session.begin();

session.command("insert into Some set prop = 'value'");

ORecord record;

try (OResultSet resultSet = session.command("insert into Some set prop = 'value'")) {
record = resultSet.next().getRecord().get();
}

session.commit();

Assert.assertTrue(record.getIdentity().isPersistent());

}

@After
public void after() {
QUERY_REMOTE_RESULTSET_PAGE_SIZE.setValue(oldPageSize);
Expand Down

0 comments on commit 171cadf

Please sign in to comment.