jbmusso / grex

JavaScript graph database client for TinkerPop2 Rexster
MIT License
46 stars 12 forks source link

Indexing ignores identifier #34

Closed Acconut closed 1 year ago

Acconut commented 10 years ago
Grex = require("grex")
client = Grex.createClient({graph:"graph"})
query = Grex.gremlin()
g = Grex.g
foo = query.var(g.addVertex())
foo.identifier // 'i0'
query(g.idx("index").put("foo", "foo", foo))
query.script // 'i0=g.addVertex()\ng.idx(\'index\').put(\'foo\',\'foo\',g.addVertex())'

g.idx().put ignores an elements identifier.

It should generate following script:

i0=g.addVertex()
g.idx('index').put('foo','foo',i0)
Acconut commented 10 years ago

I'm not entirely sure, but maybe this can be achieved by testing in Argument.parse whether an identifier for the argument exists.

jbmusso commented 10 years ago

Got it, identifiers are currently only supported in addEdge(). This definitely needs to be supported everywhere, in a generic way. This is indeed related to the Argument class, which needs to be updated to support bound parameters (v0.7.0 milestone).

Until this is fixed, you can circumvent this limitation by supplying a formatted string to query():

query('g.idx("index").put("foo", "foo", %s)', 'i0');

should do the trick.

Acconut commented 10 years ago

Thanks, I'll use this for now.

Acconut commented 10 years ago

I think your workaround won't do it because 'i0' will be inserted as a parameter and so ends up as a string.

I'll try following:

query('g.idx("index").put("foo", "foo", ' + foo.identifier + ')');