From cc54b9bc151b7219fc84eb3a6e2f845d639a4b2e Mon Sep 17 00:00:00 2001 From: mkr Date: Sat, 11 Mar 2023 17:16:52 +0100 Subject: [PATCH] Bumping Play from 2.7.9 to 2.8.18 * No longer relying on Anorm's deprecated namedWithSymbol implicit conversions * Fix some typecase warnings --- app/controllers/ApiController.scala | 2 +- app/models/Id.scala | 2 +- app/models/SearchManagementRepository.scala | 10 +++++----- app/models/eventhistory/InputEvent.scala | 18 +++++++++--------- build.sbt | 9 ++++++--- project/plugins.sbt | 2 +- test/models/DBCompatibilitySpec.scala | 7 ++++--- 7 files changed, 27 insertions(+), 23 deletions(-) diff --git a/app/controllers/ApiController.scala b/app/controllers/ApiController.scala index 6e81c678..9f93a6fe 100644 --- a/app/controllers/ApiController.scala +++ b/app/controllers/ApiController.scala @@ -433,7 +433,7 @@ class ApiController @Inject()(authActionFactory: AuthActionFactory, } private def lookupUserInfo(request: Request[AnyContent]) = { val userInfo: Option[String] = request match { - case _: UserRequest[A] => Option(request.asInstanceOf[UserRequest[A]].username) + case _: UserRequest[_] => Option(request.asInstanceOf[UserRequest[_]].username) case _ => None } userInfo diff --git a/app/models/Id.scala b/app/models/Id.scala index 5eb4e8de..19307583 100644 --- a/app/models/Id.scala +++ b/app/models/Id.scala @@ -33,7 +33,7 @@ abstract class IdObject[T <: Id](fromString: String => T) { def apply(str: String): T = fromString(str) - implicit val jsonWrites: Writes[T] = Id.jsonWrites + implicit val jsonWrites: Writes[T] = Id.jsonWrites.asInstanceOf[Writes[T]] implicit val jsonReads: Reads[T] = Reads[T](_.validate[String].map(apply)) def apply(): T = apply(UUID.randomUUID().toString) diff --git a/app/models/SearchManagementRepository.scala b/app/models/SearchManagementRepository.scala index 92b674cc..0a98be15 100644 --- a/app/models/SearchManagementRepository.scala +++ b/app/models/SearchManagementRepository.scala @@ -234,11 +234,11 @@ class SearchManagementRepository @Inject()(dbapi: DBApi, toggleService: FeatureT def addNewDeploymentLogOk(solrIndexId: String, targetPlatform: String): Boolean = db.withConnection { implicit connection => SQL("insert into deployment_log(id, solr_index_id, target_platform, last_update, result) values ({id}, {solr_index_id}, {target_platform}, {last_update}, {result})") .on( - 'id -> UUID.randomUUID().toString, - 'solr_index_id -> solrIndexId, - 'target_platform -> targetPlatform, - 'last_update -> new Date(), - 'result -> 0 + "id" -> UUID.randomUUID().toString, + "solr_index_id" -> solrIndexId, + "target_platform" -> targetPlatform, + "last_update" -> new Date(), + "result" -> 0 ) .execute() } diff --git a/app/models/eventhistory/InputEvent.scala b/app/models/eventhistory/InputEvent.scala index 84a180c8..066d48ee 100644 --- a/app/models/eventhistory/InputEvent.scala +++ b/app/models/eventhistory/InputEvent.scala @@ -271,8 +271,8 @@ object InputEvent extends Logging { s"order by $EVENT_TIME asc" ) .on( - 'dateFrom -> dateFrom, - 'dateTo -> dateTo + "dateFrom" -> dateFrom, + "dateTo" -> dateTo ) .as(sqlParser.*) @@ -304,8 +304,8 @@ object InputEvent extends Logging { s"limit 1" ) .on( - 'inputId -> inputEvent.inputId, - 'dateFrom -> inputEvent.eventTime, + "inputId" -> inputEvent.inputId, + "dateFrom" -> inputEvent.eventTime, ) .as(sqlParser.*) @@ -340,9 +340,9 @@ object InputEvent extends Logging { s"order by $EVENT_TIME asc" ) .on( - 'inputId -> inputId, - 'dateFrom -> dateFrom, - 'dateTo -> dateTo + "inputId" -> inputId, + "dateFrom" -> dateFrom, + "dateTo" -> dateTo ) .as(sqlParser.*) @@ -359,8 +359,8 @@ object InputEvent extends Logging { s"limit 1" ) .on( - 'inputId -> inputId, - 'dateFrom -> dateFrom, + "inputId" -> inputId, + "dateFrom" -> dateFrom, ) .as(sqlParser.*) diff --git a/build.sbt b/build.sbt index b372457b..076e213f 100644 --- a/build.sbt +++ b/build.sbt @@ -1,7 +1,7 @@ import com.typesafe.sbt.GitBranchPrompt name := "search-management-ui" -version := "3.15.4" +version := "3.16.0" scalaVersion := "2.12.17" @@ -50,7 +50,7 @@ libraryDependencies ++= { "org.postgresql" % "postgresql" % "42.5.1", "org.xerial" % "sqlite-jdbc" % "3.40.0.0", "org.playframework.anorm" %% "anorm" % "2.7.0", - "com.typesafe.play" %% "play-json" % "2.6.12", + "com.typesafe.play" %% "play-json" % "2.9.3", "com.pauldijou" %% "jwt-play" % "4.1.0", "org.scalatestplus.play" %% "scalatestplus-play" % "3.1.0" % Test, "org.mockito" % "mockito-all" % "1.10.19" % Test, @@ -68,7 +68,8 @@ dependencyOverrides ++= { Seq( "com.fasterxml.jackson.core" % "jackson-annotations" % jacksonVersion, "com.fasterxml.jackson.core" % "jackson-core" % jacksonVersion, - "com.fasterxml.jackson.core" % "jackson-databind" % jacksonVersion + "com.fasterxml.jackson.core" % "jackson-databind" % jacksonVersion, + "com.fasterxml.jackson.module" %% "jackson-module-scala" % jacksonVersion ) } @@ -81,6 +82,8 @@ assembly / assemblyMergeStrategy := { // one with the given settings MergeStrategy.discard case x if x.endsWith("module-info.class") => MergeStrategy.discard + // Protobuf schemas, we just use the first one as we don't use Protobuf at all + case x if x.endsWith(".proto") => MergeStrategy.first case "play/reference-overrides.conf" => MergeStrategy.concat case x => val oldStrategy = (assembly / assemblyMergeStrategy).value diff --git a/project/plugins.sbt b/project/plugins.sbt index 1b9ba000..da372d3a 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,4 +1,4 @@ -addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.7.9") +addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.8.18") addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "1.0.2") addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.6.4") addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "2.0.0") diff --git a/test/models/DBCompatibilitySpec.scala b/test/models/DBCompatibilitySpec.scala index 66f69120..79c8f198 100644 --- a/test/models/DBCompatibilitySpec.scala +++ b/test/models/DBCompatibilitySpec.scala @@ -1,8 +1,7 @@ package models import java.time.LocalDateTime -import scala.util.{Try, Failure} - +import scala.util.Try import org.scalatest.{BeforeAndAfterAll, FlatSpec, Matchers} import play.api.db.Database import models.input.{InputTag, InputTagId, SearchInput, SearchInputWithRules} @@ -109,7 +108,9 @@ abstract class DBCompatibilitySpec extends FlatSpec with Matchers with TestData val trySecondCreate = Try( SmuiMigrationLock.create(MIGRATION_KEY) ) - trySecondCreate shouldBe Failure + // Postgres: ERROR: duplicate key value violates unique constraint "smui_migration_lock_pkey" + // SQLite: [SQLITE_CONSTRAINT_PRIMARYKEY] A PRIMARY KEY constraint failed (UNIQUE constraint failed: smui_migration_lock.migration_key) + trySecondCreate.isFailure shouldBe true // thread#1: make sure, the test migration can be selected (while its locked), but is not completed yet val migrationLockEntry = SmuiMigrationLock.select(MIGRATION_KEY).get migrationLockEntry.migrationKey shouldBe MIGRATION_KEY