Hello,

I'm using OrientDB 2.2.32.  We're updating our software from 2.0.8.

The traverse() operator in selects does not appear to be working.

When I run the attached program, I get 
a com.orientechnologies.orient.core.sql.OCommandSQLParsingException.

Exception in thread "main" 
com.orientechnologies.orient.core.sql.OCommandSQLParsingException: Error 
parsing query:
SELECT FROM Person WHERE givenname = 'William' and in traverse(0,-1,'in') ( 
givenname = 'George' )
                                                    ^
Encountered "" at line 1, column 52.
Was expecting one of:
    
DB name="familytree"

I hope it hasn't been removed.  We use both the TRAVERSE FROM and
SELECT FROM WHERE traverse() extensively.

TRAVERSE FROM is wonderful for gathering a group of records from a given 
point.
The traverse() operator is wonderful for queries like the above (return all 
people named William
descended from a person named George.

We really need both.

Thanks,

Steven Tomer

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"OrientDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.
import com.orientechnologies.orient.core.db.document.*;
import com.orientechnologies.orient.core.record.impl.ODocument;
import com.orientechnologies.orient.core.metadata.schema.*;
import com.orientechnologies.orient.core.id.*;
import com.orientechnologies.orient.client.remote.OServerAdmin;
import com.orientechnologies.orient.core.sql.query.*;

import java.io.IOException;
import java.util.*;

public class FamilyTree {

    private static ODocument addUnconnectedPerson(String givenname, String surname) {
        ODocument doc = new ODocument("Person");
        doc.field("givenname", givenname).field("surname", surname);
        Set<ORID> inset = new HashSet();
        Set<ORID> outset = new HashSet();
        doc.field("in", inset, OType.LINKSET);
        doc.field("out", outset, OType.LINKSET);
        doc.save();
        return doc;
    }

    private static void addEdge(ODocument from, ODocument to, String type) {
        ODocument edge = new ODocument("MyEdge");
        edge.field("in", from.getIdentity());
        edge.field("out", to.getIdentity());
        edge.field("type", type);
        edge.save();

        Set<ORID> outset = from.field("out");
        outset.add(edge.getIdentity());
        Set<ORID> inset = to.field("in");
        inset.add(edge.getIdentity());
        from.save();
        to.save();
    }

    private static ODocument addChild(ODocument father, String givenname, String surname) {
        ODocument child = addUnconnectedPerson(givenname, surname);
        addEdge(father, child, "child");
        return child;
    }


    public static void main(String[] args) {
        final String databaseName = "familytree";
        final String rootPassword = "<ROOTPASSWORD>";

        try {
            OServerAdmin serverAdmin = new OServerAdmin("remote:localhost").connect("root", rootPassword);

            if (serverAdmin.listDatabases().containsKey(databaseName)) {
                System.out.println("Removing Existing FamilyTree Database");
                serverAdmin.dropDatabase(databaseName, "plocal");
            }

            System.out.println("Creating FamilyTree Database");
            serverAdmin.createDatabase(databaseName, "document", "plocal");

            // OPEN THE DATABASE
            ODatabaseDocumentTx db = new ODatabaseDocumentTx(
               "remote:localhost/" + databaseName).open("admin", "admin");

            // SCHEMA
            OClass vertex = db.getMetadata().getSchema().createClass("MyVertex");
            vertex.createProperty("in", OType.LINKSET);
            vertex.createProperty("out", OType.LINKSET);           

            OClass edge = db.getMetadata().getSchema().createClass("MyEdge");
            edge.createProperty("in", OType.LINK);
            edge.createProperty("out", OType.LINK);           
            edge.createProperty("type", OType.STRING);

            OClass person = db.getMetadata().getSchema().createClass("Person", vertex);
            person.createProperty("givenname", OType.STRING);
            person.createProperty("surname", OType.STRING);

            // POPULATE THE DATABSE
            ODocument l1 = addUnconnectedPerson("James", "Taylor");
            ODocument l2_1 = addChild(l1, "John", "Taylor");
            ODocument l2_2 = addChild(l1, "Michael", "Taylor");
            ODocument l2_3 = addChild(l1, "George", "Taylor");
            ODocument l2_4 = addChild(l1, "David", "Taylor");

            ODocument l2_1_1 = addChild(l2_1, "John", "Taylor");
            ODocument l2_1_2 = addChild(l2_1, "Henry", "Taylor");
            ODocument l2_1_3 = addChild(l2_1, "William", "Taylor");

            ODocument l2_2_1 = addChild(l2_2, "William", "Taylor");
            ODocument l2_2_2 = addChild(l2_2, "James", "Taylor");
            ODocument l2_2_3 = addChild(l2_2, "George", "Taylor");
            
            ODocument l2_3_1 = addChild(l2_3, "David", "Taylor");
            ODocument l2_3_2 = addChild(l2_3, "Michael", "Taylor");
            ODocument l2_3_3 = addChild(l2_3, "George", "Taylor");

            ODocument l2_4_1 = addChild(l2_4, "William", "Taylor");
            ODocument l2_4_2 = addChild(l2_4, "James", "Taylor");
            ODocument l2_4_3 = addChild(l2_4, "Steven", "Taylor");

            ODocument l2_2_3_1 = addChild(l2_2_3, "William", "Taylor");
            ODocument l2_2_3_2 = addChild(l2_2_3, "Christopher", "Taylor");

            ODocument l2_3_3_1 = addChild(l2_3_3, "David", "Taylor");
            ODocument l2_3_3_2 = addChild(l2_3_3, "Adam", "Taylor");

            List<ODocument> result = db.query(new OSQLSynchQuery<ODocument>("SELECT FROM Person WHERE givenname = 'William'"));
            for (ODocument d : result) 
                System.out.println(d.toString());

            List<ODocument> result2 = db.query(new OSQLSynchQuery<ODocument>("SELECT FROM Person WHERE givenname = 'William' and in traverse(0,-1,'in') ( givenname = 'George' )"));
            for (ODocument d : result2) 
                System.out.println(d.toString());

            db.close();
        }
        catch (final IOException ex) {
            System.out.println("IOException");            
        }
    }

}

Reply via email to