Skip to content

Commit

Permalink
Remove deprecated EntityQuery.update/insert APIs (#2412)
Browse files Browse the repository at this point in the history
* Remove deprecated APIs

* Missed a module

* Add another module
  • Loading branch information
deusaquilus authored Jan 28, 2022
1 parent 6204c7e commit 36f467a
Show file tree
Hide file tree
Showing 14 changed files with 49 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class CaseClassQueryCassandraSpec extends CassandraAlpakkaSpec {
case class Address(id: Int, street: String, zip: Int, otherExtraInfo: String)

val peopleInsert =
quote((p: Contact) => query[Contact].insert(p))
quote((p: Contact) => query[Contact].insertValue(p))

val peopleEntries = List(
Contact(1, "Alex", "Jones", 60, 2, "foo"),
Expand All @@ -17,7 +17,7 @@ class CaseClassQueryCassandraSpec extends CassandraAlpakkaSpec {
)

val addressInsert =
quote((c: Address) => query[Address].insert(c))
quote((c: Address) => query[Address].insertValue(c))

val addressEntries = List(
Address(1, "123 Fake Street", 11234, "something"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class DecodeNullSpec extends CassandraAlpakkaSpec {
val result =
for {
_ <- testDB.run(writeEntities.delete)
_ <- testDB.run(writeEntities.insert(lift(insertValue)))
_ <- testDB.run(writeEntities.insertValue(lift(insertValue)))
result <- testDB.run(query[DecodeNullTestEntity])
} yield {
result
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class EncodingSpec extends EncodingSpecHelper with CassandraAlpakkaSpec {
import testDB._
for {
_ <- testDB.run(query[EncodingTestEntity].delete)
_ <- testDB.run(liftQuery(insertValues).foreach(e => query[EncodingTestEntity].insert(e)))
_ <- testDB.run(liftQuery(insertValues).foreach(e => query[EncodingTestEntity].insertValue(e)))
result <- testDB.run(query[EncodingTestEntity])
} yield {
verify(result)
Expand All @@ -29,7 +29,7 @@ class EncodingSpec extends EncodingSpecHelper with CassandraAlpakkaSpec {
await {
for {
_ <- testDB.run(query[EncodingTestEntity].delete)
_ <- testDB.run(liftQuery(insertValues).foreach(e => query[EncodingTestEntity].insert(e)))
_ <- testDB.run(liftQuery(insertValues).foreach(e => query[EncodingTestEntity].insertValue(e)))
r <- testDB.run(q(liftQuery(insertValues.map(_.id))))
} yield {
verify(r)
Expand Down Expand Up @@ -79,7 +79,7 @@ class EncodingSpec extends EncodingSpecHelper with CassandraAlpakkaSpec {
await {
for {
_ <- ctx.run(jq.delete)
_ <- ctx.run(jq.insert(lift(j)))
_ <- ctx.run(jq.insertValue(lift(j)))
r <- ctx.run(cq)
} yield {
r.headOption mustBe Some(c)
Expand All @@ -89,7 +89,7 @@ class EncodingSpec extends EncodingSpecHelper with CassandraAlpakkaSpec {
await {
for {
_ <- ctx.run(cq.delete)
_ <- ctx.run(cq.insert(lift(c)))
_ <- ctx.run(cq.insertValue(lift(c)))
r <- ctx.run(jq)
} yield {
r.headOption mustBe Some(j)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class ListsEncodingSpec extends CollectionsSpec with CassandraAlpakkaSpec {
"List encoders/decoders for CassandraTypes and CassandraMappers" in {
await {
for {
_ <- ctx.run(q.insert(lift(e)))
_ <- ctx.run(q.insertValue(lift(e)))
res <- ctx.run(q.filter(_.id == 1))
} yield {
res.head mustBe e
Expand All @@ -49,7 +49,7 @@ class ListsEncodingSpec extends CollectionsSpec with CassandraAlpakkaSpec {

await {
for {
_ <- ctx.run(q.insert(lift(e)))
_ <- ctx.run(q.insertValue(lift(e)))
res <- ctx.run(q.filter(_.id == 1))
} yield {
res.head mustBe e
Expand All @@ -64,7 +64,7 @@ class ListsEncodingSpec extends CollectionsSpec with CassandraAlpakkaSpec {

await {
for {
_ <- ctx.run(q.insert(lift(e)))
_ <- ctx.run(q.insertValue(lift(e)))
res <- ctx.run(q.filter(_.id == 1))
} yield {
res.head mustBe e
Expand All @@ -79,7 +79,7 @@ class ListsEncodingSpec extends CollectionsSpec with CassandraAlpakkaSpec {

await {
for {
_ <- ctx.run(q.insert(lift(e)))
_ <- ctx.run(q.insertValue(lift(e)))
res <- ctx.run(q.filter(_.id == 1))
} yield {
res.head mustBe e
Expand All @@ -94,7 +94,7 @@ class ListsEncodingSpec extends CollectionsSpec with CassandraAlpakkaSpec {

await {
for {
_ <- ctx.run(q.insert(lift(e)))
_ <- ctx.run(q.insertValue(lift(e)))
res <- ctx.run(q.filter(_.id == 4))
} yield {
res.head.blobs.map(_.toList) mustBe e.blobs.map(_.toList)
Expand All @@ -106,7 +106,7 @@ class ListsEncodingSpec extends CollectionsSpec with CassandraAlpakkaSpec {
val e = ListFrozen(List(1, 2))
await {
for {
_ <- ctx.run(listFroz.insert(lift(e)))
_ <- ctx.run(listFroz.insertValue(lift(e)))
res1 <- ctx.run(listFroz.filter(_.id == lift(List(1, 2))))
res2 <- ctx.run(listFroz.filter(_.id == lift(List(1))))
} yield {
Expand All @@ -116,7 +116,7 @@ class ListsEncodingSpec extends CollectionsSpec with CassandraAlpakkaSpec {
}
await {
for {
_ <- ctx.run(listFroz.insert(lift(e)))
_ <- ctx.run(listFroz.insertValue(lift(e)))
res1 <- ctx.run(listFroz.filter(_.id.contains(2)).allowFiltering)
res2 <- ctx.run(listFroz.filter(_.id.contains(3)).allowFiltering)
} yield {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class MapsEncodingSpec extends CollectionsSpec with CassandraAlpakkaSpec {
"Map encoders/decoders" in {
await {
for {
_ <- ctx.run(q.insert(lift(e)))
_ <- ctx.run(q.insertValue(lift(e)))
res <- ctx.run(q.filter(_.id == 1))
} yield {
res.head mustBe e
Expand All @@ -46,7 +46,7 @@ class MapsEncodingSpec extends CollectionsSpec with CassandraAlpakkaSpec {

await {
for {
_ <- ctx.run(q.insert(lift(e)))
_ <- ctx.run(q.insertValue(lift(e)))
res <- ctx.run(q.filter(_.id == 1))
} yield {
res.head mustBe e
Expand All @@ -61,7 +61,7 @@ class MapsEncodingSpec extends CollectionsSpec with CassandraAlpakkaSpec {

await {
for {
_ <- ctx.run(q.insert(lift(e)))
_ <- ctx.run(q.insertValue(lift(e)))
res <- ctx.run(q.filter(_.id == 1))
} yield {
res.head mustBe e
Expand All @@ -76,7 +76,7 @@ class MapsEncodingSpec extends CollectionsSpec with CassandraAlpakkaSpec {

await {
for {
_ <- ctx.run(q.insert(lift(e)))
_ <- ctx.run(q.insertValue(lift(e)))
res <- ctx.run(q.filter(_.id == 1))
} yield {
res.head mustBe e
Expand All @@ -89,7 +89,7 @@ class MapsEncodingSpec extends CollectionsSpec with CassandraAlpakkaSpec {

await {
for {
_ <- ctx.run(mapFroz.insert(lift(e)))
_ <- ctx.run(mapFroz.insertValue(lift(e)))
res1 <- ctx.run(mapFroz.filter(_.id == lift(Map(1 -> true))))
res2 <- ctx.run(mapFroz.filter(_.id == lift(Map(1 -> false))))
} yield {
Expand All @@ -99,7 +99,7 @@ class MapsEncodingSpec extends CollectionsSpec with CassandraAlpakkaSpec {
}
await {
for {
_ <- ctx.run(mapFroz.insert(lift(e)))
_ <- ctx.run(mapFroz.insertValue(lift(e)))
res1 <- ctx.run(mapFroz.filter(_.id.contains(1)).allowFiltering)
res2 <- ctx.run(mapFroz.filter(_.id.contains(2)).allowFiltering)
} yield {
Expand All @@ -114,7 +114,7 @@ class MapsEncodingSpec extends CollectionsSpec with CassandraAlpakkaSpec {

await {
for {
_ <- ctx.run(mapFroz.insert(lift(e)))
_ <- ctx.run(mapFroz.insertValue(lift(e)))
res1 <- ctx.run(mapFroz.filter(_.id.containsValue(true)).allowFiltering)
res2 <- ctx.run(mapFroz.filter(_.id.containsValue(false)).allowFiltering)
} yield {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class PeopleCassandraSpec extends CassandraAlpakkaSpec {
testDB.run(query[Person].delete)
}
await {
testDB.run(liftQuery(entries).foreach(e => query[Person].insert(e)))
testDB.run(liftQuery(entries).foreach(e => query[Person].insertValue(e)))
}
()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class SetsEncodingSpec extends CollectionsSpec with CassandraAlpakkaSpec {
"Set encoders/decoders for CassandraTypes and CassandraMappers" in {
await {
for {
_ <- ctx.run(q.insert(lift(e)))
_ <- ctx.run(q.insertValue(lift(e)))
res <- ctx.run(q.filter(_.id == 1))
} yield {
res.head mustBe e
Expand All @@ -46,7 +46,7 @@ class SetsEncodingSpec extends CollectionsSpec with CassandraAlpakkaSpec {

await {
for {
_ <- ctx.run(q.insert(lift(e)))
_ <- ctx.run(q.insertValue(lift(e)))
res <- ctx.run(q.filter(_.id == 1))
} yield {
res.head mustBe e
Expand All @@ -61,7 +61,7 @@ class SetsEncodingSpec extends CollectionsSpec with CassandraAlpakkaSpec {

await {
for {
_ <- ctx.run(q.insert(lift(e)))
_ <- ctx.run(q.insertValue(lift(e)))
res <- ctx.run(q.filter(_.id == 1))
} yield {
res.head mustBe e
Expand All @@ -76,7 +76,7 @@ class SetsEncodingSpec extends CollectionsSpec with CassandraAlpakkaSpec {

await {
for {
_ <- ctx.run(q.insert(lift(e)))
_ <- ctx.run(q.insertValue(lift(e)))
res <- ctx.run(q.filter(_.id == 1))
} yield {
res.head mustBe e
Expand All @@ -91,7 +91,7 @@ class SetsEncodingSpec extends CollectionsSpec with CassandraAlpakkaSpec {

await {
for {
_ <- ctx.run(q.insert(lift(e)))
_ <- ctx.run(q.insertValue(lift(e)))
res <- ctx.run(q.filter(_.id == 4))
} yield {
res.head.blobs.map(_.toSet) mustBe e.blobs.map(_.toSet)
Expand All @@ -103,7 +103,7 @@ class SetsEncodingSpec extends CollectionsSpec with CassandraAlpakkaSpec {
val e = SetFrozen(Set(1, 2))
await {
for {
_ <- ctx.run(setFroz.insert(lift(e)))
_ <- ctx.run(setFroz.insertValue(lift(e)))
res1 <- ctx.run(setFroz.filter(_.id == lift(Set(1, 2))))
res2 <- ctx.run(setFroz.filter(_.id == lift(Set(1))))
} yield {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class UdtEncodingSessionContextSpec extends UdtSpec with CassandraAlpakkaSpec {

await {
for {
_ <- ctx1.run(query[WithEverything].insert(lift(e)))
_ <- ctx1.run(query[WithEverything].insertValue(lift(e)))
res <- ctx1.run(query[WithEverything].filter(_.id == 1))
} yield {
res.headOption must contain(e)
Expand All @@ -73,7 +73,7 @@ class UdtEncodingSessionContextSpec extends UdtSpec with CassandraAlpakkaSpec {

await {
for {
_ <- ctx1.run(query[WithEverything].insert(lift(e)))
_ <- ctx1.run(query[WithEverything].insertValue(lift(e)))
res <- ctx1.run(query[WithEverything].filter(_.id == 2))
} yield {
res.headOption must contain(e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ class DynamicQueryDslMacro(val c: MacroContext) {

def insertValue(value: Tree): Tree =
q"""
DynamicInsert(${c.prefix}.q.insert(lift($value)))
DynamicInsert(${c.prefix}.q.insertValue(lift($value)))
"""

def updateValue(value: Tree): Tree =
q"""
DynamicUpdate(${c.prefix}.q.update(lift($value)))
DynamicUpdate(${c.prefix}.q.updateValue(lift($value)))
"""
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ class DynamicQueryDslMacro(val c: MacroContext) {

def insertValue(value: Tree): Tree =
q"""
DynamicInsert(${c.prefix}.q.insert(lift($value)))
DynamicInsert(${c.prefix}.q.insertValue(lift($value)))
"""

def updateValue(value: Tree): Tree =
q"""
DynamicUpdate(${c.prefix}.q.update(lift($value)))
DynamicUpdate(${c.prefix}.q.updateValue(lift($value)))
"""
}

Expand Down
4 changes: 0 additions & 4 deletions quill-core/src/main/scala/io/getquill/ModelMacro.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,9 @@ sealed trait EntityQuery[T]
override def map[R](f: T => R): EntityQuery[R] = NonQuotedException()

def insertValue(value: T): Insert[T] = macro QueryDslMacro.expandInsert[T]
@deprecated("EntityQuery.insert(value) is deprecated due to upstream Scala 3 requirements. Use EntityQuery.insertValue(value) instead.", "3.13.0")
def insert(value: T): Insert[T] = macro QueryDslMacro.expandInsert[T]
def insert(f: (T => (Any, Any)), f2: (T => (Any, Any))*): Insert[T]

def updateValue(value: T): Update[T] = macro QueryDslMacro.expandUpdate[T]
@deprecated("EntityQuery.update(value) is deprecated due to upstream Scala 3 requirements. Use EntityQuery.updateValue(value) instead.", "3.13.0")
def update(value: T): Update[T] = macro QueryDslMacro.expandUpdate[T]
def update(f: (T => (Any, Any)), f2: (T => (Any, Any))*): Update[T]

def delete: Delete[T]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class ArrayAsyncEncodingSpec extends ArrayEncodingBaseSpec with ZioSpec {
val q = quote(query[ArraysTestEntity])

"Support all sql base types and `Iterable` implementers" in {
runSyncUnsafe(context.run(q.insert(lift(e))))
runSyncUnsafe(context.run(q.insertValue(lift(e))))
val actual = runSyncUnsafe(context.run(q)).head
actual mustEqual e
baseEntityDeepCheck(actual, e)
Expand All @@ -23,7 +23,7 @@ class ArrayAsyncEncodingSpec extends ArrayEncodingBaseSpec with ZioSpec {
case class JodaTimes(timestamps: Seq[JodaLocalDateTime], dates: Seq[JodaLocalDate])
val jE = JodaTimes(Seq(JodaLocalDateTime.now()), Seq(JodaLocalDate.now()))
val jQ = quote(querySchema[JodaTimes]("ArraysTestEntity"))
runSyncUnsafe(context.run(jQ.insert(lift(jE))))
runSyncUnsafe(context.run(jQ.insertValue(lift(jE))))
val actual = runSyncUnsafe(context.run(jQ)).head
actual.timestamps mustBe jE.timestamps
actual.dates mustBe jE.dates
Expand All @@ -33,7 +33,7 @@ class ArrayAsyncEncodingSpec extends ArrayEncodingBaseSpec with ZioSpec {
case class JodaTimes(timestamps: Seq[JodaDateTime])
val jE = JodaTimes(Seq(JodaDateTime.now()))
val jQ = quote(querySchema[JodaTimes]("ArraysTestEntity"))
runSyncUnsafe(context.run(jQ.insert(lift(jE))))
runSyncUnsafe(context.run(jQ.insertValue(lift(jE))))
val actual = runSyncUnsafe(context.run(jQ)).head
actual.timestamps mustBe jE.timestamps
}
Expand All @@ -42,15 +42,15 @@ class ArrayAsyncEncodingSpec extends ArrayEncodingBaseSpec with ZioSpec {
case class Java8Times(timestamps: Seq[LocalDateTime], dates: Seq[LocalDate])
val jE = Java8Times(Seq(LocalDateTime.now()), Seq(LocalDate.now()))
val jQ = quote(querySchema[Java8Times]("ArraysTestEntity"))
runSyncUnsafe(context.run(jQ.insert(lift(jE))))
runSyncUnsafe(context.run(jQ.insertValue(lift(jE))))
val actual = runSyncUnsafe(context.run(jQ)).head
actual.timestamps mustBe jE.timestamps
actual.dates mustBe jE.dates
}

"Support Iterable encoding basing on MappedEncoding" in {
val wrapQ = quote(querySchema[WrapEntity]("ArraysTestEntity"))
runSyncUnsafe(context.run(wrapQ.insert(lift(wrapE))))
runSyncUnsafe(context.run(wrapQ.insertValue(lift(wrapE))))
runSyncUnsafe(context.run(wrapQ)).head mustBe wrapE
}

Expand All @@ -61,15 +61,15 @@ class ArrayAsyncEncodingSpec extends ArrayEncodingBaseSpec with ZioSpec {
arrayDecoder[LocalDate, LocalDate, Col](identity)
}
import newCtx._
runSyncUnsafe(newCtx.run(query[ArraysTestEntity].insert(lift(e))))
runSyncUnsafe(newCtx.run(query[ArraysTestEntity].insertValue(lift(e))))
intercept[FiberFailure] {
runSyncUnsafe(newCtx.run(query[ArraysTestEntity])).head mustBe e
}
newCtx.close()
}

"Arrays in where clause" in {
runSyncUnsafe(context.run(q.insert(lift(e))))
runSyncUnsafe(context.run(q.insertValue(lift(e))))
val actual1 = runSyncUnsafe(context.run(q.filter(_.texts == lift(List("test")))))
val actual2 = runSyncUnsafe(context.run(q.filter(_.texts == lift(List("test2")))))
baseEntityDeepCheck(actual1.head, e)
Expand Down Expand Up @@ -148,7 +148,7 @@ class ArrayAsyncEncodingSpec extends ArrayEncodingBaseSpec with ZioSpec {
val realEntity = quote {
querySchema[RealEncodingTestEntity]("EncodingTestEntity")
}
runSyncUnsafe(context.run(realEntity.insert(lift(insertValue))))
runSyncUnsafe(context.run(realEntity.insertValue(lift(insertValue))))

case class EncodingTestEntity(v1: List[String])
intercept[FiberFailure](runSyncUnsafe(context.run(query[EncodingTestEntity])))
Expand Down
Loading

0 comments on commit 36f467a

Please sign in to comment.