title: Compojure + clojure.contrib.sql: SELECT query is being cached. Why?
body: <p>I'm writing a Compojure TODO app and with MySQL as the primary data store. I'm using clojure.contrib.sql to interface with MySQL as follows:</p>
  
  <pre><code>(def db {:classname "com.mysql.jdbc.Driver"
           :subprotocol "mysql"
           :subname "//localhost:3306/todo"
           :user "&lt;user&gt;"
           :password ""})
  </code></pre>
  
  <p>The queries I'm using seem to work, however the results appear to be cached. For example, after running</p>
  
  <pre><code>(with-connection db
    (insert-values :todos
      [:name] [name]))
  </code></pre>
  
  <p>the value is successfully inserted into the database. However,</p>
  
  <pre><code>(defn sql-query [query]
    (with-connection db
      (with-query-results rows [query]
        (into [] rows))))
  </code></pre>
  
  <p>returns the same value, regardless of how many items are inserted. Of course, if I restart the web app, the results are updated, but this doesn't seem very production-friendly :).</p>
  
  <p>Any idea why this would be happening? Thanks in advance.</p>
  
  <p>As requested, here is the top-level form for the SELECT query:</p>
  
  <pre><code>(def home-view
    (render
      (base {:title "Clojure Todo"
             :content (apply str
               (map #(% :name)
                 (sql-query "select * from todos")))})))
  </code></pre>