Skip to content

Commit

Permalink
Issue #7484 was fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
andrii0lomakin committed Jul 13, 2017
1 parent dd89fde commit cd7c3f1
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -909,7 +909,7 @@ public Iterable<Vertex> getVertices(final String label, final String[] iKey, Obj
}
List<Object> keys = Arrays.asList(convertKeys(idx, sortedParams));
Object key;
if (keys.size() == 1) {
if (indexFields.size() == 1) {
key = keys.get(0);
} else {
key = new OCompositeKey(keys);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import com.orientechnologies.orient.core.index.OCompositeKey;
import com.orientechnologies.orient.core.index.OIndexException;
import com.orientechnologies.orient.core.metadata.schema.OClass;
import com.orientechnologies.orient.core.metadata.schema.OType;
import com.orientechnologies.orient.core.record.impl.ODocument;
import com.orientechnologies.orient.core.sql.OCommandSQL;
Expand All @@ -30,9 +31,7 @@
import org.junit.BeforeClass;
import org.junit.Test;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.*;

import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
Expand Down Expand Up @@ -115,6 +114,41 @@ public void testIndexCollate() {

}

@Test
public void testGetCompositeKeyBySingleValue() {
OrientGraph g = new OrientGraph(URL, "admin", "admin");

OrientVertexType vComposite = g.createVertexType("VComposite");
vComposite.createProperty("login", OType.STRING);
vComposite.createProperty("permissions", OType.EMBEDDEDSET, OType.STRING);

vComposite.createIndex("VComposite_Login_Perm", OClass.INDEX_TYPE.UNIQUE, "login", "permissions");

String loginOne = "admin";
Set<String> permissionsOne = new HashSet<String>();
permissionsOne.add("perm1");
permissionsOne.add("perm2");

String loginTwo = "user";
Set<String> permissionsTwo = new HashSet<String>();
permissionsTwo.add("perm3");
permissionsTwo.add("perm4");

g.addVertex("class:VComposite", "login", loginOne, "permissions", permissionsOne);
g.commit();

g.addVertex("class:VComposite", "login", loginTwo, "permissions", permissionsTwo);
g.commit();

Iterable<Vertex> vertices = g.getVertices("VComposite", new String[] { "login" }, new String[] { "admin" });
Iterator<Vertex> verticesIterator = vertices.iterator();

Assert.assertTrue(verticesIterator.hasNext());
Vertex vertex = verticesIterator.next();
Assert.assertEquals(vertex.getProperty("login"), "admin");
Assert.assertEquals(vertex.getProperty("permissions"), permissionsOne);
}

@Test
public void testEmbeddedListAsVertexProperty() {
OrientGraph g = new OrientGraph(URL, "admin", "admin");
Expand Down Expand Up @@ -407,8 +441,6 @@ public void testCompositeExceptionKey() {
Iterable<Vertex> vertices = graph.command(new OCommandSQL("select from index:account.composite where key = [ 'foo', 'baz' ]"))
.execute();



List<Vertex> list = new ArrayList<>();
vertices.forEach(list::add);

Expand Down

0 comments on commit cd7c3f1

Please sign in to comment.