1

When trying to create a table using clojure.java.sql/create-table I get the exception:

batch entry 0: near "-": syntax error
  [Thrown class java.sql.BatchUpdateException]

The create-table call looks like this:

   (sql/create-table :stories
        [:story-id :integer "PRIMARY KEY"]
        [:story-name :text]
        [:story-name-url :text]
        [:category :text]
        [:genre-one :text]
        [:genre-two :text]
        [:created-on :text]
        [:updated-on :text]
        [:review-count :integer]
        [:chapter-count :integer]
        [:word-count :integer]
        [:rating :integer]
        [:language :integer]
        [:is-complete :boolean]
        [:is-crossover :boolean]
        [:type :text]
        [:pairing :text])))) 

1 Answer 1

2

The problem is that fields can't have the '-' character in them. Changing the '-' to '_' will fix the problem.

Sign up to request clarification or add additional context in comments.

1 Comment

Yes. A lot of the Clojure code I see uses keywords with - instead of _ in them. I think it happens because Clojure users are allowed to use - inside function names so it has become the defacto space-like character. I figure I'm not the only who keeps making this mistake.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.