Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unix-timestamp->honeysql implementation for h2 is incorrect for microseconds #16628

Closed
jeff303 opened this issue Jun 16, 2021 · 5 comments · Fixed by #16631
Closed

unix-timestamp->honeysql implementation for h2 is incorrect for microseconds #16628

jeff303 opened this issue Jun 16, 2021 · 5 comments · Fixed by #16631
Labels
Database/H2 Priority:P3 Cosmetic bugs, minor bugs with a clear workaround Type:Bug Product defects
Milestone

Comments

@jeff303
Copy link
Contributor

jeff303 commented Jun 16, 2021

The current implementation has:

(defmethod sql.qp/unix-timestamp->honeysql [:h2 :millisecond] [_ _ expr]
  (add-to-1970 expr "millisecond"))

(defmethod sql.qp/unix-timestamp->honeysql [:h2 :millisecond] [_ _ expr]
  (add-to-1970 expr "microsecond"))

The 2nd param to the last one should clearly be :microseconds, and the first should be :milliseconds (plural). Unclear why current test suite doesn't fail from this.

@flamber
Copy link
Contributor

flamber commented Jun 16, 2021

H2 understands this magically - at least based on @dpsutton's description in #14024

@jeff303
Copy link
Contributor Author

jeff303 commented Jun 16, 2021

H2 understands this magically - at least based on @dpsutton's description in #14024

Yeah it may understand that keyword, but this is all Clojure stuff before we even call it. In fact the second defmethod is completely overwriting the first (currently) because it declares the exact same dispatch vals. And in addition, a dispatch val of :millisecond (as opposed to :milliseconds) is not used anywhere else for the same multimethod, which is very suspicious.

@dpsutton
Copy link
Contributor

His point is that these two implementations clobber each other. it's the duplicate [:h2 :millisecond]. And certainly one of those should be [:h2 :microseconds]. Good catch @jeff-bruemmer

@dpsutton
Copy link
Contributor

@jeff303 are you gonna do a quick patch or want me to?

@flamber flamber added the Priority:P3 Cosmetic bugs, minor bugs with a clear workaround label Jun 16, 2021
@jeff303
Copy link
Contributor Author

jeff303 commented Jun 16, 2021

@jeff303 are you gonna do a quick patch or want me to?

Go ahead if you're interested. I just happened to notice while knee deep in something else and wanted to capture it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Database/H2 Priority:P3 Cosmetic bugs, minor bugs with a clear workaround Type:Bug Product defects
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants