Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get returns triples which start with the search criteria #38

Closed
richorama opened this issue Sep 20, 2013 · 3 comments
Closed

Get returns triples which start with the search criteria #38

richorama opened this issue Sep 20, 2013 · 3 comments

Comments

@richorama
Copy link

Hi,

When I do a search for triples, I get back all triples that start with the supplied criteria. I would expect to see only triples that exactly match the criteria.

Illustrated by this repl session:

$ node
> var db = require('levelgraph')('test');
> db.put({subject:'a', predicate:'b', object:'c'});
> db.put({subject:'a1', predicate:'b1', object:'c1'});
> db.put({subject:'a2', predicate:'b2', object:'c2'});
> db.get({subject:'a'}, console.log);

[ { subject: 'a1', predicate: 'b1', object: 'c1' },
  { subject: 'a2', predicate: 'b2', object: 'c2' },
  { subject: 'a', predicate: 'b', object: 'c' } ]

However, I would expect (like!) this behaviour:

> db.get({subject:'a'}, console.log);

[ { subject: 'a1', predicate: 'b1', object: 'c1' } ]

Is there a way to configure this?

Thanks,

Richard.

@mcollina
Copy link
Collaborator

Actually it's a bug, but it's easy to fix.
I think it's enough to change the range pattern in
https://github.com/mcollina/levelgraph/blob/master/lib/utilities.js#L107-L108

to:

{
  start: key + ':',
  end: key + '\xff',
  fillCache: true
}

I'll fix it asap.

Thanks!

@richorama
Copy link
Author

Thanks!

@mcollina
Copy link
Collaborator

Released as 0.6.9.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants