Skip to content
This repository has been archived by the owner on Mar 4, 2019. It is now read-only.

Case Issue With Functions #64

Closed
paulxtiseo opened this issue May 14, 2015 · 12 comments
Closed

Case Issue With Functions #64

paulxtiseo opened this issue May 14, 2015 · 12 comments

Comments

@paulxtiseo
Copy link
Contributor

Requested as its own ticket from issue #26

I have a function in postgresql as:

CREATE OR REPLACE FUNCTION "getOrderByOperator"(IN opid bigint)

Now, MassiveJS gives me a db.getOrderByOperator() to call. But, when I call it, it errors with [error: function getorderbyoperator(unknown) does not exist]. True, it does not exist, but only because it's (I'm assuming) lowercasing the whole thing rather than using it as-is.

Is this fixed? Fixable? Is there a workaround short of constraining to snake casing or abandoning MassiveJS altogether?

@xivSolutions
Copy link
Collaborator

This is fixable. I can push a fix in the next day or two. Traveling atm.

@paulxtiseo
Copy link
Contributor Author

I think I have a fix. I am changing line 263 from:

sql = "select * from " + fn.name;
to
sql = util.format("select * from \"%s\"", fn.name);

Does that seem correct? This will force all sql to use quoted identifiers.

@xivSolutions
Copy link
Collaborator

Do the tests pass when you run them with this in place?

@paulxtiseo
Copy link
Contributor Author

👍

$ npm test

> massive@2.0.4 test /Repositories/~Personal/massive-js
> mocha .



  0 passing

@xivSolutions
Copy link
Collaborator

Uh...zero passing?

@paulxtiseo
Copy link
Contributor Author

Ah, true. I didn't see any red, so I too quickly assumed passing tests.

So, not sure why tests didn't run? I did run npm test from the CLI in the Massive root directory... Looking into it...

@xivSolutions
Copy link
Collaborator

If you have mocha installed you should be able to just do 'mocha' from the project root

@paulxtiseo
Copy link
Contributor Author

Strange. Never had this before. And I did confirm I have an up-to-date Mocha.

[~/Repositori...onal/massive-js] $ mocha


  Document queries
    1) "before all" hook

  0 passing (34ms)
  1 failing

/usr/local/lib/node_modules/mocha/lib/reporters/base.js:197
      var match = message.match(/^([^:]+): expected/);
                          ^
TypeError: undefined is not a function
    at /usr/local/lib/node_modules/mocha/lib/reporters/base.js:197:27
    at Array.forEach (native)
    at Function.exports.list (/usr/local/lib/node_modules/mocha/lib/reporters/base.js:161:12)
    at Spec.Base.epilogue (/usr/local/lib/node_modules/mocha/lib/reporters/base.js:317:10)
    at Runner.emit (events.js:129:20)
    at Runner.uncaught (/usr/local/lib/node_modules/mocha/lib/runner.js:593:8)
    at process.uncaught (/usr/local/lib/node_modules/mocha/lib/runner.js:612:10)
    at process.emit (events.js:107:17)
    at process._fatalException (node.js:236:26)

@xivSolutions
Copy link
Collaborator

Is there a database named "massive" defined in your Postgres cluster?

@paulxtiseo
Copy link
Contributor Author

Stupidly, that was it. I modified the connection string and it ran the tests.

43 tests failed, but all for TypeError: Cannot read property 'findDoc' of undefined. Or, for searchDoc.

@xivSolutions
Copy link
Collaborator

This fix works for me, and all tests still pass. I'm going to merge this, but then add some tests for this case.

@xivSolutions
Copy link
Collaborator

@paulxtiseo - not certain what's going on with your failing tests for findDoc and searchDoc. I merged your changes, all tests pass, and I added a couple tests to test the escape stuff you put in. All tests pass. :-)

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

No branches or pull requests

2 participants