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

Please create a nowtz for working with Timestamptz #1752

Closed
lholden opened this Issue Jun 1, 2018 · 2 comments

Comments

Projects
None yet
3 participants
@lholden

lholden commented Jun 1, 2018

Due to a lack of implicit conversions currently if one wants to perform something such as

accessed_at.lt(now - 15.minutes())

Where accessed_at is a Timestamptz, one instead has to write:

accessed_at.lt(now.into_sql::<Timestamptz>() - 15.minutes())

Adding something like nowtz to the Diesel DSL would allow us to instead write:

accessed_at.lt(nowtz - 15.minutes())

@lholden lholden changed the title from Please create a nowtz for working with timestamps having timezones. to Please create a nowtz for working with Timestamptz Jun 1, 2018

@sgrif

This comment has been minimized.

Member

sgrif commented Sep 12, 2018

After implementing this, I'm not sure it really makes sense to have this in Diesel. The use case feels very niche, and not something that I think is worth maintaining in our own codebase -- Especially since you can have this in your own code base:

fn nowtz() -> AsExprOf<now, Timestamptz> {
    now.into_sql()
}

@sgrif sgrif closed this Sep 12, 2018

@berkus

This comment has been minimized.

berkus commented Sep 13, 2018

Ok, will add this to my codebase.. And probably many more will..

Is it possible to add this simple function in diesel just once instead?

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