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

[WIP] Add DSL for datetime/duration #1635

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

Conversation

mdedetrich
Copy link
Collaborator

@mdedetrich mdedetrich commented Sep 22, 2019

Problem

This PR is intended to add a DSL for the various DateTime/Duration functions in Postgres. The intention is to allow you do things like

query[Table].filter(t => t.time < now() - 5.minutes)

where now() translates to the postgres now() function and the 5.minutes translates to postgres Interval type.

Solution

TBD

Notes

Since Encoder/Decoder for LocalDate is already defined in the base Encoders.scala and Decoders.scala JDBC files, we override it our custom Postgres datetime Encoder/Decoder. While there is an argument that this is pointless and we should just not include the these Encoder's/Decoder's which are already defined, the Postgres JDBC converters are both faster and is what is official supported for use when using Postgres JDBC.

Also since we are adding capability for the datetime types provided by JSR-310 this effectively means that quill will only support JVM versions 1.8+ effective of this PR. I don't know how much of an issue this is, however note that JVM 1.6 is already out of EOL support from Oracle. The only area I could practically see this being a problem is if someone is using Quill on Android (is anyone doing this?)

Checklist

  • Unit test all changes
  • Update README.md if applicable
  • Add [WIP] to the pull request title if it's work in progress
  • Squash commits that aren't meaningful changes
  • Run sbt scalariformFormat test:scalariformFormat to make sure that the source files are formatted

@getquill/maintainers

@mdedetrich mdedetrich force-pushed the datetime-duration-dsl branch 12 times, most recently from e4dabad to 1494e5c Compare September 29, 2019 12:19
@mdedetrich mdedetrich force-pushed the datetime-duration-dsl branch 5 times, most recently from e69e673 to 83aa453 Compare September 29, 2019 23:47
@mdedetrich mdedetrich force-pushed the datetime-duration-dsl branch from 83aa453 to 6e38a4b Compare October 12, 2019 12:41
@deusaquilus
Copy link
Collaborator

deusaquilus commented Aug 23, 2020

@mdedetrich This is really great, I’m hoping we can incorporate stuff like this into other dialects! There are probably some things that need to be added to the Postgres Dialect tokenizer as well as the parser for this to work.

Come to think of it, the easiest way to implement this is going to be with Quats that represent time intervals. Otherwise we’d need to add a bunch of AST elements to represent the different operations.

I’m going to document how to approach this issue using Quats in the coming days.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

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.

3 participants