-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error position #20
Comments
Hi, thanks for the issue. I reckon the solution of putting the Probably the main reason I don't do much with the errors is that I don't know what errors might be thrown. I assume not every error will have a What I tend to do in your position is to look at the PostgreSQL logs, mainly because I don't trust JS libraries (including mine!) to give the full picture. |
Similar problem on my first attempts to use this library. I get pumped and write a big migration, then gotta debug it. But the error message reads: error at or near "." ... and there are 76 "." in the migration!
Can we at least add line indicator? |
I don't think Postgres gives that information (correct me if I'm wrong). We can only report what we get back from Postgres. Again, I'm happy to accept a PR for this. |
I've hand-written a pretty large baseline migration, and then started debugging it by creating a fresh database and running
postgres-migrations
repeatedly. One problem I've run into is that crucial error details are lost inside this library, here:postgres-migrations/src/run-migration.js
Lines 49 to 61 in 25e7379
Sometimes PostgreSQL spews out messages like
syntax error at or near ")"
, in a file full of functions, triggers, constraints, arrays, etc. The only way to find the cause for an error like that is to know theposition
, which is contained inside theerr
returned from the driver.The easiest solution would probably be to extend the error message with
Position: ${err.position}
, but there may be some value is passing through the other fields too. An even better solution would be to print the problematic line and its surroundings, with the exact position pointed out with a^
, but that's a lot of extra effort for a small QoL improvement, so that's just an idea for the future.The text was updated successfully, but these errors were encountered: