java.jdbc

Laziness on metadata-result results in closed resultset under Microsoft SQL

Details

  • Type: Defect Defect
  • Status: Resolved Resolved
  • Priority: Major Major
  • Resolution: Completed
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None

Description

Getting a collection of tables, and then using these to get the columns inside the tables work swimmingly under Oracle, but throws an exception under Microsoft SQL (driver 4.0.2206.100)

CompilerException com.microsoft.sqlserver.jdbc.SQLServerException: The result set is closed., compiling:(form-init602030969958815921.clj:2:3)

 (def tables
    (jdbc/with-db-metadata [m db]
                           (->>
                             (jdbc/metadata-result  (.getTables m nil nil nil (into-array String ["TABLE"])))
                             (map :table_name)
                             doall)))

  (def columns
    (jdbc/with-db-metadata [m db]
                      (->>
                        tables
                        (mapcat #(jdbc/metadata-result (.getColumns m nil nil % nil)))
                        doall)))

The problem lies in the mapcat part. Using only map works fine, but there's no way to concat before the doall, since that results in the same exception.

Changing metadata-result from

(if (instance? java.sql.ResultSet rs-or-value)
    (result-set-seq rs-or-value :identifiers identifiers :as-arrays? as-arrays?)
    rs-or-value)

to

(if (instance? java.sql.ResultSet rs-or-value)
    (doall (result-set-seq rs-or-value :identifiers identifiers :as-arrays? as-arrays?))
   rs-or-value)

fixes things, but I'm not entirely sure of the consequences that would entail in case laziness would be intended.

Activity

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: