Skip to content

Conversation

@mattiuusitalo
Copy link
Contributor

java.sql.Date is a subclass of java.util.Date but throws a runtime exception UnsupportedOperationException when called, because a SQL date inherently has no time information associated with it. It is just a date.

Therefore a special case is added to the protocol to support pretty printing java.sql.Date objects.

java.sql.Date is a subclass of java.util.Date but throws a runtime
exception `UnsupportedOperationException` when called, because a SQL
date inherently has no time information associated with it. It is just
a date.

Therefore a special case is added to the protocol to support pretty
printing java.sql.Date objects.
@mattiuusitalo
Copy link
Contributor Author

This'd fix #85

@brandonbloom
Copy link
Owner

brandonbloom commented Jul 16, 2025

Could you add some tests to ednize_test.cljc please?

@mattiuusitalo
Copy link
Contributor Author

Could you add some tests to ednize_test.cljc please?

Sure can! Do you have a target level for the test coverage? I added a similar level that was currently there for this PR.

@brandonbloom
Copy link
Owner

FAIL in (ednize-test) (ednize_test.cljc:24)
convert instants to tagged literals
expected: (= (edn (-> java.sql.Date (.getConstructor (into-array Class [Long/TYPE])) (.newInstance (into-array Object [0])))) (tagged-literal (quote inst) "1970-01-01"))
  actual: (not (= #inst "1969-12-31" #inst "1970-01-01"))

Time zone issue?

We can just use toString to get the correct format.

The older version of the test depended upon being in the correct
timezone.
@mattiuusitalo
Copy link
Contributor Author

FAIL in (ednize-test) (ednize_test.cljc:24)
convert instants to tagged literals
expected: (= (edn (-> java.sql.Date (.getConstructor (into-array Class [Long/TYPE])) (.newInstance (into-array Object [0])))) (tagged-literal (quote inst) "1970-01-01"))
  actual: (not (= #inst "1969-12-31" #inst "1970-01-01"))

Time zone issue?

Indeed. As far as I can tell the problem was in constructing the test data more than the actual implementation. I simplified the printing implementation though, as I noticed that toString does the right thing.

@brandonbloom
Copy link
Owner

Thanks! changes are now on master branch,

@brandonbloom
Copy link
Owner

This PR has been included in release v0.6.28! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants