mmkal / pgkit

PostgreSQL🤝TypeScript monorepo. SQL client/admin UI/smart migrator/type generator/schema inspector
https://pgkit.dev
176 stars 24 forks source link

Better display of SQL syntax errors in migrations #272

Open faassen opened 3 years ago

faassen commented 3 years ago

Messages like this:

(node:476555) UnhandledPromiseRejectionWarning: error: syntax error at or near "FOREIGN_KEY"
 at Parser.parseErrorMessage (/home/faassen/projects/expslonik/node_modules/pg-protocol/dist/parser.js:278:15)

Aren't very helpful when debugging. In case of an SQL syntax error I'd prefer to see an indication of on which line/character there is an SQL syntax error, in which migration, and no traceback.

mmkal commented 3 years ago

Agreed. There's a fix for this incoming along with a few other cli improvements.

mmkal commented 3 years ago

Improved in v0.8.x. Example: https://github.com/mmkal/slonik-tools/blob/8d7c4a2110db0caed64ebe2d19d95d9918ded1c8/packages/migrator/test/transaction.test.ts#L35

I'm going to leave this open though, since it only shows the migration/file name but it'd be nice to parse the error message for the line number like you say.