Skip to content
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

Make error reporting work for multiple current migrations #127

Open
ben-pr-p opened this issue Jun 2, 2021 · 0 comments
Open

Make error reporting work for multiple current migrations #127

ben-pr-p opened this issue Jun 2, 2021 · 0 comments
Labels
bug Something isn't working

Comments

@ben-pr-p
Copy link
Contributor

ben-pr-p commented Jun 2, 2021

Summary

When I have multiple files in my current migration, and I make an error, I get something like:

:octagonal_sign: Error occurred at line 67, column 1 of "current.sql":
|
|
|   )
| ^
| 42601: syntax error at or near ")"
    error: syntax error at or near ")"
        at Parser.parseErrorMessage (/Users/mgoldfield/Rewired/assemble/node_modules/pg-protocol/dist/parser.js:287:98)
        at Parser.handlePacket (/Users/mgoldfield/Rewired/assemble/node_modules/pg-protocol/dist/parser.js:126:29)
        at Parser.parse (/Users/mgoldfield/Rewired/assemble/node_modules/pg-protocol/dist/parser.js:39:38)
        at Socket.<anonymous> (/Users/mgoldfield/Rewired/assemble/node_modules/pg-protocol/dist/index.js:11:42)
        at Socket.emit (events.js:315:20)
        at addChunk (internal/streams/readable.js:309:12)
        at readableAddChunk (internal/streams/readable.js:284:9)
        at Socket.Readable.push (internal/streams/readable.js:223:10)
        at TCP.onStreamRead (internal/stream_base_commons.js:188:23)

    Severity:    ERROR
    Code:        42601

However, this was actually on line 21 of my third current migration file.

It'd be nice if

Steps to reproduce

Create multiple current migrations, and then make an error in one other than the first. The line numbers of the errors will not match up.

Expected results

Something like "Error occurred at line 21 of <your-sql-file.sql>".

Actual results

Error occurred at line 67, column 1 of "current.sql"

Additional context

Graphile-migrate 0.12.0

Possible Solution

I think we'll have to build a little source map in memory, storing file offsets?

Happy to take this one! Will approach it by storing file offsets unless you'd like a different approach.

@benjie benjie added the bug Something isn't working label Jun 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants