graphile / graphile/migrate

SQL errors lost in Javascript stacktrace

Open
#99 1 comment 1 reaction 0 assignees View on GitHub
Dominant language
TypeScript
Stars
835
Forks
64
Avg merge
17m
Merged PRs (30d)
5

Description

### Feature description

When running `migrate watch` in a rather short terminal window SQL errors are lost amongst Javascript stack traces

### Motivating example

There are 10 lines of JS stack trace for 2 lines of SQL errors.

```
graphile-migrate: Already up to date
[2020-11-04T06:48:27.687Z]: Running current.sql

🛑 Error occurred at line 12, column 1 of "current.sql":
| alter table taxonomy_level
| add constraint fk_taxonomy_level_parent foreign key (parent_id, project_id, environment_id)
| references taxonomy_level (id, project_id, environment_id);
| asdf;
| --^
| 42601: syntax error at or near "asdf"
error: syntax error at or near "asdf"
at Parser.parseErrorMessage (/Users/.../node_modules/pg-protocol/dist/parser.js:278:15)
at Parser.handlePacket (/Users/.../node_modules/pg-protocol/dist/parser.js:126:29)
at Parser.parse (/Users/.../node_modules/pg-protocol/dist/parser.js:39:38)
at Socket. (/Users/.../node_modules/pg-protocol/dist/index.js:8:42)
at Socket.emit (node:events:327:20)
at addChunk (node:internal/streams/readable:304:12)
at readableAddChunk (node:internal/streams/readable:279:9)
at Socket.Readable.push (node:internal/streams/readable:218:10)
at TCP.onStreamRead (node:internal/stream_base_commons:192:23)

Severity: ERROR
Code: 42601

```

### Breaking changes

I feel this can be implemented without much overhead.

### Supporting development

I [tick all that apply]:

- [x] am interested in building this feature myself
- [ ] am interested in collaborating on building this feature
- [ ] am willing to help testing this feature before it's released
- [ ] am willing to write a test-driven test suite for this feature (before it exists)
- [ ] am a [Graphile sponsor](https://www.graphile.org/sponsor/) ❤️
- [ ] have an active [support or consultancy contract](https://www.graphile.org/support/) with Graphile

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.