Error returned from .query is malformed #106

Open
carnedv opened this Issue Jan 29, 2013 · 6 comments

Projects

None yet

3 participants

@carnedv
carnedv commented Jan 29, 2013

I'm using the development branch and cannot log the error message on failed .query calls because the error message is malformed.

Example:

{ [Error: [Microsoft][SQL Server Native Client 10.0][SQL Server]Violation of PRIMARY KEY constraint 'PK_Foo'. Cannot insert duplicate key in object 'dbo.Foo'.] sqlstate: '23000', code: 2627 }

sqlstate and code are retrievable as valid object properties, but the error message is not assigned to a property nor quoted to be a string, making it irretrievable/unusable.

To reproduce: using development branch, submit a .query that fails, then view err parameter in callback.

@jkint
Contributor
jkint commented Jan 29, 2013

Is there a reason that you're not using the master branch? I'm not sure the problem isn't on that branch too, but that is now the preferred branch for new development.

@carnedv
carnedv commented Jan 29, 2013

I switched to development because master was not catching the error at all, just outputting a string to stdout. Might also have had an issue compiling it on my machine. I'll try to recompile the most recent master and see what it does and report back.

@carnedv
carnedv commented Jan 29, 2013

Was able to manually build the latest master and switched to using it. Same behavior that I initially reported was still observed. Also, on a different INSERT query I also got the err parameter returned as boolean 'true' without an uncaught exception. I can take the time to trace where each of those failed if it would be beneficial.

@jkint
Contributor
jkint commented Jan 29, 2013

If you desire to trace it, by all means, please do so. If you do fix it, please see CONTRIBUTING.md for guidelines on how to submit your fix.

If you prefer, some sample code would go a long way to helping me find the error(s) and fixing them.

Thanks.

@iolsen
iolsen commented Apr 29, 2013

FWIW, I can reproduce the err parameter coming back a simple boolean true by passing an array parameter to the query where it expects a string:

  sql.queryRaw(conn_str, "INSERT INTO foo (nvarchar_type_col) VALUES (?)",
    [["array not string"]],
    function(err) { console.log(util.inspect(err)); }
  );
@jkint
Contributor
jkint commented May 20, 2013

Thanks. I will look into it as soon as I can. I just returned from a lengthy out of town trip.

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