Closed adfretlink closed 6 years ago
Hey, @ameingast, any news on this PR ? I can handle even a refusal, no biggie :smile:, I'd just like to know where it stands.
@adfretlink I didn't have time to look at the PR, yet. I'll try to get it done by next week. Thanks for contributing!
This PR tries to improve error management, by helping users locate where their migration script went wrong.
It displays the migration file handled by postgresql-simple-migration before executing it. Previous behaviour was to display it only after the script had been run - so when an error arose, the name of the migration script currently run was not displayed, making it more difficult to understand what file was failing.
It display what query was running when failing. That needed some changes : first I had to plug a specific exception type to store the query. But then I realized that script are currently considered as one, single, big query (even when there are actually several queries inside). So I had to write a small parser to separate queries, handling specific cases like escaped quotes. I looked for existing SQL parsers, but there are few in haskell, most are experimentla, and would add heavy dependencies. My solution is less elegant than a attoparsec (or any similar parsing library) based one, but - I hope - less heavyweighted. I also added tests on the parser.