Skip to content

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

Merged
tminglei merged 1 commit intotminglei:masterfrom
hughsimpson:add-support-for-date_bin
Jun 30, 2023
Merged

Add support for date_bin (available in postgres >= 14)#648
tminglei merged 1 commit intotminglei:masterfrom
hughsimpson:add-support-for-date_bin

Conversation

@hughsimpson
Copy link
Copy Markdown
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.

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Owner

Merged. Thanks! 👍

@hughsimpson hughsimpson deleted the add-support-for-date_bin branch June 30, 2023 15:04
@hughsimpson
Copy link
Copy Markdown
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
Copy Markdown
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