From 60d3ff046d60094c84a0a3af0b4c1bb7f3162b82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Krenski?= Date: Wed, 25 Sep 2024 16:35:02 +0200 Subject: [PATCH] opt-in auto MacroBsonFormat --- .../rogue/cc/macros/MacroBsonFormatDeriving.scala | 9 +++++---- .../test/scala/me/sgrouples/MacroDerivationTests.scala | 1 + .../test/scala/me/sgrouples/rogue/AsyncBatchSpec.scala | 1 + .../test/scala/me/sgrouples/rogue/BsonFormatsTests.scala | 1 + .../scala/me/sgrouples/rogue/cc/ArrayListTests.scala | 1 + .../scala/me/sgrouples/rogue/cc/CCListArrayTest.scala | 1 + cc/src/test/scala/me/sgrouples/rogue/cc/CcMetaSpec.scala | 1 + .../me/sgrouples/rogue/cc/ComplexCaseClassSpec.scala | 1 + .../scala/me/sgrouples/rogue/cc/EnumIdFieldSpec.scala | 1 + .../scala/me/sgrouples/rogue/cc/ListFieldCaseSpec.scala | 1 + .../test/scala/me/sgrouples/rogue/cc/MapFormatSpec.scala | 1 + .../me/sgrouples/rogue/cc/ObjectIdSubtypeSpec.scala | 1 + .../me/sgrouples/rogue/cc/QueryFieldHelperSpec.scala | 1 + .../scala/me/sgrouples/rogue/cc/RCcMetaExtSpec.scala | 1 + .../scala/me/sgrouples/rogue/cc/RccMeta212Spec.scala | 1 + cc/src/test/scala/me/sgrouples/rogue/cc/TestModels.scala | 1 + .../me/sgrouples/rogue/cc/macros/BinArrayTest.scala | 1 + .../test/scala/me/sgrouples/rogue/cc/macros/Metas.scala | 1 + .../rogue/macrotests/MacroComplexCaseClassSpec.scala | 1 + .../sgrouples/rogue/macrotests/MacroMapFormatSpec.scala | 1 + .../rogue/macrotests/MacroQueryFieldHelperSpec.scala | 1 + .../me/sgrouples/rogue/naming/NamingStrategySpec.scala | 1 + 22 files changed, 26 insertions(+), 4 deletions(-) diff --git a/bsonmacros/src/main/scala/me/sgrouples/rogue/cc/macros/MacroBsonFormatDeriving.scala b/bsonmacros/src/main/scala/me/sgrouples/rogue/cc/macros/MacroBsonFormatDeriving.scala index 221b530..70b3b25 100644 --- a/bsonmacros/src/main/scala/me/sgrouples/rogue/cc/macros/MacroBsonFormatDeriving.scala +++ b/bsonmacros/src/main/scala/me/sgrouples/rogue/cc/macros/MacroBsonFormatDeriving.scala @@ -3,10 +3,11 @@ import scala.deriving.* import scala.annotation.experimental trait MacroBsonFormatDeriving: - transparent implicit inline def derivedAuto[A]: MacroBsonFormat[A] = ${ - MacroBsonFormatDerivingImpl.genAuto[A] - } - transparent inline def derived[A]: MacroBsonFormat[A] = ${ MacroBsonFormatDerivingImpl.gen[A] } + +object MacroBsonFormatAuto: + transparent implicit inline def derivedAuto[A]: MacroBsonFormat[A] = ${ + MacroBsonFormatDerivingImpl.genAuto[A] + } diff --git a/bsonmacros/src/test/scala/me/sgrouples/MacroDerivationTests.scala b/bsonmacros/src/test/scala/me/sgrouples/MacroDerivationTests.scala index bc5f1f8..321aacd 100644 --- a/bsonmacros/src/test/scala/me/sgrouples/MacroDerivationTests.scala +++ b/bsonmacros/src/test/scala/me/sgrouples/MacroDerivationTests.scala @@ -3,6 +3,7 @@ package me.sgrouples import munit.FunSuite import me.sgrouples.rogue.cc.macros.MacroBsonFormat import me.sgrouples.rogue.cc.macros.MacroBsonFormat.* +import me.sgrouples.rogue.cc.macros.MacroBsonFormatAuto.* import org.bson.types.ObjectId import java.time.LocalDateTime import java.time.temporal.ChronoUnit diff --git a/cc/src/test/scala/me/sgrouples/rogue/AsyncBatchSpec.scala b/cc/src/test/scala/me/sgrouples/rogue/AsyncBatchSpec.scala index fef8204..92333e4 100644 --- a/cc/src/test/scala/me/sgrouples/rogue/AsyncBatchSpec.scala +++ b/cc/src/test/scala/me/sgrouples/rogue/AsyncBatchSpec.scala @@ -3,6 +3,7 @@ package me.sgrouples.rogue import java.util.concurrent.atomic.AtomicInteger import me.sgrouples.rogue.cc.MongoTestConn import me.sgrouples.rogue.cc.macros._ +import me.sgrouples.rogue.cc.macros.MacroBsonFormatAuto.* import me.sgrouples.rogue.cc.CcRogue._ import munit.FunSuite diff --git a/cc/src/test/scala/me/sgrouples/rogue/BsonFormatsTests.scala b/cc/src/test/scala/me/sgrouples/rogue/BsonFormatsTests.scala index fb4aa50..8cf247c 100644 --- a/cc/src/test/scala/me/sgrouples/rogue/BsonFormatsTests.scala +++ b/cc/src/test/scala/me/sgrouples/rogue/BsonFormatsTests.scala @@ -1,5 +1,6 @@ package me.sgrouples.rogue import me.sgrouples.rogue.cc.macros.* +import me.sgrouples.rogue.cc.macros.MacroBsonFormatAuto.* import me.sgrouples.rogue.cc.* import org.bson.BsonDocument import org.bson.types.ObjectId diff --git a/cc/src/test/scala/me/sgrouples/rogue/cc/ArrayListTests.scala b/cc/src/test/scala/me/sgrouples/rogue/cc/ArrayListTests.scala index cf078e5..f19aa1b 100644 --- a/cc/src/test/scala/me/sgrouples/rogue/cc/ArrayListTests.scala +++ b/cc/src/test/scala/me/sgrouples/rogue/cc/ArrayListTests.scala @@ -3,6 +3,7 @@ package me.sgrouples.rogue.cc import munit.FunSuite import org.mongodb.scala.MongoDatabase import me.sgrouples.rogue.cc.macros._ +import me.sgrouples.rogue.cc.macros.MacroBsonFormatAuto.* import me.sgrouples.rogue.cc.CcRogue._ import scala.concurrent.Future diff --git a/cc/src/test/scala/me/sgrouples/rogue/cc/CCListArrayTest.scala b/cc/src/test/scala/me/sgrouples/rogue/cc/CCListArrayTest.scala index 8ed2f57..887bd0c 100644 --- a/cc/src/test/scala/me/sgrouples/rogue/cc/CCListArrayTest.scala +++ b/cc/src/test/scala/me/sgrouples/rogue/cc/CCListArrayTest.scala @@ -3,6 +3,7 @@ package me.sgrouples.rogue.cc import me.sgrouples.rogue.* import me.sgrouples.rogue.cc.CcRogue.{given, *} import me.sgrouples.rogue.cc.macros.* +import me.sgrouples.rogue.cc.macros.MacroBsonFormatAuto.* import org.bson.types.ObjectId import munit.FunSuite import me.sgrouples.rogue.QueryParser.* diff --git a/cc/src/test/scala/me/sgrouples/rogue/cc/CcMetaSpec.scala b/cc/src/test/scala/me/sgrouples/rogue/cc/CcMetaSpec.scala index 88772bd..055dc5f 100644 --- a/cc/src/test/scala/me/sgrouples/rogue/cc/CcMetaSpec.scala +++ b/cc/src/test/scala/me/sgrouples/rogue/cc/CcMetaSpec.scala @@ -3,6 +3,7 @@ package me.sgrouples.rogue.cc import org.bson.types.ObjectId import munit.FunSuite import me.sgrouples.rogue.cc.macros.* +import me.sgrouples.rogue.cc.macros.MacroBsonFormatAuto.* import com.softwaremill.tagging.* case class IdOneEnum(_id: ObjectId, one: String, en: VenueStatus.Value) diff --git a/cc/src/test/scala/me/sgrouples/rogue/cc/ComplexCaseClassSpec.scala b/cc/src/test/scala/me/sgrouples/rogue/cc/ComplexCaseClassSpec.scala index 61d95d0..9774ff3 100644 --- a/cc/src/test/scala/me/sgrouples/rogue/cc/ComplexCaseClassSpec.scala +++ b/cc/src/test/scala/me/sgrouples/rogue/cc/ComplexCaseClassSpec.scala @@ -6,6 +6,7 @@ import java.time.temporal.{ChronoUnit} import org.bson.types.ObjectId import munit.FunSuite import me.sgrouples.rogue.cc.macros.* +import me.sgrouples.rogue.cc.macros.MacroBsonFormatAuto.* import com.softwaremill.tagging.* trait User diff --git a/cc/src/test/scala/me/sgrouples/rogue/cc/EnumIdFieldSpec.scala b/cc/src/test/scala/me/sgrouples/rogue/cc/EnumIdFieldSpec.scala index 1284c14..907d33a 100644 --- a/cc/src/test/scala/me/sgrouples/rogue/cc/EnumIdFieldSpec.scala +++ b/cc/src/test/scala/me/sgrouples/rogue/cc/EnumIdFieldSpec.scala @@ -4,6 +4,7 @@ import munit.FunSuite import CcRogue._ import me.sgrouples.rogue.cc.macros.* import me.sgrouples.rogue.cc.CcRogue.* +import me.sgrouples.rogue.cc.macros.MacroBsonFormatAuto.* object EnumIdFieldEnum extends Enumeration { val one: Value = Value diff --git a/cc/src/test/scala/me/sgrouples/rogue/cc/ListFieldCaseSpec.scala b/cc/src/test/scala/me/sgrouples/rogue/cc/ListFieldCaseSpec.scala index 52d9efe..7ddaabe 100644 --- a/cc/src/test/scala/me/sgrouples/rogue/cc/ListFieldCaseSpec.scala +++ b/cc/src/test/scala/me/sgrouples/rogue/cc/ListFieldCaseSpec.scala @@ -4,6 +4,7 @@ import org.bson.types.ObjectId import munit.FunSuite import me.sgrouples.rogue.cc.CcRogue.* import me.sgrouples.rogue.cc.macros.* +import me.sgrouples.rogue.cc.macros.MacroBsonFormatAuto.* import scala.concurrent.ExecutionContext.Implicits.global case class Cont(_id: ObjectId, lst: Seq[ObjectId]) diff --git a/cc/src/test/scala/me/sgrouples/rogue/cc/MapFormatSpec.scala b/cc/src/test/scala/me/sgrouples/rogue/cc/MapFormatSpec.scala index 05f55f1..d5bb2f6 100644 --- a/cc/src/test/scala/me/sgrouples/rogue/cc/MapFormatSpec.scala +++ b/cc/src/test/scala/me/sgrouples/rogue/cc/MapFormatSpec.scala @@ -2,6 +2,7 @@ package me.sgrouples.rogue.cc import munit.FunSuite import me.sgrouples.rogue.cc.macros.* +import me.sgrouples.rogue.cc.macros.MacroBsonFormatAuto.* import me.sgrouples.rogue.map.MapKeyFormat import org.bson.types.ObjectId import com.softwaremill.tagging.* diff --git a/cc/src/test/scala/me/sgrouples/rogue/cc/ObjectIdSubtypeSpec.scala b/cc/src/test/scala/me/sgrouples/rogue/cc/ObjectIdSubtypeSpec.scala index 5bd6df8..e5c437e 100644 --- a/cc/src/test/scala/me/sgrouples/rogue/cc/ObjectIdSubtypeSpec.scala +++ b/cc/src/test/scala/me/sgrouples/rogue/cc/ObjectIdSubtypeSpec.scala @@ -4,6 +4,7 @@ import java.util.UUID import io.fsq.rogue._ import me.sgrouples.rogue.cc.macros.* +import me.sgrouples.rogue.cc.macros.MacroBsonFormatAuto.* import me.sgrouples.rogue.cc import org.bson.types.ObjectId import munit.FunSuite diff --git a/cc/src/test/scala/me/sgrouples/rogue/cc/QueryFieldHelperSpec.scala b/cc/src/test/scala/me/sgrouples/rogue/cc/QueryFieldHelperSpec.scala index 3d3cce7..4ebe5c2 100644 --- a/cc/src/test/scala/me/sgrouples/rogue/cc/QueryFieldHelperSpec.scala +++ b/cc/src/test/scala/me/sgrouples/rogue/cc/QueryFieldHelperSpec.scala @@ -3,6 +3,7 @@ package me.sgrouples.rogue.cc import org.bson.types.ObjectId import me.sgrouples.rogue._ import me.sgrouples.rogue.cc.macros.* +import me.sgrouples.rogue.cc.macros.MacroBsonFormatAuto.* import me.sgrouples.rogue.cc.Metas.VenueRMeta import me.sgrouples.rogue.cc.CcRogue.* import munit.FunSuite diff --git a/cc/src/test/scala/me/sgrouples/rogue/cc/RCcMetaExtSpec.scala b/cc/src/test/scala/me/sgrouples/rogue/cc/RCcMetaExtSpec.scala index 5b97892..2c64466 100644 --- a/cc/src/test/scala/me/sgrouples/rogue/cc/RCcMetaExtSpec.scala +++ b/cc/src/test/scala/me/sgrouples/rogue/cc/RCcMetaExtSpec.scala @@ -2,6 +2,7 @@ package me.sgrouples.rogue.cc import munit.FunSuite import me.sgrouples.rogue.cc.macros.* +import me.sgrouples.rogue.cc.macros.MacroBsonFormatAuto.* import com.softwaremill.tagging.* import org.bson.types.ObjectId import java.util.UUID diff --git a/cc/src/test/scala/me/sgrouples/rogue/cc/RccMeta212Spec.scala b/cc/src/test/scala/me/sgrouples/rogue/cc/RccMeta212Spec.scala index d4eeae8..1add343 100644 --- a/cc/src/test/scala/me/sgrouples/rogue/cc/RccMeta212Spec.scala +++ b/cc/src/test/scala/me/sgrouples/rogue/cc/RccMeta212Spec.scala @@ -3,6 +3,7 @@ package me.sgrouples.rogue.cc import java.time.Instant import me.sgrouples.rogue.cc.macros.* +import me.sgrouples.rogue.cc.macros.MacroBsonFormatAuto.* import org.bson.types.ObjectId import munit.FunSuite trait QueryById[M] { diff --git a/cc/src/test/scala/me/sgrouples/rogue/cc/TestModels.scala b/cc/src/test/scala/me/sgrouples/rogue/cc/TestModels.scala index 558b707..aa4d08c 100644 --- a/cc/src/test/scala/me/sgrouples/rogue/cc/TestModels.scala +++ b/cc/src/test/scala/me/sgrouples/rogue/cc/TestModels.scala @@ -1,6 +1,7 @@ package me.sgrouples.rogue.cc import io.fsq.rogue.index.{Asc, Desc, IndexBuilder, Text} import me.sgrouples.rogue.cc.macros.* +import me.sgrouples.rogue.cc.macros.MacroBsonFormatAuto.* import me.sgrouples.rogue.* import me.sgrouples.rogue.naming.PluralLowerCase import org.bson.types.ObjectId diff --git a/cc/src/test/scala/me/sgrouples/rogue/cc/macros/BinArrayTest.scala b/cc/src/test/scala/me/sgrouples/rogue/cc/macros/BinArrayTest.scala index 330b3f8..29b6a1d 100644 --- a/cc/src/test/scala/me/sgrouples/rogue/cc/macros/BinArrayTest.scala +++ b/cc/src/test/scala/me/sgrouples/rogue/cc/macros/BinArrayTest.scala @@ -1,6 +1,7 @@ package me.sgrouples.rogue.cc.macros import munit.FunSuite import me.sgrouples.rogue.cc.* +import me.sgrouples.rogue.cc.macros.MacroBsonFormatAuto.* case class CArrays(bytes: Array[Byte], strings:Array[String]) diff --git a/cc/src/test/scala/me/sgrouples/rogue/cc/macros/Metas.scala b/cc/src/test/scala/me/sgrouples/rogue/cc/macros/Metas.scala index 23a8649..cd3b16b 100644 --- a/cc/src/test/scala/me/sgrouples/rogue/cc/macros/Metas.scala +++ b/cc/src/test/scala/me/sgrouples/rogue/cc/macros/Metas.scala @@ -7,6 +7,7 @@ import me.sgrouples.rogue.cc.CcRogue.{given, *} import me.sgrouples.rogue.naming.PluralLowerCase import org.bson.types.ObjectId import com.softwaremill.tagging.* +import me.sgrouples.rogue.cc.macros.MacroBsonFormatAuto.* import java.time.Instant import java.util.{Currency, Locale, UUID} diff --git a/cc/src/test/scala/me/sgrouples/rogue/macrotests/MacroComplexCaseClassSpec.scala b/cc/src/test/scala/me/sgrouples/rogue/macrotests/MacroComplexCaseClassSpec.scala index 621f7ea..d51e836 100644 --- a/cc/src/test/scala/me/sgrouples/rogue/macrotests/MacroComplexCaseClassSpec.scala +++ b/cc/src/test/scala/me/sgrouples/rogue/macrotests/MacroComplexCaseClassSpec.scala @@ -5,6 +5,7 @@ import java.time.temporal.ChronoUnit import me.sgrouples.rogue.cc._ import me.sgrouples.rogue.cc.macros._ +import me.sgrouples.rogue.cc.macros.MacroBsonFormatAuto.* import org.bson.types.ObjectId import munit.FunSuite import com.softwaremill.tagging.* diff --git a/cc/src/test/scala/me/sgrouples/rogue/macrotests/MacroMapFormatSpec.scala b/cc/src/test/scala/me/sgrouples/rogue/macrotests/MacroMapFormatSpec.scala index 8de0986..8ee8acc 100644 --- a/cc/src/test/scala/me/sgrouples/rogue/macrotests/MacroMapFormatSpec.scala +++ b/cc/src/test/scala/me/sgrouples/rogue/macrotests/MacroMapFormatSpec.scala @@ -2,6 +2,7 @@ package me.sgrouples.rogue.macrotests import me.sgrouples.rogue.cc.CustomKey import me.sgrouples.rogue.cc.macros._ +import me.sgrouples.rogue.cc.macros.MacroBsonFormatAuto.* import me.sgrouples.rogue.macrotests.Domain.StrLongMapT import org.bson.types.ObjectId import com.softwaremill.tagging.* diff --git a/cc/src/test/scala/me/sgrouples/rogue/macrotests/MacroQueryFieldHelperSpec.scala b/cc/src/test/scala/me/sgrouples/rogue/macrotests/MacroQueryFieldHelperSpec.scala index dfc0d73..7b5d3c5 100644 --- a/cc/src/test/scala/me/sgrouples/rogue/macrotests/MacroQueryFieldHelperSpec.scala +++ b/cc/src/test/scala/me/sgrouples/rogue/macrotests/MacroQueryFieldHelperSpec.scala @@ -2,6 +2,7 @@ package me.sgrouples.rogue.macrotests import me.sgrouples.rogue.cc.{QueryFieldHelpers, TestDomainObject} import me.sgrouples.rogue.cc.macros._ +import me.sgrouples.rogue.cc.macros.MacroBsonFormatAuto.* import munit.FunSuite import scala.concurrent.Future import scala.util.Try diff --git a/cc/src/test/scala/me/sgrouples/rogue/naming/NamingStrategySpec.scala b/cc/src/test/scala/me/sgrouples/rogue/naming/NamingStrategySpec.scala index 76c6ea4..b7089ff 100644 --- a/cc/src/test/scala/me/sgrouples/rogue/naming/NamingStrategySpec.scala +++ b/cc/src/test/scala/me/sgrouples/rogue/naming/NamingStrategySpec.scala @@ -1,6 +1,7 @@ package me.sgrouples.rogue.naming import me.sgrouples.rogue.cc.macros._ +import me.sgrouples.rogue.cc.macros.MacroBsonFormatAuto.* import munit.FunSuite /** Created by mwielocha on 09/08/16.