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

Blank comment lines in SQL files mess up HugSQL parsing #44

Closed
timgilbert opened this issue Jun 6, 2016 · 3 comments
Closed

Blank comment lines in SQL files mess up HugSQL parsing #44

timgilbert opened this issue Jun 6, 2016 · 3 comments
Labels

Comments

@timgilbert
Copy link

timgilbert commented Jun 6, 2016

I've got these two lines in a SQL file. Note that the second function contains a single blank comment right before the WHERE clause:

-- :name without-blank-comment :? :1
SELECT COUNT(*)
FROM users u
WHERE u.id = 1

-- :name with-blank-comment :? :1
SELECT COUNT(*)
FROM users u
--
WHERE u.id = 1

When I run this file via Clojure code looking similar to:

(hugsql/def-db-fns "hugsql/user.sql")

(defn comment-test []
  (log/spy (with-blank-comment (db/get-db-spec) {}))
  (log/spy (without-blank-comment (db/get-db-spec) {})))

The first result returns 1 (as I expected) but the second row returns 10 (one per row in that table in the database I'm connecting to).

It appears that somewhere in the SQL parsing, having a line that is only a comment string is aborting the processing, so that the WHERE clause is ignored in the name with-blank-comment function.

I doubt this is relevant, but I'm connecting to a Postgres backend; I've got [com.layerware/hugsql "0.4.6"]and [org.clojure/java.jdbc "0.4.2"] in my lein deps :tree output.

@csummers csummers added the bug label Jun 6, 2016
@csummers
Copy link
Member

csummers commented Jun 6, 2016

Looks like a bug! Thanks for the report. I can confirm this is also an issue in version 0.4.7.

@csummers
Copy link
Member

This should be in the next release later this week. Thanks for the report!

@csummers
Copy link
Member

This is released in 0.4.8 (finally!). Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants