Skip to content

Commit

Permalink
chore(deps): bump mariadb-java-client from 3.3.3 to 3.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
yoshinorin committed Jul 14, 2024
1 parent 5db7014 commit 77ac627
Show file tree
Hide file tree
Showing 13 changed files with 45 additions and 59 deletions.
2 changes: 1 addition & 1 deletion project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ object Dependencies {
"com.github.plokhotnyuk.jsoniter-scala" %% "jsoniter-scala-core" % jsoniterVersion,
"com.github.plokhotnyuk.jsoniter-scala" %% "jsoniter-scala-macros" % jsoniterVersion % "compile-internal",
"com.github.plokhotnyuk.jsoniter-scala" %% "jsoniter-scala-macros" % jsoniterVersion % "test-internal",
"org.mariadb.jdbc" % "mariadb-java-client" % "3.3.3",
"org.mariadb.jdbc" % "mariadb-java-client" % "3.4.0",
"org.tpolecat" %% "doobie-core" % doobieVersion,
// "org.tpolecat" %% "doobie-scalatest" % doobieVersion % Test,
"org.wvlet.airframe" %% "airframe-ulid" % "24.7.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package net.yoshinorin.qualtet.domains.contentSerializing
import cats.data.NonEmptyList
import doobie.{Read, Write}
import doobie.implicits.toSqlInterpolator
import doobie.util.update.Update
import doobie.util.query
import doobie.util.update.{Update, Update0}
import doobie.util.{fragments, query}
import net.yoshinorin.qualtet.domains.contents.ContentId
import net.yoshinorin.qualtet.domains.series.SeriesId

Expand All @@ -26,21 +26,21 @@ object ContentSerializingQuery {
Update[ContentSerializing](q)
}

def deleteBySeriesId(id: SeriesId): query.Query0[Unit] = {
sql"DELETE FROM contents_serializing WHERE series_id = ${id.value}"
.query[Unit]
def deleteBySeriesId(id: SeriesId): Update0 = {
sql"DELETE FROM contents_serializing WHERE series_id = ${id.value}".update
}

def deleteByContentId(id: ContentId): query.Query0[Unit] = {
sql"DELETE FROM contents_serializing WHERE content_id = ${id.value}"
.query[Unit]
def deleteByContentId(id: ContentId): Update0 = {
sql"DELETE FROM contents_serializing WHERE content_id = ${id.value}".update
}

def delete(seriesId: SeriesId, contentIds: Seq[ContentId]): query.Query0[Unit] = {
(fr"""
def delete(seriesId: SeriesId, contentIds: Seq[ContentId]): Update0 = {
val query = fr"""
DELETE FROM contents_serializing
WHERE series_id = ${seriesId.value}
AND """ ++ doobie.util.fragments.in(fr"content_id", NonEmptyList.fromList(contentIds.toList.map(c => c.value)).get)).query[Unit]
AND """ ++ fragments.in(fr"content_id", NonEmptyList.fromList(contentIds.toList.map(c => c.value)).get)

query.update
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ object ContentSerializingRepository {
}

override def deleteBySeriesId(id: SeriesId): ConnectionIO[Unit] = {
ContentSerializingQuery.deleteBySeriesId(id).option.map(_ => ())
ContentSerializingQuery.deleteBySeriesId(id).run.map(_ => ())
}

override def deleteByContentId(id: ContentId): ConnectionIO[Unit] = {
ContentSerializingQuery.deleteByContentId(id).option.map(_ => ())
ContentSerializingQuery.deleteByContentId(id).run.map(_ => ())
}

override def delete(seriesId: SeriesId, contentIds: Seq[ContentId]): ConnectionIO[Unit] = {
ContentSerializingQuery.delete(seriesId, contentIds).option.map(_ => ())
ContentSerializingQuery.delete(seriesId, contentIds).run.map(_ => ())
}
override def fakeRequestInt: ConnectionIO[Int] = 0.pure[ConnectionIO]
override def fakeRequestUnit: ConnectionIO[Unit] = ().pure[ConnectionIO]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package net.yoshinorin.qualtet.domains.contentTaggings
import cats.data.NonEmptyList
import doobie.{Read, Write}
import doobie.implicits.toSqlInterpolator
import doobie.util.update.Update
import doobie.util.query
import doobie.util.update.{Update, Update0}
import doobie.util.{fragments, query}
import net.yoshinorin.qualtet.domains.tags.TagId
import net.yoshinorin.qualtet.domains.contents.ContentId

Expand All @@ -26,29 +26,21 @@ object ContentTaggingQuery {
Update[ContentTagging](q)
}

def deleteByContentId(id: ContentId): query.Query0[Unit] = {
sql"DELETE FROM contents_tagging WHERE content_id = ${id.value}"
.query[Unit]
def deleteByContentId(id: ContentId): Update0 = {
sql"DELETE FROM contents_tagging WHERE content_id = ${id.value}".update
}

def deleteByTagId(id: TagId): query.Query0[Unit] = {
sql"DELETE FROM contents_tagging WHERE tag_id = ${id.value}"
.query[Unit]
def deleteByTagId(id: TagId): Update0 = {
sql"DELETE FROM contents_tagging WHERE tag_id = ${id.value}".update
}

def delete(contentId: ContentId, tagIds: Seq[TagId]): query.Query0[Unit] = {
// https://tpolecat.github.io/doobie/docs/05-Parameterized.html#dealing-with-in-clauses
// https://tpolecat.github.io/doobie/docs/08-Fragments.html#composing-sql-literals
//
// val inClauseFragment = fr" tag_id IN (" ++ tagIds.map(n => fr"$n").intercalate(fr",") ++ fr")"
// val sTagIds = tagIds.map(t => s"${t.value}").mkString(",")
// val inClauseFragment = fr" tag_id IN (" ++ fr"${sTagIds}" ++ fr")"
// val inClauseFragment = doobie.util.fragments.in(fr"tag_id", NonEmptyList.fromList(tagIds.toList))

(fr"""
def delete(contentId: ContentId, tagIds: Seq[TagId]): Update0 = {
val query = fr"""
DELETE FROM contents_tagging
WHERE content_id = ${contentId.value}
AND """ ++ doobie.util.fragments.in(fr"tag_id", NonEmptyList.fromList(tagIds.toList.map(t => t.value)).get)).query[Unit]
AND """ ++ fragments.in(fr"tag_id", NonEmptyList.fromList(tagIds.toList.map(t => t.value)).get)

query.update
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ object ContentTaggingRepository {
ContentTaggingQuery.findByTagId(id).to[Seq]
}
override def deleteByContentId(id: ContentId): ConnectionIO[Unit] = {
ContentTaggingQuery.deleteByContentId(id).option.map(_ => ())
ContentTaggingQuery.deleteByContentId(id).run.map(_ => ())
}
override def deleteByTagId(id: TagId): ConnectionIO[Unit] = {
ContentTaggingQuery.deleteByTagId(id).option.map(_ => ())
ContentTaggingQuery.deleteByTagId(id).run.map(_ => ())
}
override def delete(contentId: ContentId, tagIds: Seq[TagId]): ConnectionIO[Unit] = {
ContentTaggingQuery.delete(contentId, tagIds).option.map(_ => ())
ContentTaggingQuery.delete(contentId, tagIds).run.map(_ => ())
}
override def fakeRequestInt: ConnectionIO[Int] = 0.pure[ConnectionIO]
override def fakeRequestUnit: ConnectionIO[Unit] = ().pure[ConnectionIO]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package net.yoshinorin.qualtet.domains.contents
import doobie.{Read, Write}
import doobie.implicits.toSqlInterpolator
import doobie.util.query.Query0
import doobie.util.update.Update
import doobie.util.update.{Update, Update0}

object ContentQuery {

Expand All @@ -22,9 +22,8 @@ object ContentQuery {
Update[Content](q)
}

def delete(id: ContentId): Query0[Unit] = {
sql"DELETE FROM contents WHERE id = ${id.value}"
.query[Unit]
def delete(id: ContentId): Update0 = {
sql"DELETE FROM contents WHERE id = ${id.value}".update
}

def findById(id: ContentId): Read[Content] ?=> Query0[Content] = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ object ContentRepository {
ContentQuery.findByPathWithMeta(path).option
}
override def delete(id: ContentId): ConnectionIO[Unit] = {
ContentQuery.delete(id).option.map(_ => ())
ContentQuery.delete(id).run.map(_ => ())
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ package net.yoshinorin.qualtet.domains.externalResources

import doobie.Write
import doobie.implicits.toSqlInterpolator
import doobie.util.update.Update
import doobie.util.query
import doobie.util.update.{Update, Update0}
import net.yoshinorin.qualtet.domains.contents.ContentId

object ExternalResourceQuery {
Expand All @@ -20,9 +19,8 @@ object ExternalResourceQuery {
Update[ExternalResource](q)
}

def delete(id: ContentId): query.Query0[Unit] = {
sql"DELETE FROM external_resources WHERE content_id = ${id.value}"
.query[Unit]
def delete(id: ContentId): Update0 = {
sql"DELETE FROM external_resources WHERE content_id = ${id.value}".update
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ object ExternalResourceRepository {
Write[(String, String, String)].contramap(p => (p.contentId.value, p.kind.value, p.name))

override def bulkUpsert(data: List[ExternalResource]): ConnectionIO[Int] = ExternalResourceQuery.bulkUpsert.updateMany(data)
override def delete(contentId: ContentId): ConnectionIO[Unit] = ExternalResourceQuery.delete(contentId).option.map(_ => ())
override def delete(contentId: ContentId): ConnectionIO[Unit] = ExternalResourceQuery.delete(contentId).run.map(_ => ())
override def fakeRequest(): ConnectionIO[Int] = 0.pure[ConnectionIO]
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ package net.yoshinorin.qualtet.domains.robots

import doobie.Write
import doobie.implicits.toSqlInterpolator
import doobie.util.update.Update
import doobie.util.query
import doobie.util.update.{Update, Update0}
import net.yoshinorin.qualtet.domains.contents.ContentId

object RobotsQuery {
Expand All @@ -18,9 +17,8 @@ object RobotsQuery {
Update[Robots](q)
}

def delete(id: ContentId): query.Query0[Unit] = {
sql"DELETE FROM robots WHERE content_id = ${id.value}"
.query[Unit]
def delete(id: ContentId): Update0 = {
sql"DELETE FROM robots WHERE content_id = ${id.value}".update
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ object RobotsRepository {
Write[(String, String)].contramap(p => (p.contentId.value, p.attributes.value))

override def upsert(data: Robots): ConnectionIO[Int] = RobotsQuery.upsert.run(data)
override def delete(contentId: ContentId): ConnectionIO[Unit] = RobotsQuery.delete(contentId).option.map(_ => ())
override def delete(contentId: ContentId): ConnectionIO[Unit] = RobotsQuery.delete(contentId).run.map(_ => ())

}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package net.yoshinorin.qualtet.domains.tags
import doobie.{Read, Write}
import doobie.implicits.toSqlInterpolator
import doobie.util.query.Query0
import doobie.util.update.Update
import doobie.util.update.{Update, Update0}
import net.yoshinorin.qualtet.domains.contents.ContentId

object TagQuery {
Expand Down Expand Up @@ -59,9 +59,8 @@ object TagQuery {
Update[Tag](q)
}

def delete(id: TagId): Query0[Unit] = {
sql"DELETE FROM tags WHERE id = ${id.value}"
.query[Unit]
def delete(id: TagId): Update0 = {
sql"DELETE FROM tags WHERE id = ${id.value}".update
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ object TagRepository {
TagQuery.findByContentId(conetntId).to[Seq]
}
override def delete(id: TagId): ConnectionIO[Unit] = {
TagQuery.delete(id).option.map(_ => ())
TagQuery.delete(id).run.map(_ => ())
}
override def fakeRequest(): ConnectionIO[Int] = 0.pure[ConnectionIO]

Expand Down

0 comments on commit 77ac627

Please sign in to comment.