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

Add support for date_bin (available in postgres >= 14) #648

Merged
merged 1 commit into from
Jun 30, 2023

Conversation

hughsimpson
Copy link
Contributor

I don't know what your take is on functions that're introduced in versions of postgres > 11 - I didn't spot anything similar in the repo already - but this is a pretty handy one, so I thought I might as well give it a shot.

@@ -145,6 +145,10 @@ class PgDateSupportJodaSuite extends AnyFunSuite with PostgresContainer {
Datetimes.filter(_.id === 101L.bind).map(r => r.datetime.trunc("day")).result.head.map(
r => assert(LocalDateTime.parse("2001-01-03T00:00:00") === r)
),
// dateBin
DBIO.seq(Option.when(pgVersion.take(2).toInt >= 14)(Datetimes.filter(_.id === 101L.bind).map(r => r.datetime.dateBin("1 hour", LocalDateTime.parse("2001-01-03T18:35:17"))).result.head.map(
Copy link
Contributor Author

@hughsimpson hughsimpson Jun 28, 2023

Choose a reason for hiding this comment

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

The gnarly little wrapper here (and elsewhere) could be refactored out for a more principled approach to supporting features that're only introduced in later versions of postgres, but I figured I'd test the waters first, and don't currently need any other feature missing from the existing set

Copy link
Owner

Choose a reason for hiding this comment

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

It doesn't matter, I think, since it's postgresql that really supports these functions, instead of slick-pg.
In fact, slick-pg is just a tool that translates from scala functions to pg functions.

@tminglei tminglei merged commit c705999 into tminglei:master Jun 30, 2023
@tminglei
Copy link
Owner

Merged. Thanks! 👍

@hughsimpson hughsimpson deleted the add-support-for-date_bin branch June 30, 2023 15:04
@hughsimpson
Copy link
Contributor Author

@tminglei Thanks for merging this - could you release it? NBD, but does let me drop the shim from my local code

@tminglei
Copy link
Owner

tminglei commented Aug 5, 2023

@hughsimpson released in v0.22.0-M4.

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