Skip to content
This repository was archived by the owner on Oct 14, 2018. It is now read-only.

Quill 1.0.1 support with java.time. #11

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

vanDonselaar
Copy link
Collaborator

Hi @olafurpg could you please review this PR?
I decided to copy the WrappedValue to the codegen because there is no other way to identify the type of the wrapped value (correct me if I'm wrong).

@olafurpg
Copy link
Owner

olafurpg commented Dec 9, 2016

Thanks for the PR! I'm at scala exchange right now, this looks great but I need to time to take a closer look after the conference :)

@vanDonselaar
Copy link
Collaborator Author

Very cool. Enjoy London!

Copy link
Owner

@olafurpg olafurpg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only comment is on WrappedValue, otherwise looks great 👍

| * Quill used to have this trait before v1, but it's still useful to keep.
| * Examples are: pattern matching on wrapped type and conversion to JSON objects.
| */
| trait WrappedValue[T] extends Any with WrappedType { self: AnyVal =>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since WrappedValue is static, could we move it somewhere outside the generated code?

  • Easiest solution would probably be to put this into a separate source file and link to from the readme for people to copy-paste into their project.
  • Another solution is put it into a separate project in the build and publish to Maven.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A separate file maybe? I think a separate project is a bit overkill for only 7 lines of code. If we generate two files (one dynamic and one static) in the same package, then the generated code is fully stand-alone valid Scala code and users won't need to manually fix imports and such. What do you think?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could add a "staticFile: Option[File]" option where we write static contents if the setting is configured. WDYT?

| * Generated using [[https://github.com/olafurpg/scala-db-codegen scala-db-codegen]]
| * - Number of tables: ${tables.size}
| * - Database URL: ${options.url}
| * - Database schema: ${options.schema}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great idea!

@@ -28,7 +28,7 @@ object TypeMap {
"varchar" -> "String",
"serial" -> "Int",
"bigserial" -> "Long",
"timestamp" -> "java.util.Date",
"timestamp" -> "java.time.LocalDateTime", // Since Quill 1.0.1, the scalajs-java-time library supports java time.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yay \o/

I haven't tried scalajs-java-time yet, seems to still be a wip. However, I'm happy to change the default since I suspect the scalajs use-case is not important for all quill users. Worst case, it's still still possible to override this in case you want java.util.Date.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also don't have any experience with scalajs-java-time. I assume the quill maintainers did this with good reasons and I am very happy with their choice. Just like you said, there is always a way to override the defaults so I think we're safe doing this. 👍

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants