dwyl / learn-postgresql

🐘 Learn how to use PostgreSQL and Structured Query Language (SQL) to store and query your relational data. 🔍
212 stars 23 forks source link

Syntax Checking SQL Statements/Schema/Queries using pgsanity #57

Open nelsonic opened 5 years ago

nelsonic commented 5 years ago

While trying to hand-write an SQL for this tutorial, I had a cryptic error: https://travis-ci.com/dwyl/learn-postgresql/builds/106420820#L508 image

{ error: syntax error at or near "("

In a file with 60 lines and thirty opening parentheses "("

image

This error message is about as helpful as sunscreen on a submarine ...

So I went hunting for a syntax checker and found: https://github.com/markdrago/pgsanity

$ pgsanity schema.sql
line 24: ERROR: syntax error at or near "("

So at least I know what line the error is on.

nelsonic commented 5 years ago

you'll never guess what it was ... 🙄 It had nothing to do with the opening bracket ... 😞 It was a missing ; (semicolon) at the end of the CREATE statement ...!! 😠 Anyway, I would never have spotted it without pgsanity as all other SQL UI/CLI/tools were just spitting out the same useless error!

Thanks to @markdrago I can move on with my life! 🎉

markdrago commented 5 years ago

Hey Nelson. Glad to hear that pgsanity helped you out. Thanks for the shout out. 😀