Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Trying to test this locally #1

Closed
e1ven opened this Issue · 7 comments

2 participants

Colin Davis Jerry Sievert
Colin Davis

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);

with

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
hostname=#

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.

Jerry Sievert
Owner

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:

http://github.com/jerrySievert/plv8

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

Colin Davis

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!
-CPD

Jerry Sievert
Owner

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

Jerry Sievert
Owner

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'));
Colin Davis

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

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

Jerry Sievert
Owner

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.

Jerry Sievert
Owner

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
Something went wrong with that request. Please try again.