Closed yogthos closed 8 years ago
What, you don't like a good Clojure NullPointerException hunt? Ha, just kidding! I've actually run into this myself transitioning from Yesql. I'll add in a validation check for this and get it into the next release.
Thanks for the report!
fantastic! :+1:
This is released in 0.4.3.
The strategy at this point is to give a little bit of context about which header keys it did find and to dump the sql template. Since the parser is generically picking up HugSQL headers (it doesn't expect :name
or its variants, just :some-key
), it doesn't catch this during the parse pass, so it checks for this right before the def pass. A later enhancement might set the reader line and column meta data for each statement, but the current fix should at least keep you from the dreaded NullPointerException.
great, I think we can close this one unless you want to keep it here for the later enhancement part :)
I was translating some queries from yesql, and I ended up having a typo where the name key looked like
-- :name:
, it took me a little bit to track it down since the stack shows:It would be good to validate the required metadata and error out explicitly if stuff like function name couldn't be parsed. Could even print the query string since it should be in context. :)