java.jdbc

Incorrect connection-uri spec

Details

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

Description

:connection-uri needs to be a String(based on implementation + doc).

However, the spec for connection-uri is defined as (s/def ::connection-uri #(instance? java.net.URI %)) .
This causes exceptions in the following manner when the spec is instrumented.

Repro

(require '[clojure.java.jdbc :as db])
(db/get-connection {:connection-uri "jdbc:h2:./foo"})
=> #object[org.h2.jdbc.JdbcConnection 0x553dd729 "conn4: url=jdbc:h2:./foo user="]
(require '[clojure.spec.test.alpha :as check]) (require 'clojure.java.jdbc.spec)
(check/instrument)
(db/get-connection {:connection-uri "jdbc:h2:./foo"})
=> Spec error

(check/unstrument)
(db/get-connection {:connection-uri "jdbc:h2:./foo"})
=> #object[org.h2.jdbc.JdbcConnection 0x553dd729 "conn4: url=jdbc:h2:./foo

Activity

Hide
Ikuru Kanuma added a comment -

Confirmed that the attached patch resolves the issue

Show
Ikuru Kanuma added a comment - Confirmed that the attached patch resolves the issue
Hide
Sean Corfield added a comment -

Good catch! Thank you! Will be in 0.7.2.

Show
Sean Corfield added a comment - Good catch! Thank you! Will be in 0.7.2.
Hide
Sean Corfield added a comment -

I changed the spec to just string? which is more idiomatic than checking instance? java.lang.String.

Show
Sean Corfield added a comment - I changed the spec to just string? which is more idiomatic than checking instance? java.lang.String.
Hide
Ikuru Kanuma added a comment -

Sounds good! Thanks for the quick response.

Show
Ikuru Kanuma added a comment - Sounds good! Thanks for the quick response.
Hide
Ikuru Kanuma added a comment -

It would be really nice this could be released...?

Show
Ikuru Kanuma added a comment - It would be really nice this could be released...?
Hide
Sean Corfield added a comment -

In release 0.7.2 which is being published today.

Show
Sean Corfield added a comment - In release 0.7.2 which is being published today.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: