postgres
postgres copied to clipboard
Error: "Could not infer helper mode for keyword" isn't helpful
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
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.
@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 ;)
Great, that does help me. Thank you :-)
Oh it's event right there in the docs. https://github.com/porsager/postgres#error-handling How could I miss that 🤦 ? Anyway, thanks