postgres icon indicating copy to clipboard operation
postgres copied to clipboard

Error: "Could not infer helper mode for keyword" isn't helpful

Open dylanplural opened this issue 3 years ago • 4 comments

I'm doing some fairly complicated query building with lots of nesting and I hit this error.

It's almost impossible to debug as it doesn't log out any useful information about which parameter triggered the error message.

I believe this error should include some more helpful information such as:

  • The type of the keyword
  • The value of the keyword
  • The position of the keyword within the query

dylanplural avatar Oct 04 '22 12:10 dylanplural

I've had similar issues. Whenever I try to build a query and ends up being invalid, all I get is the Postgres error saying "invalid syntax near SELECT" or so which is often not enough to point to the error directly.

It would be useful to get the full string that was sent to the DB also in the error case. I can get it with .describe() but when the query is invalid that doesn't work.

ChristophP avatar Oct 05 '22 07:10 ChristophP

@dylanplural I've got a POC to improve these things that I'm toying around with, but time is unfortunately quite limited for me currently :-(

@ChristophP On the error object you have non enumerable properties query and parameters. Setting debug: true will make query and parameters enumerable so they will show up when logging the errors. That should help you ;)

porsager avatar Oct 12 '22 19:10 porsager

Great, that does help me. Thank you :-)

ChristophP avatar Oct 13 '22 12:10 ChristophP

Oh it's event right there in the docs. https://github.com/porsager/postgres#error-handling How could I miss that 🤦 ? Anyway, thanks

ChristophP avatar Oct 13 '22 12:10 ChristophP