Skip to content

Commit

Permalink
add back support for scala 2.12
Browse files Browse the repository at this point in the history
  • Loading branch information
tminglei committed Aug 5, 2023
1 parent 1034ad5 commit 366d523
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
strategy:
matrix:
java: [8, 11]
scala: [2.13.11]
scala: [2.12.18, 2.13.11]
postgres: [11, 12, 13, 14]
name: Test (Postgres ${{ matrix.postgres }} Scala ${{ matrix.scala }} Java ${{ matrix.java }})
runs-on: ubuntu-latest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ class PgDateSupportJodaSuite extends AnyFunSuite with PostgresContainer {
Period.parse("PT63H16M2S"), Instant.parse("2019-11-03 13:19:03.000+03", jodaTzDateTimeFormatter))

test("Joda time Lifted support") {
def when[A](cond: Boolean)(a: => A): Option[A] =
if (cond) Some(a) else None

val now = LocalDateTime.now
val now1 = DateTime.now
val now2 = LocalTime.now
Expand Down Expand Up @@ -146,7 +149,8 @@ class PgDateSupportJodaSuite extends AnyFunSuite with PostgresContainer {
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(
DBIO.seq(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(
r => assert(LocalDateTime.parse("2001-01-03T12:35:17") === r)
)).toSeq:_*),
// isFinite
Expand Down Expand Up @@ -210,9 +214,10 @@ class PgDateSupportJodaSuite extends AnyFunSuite with PostgresContainer {
r => assert(DateTime.parse("2001-01-03 00:00:00.000+08", jodaTzDateTimeFormatter) === r)
),
// dateBin
DBIO.seq(Option.when(pgVersion.take(2).toInt >= 14)(Datetimes.filter(_.id === 101L.bind).map(r => r.datetimetz.dateBin("1 hour", DateTime.parse("2001-01-02T18:35:17+08"))).result.head.map(
r => assert(DateTime.parse("2001-01-03 12:35:17.000+08", jodaTzDateTimeFormatter) === r)
)).toSeq:_*)
DBIO.seq(when(pgVersion.take(2).toInt >= 14)(
Datetimes.filter(_.id === 101L.bind).map(r => r.datetimetz.dateBin("1 hour", DateTime.parse("2001-01-02T18:35:17+08"))).result.head.map(
r => assert(DateTime.parse("2001-01-03 12:35:17.000+08", jodaTzDateTimeFormatter) === r)
)).toSeq:_*)
),
// update and check
DBIO.seq(
Expand Down
3 changes: 2 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
val scala212 = "2.12.18"
val scala213 = "2.13.11"

lazy val commonSettings = Seq(
Expand All @@ -7,7 +8,7 @@ lazy val commonSettings = Seq(
version := "0.22.0-M4",

scalaVersion := scala213,
crossScalaVersions := Seq(scala213),
crossScalaVersions := Seq(scala212, scala213),
scalacOptions ++= Seq("-deprecation", "-feature",
"-language:implicitConversions",
"-language:reflectiveCalls",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ class PgDate2SupportSuite extends AnyFunSuite with PostgresContainer {
TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"))

test("Java8 date Lifted support") {
def when[A](cond: Boolean)(a: => A): Option[A] =
if (cond) Some(a) else None

Await.result(db.run(
DBIO.seq(
sqlu"SET TIMEZONE TO '+8';",
Expand Down Expand Up @@ -163,9 +166,10 @@ class PgDate2SupportSuite extends AnyFunSuite with PostgresContainer {
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(
r => assert(LocalDateTime.parse("2001-01-03T12:35:17") === r)
)).toSeq:_*),
DBIO.seq(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(
r => assert(LocalDateTime.parse("2001-01-03T12:35:17") === r)
)).toSeq:_*),
// isFinite
Datetimes.filter(_.id === 101L.bind).map(r => r.dateTime.isFinite).result.head.map(
r => assert(true === r)
Expand Down Expand Up @@ -229,9 +233,10 @@ class PgDate2SupportSuite extends AnyFunSuite with PostgresContainer {
r => assert(ZonedDateTime.parse("2001-01-03 00:00:00+08", date2TzDateTimeFormatter) === r)
),
// dateBin
DBIO.seq(Option.when(pgVersion.take(2).toInt >= 14)(Datetimes.filter(_.id === 101L.bind).map(r => r.dateTimeTz.dateBin("1 hour", ZonedDateTime.parse("2001-01-03 18:35:17+03", date2TzDateTimeFormatter))).result.head.map(
r => assert(ZonedDateTime.parse("2001-01-03 12:35:17+08", date2TzDateTimeFormatter) === r)
)).toSeq:_*)
DBIO.seq(when(pgVersion.take(2).toInt >= 14)(
Datetimes.filter(_.id === 101L.bind).map(r => r.dateTimeTz.dateBin("1 hour", ZonedDateTime.parse("2001-01-03 18:35:17+03", date2TzDateTimeFormatter))).result.head.map(
r => assert(ZonedDateTime.parse("2001-01-03 12:35:17+08", date2TzDateTimeFormatter) === r)
)).toSeq:_*)
),
// Timezones
Datetimes.filter(_.id === 101L.bind).map(r => r.zone).result.head.map(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ class PgDateSupportSuite extends AnyFunSuite with PostgresContainer {
ts("2019-11-3 13:19:03"), tstz("2019-11-03T13:19:03+03:00"), Interval("63 hours 16 mins 2 secs"))

test("Date Lifted support") {
def when[A](cond: Boolean)(a: => A): Option[A] =
if (cond) Some(a) else None

Await.result(db.run(
DBIO.seq(
sqlu"SET TIMEZONE TO '+8';",
Expand Down Expand Up @@ -145,9 +148,10 @@ class PgDateSupportSuite extends AnyFunSuite with PostgresContainer {
r => assert(ts("2001-1-3 00:00:00.0").toLocalDateTime === r.toLocalDateTime)
),
// dateBin
DBIO.seq(Option.when(pgVersion.take(2).toInt >= 14)(Datetimes.filter(_.id === 101L.bind).map(r => r.timestamp.dateBin("1 hour", ts("2001-1-3 18:35:17"))).result.head.map(
r => assert(ts("2001-01-03 12:35:17").toLocalDateTime === r.toLocalDateTime)
)).toSeq: _*),
DBIO.seq(when(pgVersion.take(2).toInt >= 14)(
Datetimes.filter(_.id === 101L.bind).map(r => r.timestamp.dateBin("1 hour", ts("2001-1-3 18:35:17"))).result.head.map(
r => assert(ts("2001-01-03 12:35:17").toLocalDateTime === r.toLocalDateTime)
)).toSeq: _*),
// isFinite
Datetimes.filter(_.id === 101L.bind).map(r => r.timestamp.isFinite).result.head.map(
r => assert(true === r)
Expand Down Expand Up @@ -209,9 +213,10 @@ class PgDateSupportSuite extends AnyFunSuite with PostgresContainer {
r => assert(tstz("2001-01-03T00:00:00+08:00").getTimeInMillis === r.getTimeInMillis)
),
// dateBin
DBIO.seq(Option.when(pgVersion.take(2).toInt >= 14)(Datetimes.filter(_.id === 101L.bind).map(r => r.timestamptz.dateBin("1 hour", tstz("2001-01-02T18:35:17+03"))).result.head.map(
r => assert(tstz("2001-01-03T12:35:17+08").getTimeInMillis === r.getTimeInMillis)
)).toSeq: _*)
DBIO.seq(when(pgVersion.take(2).toInt >= 14)(
Datetimes.filter(_.id === 101L.bind).map(r => r.timestamptz.dateBin("1 hour", tstz("2001-01-02T18:35:17+08:00"))).result.head.map(
r => assert(tstz("2001-01-03T12:35:17+08:00").getTimeInMillis === r.getTimeInMillis)
)).toSeq: _*)
)
)
).andFinally(
Expand Down

0 comments on commit 366d523

Please sign in to comment.