Trying to test this locally #1

e1ven opened this Issue Jan 2, 2013 · 7 comments


None yet
2 participants

e1ven commented Jan 2, 2013

Thanks for writing this, it's a very cool idea! ;)

I'm trying to test locally, and ran into some problems-

I was getting a "DETAIL: undefined() LINE 0: [object Object]" error when trying to save any javascript, including the .sql file you included.

It looks like this is because it's treating it as an object, not a JS string.
I was able to get past this, by replacing

var obj = JSON.parse(data);


var obj = JSON.parse(JSON.stringify(data));

After making this change I was able to import as expected.

I am still having issues querying, however.

hostname=# SELECT find('cities', '{ "Country": "zw" }');
ERROR: type "undefined" does not exist

ERROR: type "undefined" does not exist

I tried a few variations of typeof() instead of === or !==, but I wasn't able to get past this.
Does this work on your machine as it is?
Any idea what I might be doing wrong?

I'm on OSX 10.8.2, using psql 9.2.1, v8 3.9.24, plv8 from git.

Any advise would be appreciated.


JerrySievert commented Jan 2, 2013

PLV8 made a breaking change with their last release - wherein they automatically did the JSON.parse() for you. If you want it working correctly right away, use my fork on my GitHub account:

In the mean time, I'll look at updating all of the code to work with this breaking change.


e1ven commented Jan 3, 2013

Thank you! Moving to your fork seems to work really well, and lets me keep playing with it.

The next thing I'm trying to figure is figuring out how to index.
It looks like I can't directly index on the find() function, because it returns a set.

I don't think I can on the where function, because it's not immutable.
Would I need to move upstream, and do the indexes on find_in_obj/etc?

Thank you once more for any and all help!


JerrySievert commented Jan 3, 2013

I have ensure_index written, but have not pushed it. Will see what I can do when I get home tonight.


JerrySievert commented Jan 3, 2013

Looks like I had ensureIndex() 90% of the way done, but not complete.

in the mean time, you can easily create indexes:

CREATE INDEX idx_cities ON col_cities (find_in_obj('data', 'address.state'));

e1ven commented Jan 3, 2013

That's not that bad at all ;) Thanks!

I tested with your city data, and it appears to work really well.
Awesome. Thank you


JerrySievert commented Jan 3, 2013

no problem. if nothing else, this got me to touch a project that i hadn't quite finished. creating a branch tonight that works with the plv8 master.


JerrySievert commented Jan 4, 2013

there is a branch beta that should allow you to work with the latest plv8 master.

going to close this for now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment