From d3bbeb59e0c3f564d9b1507a33708af11edeee54 Mon Sep 17 00:00:00 2001 From: jules Ivanic Date: Thu, 28 Sep 2023 19:59:10 +0400 Subject: [PATCH 1/2] More Scalafix --- .../alpakka/CaseClassQueryCassandraSpec.scala | 4 +- .../alpakka/CassandraContextSpec.scala | 6 +- .../cassandra/alpakka/DecodeNullSpec.scala | 2 +- .../cassandra/alpakka/EncodingSpec.scala | 12 +- .../cassandra/alpakka/ListsEncodingSpec.scala | 19 +- .../cassandra/alpakka/MapsEncodingSpec.scala | 19 +- .../alpakka/PeopleCassandraSpec.scala | 8 +- .../QueryResultTypeCassandraAsyncSpec.scala | 2 +- .../cassandra/alpakka/SetsEncodingSpec.scala | 13 +- .../udt/UdtEncodingSessionContextSpec.scala | 10 +- .../cassandra/monix/DecodeNullSpec.scala | 3 +- .../QueryResultTypeCassandraMonixSpec.scala | 6 +- .../context/cassandra/monix/package.scala | 2 +- .../cassandra/streaming/DecodeNullSpec.scala | 3 +- .../QueryResultTypeCassandraStreamSpec.scala | 4 +- .../context/cassandra/streaming/package.scala | 2 +- .../io/getquill/cassandrazio/Quill.scala | 2 +- .../CaseClassQueryCassandraSpec.scala | 4 +- .../cassandra/CassandraContextMacroSpec.scala | 4 +- .../cassandra/CassandraContextSpec.scala | 9 +- .../cassandra/CassandraTestEntities.scala | 7 +- .../context/cassandra/CollectionsSpec.scala | 8 +- .../context/cassandra/CqlIdiomSpec.scala | 20 +- .../context/cassandra/CqlQuerySpec.scala | 4 +- .../context/cassandra/DecodeNullSpec.scala | 3 +- .../context/cassandra/EncodingSpec.scala | 12 +- .../cassandra/EncodingSpecHelper.scala | 4 +- .../context/cassandra/ListsEncodingSpec.scala | 23 +-- .../context/cassandra/MapsEncodingSpec.scala | 18 +- .../cassandra/PeopleCassandraSpec.scala | 4 +- .../QueryResultTypeCassandraAsyncSpec.scala | 2 +- .../QueryResultTypeCassandraSpec.scala | 23 +-- .../QueryResultTypeCassandraSyncSpec.scala | 2 +- .../context/cassandra/SetsEncodingSpec.scala | 16 +- .../cluster/SessionBuilderSpec.scala | 2 +- .../cassandra/norm/RenamePropertiesSpec.scala | 4 +- .../cassandra/ops/CassandraOpsSpec.scala | 1 - .../getquill/context/cassandra/package.scala | 8 +- .../udt/UdtEncodingMirrorContextSpec.scala | 4 +- .../udt/UdtEncodingSessionContextSpec.scala | 18 +- .../scala/io/getquill/codegen/DagTest.scala | 4 +- .../getquill/codegen/SimpleCodegenSpec.scala | 12 +- .../io/getquill/codegen/StructuralTests.scala | 32 ++-- .../codegen/WithStandardCodegen.scala | 2 +- .../integration/CodegenTestCaseRunner.scala | 3 +- .../integration/CodegenTestCases.scala | 24 +-- .../codegen/integration/DbHelper.scala | 2 +- .../getquill/codegen/util/ConfigPrefix.scala | 2 +- .../io/getquill/codegen/util/OptionOps.scala | 2 +- .../getquill/codegen/util/SchemaMaker.scala | 4 +- .../io/getquill/codegen/util/StringUtil.scala | 2 +- .../scala/io/getquill/monad/IOMonad.scala | 6 +- .../io/getquill/AsyncMirrorContextSpec.scala | 2 +- .../scala/io/getquill/MirrorContextSpec.scala | 2 +- .../src/test/scala/io/getquill/OpsSpec.scala | 24 +-- .../OptionalProductEncodingSpec.scala | 20 +- .../scala/io/getquill/QueryProbingSpec.scala | 2 +- .../test/scala/io/getquill/TestEntities.scala | 34 ++-- .../UnlimitedOptionalEmbeddedSpec.scala | 4 +- .../src/test/scala/io/getquill/VIdent.scala | 2 +- .../scala/io/getquill/ast/AstOpsSpec.scala | 2 +- .../ast/StatefulTransformerSpec.scala | 146 +++++++------- .../ast/StatelessTransformerSpec.scala | 22 +-- .../scala/io/getquill/base/EncodingSpec.scala | 10 +- .../test/scala/io/getquill/base/Spec.scala | 17 +- .../io/getquill/context/ActionMacroSpec.scala | 10 +- .../io/getquill/context/BindMacroSpec.scala | 2 +- .../context/ContextInstanceSpec.scala | 14 +- .../getquill/context/ContextMacroSpec.scala | 14 +- .../context/EncodeBindVariablesSpec.scala | 12 +- .../io/getquill/context/QueryMacroSpec.scala | 2 +- .../context/mirror/MirrorIdiomSpec.scala | 12 +- .../io/getquill/dsl/EncodingDslSpec.scala | 8 +- .../scala/io/getquill/dsl/MetaDslSpec.scala | 69 ++++--- .../scala/io/getquill/monad/IOMonadSpec.scala | 2 +- .../monad/ScalaFutureIOMonadSpec.scala | 2 +- .../io/getquill/monad/SyncIOMonadSpec.scala | 2 +- .../io/getquill/norm/AdHocReductionSpec.scala | 16 +- .../io/getquill/norm/AttachToEntitySpec.scala | 58 +++--- .../io/getquill/norm/BetaReductionSpec.scala | 2 +- .../getquill/norm/ExpandReturningSpec.scala | 4 +- .../norm/FlattenOptionOperationSpec.scala | 14 +- .../getquill/norm/NormalizeCachingSpec.scala | 3 +- .../norm/NormalizeNestedStructuresSpec.scala | 63 +++--- .../norm/NormalizeReturningSpec.scala | 6 +- .../io/getquill/norm/NormalizeSpec.scala | 4 +- .../io/getquill/norm/OrderTermsSpec.scala | 8 +- .../io/getquill/norm/QueryGenerator.scala | 10 +- .../norm/SimplifyNullChecksSpec.scala | 8 +- .../getquill/norm/SymbolicReductionSpec.scala | 23 +-- .../AvoidAliasConflictComplexSpec.scala | 7 +- .../norm/capture/AvoidAliasConflictSpec.scala | 66 +++---- .../norm/capture/AvoidCaptureSpec.scala | 6 +- .../getquill/norm/capture/DealiasSpec.scala | 4 +- .../scala/io/getquill/quat/QuatSpec.scala | 31 ++- .../CompatibleDynamicQuerySpec.scala | 30 +-- .../getquill/quotation/DynamicQuerySpec.scala | 32 ++-- .../quotation/FreeVariablesSpec.scala | 12 +- .../io/getquill/quotation/QuotationSpec.scala | 180 +++++++++--------- .../io/getquill/quotation/RebindSpec.scala | 2 +- .../scala/io/getquill/util/CacheSpec.scala | 2 +- .../io/getquill/util/InterpolatorSpec.scala | 6 +- .../doobie/PeopleZioReturningSpec.scala | 5 +- .../doobie/PostgresDoobieContextSuite.scala | 4 +- .../io/getquill/doobie/issue/Issue1067.scala | 3 +- .../jasync/mysql/MysqlJAsyncContextSpec.scala | 8 +- .../mysql/MysqlJAsyncEncodingSpec.scala | 26 +-- .../jasync/mysql/ProductMysqlJAsyncSpec.scala | 6 +- .../QueryResultTypeMysqlJAsyncSpec.scala | 2 +- .../postgres/ArrayAsyncEncodingSpec.scala | 8 +- .../postgres/OptionalNestedAsyncSpec.scala | 2 +- .../postgres/PostgresAsyncEncodingSpec.scala | 16 +- .../postgres/PostgresJAsyncContextSpec.scala | 8 +- .../postgres/ProductPostgresAsyncSpec.scala | 6 +- .../QueryResultTypePostgresAsyncSpec.scala | 2 +- .../postgres/ArrayAsyncEncodingSpec.scala | 8 +- .../postgres/CaseClassQueryAsyncSpec.scala | 2 +- .../postgres/PostgresAsyncEncodingSpec.scala | 17 +- .../postgres/PostgresJAsyncContextSpec.scala | 4 +- .../postgres/ProductPostgresAsyncSpec.scala | 6 +- .../QueryResultTypePostgresAsyncSpec.scala | 2 +- .../qzio/jasync/postgres/ZioSpec.scala | 6 +- .../TransactionalExecutionContextSpec.scala | 2 +- .../test/scala/io/getquill/MonixSpec.scala | 7 +- .../scala/io/getquill/PeopleMonixSpec.scala | 4 +- .../getquill/PrepareMonixJdbcSpecBase.scala | 12 +- .../io/getquill/ResultSetIteratorSpec.scala | 11 +- .../test/scala/io/getquill/RunnerSpec.scala | 4 +- .../io/getquill/h2/MonixJdbcContextSpec.scala | 2 +- .../io/getquill/h2/ProductJdbcSpec.scala | 2 +- .../src/test/scala/io/getquill/h2/h2.scala | 2 +- .../StreamResultsOrBlowUpSpec.scala | 2 +- .../io/getquill/mock/Introspection.scala | 10 +- .../scala/io/getquill/mock/MockTests.scala | 17 +- .../getquill/mysql/MonixJdbcContextSpec.scala | 2 +- .../io/getquill/mysql/ProductJdbcSpec.scala | 2 +- .../test/scala/io/getquill/mysql/mysql.scala | 2 +- .../oracle/MonixJdbcContextSpec.scala | 2 +- .../io/getquill/oracle/ProductJdbcSpec.scala | 2 +- .../scala/io/getquill/oracle/oracle.scala | 2 +- .../postgres/ConnectionLeakTest.scala | 5 +- .../postgres/MonixJdbcContextSpec.scala | 2 +- .../getquill/postgres/ProductJdbcSpec.scala | 2 +- .../scala/io/getquill/postgres/package.scala | 2 +- .../sqlite/MonixJdbcContextSpec.scala | 2 +- .../io/getquill/sqlite/ProductJdbcSpec.scala | 2 +- .../scala/io/getquill/sqlite/sqlite.scala | 2 +- .../sqlserver/MonixJdbcContextSpec.scala | 2 +- .../getquill/sqlserver/ProductJdbcSpec.scala | 2 +- .../io/getquill/sqlserver/sqlserver.scala | 2 +- .../examples/IdiomaticAppWithEncoders.scala | 27 +-- .../getquill/postgres/PostgresJsonSpec.scala | 10 +- .../io/getquill/PrepareZioJdbcSpecBase.scala | 12 +- .../io/getquill/ResultSetIteratorSpec.scala | 10 +- .../src/test/scala/io/getquill/ZioSpec.scala | 10 +- .../io/getquill/examples/IdiomaticApp.scala | 25 +-- .../getquill/examples/IdiomaticAppPlain.scala | 14 +- .../io/getquill/examples/other/PlainApp.scala | 6 +- .../examples/other/PlainAppDataSource.scala | 8 +- .../examples/other/PlainAppDataSource2.scala | 2 +- .../examples/other/ServiceExample.scala | 7 +- .../io/getquill/examples/other/ZioApp.scala | 8 +- .../examples/other/ZioAppDataSource.scala | 8 +- .../examples/other/ZioAppExample.scala | 15 +- .../examples/other/ZioAppImplicitEnv.scala | 19 +- .../examples/other/ZioAppManual.scala | 5 +- .../io/getquill/h2/PrepareJdbcSpec.scala | 9 +- .../io/getquill/h2/ProductJdbcSpec.scala | 2 +- .../io/getquill/h2/ZioJdbcContextSpec.scala | 2 +- .../src/test/scala/io/getquill/h2/h2.scala | 3 +- .../StreamResultsOrBlowUpSpec.scala | 9 +- .../misc/ImplicitEnvPatternSpec.scala | 2 +- .../io/getquill/misc/OnDataSourceSpec.scala | 4 +- .../misc/ZioJdbcUnderlyingContextSpec.scala | 2 +- .../test/scala/io/getquill/misc/package.scala | 3 +- .../io/getquill/mock/Introspection.scala | 10 +- .../scala/io/getquill/mock/ZioMockSpec.scala | 10 +- .../io/getquill/mysql/ProductJdbcSpec.scala | 2 +- .../getquill/mysql/ZioJdbcContextSpec.scala | 2 +- .../test/scala/io/getquill/mysql/mysql.scala | 3 +- .../io/getquill/oracle/ProductJdbcSpec.scala | 2 +- .../scala/io/getquill/oracle/oracle.scala | 3 +- .../postgres/ConnectionLeakTest.scala | 9 +- .../postgres/MultiLevelServiceSpec.scala | 24 +-- .../getquill/postgres/ProductJdbcSpec.scala | 2 +- .../getquill/postgres/QuillServiceSpec.scala | 2 +- .../postgres/ZioJdbcContextSpec.scala | 2 +- .../scala/io/getquill/postgres/package.scala | 3 +- .../io/getquill/sqlite/PrepareJdbcSpec.scala | 9 +- .../io/getquill/sqlite/ProductJdbcSpec.scala | 2 +- .../getquill/sqlite/ZioJdbcContextSpec.scala | 2 +- .../scala/io/getquill/sqlite/sqlite.scala | 3 +- .../getquill/sqlserver/ProductJdbcSpec.scala | 2 +- .../sqlserver/ZioJdbcContextSpec.scala | 2 +- .../io/getquill/sqlserver/sqlserver.scala | 3 +- .../context/jdbc/PrepareJdbcSpecBase.scala | 13 +- .../jdbc/h2/CaseClassQueryJdbcSpec.scala | 2 +- .../context/jdbc/h2/DepartmentsJdbcSpec.scala | 2 +- .../context/jdbc/h2/DistinctJdbcSpec.scala | 2 +- .../context/jdbc/h2/JdbcContextSpec.scala | 2 +- .../context/jdbc/h2/OptionJdbcSpec.scala | 2 +- .../context/jdbc/h2/PeopleJdbcSpec.scala | 2 +- .../context/jdbc/h2/ProductJdbcSpec.scala | 4 +- .../jdbc/mysql/CaseClassQueryJdbcSpec.scala | 2 +- .../jdbc/mysql/DepartmentsJdbcSpec.scala | 2 +- .../context/jdbc/mysql/DistinctJdbcSpec.scala | 2 +- .../context/jdbc/mysql/JdbcContextSpec.scala | 4 +- .../context/jdbc/mysql/OptionJdbcSpec.scala | 2 +- .../context/jdbc/mysql/PeopleJdbcSpec.scala | 2 +- .../context/jdbc/mysql/ProductJdbcSpec.scala | 4 +- .../jdbc/mysql/QueryResultTypeJdbcSpec.scala | 2 +- .../jdbc/oracle/CaseClassQueryJdbcSpec.scala | 2 +- .../jdbc/oracle/DepartmentsJdbcSpec.scala | 2 +- .../jdbc/oracle/DistinctJdbcSpec.scala | 2 +- .../context/jdbc/oracle/JdbcContextSpec.scala | 6 +- .../jdbc/oracle/JdbcEncodingSpec.scala | 8 +- .../context/jdbc/oracle/OptionJdbcSpec.scala | 2 +- .../context/jdbc/oracle/PeopleJdbcSpec.scala | 2 +- .../context/jdbc/oracle/ProductJdbcSpec.scala | 4 +- .../jdbc/oracle/QueryResultTypeJdbcSpec.scala | 4 +- .../jdbc/postgres/ArrayJdbcEncodingSpec.scala | 19 +- .../jdbc/postgres/BatchUpdateJdbcSpec.scala | 2 - .../postgres/CaseClassQueryJdbcSpec.scala | 2 +- .../jdbc/postgres/DepartmentsJdbcSpec.scala | 2 +- .../jdbc/postgres/DistinctJdbcSpec.scala | 3 +- .../jdbc/postgres/JdbcContextSpec.scala | 12 +- .../jdbc/postgres/JdbcEncodingSpec.scala | 2 +- .../jdbc/postgres/OnConflictJdbcSpec.scala | 2 +- .../jdbc/postgres/OptionJdbcSpec.scala | 2 +- .../postgres/OptionalNestedJdbcSpec.scala | 2 +- .../postgres/PeopleJdbcAggregationSpec.scala | 2 +- .../jdbc/postgres/PeopleJdbcSpec.scala | 2 +- .../jdbc/postgres/ProductJdbcSpec.scala | 6 +- .../jdbc/sqlite/BatchValuesJdbcSpec.scala | 1 - .../jdbc/sqlite/CaseClassQueryJdbcSpec.scala | 2 +- .../jdbc/sqlite/DepartmentsJdbcSpec.scala | 2 +- .../jdbc/sqlite/DistinctJdbcSpec.scala | 2 +- .../context/jdbc/sqlite/JdbcContextSpec.scala | 2 +- .../context/jdbc/sqlite/OptionJdbcSpec.scala | 2 +- .../context/jdbc/sqlite/PeopleJdbcSpec.scala | 2 +- .../context/jdbc/sqlite/ProductJdbcSpec.scala | 4 +- .../jdbc/sqlserver/BatchValuesJdbcSpec.scala | 2 +- .../jdbc/sqlserver/DepartmentsJdbcSpec.scala | 2 +- .../jdbc/sqlserver/DistinctJdbcSpec.scala | 2 +- .../jdbc/sqlserver/JdbcContextSpec.scala | 10 +- .../jdbc/sqlserver/OptionJdbcSpec.scala | 2 +- .../jdbc/sqlserver/PeopleJdbcSpec.scala | 2 +- .../jdbc/sqlserver/ProductJdbcSpec.scala | 4 +- .../orientdb/CaseClassQueryOrientSpec.scala | 4 +- .../context/orientdb/DecodeNullSpec.scala | 2 +- .../context/orientdb/EncodingSpec.scala | 10 +- .../context/orientdb/ListsEncodingSpec.scala | 10 +- .../context/orientdb/MapsEncodingSpec.scala | 6 +- .../orientdb/OrientDBContextMacroSpec.scala | 2 +- .../orientdb/OrientDBContextSpec.scala | 12 +- .../context/orientdb/OrientDBIdiomSpec.scala | 12 +- .../context/orientdb/OrientDBQuerySpec.scala | 20 +- .../QueryResultTypeOrientDBSync.scala | 2 +- .../context/orientdb/SetsEncodingSpec.scala | 10 +- .../getquill/context/orientdb/orientdb.scala | 4 +- .../spark/AliasNestedQueryColumnsSpec.scala | 6 +- .../context/spark/CaseClassQuerySpec.scala | 34 ++-- .../context/spark/DepartmentsSparkSpec.scala | 6 +- .../context/spark/EncodingSparkSpec.scala | 12 +- .../context/spark/MiscQueriesSpec.scala | 8 +- .../context/spark/PeopleSparkSpec.scala | 10 +- .../context/spark/QuestionMarkSpec.scala | 4 +- .../context/spark/QuillSparkContextSpec.scala | 2 +- .../context/spark/SparkDialectSpec.scala | 6 +- .../context/spark/TypeMemberJoinSpec.scala | 12 +- .../context/spark/VariableShadowSpec.scala | 19 +- .../spark/examples/GitHubExample.scala | 20 +- .../spark/examples/TopHashtagsExample.scala | 15 +- .../spark/norm/ExpandEntityIdsSpec.scala | 45 ++--- .../spark/norm/QuestionMarkEscaperSpec.scala | 16 +- .../io/getquill/context/spark/package.scala | 2 +- .../context/sql/AggregationSpec.scala | 10 +- .../getquill/context/sql/DistinctSpec.scala | 4 +- .../getquill/context/sql/EmbeddedSpec.scala | 26 +-- .../getquill/context/sql/EncodingSpec.scala | 23 ++- .../io/getquill/context/sql/GroupBySpec.scala | 18 +- .../io/getquill/context/sql/InfixSpec.scala | 16 +- .../context/sql/NestedDistinctSpec.scala | 68 +++---- .../context/sql/OptionQuerySpec.scala | 9 +- .../getquill/context/sql/OptionSqlSpec.scala | 4 +- .../io/getquill/context/sql/OrderBySpec.scala | 2 +- .../io/getquill/context/sql/PrepareSpec.scala | 2 +- .../io/getquill/context/sql/ProductSpec.scala | 11 +- .../context/sql/QuerySchemaSpec.scala | 4 +- .../context/sql/SqlActionMacroSpec.scala | 92 ++++----- .../getquill/context/sql/SqlContextSpec.scala | 6 +- .../context/sql/SqlQueryMacroSpec.scala | 2 +- .../getquill/context/sql/SqlQuerySpec.scala | 48 ++--- .../getquill/context/sql/TestDecoders.scala | 4 +- .../getquill/context/sql/TestEncoders.scala | 4 +- .../context/sql/base/ArrayOpsSpec.scala | 7 +- .../sql/base/BatchUpdateValuesSpec.scala | 6 +- .../context/sql/base/BatchValuesSpec.scala | 2 +- .../context/sql/base/CaseClassQuerySpec.scala | 4 +- .../context/sql/base/DepartmentsSpec.scala | 9 +- .../context/sql/base/OnConflictSpec.scala | 13 +- .../sql/base/PeopleAggregationSpec.scala | 4 +- .../sql/base/PeopleReturningSpec.scala | 4 +- .../context/sql/base/PeopleSpec.scala | 7 +- .../sql/base/QueryResultTypeSpec.scala | 47 ++--- .../sql/encoding/ArrayEncodingBaseSpec.scala | 4 +- .../sql/idiom/AbstractMySQLDialectSpec.scala | 5 +- .../sql/idiom/BooleanLiteralSupportSpec.scala | 34 ++-- .../context/sql/idiom/H2DialectSpec.scala | 2 +- .../context/sql/idiom/MySQL5DialectSpec.scala | 3 +- .../context/sql/idiom/MySQLDialectSpec.scala | 3 +- .../idiom/NestedQueryNamingStrategySpec.scala | 1 - .../OffsetWithoutLimitWorkaroundSpec.scala | 2 +- .../context/sql/idiom/OnConflictSpec.scala | 5 +- .../context/sql/idiom/OracleDialectSpec.scala | 22 +-- .../sql/idiom/PostgresDialectSpec.scala | 4 +- .../sql/idiom/SQLServerDialectSpec.scala | 18 +- .../context/sql/idiom/SqlActionSpec.scala | 12 +- .../sql/idiom/SqlIdiomNamingSpec.scala | 4 +- .../sql/idiom/SqlIdiomOptionCompareSpec.scala | 16 +- .../context/sql/idiom/SqlIdiomSpec.scala | 41 ++-- .../context/sql/idiom/SqliteDialectSpec.scala | 4 +- .../sql/idiom/VerifySqlQuerySpec.scala | 2 +- .../sql/mirror/ArrayMirrorEncodingSpec.scala | 3 +- .../sql/mirror/ObservationMirrorSpec.scala | 5 +- .../sql/norm/AddDropToNestedOrderBySpec.scala | 4 +- .../context/sql/norm/ExpandDistinctSpec.scala | 3 +- .../sql/norm/ExpandNestedQueriesSpec.scala | 80 ++++---- .../norm/FlattenGroupByAggregationSpec.scala | 30 +-- .../context/sql/norm/JoinComplexSpec.scala | 2 +- .../norm/RenamePropertiesOverrideSpec.scala | 50 ++--- .../sql/norm/RenamePropertiesSpec.scala | 55 +++--- .../scala/io/getquill/quat/QuatRunSpec.scala | 2 +- 333 files changed, 1710 insertions(+), 1668 deletions(-) diff --git a/quill-cassandra-alpakka/src/test/scala/io/getquill/context/cassandra/alpakka/CaseClassQueryCassandraSpec.scala b/quill-cassandra-alpakka/src/test/scala/io/getquill/context/cassandra/alpakka/CaseClassQueryCassandraSpec.scala index 31a4be24ef..f2977e1357 100644 --- a/quill-cassandra-alpakka/src/test/scala/io/getquill/context/cassandra/alpakka/CaseClassQueryCassandraSpec.scala +++ b/quill-cassandra-alpakka/src/test/scala/io/getquill/context/cassandra/alpakka/CaseClassQueryCassandraSpec.scala @@ -10,7 +10,7 @@ class CaseClassQueryCassandraSpec extends CassandraAlpakkaSpec { val peopleInsert = quote((p: Contact) => query[Contact].insertValue(p)) - val peopleEntries = List( + val peopleEntries: List[Contact] = List( Contact(1, "Alex", "Jones", 60, 2, "foo"), Contact(2, "Bert", "James", 55, 3, "bar"), Contact(3, "Cora", "Jasper", 33, 3, "baz") @@ -19,7 +19,7 @@ class CaseClassQueryCassandraSpec extends CassandraAlpakkaSpec { val addressInsert = quote((c: Address) => query[Address].insertValue(c)) - val addressEntries = List( + val addressEntries: List[Address] = List( Address(1, "123 Fake Street", 11234, "something"), Address(2, "456 Old Street", 45678, "something else"), Address(3, "789 New Street", 89010, "another thing") diff --git a/quill-cassandra-alpakka/src/test/scala/io/getquill/context/cassandra/alpakka/CassandraContextSpec.scala b/quill-cassandra-alpakka/src/test/scala/io/getquill/context/cassandra/alpakka/CassandraContextSpec.scala index 8bfb19f77b..b4c1ded27e 100644 --- a/quill-cassandra-alpakka/src/test/scala/io/getquill/context/cassandra/alpakka/CassandraContextSpec.scala +++ b/quill-cassandra-alpakka/src/test/scala/io/getquill/context/cassandra/alpakka/CassandraContextSpec.scala @@ -8,7 +8,7 @@ import scala.util.Try class CassandraContextSpec extends CassandraAlpakkaSpec { import testDB._ "run non-batched action" in { - case class TestEntity(id: Int, s: String, i: Int, l: Long, o: Int) + final case class TestEntity(id: Int, s: String, i: Int, l: Long, o: Int) val update = quote { query[TestEntity].filter(_.id == lift(1)).update(_.i -> lift(1)) } @@ -17,11 +17,11 @@ class CassandraContextSpec extends CassandraAlpakkaSpec { "fail on returning" in { - val p: Prepare = (x, session) => (Nil, x) + val p: Prepare = (x, _) => (List.empty, x) val e: Extractor[Int] = (_, _) => 1 intercept[IllegalStateException](executeActionReturning("", p, e, "")(ExecutionInfo.unknown, ())).getMessage mustBe - intercept[IllegalStateException](executeBatchActionReturning(Nil, e)(ExecutionInfo.unknown, ())).getMessage + intercept[IllegalStateException](executeBatchActionReturning(List.empty, e)(ExecutionInfo.unknown, ())).getMessage } "return failed future on `prepare` error in async context" - { diff --git a/quill-cassandra-alpakka/src/test/scala/io/getquill/context/cassandra/alpakka/DecodeNullSpec.scala b/quill-cassandra-alpakka/src/test/scala/io/getquill/context/cassandra/alpakka/DecodeNullSpec.scala index 258ef108e2..6f738eb46b 100644 --- a/quill-cassandra-alpakka/src/test/scala/io/getquill/context/cassandra/alpakka/DecodeNullSpec.scala +++ b/quill-cassandra-alpakka/src/test/scala/io/getquill/context/cassandra/alpakka/DecodeNullSpec.scala @@ -26,6 +26,6 @@ class DecodeNullSpec extends CassandraAlpakkaSpec { case class DecodeNullTestWriteEntity(id: Int, value: Option[Int]) - val insertValue = DecodeNullTestWriteEntity(0, None) + val insertValue: DecodeNullTestWriteEntity = DecodeNullTestWriteEntity(0, None) } diff --git a/quill-cassandra-alpakka/src/test/scala/io/getquill/context/cassandra/alpakka/EncodingSpec.scala b/quill-cassandra-alpakka/src/test/scala/io/getquill/context/cassandra/alpakka/EncodingSpec.scala index 19f56415fd..1c8c363e37 100644 --- a/quill-cassandra-alpakka/src/test/scala/io/getquill/context/cassandra/alpakka/EncodingSpec.scala +++ b/quill-cassandra-alpakka/src/test/scala/io/getquill/context/cassandra/alpakka/EncodingSpec.scala @@ -39,18 +39,18 @@ class EncodingSpec extends EncodingSpecHelper with CassandraAlpakkaSpec { "mappedEncoding" in { import testDB._ - case class A() - case class B() - val a1: Encoder[A] = encoder((b, c, d, s) => d) - val a2: Decoder[A] = decoder((b, c, s) => A()) + final case class A() + final case class B() + val a1: Encoder[A] = encoder((_, _, d, _) => d) + val a2: Decoder[A] = decoder((_, _, _) => A()) mappedDecoder(MappedEncoding[A, B](_ => B()), a2).isInstanceOf[CassandraDecoder[B]] mustBe true mappedEncoder(MappedEncoding[B, A](_ => A()), a1).isInstanceOf[CassandraEncoder[B]] mustBe true } "date and timestamps" - { import testDB._ - case class Java8Types(v9: LocalDate, v11: Instant, o9: Option[ZonedDateTime], id: Int = 1, v1: String = "") - case class CasTypes(v9: LocalDate, v11: Instant, o9: Option[ZonedDateTime], id: Int = 1, v1: String = "") + final case class Java8Types(v9: LocalDate, v11: Instant, o9: Option[ZonedDateTime], id: Int = 1, v1: String = "") + final case class CasTypes(v9: LocalDate, v11: Instant, o9: Option[ZonedDateTime], id: Int = 1, v1: String = "") "mirror" in { implicitly[Encoder[LocalDate]] diff --git a/quill-cassandra-alpakka/src/test/scala/io/getquill/context/cassandra/alpakka/ListsEncodingSpec.scala b/quill-cassandra-alpakka/src/test/scala/io/getquill/context/cassandra/alpakka/ListsEncodingSpec.scala index 087fadc4d4..8c3b7b8d0e 100644 --- a/quill-cassandra-alpakka/src/test/scala/io/getquill/context/cassandra/alpakka/ListsEncodingSpec.scala +++ b/quill-cassandra-alpakka/src/test/scala/io/getquill/context/cassandra/alpakka/ListsEncodingSpec.scala @@ -4,6 +4,7 @@ import io.getquill.context.cassandra.CollectionsSpec import java.time.{Instant, LocalDate} import java.util.UUID +import io.getquill.{ EntityQuery, Quoted } class ListsEncodingSpec extends CollectionsSpec with CassandraAlpakkaSpec { val ctx = testDB @@ -25,7 +26,7 @@ class ListsEncodingSpec extends CollectionsSpec with CassandraAlpakkaSpec { uuids: List[UUID] ) - val e = ListsEntity( + val e: ListsEntity = ListsEntity( 1, List("c"), List(BigDecimal(1.33)), @@ -41,7 +42,7 @@ class ListsEncodingSpec extends CollectionsSpec with CassandraAlpakkaSpec { List(UUID.randomUUID()) ) - val q = quote(query[ListsEntity]) + val q: Quoted[EntityQuery[ListsEntity]] = quote(query[ListsEntity]) "List encoders/decoders for CassandraTypes and CassandraMappers" in { await { @@ -55,8 +56,8 @@ class ListsEncodingSpec extends CollectionsSpec with CassandraAlpakkaSpec { } "Empty lists and optional fields" in { - case class Entity(id: Int, texts: Option[List[String]], bools: Option[List[Boolean]], ints: List[Int]) - val e = Entity(1, Some(List("1", "2")), None, Nil) + final case class Entity(id: Int, texts: Option[List[String]], bools: Option[List[Boolean]], ints: List[Int]) + val e = Entity(1, Some(List("1", "2")), None, List.empty) val q = quote(querySchema[Entity]("ListsEntity")) await { @@ -70,7 +71,7 @@ class ListsEncodingSpec extends CollectionsSpec with CassandraAlpakkaSpec { } "Mapped encoding for CassandraType" in { - case class StrEntity(id: Int, texts: List[StrWrap]) + final case class StrEntity(id: Int, texts: List[StrWrap]) val e = StrEntity(1, List("1", "2").map(StrWrap.apply)) val q = quote(querySchema[StrEntity]("ListsEntity")) @@ -85,7 +86,7 @@ class ListsEncodingSpec extends CollectionsSpec with CassandraAlpakkaSpec { } "Mapped encoding for CassandraMapper types" in { - case class IntEntity(id: Int, ints: List[IntWrap]) + final case class IntEntity(id: Int, ints: List[IntWrap]) val e = IntEntity(1, List(1, 2).map(IntWrap.apply)) val q = quote(querySchema[IntEntity]("ListsEntity")) @@ -100,7 +101,7 @@ class ListsEncodingSpec extends CollectionsSpec with CassandraAlpakkaSpec { } "Blob (Array[Byte]) support" in { - case class BlobsEntity(id: Int, blobs: List[Array[Byte]]) + final case class BlobsEntity(id: Int, blobs: List[Array[Byte]]) val e = BlobsEntity(4, List(Array(1.toByte, 2.toByte), Array(2.toByte))) val q = quote(querySchema[BlobsEntity]("ListsEntity")) @@ -123,7 +124,7 @@ class ListsEncodingSpec extends CollectionsSpec with CassandraAlpakkaSpec { res2 <- ctx.run(listFroz.filter(_.id == lift(List(1)))) } yield { res1 mustBe List(e) - res2 mustBe Nil + res2 mustBe List.empty } } await { @@ -133,7 +134,7 @@ class ListsEncodingSpec extends CollectionsSpec with CassandraAlpakkaSpec { res2 <- ctx.run(listFroz.filter(_.id.contains(3)).allowFiltering) } yield { res1 mustBe List(e) - res2 mustBe Nil + res2 mustBe List.empty } } } diff --git a/quill-cassandra-alpakka/src/test/scala/io/getquill/context/cassandra/alpakka/MapsEncodingSpec.scala b/quill-cassandra-alpakka/src/test/scala/io/getquill/context/cassandra/alpakka/MapsEncodingSpec.scala index 9fe45c5ba7..d133afe7fd 100644 --- a/quill-cassandra-alpakka/src/test/scala/io/getquill/context/cassandra/alpakka/MapsEncodingSpec.scala +++ b/quill-cassandra-alpakka/src/test/scala/io/getquill/context/cassandra/alpakka/MapsEncodingSpec.scala @@ -4,6 +4,7 @@ import io.getquill.context.cassandra.CollectionsSpec import java.time.{Instant, LocalDate} import java.util.UUID +import io.getquill.{ EntityQuery, Quoted } class MapsEncodingSpec extends CollectionsSpec with CassandraAlpakkaSpec { val ctx = testDB @@ -18,7 +19,7 @@ class MapsEncodingSpec extends CollectionsSpec with CassandraAlpakkaSpec { uuidTimestamp: Map[UUID, Instant] ) - val e = MapsEntity( + val e: MapsEntity = MapsEntity( 1, Map("1" -> BigDecimal(1)), Map(1 -> 1d, 2 -> 2d, 3 -> 3d), @@ -26,7 +27,7 @@ class MapsEncodingSpec extends CollectionsSpec with CassandraAlpakkaSpec { Map(true -> LocalDate.now()), Map(UUID.randomUUID() -> Instant.now()) ) - val q = quote(query[MapsEntity]) + val q: Quoted[EntityQuery[MapsEntity]] = quote(query[MapsEntity]) "Map encoders/decoders" in { await { @@ -40,13 +41,13 @@ class MapsEncodingSpec extends CollectionsSpec with CassandraAlpakkaSpec { } "Empty maps and optional fields" in { - case class Entity( + final case class Entity( id: Int, textDecimal: Option[Map[String, BigDecimal]], intDouble: Option[Map[Int, Double]], longFloat: Map[Long, Float] ) - val e = Entity(1, Some(Map("1" -> BigDecimal(1))), None, Map()) + val e = Entity(1, Some(Map("1" -> BigDecimal(1))), None, Map.empty) val q = quote(querySchema[Entity]("MapsEntity")) await { @@ -60,7 +61,7 @@ class MapsEncodingSpec extends CollectionsSpec with CassandraAlpakkaSpec { } "Mapped encoding for CassandraType" in { - case class StrEntity(id: Int, textDecimal: Map[StrWrap, BigDecimal]) + final case class StrEntity(id: Int, textDecimal: Map[StrWrap, BigDecimal]) val e = StrEntity(1, Map(StrWrap("1") -> BigDecimal(1))) val q = quote(querySchema[StrEntity]("MapsEntity")) @@ -75,7 +76,7 @@ class MapsEncodingSpec extends CollectionsSpec with CassandraAlpakkaSpec { } "Mapped encoding for CassandraMapper types" in { - case class IntEntity(id: Int, intDouble: Map[IntWrap, Double]) + final case class IntEntity(id: Int, intDouble: Map[IntWrap, Double]) val e = IntEntity(1, Map(IntWrap(1) -> 1d)) val q = quote(querySchema[IntEntity]("MapsEntity")) @@ -99,7 +100,7 @@ class MapsEncodingSpec extends CollectionsSpec with CassandraAlpakkaSpec { res2 <- ctx.run(mapFroz.filter(_.id == lift(Map(1 -> false)))) } yield { res1 mustBe List(e) - res2 mustBe Nil + res2 mustBe List.empty } } await { @@ -109,7 +110,7 @@ class MapsEncodingSpec extends CollectionsSpec with CassandraAlpakkaSpec { res2 <- ctx.run(mapFroz.filter(_.id.contains(2)).allowFiltering) } yield { res1 mustBe List(e) - res2 mustBe Nil + res2 mustBe List.empty } } } @@ -124,7 +125,7 @@ class MapsEncodingSpec extends CollectionsSpec with CassandraAlpakkaSpec { res2 <- ctx.run(mapFroz.filter(_.id.containsValue(false)).allowFiltering) } yield { res1 mustBe List(e) - res2 mustBe Nil + res2 mustBe List.empty } } } diff --git a/quill-cassandra-alpakka/src/test/scala/io/getquill/context/cassandra/alpakka/PeopleCassandraSpec.scala b/quill-cassandra-alpakka/src/test/scala/io/getquill/context/cassandra/alpakka/PeopleCassandraSpec.scala index 9ec884bdc4..bd798ac6ce 100644 --- a/quill-cassandra-alpakka/src/test/scala/io/getquill/context/cassandra/alpakka/PeopleCassandraSpec.scala +++ b/quill-cassandra-alpakka/src/test/scala/io/getquill/context/cassandra/alpakka/PeopleCassandraSpec.scala @@ -9,7 +9,7 @@ class PeopleCassandraSpec extends CassandraAlpakkaSpec { case class Person(id: Int, name: String, age: Int) - val entries = List( + val entries: List[Person] = List( Person(1, "Bob", 30), Person(2, "Gus", 40), Person(3, "Pet", 20), @@ -17,7 +17,7 @@ class PeopleCassandraSpec extends CassandraAlpakkaSpec { Person(5, "Dre", 60) ) - override def beforeAll = { + override def beforeAll: Unit = { await { testDB.run(query[Person].delete) } @@ -27,11 +27,11 @@ class PeopleCassandraSpec extends CassandraAlpakkaSpec { () } - val qByIds = quote { (ids: Query[Int]) => + val qByIds: Quoted[Query[Int] => EntityQuery[Person]] = quote { (ids: Query[Int]) => query[Person].filter(p => ids.contains(p.id)) } - val q = quote { + val q: Quoted[EntityQuery[Person]] = quote { query[Person] } diff --git a/quill-cassandra-alpakka/src/test/scala/io/getquill/context/cassandra/alpakka/QueryResultTypeCassandraAsyncSpec.scala b/quill-cassandra-alpakka/src/test/scala/io/getquill/context/cassandra/alpakka/QueryResultTypeCassandraAsyncSpec.scala index 390b92fc8a..3a21c5a358 100644 --- a/quill-cassandra-alpakka/src/test/scala/io/getquill/context/cassandra/alpakka/QueryResultTypeCassandraAsyncSpec.scala +++ b/quill-cassandra-alpakka/src/test/scala/io/getquill/context/cassandra/alpakka/QueryResultTypeCassandraAsyncSpec.scala @@ -8,7 +8,7 @@ class QueryResultTypeCassandraAsyncSpec extends QueryResultTypeCassandraSpec wit val context = testDB import context._ - override def beforeAll = { + override def beforeAll: Unit = { await(context.run(deleteAll)) await(context.run(liftQuery(entries).foreach(e => insert(e)))) () diff --git a/quill-cassandra-alpakka/src/test/scala/io/getquill/context/cassandra/alpakka/SetsEncodingSpec.scala b/quill-cassandra-alpakka/src/test/scala/io/getquill/context/cassandra/alpakka/SetsEncodingSpec.scala index c7481e177b..a7a47ddf5e 100644 --- a/quill-cassandra-alpakka/src/test/scala/io/getquill/context/cassandra/alpakka/SetsEncodingSpec.scala +++ b/quill-cassandra-alpakka/src/test/scala/io/getquill/context/cassandra/alpakka/SetsEncodingSpec.scala @@ -4,6 +4,7 @@ import io.getquill.context.cassandra.CollectionsSpec import java.time.{Instant, LocalDate} import java.util.UUID +import io.getquill.{ EntityQuery, Quoted } class SetsEncodingSpec extends CollectionsSpec with CassandraAlpakkaSpec { val ctx = testDB @@ -23,7 +24,7 @@ class SetsEncodingSpec extends CollectionsSpec with CassandraAlpakkaSpec { timestamps: Set[Instant], uuids: Set[UUID] ) - val e = SetsEntity( + val e: SetsEntity = SetsEntity( 1, Set("c"), Set(BigDecimal(1.33)), @@ -36,7 +37,7 @@ class SetsEncodingSpec extends CollectionsSpec with CassandraAlpakkaSpec { Set(Instant.now()), Set(UUID.randomUUID()) ) - val q = quote(query[SetsEntity]) + val q: Quoted[EntityQuery[SetsEntity]] = quote(query[SetsEntity]) "Set encoders/decoders for CassandraTypes and CassandraMappers" in { await { @@ -50,7 +51,7 @@ class SetsEncodingSpec extends CollectionsSpec with CassandraAlpakkaSpec { } "Empty sets and optional fields" in { - case class Entity(id: Int, texts: Option[Set[String]], bools: Option[Set[Boolean]], ints: Set[Int]) + final case class Entity(id: Int, texts: Option[Set[String]], bools: Option[Set[Boolean]], ints: Set[Int]) val e = Entity(1, Some(Set("1", "2")), None, Set.empty) val q = quote(querySchema[Entity]("SetsEntity")) @@ -65,7 +66,7 @@ class SetsEncodingSpec extends CollectionsSpec with CassandraAlpakkaSpec { } "Mapped encoding for CassandraType" in { - case class StrEntity(id: Int, texts: Set[StrWrap]) + final case class StrEntity(id: Int, texts: Set[StrWrap]) val e = StrEntity(1, Set("1", "2").map(StrWrap.apply)) val q = quote(querySchema[StrEntity]("SetsEntity")) @@ -80,7 +81,7 @@ class SetsEncodingSpec extends CollectionsSpec with CassandraAlpakkaSpec { } "Mapped encoding for CassandraMapper types" in { - case class IntEntity(id: Int, ints: Set[IntWrap]) + final case class IntEntity(id: Int, ints: Set[IntWrap]) val e = IntEntity(1, Set(1, 2).map(IntWrap.apply)) val q = quote(querySchema[IntEntity]("SetsEntity")) @@ -95,7 +96,7 @@ class SetsEncodingSpec extends CollectionsSpec with CassandraAlpakkaSpec { } "Blob (Array[Byte]) support" in { - case class BlobsEntity(id: Int, blobs: Set[Array[Byte]]) + final case class BlobsEntity(id: Int, blobs: Set[Array[Byte]]) val e = BlobsEntity(4, Set(Array(1.toByte, 2.toByte), Array(2.toByte))) val q = quote(querySchema[BlobsEntity]("SetsEntity")) diff --git a/quill-cassandra-alpakka/src/test/scala/io/getquill/context/cassandra/alpakka/udt/UdtEncodingSessionContextSpec.scala b/quill-cassandra-alpakka/src/test/scala/io/getquill/context/cassandra/alpakka/udt/UdtEncodingSessionContextSpec.scala index 176c0690d2..55924919c6 100644 --- a/quill-cassandra-alpakka/src/test/scala/io/getquill/context/cassandra/alpakka/udt/UdtEncodingSessionContextSpec.scala +++ b/quill-cassandra-alpakka/src/test/scala/io/getquill/context/cassandra/alpakka/udt/UdtEncodingSessionContextSpec.scala @@ -29,8 +29,8 @@ class UdtEncodingSessionContextSpec extends UdtSpec with CassandraAlpakkaSpec { implicitly[Encoder[List[Personal]]] } "MappedEncoding" in { - case class FirstName(name: String) - case class MyName(firstName: FirstName) extends Udt + final case class FirstName(name: String) + final case class MyName(firstName: FirstName) extends Udt implicit val encodeFirstName = MappedEncoding[FirstName, String](_.name) implicit val decodeFirstName = MappedEncoding[String, FirstName](FirstName) @@ -45,7 +45,7 @@ class UdtEncodingSessionContextSpec extends UdtSpec with CassandraAlpakkaSpec { "Complete examples" - { import ctx1._ "without meta" in { - case class WithEverything(id: Int, personal: Personal, nameList: List[Name]) + final case class WithEverything(id: Int, personal: Personal, nameList: List[Name]) val e = WithEverything( 1, @@ -71,8 +71,8 @@ class UdtEncodingSessionContextSpec extends UdtSpec with CassandraAlpakkaSpec { } } "with meta" in { - case class MyName(first: String) extends Udt - case class WithEverything(id: Int, name: MyName, nameList: List[MyName]) + final case class MyName(first: String) extends Udt + final case class WithEverything(id: Int, name: MyName, nameList: List[MyName]) implicit val myNameMeta = udtMeta[MyName]("Name", _.first -> "firstName") val e = WithEverything(2, MyName("first"), List(MyName("first"))) diff --git a/quill-cassandra-monix/src/test/scala/io/getquill/context/cassandra/monix/DecodeNullSpec.scala b/quill-cassandra-monix/src/test/scala/io/getquill/context/cassandra/monix/DecodeNullSpec.scala index e9ee3aa460..8511d917e1 100644 --- a/quill-cassandra-monix/src/test/scala/io/getquill/context/cassandra/monix/DecodeNullSpec.scala +++ b/quill-cassandra-monix/src/test/scala/io/getquill/context/cassandra/monix/DecodeNullSpec.scala @@ -1,6 +1,5 @@ package io.getquill.context.cassandra.monix -import io.getquill._ import io.getquill.base.Spec class DecodeNullSpec extends Spec { @@ -31,5 +30,5 @@ class DecodeNullSpec extends Spec { case class DecodeNullTestWriteEntity(id: Int, value: Option[Int]) - val insertValue = DecodeNullTestWriteEntity(0, None) + val insertValue: DecodeNullTestWriteEntity = DecodeNullTestWriteEntity(0, None) } diff --git a/quill-cassandra-monix/src/test/scala/io/getquill/context/cassandra/monix/QueryResultTypeCassandraMonixSpec.scala b/quill-cassandra-monix/src/test/scala/io/getquill/context/cassandra/monix/QueryResultTypeCassandraMonixSpec.scala index 3fc6a7d897..b7b7bf251b 100644 --- a/quill-cassandra-monix/src/test/scala/io/getquill/context/cassandra/monix/QueryResultTypeCassandraMonixSpec.scala +++ b/quill-cassandra-monix/src/test/scala/io/getquill/context/cassandra/monix/QueryResultTypeCassandraMonixSpec.scala @@ -11,13 +11,13 @@ class QueryResultTypeCassandraMonixSpec extends QueryResultTypeCassandraSpec { import context._ - def result[T](t: Task[T]) = + def result[T](t: Task[T]): T = await(t.runToFuture(global)) - def result[T](t: Observable[T]) = + def result[T](t: Observable[T]): List[T] = await(t.foldLeftL(List.empty[T])(_ :+ _).runToFuture) - override def beforeAll = { + override def beforeAll: Unit = { result(context.run(deleteAll)) result(context.run(liftQuery(entries).foreach(e => insert(e)))) () diff --git a/quill-cassandra-monix/src/test/scala/io/getquill/context/cassandra/monix/package.scala b/quill-cassandra-monix/src/test/scala/io/getquill/context/cassandra/monix/package.scala index f943e17d01..8cb7042104 100644 --- a/quill-cassandra-monix/src/test/scala/io/getquill/context/cassandra/monix/package.scala +++ b/quill-cassandra-monix/src/test/scala/io/getquill/context/cassandra/monix/package.scala @@ -2,5 +2,5 @@ package io.getquill.context.cassandra import io.getquill.{CassandraMonixContext, Literal} package object monix { - lazy val testMonixDB = new CassandraMonixContext(Literal, "testStreamDB") with CassandraTestEntities + lazy val testMonixDB: CassandraMonixContext[Literal.type] with CassandraTestEntities = new CassandraMonixContext(Literal, "testStreamDB") with CassandraTestEntities } diff --git a/quill-cassandra-monix/src/test/scala/io/getquill/context/cassandra/streaming/DecodeNullSpec.scala b/quill-cassandra-monix/src/test/scala/io/getquill/context/cassandra/streaming/DecodeNullSpec.scala index e5ff978337..a68deb82af 100644 --- a/quill-cassandra-monix/src/test/scala/io/getquill/context/cassandra/streaming/DecodeNullSpec.scala +++ b/quill-cassandra-monix/src/test/scala/io/getquill/context/cassandra/streaming/DecodeNullSpec.scala @@ -1,6 +1,5 @@ package io.getquill.context.cassandra.streaming -import io.getquill._ import io.getquill.base.Spec import monix.reactive.Observable @@ -32,5 +31,5 @@ class DecodeNullSpec extends Spec { case class DecodeNullTestWriteEntity(id: Int, value: Option[Int]) - val insertValue = DecodeNullTestWriteEntity(0, None) + val insertValue: DecodeNullTestWriteEntity = DecodeNullTestWriteEntity(0, None) } diff --git a/quill-cassandra-monix/src/test/scala/io/getquill/context/cassandra/streaming/QueryResultTypeCassandraStreamSpec.scala b/quill-cassandra-monix/src/test/scala/io/getquill/context/cassandra/streaming/QueryResultTypeCassandraStreamSpec.scala index 4196baa6d7..1bb4c9ff98 100644 --- a/quill-cassandra-monix/src/test/scala/io/getquill/context/cassandra/streaming/QueryResultTypeCassandraStreamSpec.scala +++ b/quill-cassandra-monix/src/test/scala/io/getquill/context/cassandra/streaming/QueryResultTypeCassandraStreamSpec.scala @@ -10,10 +10,10 @@ class QueryResultTypeCassandraStreamSpec extends QueryResultTypeCassandraSpec { import context._ - def result[T](t: Observable[T]) = + def result[T](t: Observable[T]): List[T] = await(t.foldLeftL(List.empty[T])(_ :+ _).runToFuture) - override def beforeAll = { + override def beforeAll: Unit = { result(context.run(deleteAll)) result(context.run(liftQuery(entries).foreach(e => insert(e)))) () diff --git a/quill-cassandra-monix/src/test/scala/io/getquill/context/cassandra/streaming/package.scala b/quill-cassandra-monix/src/test/scala/io/getquill/context/cassandra/streaming/package.scala index 439312456c..48ba2cc8cc 100644 --- a/quill-cassandra-monix/src/test/scala/io/getquill/context/cassandra/streaming/package.scala +++ b/quill-cassandra-monix/src/test/scala/io/getquill/context/cassandra/streaming/package.scala @@ -2,5 +2,5 @@ package io.getquill.context.cassandra import io.getquill.{CassandraStreamContext, Literal} package object streaming { - lazy val testStreamDB = new CassandraStreamContext(Literal, "testStreamDB") with CassandraTestEntities + lazy val testStreamDB: CassandraStreamContext[Literal.type] with CassandraTestEntities = new CassandraStreamContext(Literal, "testStreamDB") with CassandraTestEntities } diff --git a/quill-cassandra-zio/src/main/scala/io/getquill/cassandrazio/Quill.scala b/quill-cassandra-zio/src/main/scala/io/getquill/cassandrazio/Quill.scala index a9f523cf96..7f77314b13 100644 --- a/quill-cassandra-zio/src/main/scala/io/getquill/cassandrazio/Quill.scala +++ b/quill-cassandra-zio/src/main/scala/io/getquill/cassandrazio/Quill.scala @@ -18,7 +18,7 @@ object Quill { ZLayer.fromFunction((session: CassandraZioSession) => new Cassandra[N](naming, session)) } - final case class Cassandra[+N <: NamingStrategy](val naming: N, session: CassandraZioSession) + class Cassandra[+N <: NamingStrategy](val naming: N, session: CassandraZioSession) extends CassandraRowContext[N] with ZioContext[CqlIdiom, N] with Context[CqlIdiom, N] diff --git a/quill-cassandra/src/test/scala/io/getquill/context/cassandra/CaseClassQueryCassandraSpec.scala b/quill-cassandra/src/test/scala/io/getquill/context/cassandra/CaseClassQueryCassandraSpec.scala index a2d4b984e9..8c68630c92 100644 --- a/quill-cassandra/src/test/scala/io/getquill/context/cassandra/CaseClassQueryCassandraSpec.scala +++ b/quill-cassandra/src/test/scala/io/getquill/context/cassandra/CaseClassQueryCassandraSpec.scala @@ -12,7 +12,7 @@ class CaseClassQueryCassandraSpec extends Spec { val peopleInsert = quote((p: Contact) => query[Contact].insertValue(p)) - val peopleEntries = List( + val peopleEntries: List[Contact] = List( Contact(1, "Alex", "Jones", 60, 2, "foo"), Contact(2, "Bert", "James", 55, 3, "bar"), Contact(3, "Cora", "Jasper", 33, 3, "baz") @@ -21,7 +21,7 @@ class CaseClassQueryCassandraSpec extends Spec { val addressInsert = quote((c: Address) => query[Address].insertValue(c)) - val addressEntries = List( + val addressEntries: List[Address] = List( Address(1, "123 Fake Street", 11234, "something"), Address(2, "456 Old Street", 45678, "something else"), Address(3, "789 New Street", 89010, "another thing") diff --git a/quill-cassandra/src/test/scala/io/getquill/context/cassandra/CassandraContextMacroSpec.scala b/quill-cassandra/src/test/scala/io/getquill/context/cassandra/CassandraContextMacroSpec.scala index 8ad30575c1..21f7eea0fa 100644 --- a/quill-cassandra/src/test/scala/io/getquill/context/cassandra/CassandraContextMacroSpec.scala +++ b/quill-cassandra/src/test/scala/io/getquill/context/cassandra/CassandraContextMacroSpec.scala @@ -31,7 +31,7 @@ class CassandraContextMacroSpec extends Spec { "probes queries" in { val ctx = new CassandraMirrorContextWithQueryProbing import ctx._ - val q = quote { + quote { query[TestEntity].filter(_.s == "fail") } "ctx.run(q)" mustNot compile @@ -48,7 +48,7 @@ class CassandraContextMacroSpec extends Spec { } "filter.map" in { val q = quote { - qr1.filter(t => t.i == lift(1)).map(t => lift(2L)) + qr1.filter(t => t.i == lift(1)).map(_ => lift(2L)) } val mirror = mirrorContext.run(q) mirror.string mustEqual "SELECT ? FROM TestEntity WHERE i = ?" diff --git a/quill-cassandra/src/test/scala/io/getquill/context/cassandra/CassandraContextSpec.scala b/quill-cassandra/src/test/scala/io/getquill/context/cassandra/CassandraContextSpec.scala index 8db98d048b..ddbe45d67e 100644 --- a/quill-cassandra/src/test/scala/io/getquill/context/cassandra/CassandraContextSpec.scala +++ b/quill-cassandra/src/test/scala/io/getquill/context/cassandra/CassandraContextSpec.scala @@ -1,6 +1,5 @@ package io.getquill.context.cassandra -import io.getquill._ import io.getquill.base.Spec import io.getquill.context.ExecutionInfo @@ -13,7 +12,7 @@ class CassandraContextSpec extends Spec { "async" in { import testAsyncDB._ - case class TestEntity(id: Int, s: String, i: Int, l: Long, o: Int) + final case class TestEntity(id: Int, s: String, i: Int, l: Long, o: Int) val update = quote { query[TestEntity].filter(_.id == lift(1)).update(_.i -> lift(1)) } @@ -21,7 +20,7 @@ class CassandraContextSpec extends Spec { } "sync" in { import testSyncDB._ - case class TestEntity(id: Int, s: String, i: Int, l: Long, o: Int) + final case class TestEntity(id: Int, s: String, i: Int, l: Long, o: Int) val update = quote { query[TestEntity].filter(_.id == lift(1)).update(_.i -> lift(1)) } @@ -31,11 +30,11 @@ class CassandraContextSpec extends Spec { "fail on returning" in { import testSyncDB._ - val p: Prepare = (x, session) => (Nil, x) + val p: Prepare = (x, _) => (List.empty, x) val e: Extractor[Int] = (_, _) => 1 intercept[IllegalStateException](executeActionReturning("", p, e, "")(ExecutionInfo.unknown, ())).getMessage mustBe - intercept[IllegalStateException](executeBatchActionReturning(Nil, e)(ExecutionInfo.unknown, ())).getMessage + intercept[IllegalStateException](executeBatchActionReturning(List.empty, e)(ExecutionInfo.unknown, ())).getMessage } "probe" in { diff --git a/quill-cassandra/src/test/scala/io/getquill/context/cassandra/CassandraTestEntities.scala b/quill-cassandra/src/test/scala/io/getquill/context/cassandra/CassandraTestEntities.scala index 7e282aad91..668b99fb77 100644 --- a/quill-cassandra/src/test/scala/io/getquill/context/cassandra/CassandraTestEntities.scala +++ b/quill-cassandra/src/test/scala/io/getquill/context/cassandra/CassandraTestEntities.scala @@ -1,16 +1,17 @@ package io.getquill.context.cassandra import io.getquill.TestEntities +import io.getquill.{ EntityQuery, Quoted } trait CassandraTestEntities extends TestEntities { this: CassandraContext[_] => case class MapFrozen(id: Map[Int, Boolean]) - val mapFroz = quote(query[MapFrozen]) + val mapFroz: Quoted[EntityQuery[MapFrozen]] = quote(query[MapFrozen]) case class SetFrozen(id: Set[Int]) - val setFroz = quote(query[SetFrozen]) + val setFroz: Quoted[EntityQuery[SetFrozen]] = quote(query[SetFrozen]) case class ListFrozen(id: List[Int]) - val listFroz = quote(query[ListFrozen]) + val listFroz: Quoted[EntityQuery[ListFrozen]] = quote(query[ListFrozen]) } diff --git a/quill-cassandra/src/test/scala/io/getquill/context/cassandra/CollectionsSpec.scala b/quill-cassandra/src/test/scala/io/getquill/context/cassandra/CollectionsSpec.scala index 9b9defa2e7..47f19505c5 100644 --- a/quill-cassandra/src/test/scala/io/getquill/context/cassandra/CollectionsSpec.scala +++ b/quill-cassandra/src/test/scala/io/getquill/context/cassandra/CollectionsSpec.scala @@ -6,10 +6,10 @@ import org.scalatest.BeforeAndAfterEach trait CollectionsSpec extends Spec with BeforeAndAfterEach { case class StrWrap(x: String) - implicit val encodeStrWrap = MappedEncoding[StrWrap, String](_.x) - implicit val decodeStrWrap = MappedEncoding[String, StrWrap](StrWrap.apply) + implicit val encodeStrWrap: MappedEncoding[StrWrap,String] = MappedEncoding[StrWrap, String](_.x) + implicit val decodeStrWrap: MappedEncoding[String,StrWrap] = MappedEncoding[String, StrWrap](StrWrap.apply) case class IntWrap(x: Int) - implicit val encodeIntWrap = MappedEncoding[IntWrap, Int](_.x) - implicit val decodeIntWrap = MappedEncoding[Int, IntWrap](IntWrap.apply) + implicit val encodeIntWrap: MappedEncoding[IntWrap,Int] = MappedEncoding[IntWrap, Int](_.x) + implicit val decodeIntWrap: MappedEncoding[Int,IntWrap] = MappedEncoding[Int, IntWrap](IntWrap.apply) } diff --git a/quill-cassandra/src/test/scala/io/getquill/context/cassandra/CqlIdiomSpec.scala b/quill-cassandra/src/test/scala/io/getquill/context/cassandra/CqlIdiomSpec.scala index 0781cb2d90..61eeac05c7 100644 --- a/quill-cassandra/src/test/scala/io/getquill/context/cassandra/CqlIdiomSpec.scala +++ b/quill-cassandra/src/test/scala/io/getquill/context/cassandra/CqlIdiomSpec.scala @@ -49,7 +49,7 @@ class CqlIdiomSpec extends Spec { "distinct" - { "simple" in { - val q = quote { + quote { qr1.distinct } "mirrorContext.run(q).string" mustNot compile @@ -126,13 +126,13 @@ class CqlIdiomSpec extends Spec { "SELECT s, i, l, o, b FROM TestEntity WHERE i = 1" } "unary (not supported)" in { - val q = quote { + quote { qr1.filter(t => !(t.i == 1)) } "mirrorContext.run(q)" mustNot compile } "function apply (not supported)" in { - val q = quote { + quote { qr1.filter(t => sql"f".as[Int => Boolean](t.i)) } "mirrorContext.run(q)" mustNot compile @@ -148,7 +148,7 @@ class CqlIdiomSpec extends Spec { "SELECT COUNT(1) FROM TestEntity WHERE i = 1" } "invalid" in { - val q = quote { + quote { qr1.map(t => t.i).max } "mirrorContext.run(q)" mustNot compile @@ -206,7 +206,7 @@ class CqlIdiomSpec extends Spec { "UPDATE TestEntity SET i = i + 1" } "invalid" in { - val q = quote { + quote { qr1.filter(t => t.i * 2 == 4) } "mirrorContext.run(q)" mustNot compile @@ -222,7 +222,7 @@ class CqlIdiomSpec extends Spec { "SELECT s, i, l, o, b FROM TestEntity WHERE s = 's'" } "unit" in { - case class Test(u: Unit) + final case class Test(u: Unit) val q = quote { query[Test].filter(t => t.u == (())).size } @@ -251,7 +251,7 @@ class CqlIdiomSpec extends Spec { "SELECT s, i, l, o, b FROM TestEntity WHERE i IN (?, ?)" } "null (not supported)" in { - val q = quote { + quote { qr1.filter(t => t.s == null) } "mirrorContext.run(q)" mustNot compile @@ -406,12 +406,12 @@ class CqlIdiomSpec extends Spec { } "cql" in { val t = implicitly[Tokenizer[CqlQuery]] - val e = CqlQuery(Entity("name", Nil, QEP), None, Nil, None, Nil, distinct = true) + val e = CqlQuery(Entity("name", List.empty, QEP), None, List.empty, None, List.empty, distinct = true) intercept[IllegalStateException](t.token(e)) t.token(e.copy(distinct = false)) mustBe stmt"SELECT * FROM name" } "fail on invalid" in { - intercept[IllegalStateException](implicitly[Tokenizer[Ast]].token(Block(Nil))) + intercept[IllegalStateException](implicitly[Tokenizer[Ast]].token(Block(List.empty))) } "value" in { implicitly[Tokenizer[Value]].token(Tuple(List(Ident("a")))) mustBe stmt"a" @@ -422,7 +422,7 @@ class CqlIdiomSpec extends Spec { "action" in { val t = implicitly[Tokenizer[AstAction]] intercept[IllegalStateException](t.token(null: AstAction)) - intercept[IllegalStateException](t.token(Insert(Nested(Ident("a")), Nil))) + intercept[IllegalStateException](t.token(Insert(Nested(Ident("a")), List.empty))) } // not actually used anywhere but doing a sanity check here "external ident sanity check" in { diff --git a/quill-cassandra/src/test/scala/io/getquill/context/cassandra/CqlQuerySpec.scala b/quill-cassandra/src/test/scala/io/getquill/context/cassandra/CqlQuerySpec.scala index 5cb23b2eba..2283b3b0ce 100644 --- a/quill-cassandra/src/test/scala/io/getquill/context/cassandra/CqlQuerySpec.scala +++ b/quill-cassandra/src/test/scala/io/getquill/context/cassandra/CqlQuerySpec.scala @@ -24,7 +24,7 @@ class CqlQuerySpec extends Spec { } "other (not supported)" in { val q = quote { - qr1.map(t => "s") + qr1.map(_ => "s") } intercept[IllegalStateException] { CqlQuery(q.ast) @@ -82,7 +82,7 @@ class CqlQuerySpec extends Spec { "SELECT s, i, l, o, b FROM TestEntity ORDER BY i DESC, s DESC" } "invalid ordering" in { - case class Test(a: (Int, Int)) + final case class Test(a: (Int, Int)) val q = quote { query[Test].sortBy(_.a)(Ord(Ord.asc, Ord.desc)) } diff --git a/quill-cassandra/src/test/scala/io/getquill/context/cassandra/DecodeNullSpec.scala b/quill-cassandra/src/test/scala/io/getquill/context/cassandra/DecodeNullSpec.scala index 1d540ace47..dc87b79fe7 100644 --- a/quill-cassandra/src/test/scala/io/getquill/context/cassandra/DecodeNullSpec.scala +++ b/quill-cassandra/src/test/scala/io/getquill/context/cassandra/DecodeNullSpec.scala @@ -1,6 +1,5 @@ package io.getquill.context.cassandra -import io.getquill._ import io.getquill.base.Spec class DecodeNullSpec extends Spec { @@ -43,6 +42,6 @@ class DecodeNullSpec extends Spec { case class DecodeNullTestWriteEntity(id: Int, value: Option[Int]) - val insertValue = DecodeNullTestWriteEntity(0, None) + val insertValue: DecodeNullTestWriteEntity = DecodeNullTestWriteEntity(0, None) } diff --git a/quill-cassandra/src/test/scala/io/getquill/context/cassandra/EncodingSpec.scala b/quill-cassandra/src/test/scala/io/getquill/context/cassandra/EncodingSpec.scala index a80db1de43..5ddaaf3cd3 100644 --- a/quill-cassandra/src/test/scala/io/getquill/context/cassandra/EncodingSpec.scala +++ b/quill-cassandra/src/test/scala/io/getquill/context/cassandra/EncodingSpec.scala @@ -60,17 +60,17 @@ class EncodingSpec extends EncodingSpecHelper { "mappedEncoding" in { import testSyncDB._ - case class A() - case class B() - val a1: Encoder[A] = encoder((b, c, d, s) => d) - val a2: Decoder[A] = decoder((b, c, s) => A()) + final case class A() + final case class B() + val a1: Encoder[A] = encoder((_, _, d, _) => d) + val a2: Decoder[A] = decoder((_, _, _) => A()) mappedDecoder(MappedEncoding[A, B](_ => B()), a2).isInstanceOf[CassandraDecoder[B]] mustBe true mappedEncoder(MappedEncoding[B, A](_ => A()), a1).isInstanceOf[CassandraEncoder[B]] mustBe true } "date and timestamps" - { - case class Java8Types(v9: LocalDate, v11: Instant, o9: Option[ZonedDateTime], id: Int = 1, v1: String = "") - case class CasTypes(v9: LocalDate, v11: Instant, o9: Option[ZonedDateTime], id: Int = 1, v1: String = "") + final case class Java8Types(v9: LocalDate, v11: Instant, o9: Option[ZonedDateTime], id: Int = 1, v1: String = "") + final case class CasTypes(v9: LocalDate, v11: Instant, o9: Option[ZonedDateTime], id: Int = 1, v1: String = "") "mirror" in { import mirrorContext._ diff --git a/quill-cassandra/src/test/scala/io/getquill/context/cassandra/EncodingSpecHelper.scala b/quill-cassandra/src/test/scala/io/getquill/context/cassandra/EncodingSpecHelper.scala index 733d69b05f..47b1a556b3 100644 --- a/quill-cassandra/src/test/scala/io/getquill/context/cassandra/EncodingSpecHelper.scala +++ b/quill-cassandra/src/test/scala/io/getquill/context/cassandra/EncodingSpecHelper.scala @@ -1,7 +1,7 @@ package io.getquill.context.cassandra import io.getquill.base.Spec -import java.util.{Date, UUID} +import java.util.UUID import java.time.{Instant, LocalDate} @@ -70,7 +70,7 @@ abstract class EncodingSpecHelper extends Spec { protected val fixUUID: UUID = UUID.fromString("606c79e8-a331-4810-8bd7-0668ff7a23ef") - val insertValues = + val insertValues: List[EncodingTestEntity] = List( EncodingTestEntity( id = 1, diff --git a/quill-cassandra/src/test/scala/io/getquill/context/cassandra/ListsEncodingSpec.scala b/quill-cassandra/src/test/scala/io/getquill/context/cassandra/ListsEncodingSpec.scala index 35bbb3d5a0..e5d5c05cfa 100644 --- a/quill-cassandra/src/test/scala/io/getquill/context/cassandra/ListsEncodingSpec.scala +++ b/quill-cassandra/src/test/scala/io/getquill/context/cassandra/ListsEncodingSpec.scala @@ -1,7 +1,8 @@ package io.getquill.context.cassandra -import java.util.{Date, UUID} +import java.util.UUID import java.time.{Instant, LocalDate} +import io.getquill.{ EntityQuery, Quoted } class ListsEncodingSpec extends CollectionsSpec { val ctx = testSyncDB @@ -22,7 +23,7 @@ class ListsEncodingSpec extends CollectionsSpec { timestamps: List[Instant], uuids: List[UUID] ) - val e = ListsEntity( + val e: ListsEntity = ListsEntity( 1, List("c"), List(BigDecimal(1.33)), @@ -38,7 +39,7 @@ class ListsEncodingSpec extends CollectionsSpec { List(UUID.randomUUID()) ) - val q = quote(query[ListsEntity]) + val q: Quoted[EntityQuery[ListsEntity]] = quote(query[ListsEntity]) "List encoders/decoders for CassandraTypes and CassandraMappers" in { ctx.run(q.insertValue(lift(e))) @@ -46,17 +47,17 @@ class ListsEncodingSpec extends CollectionsSpec { } "Empty lists and optional fields" in { - case class Entity(id: Int, texts: Option[List[String]], bools: Option[List[Boolean]], ints: List[Int]) - val e = Entity(1, Some(List("1", "2")), None, Nil) + final case class Entity(id: Int, texts: Option[List[String]], bools: Option[List[Boolean]], ints: List[Int]) + val e = Entity(1, Some(List("1", "2")), None, List.empty) val q = quote(querySchema[Entity]("ListsEntity")) ctx.run(q.insertValue(lift(e))) - val r = ctx.run(q.filter(_.id == 1)).head + ctx.run(q.filter(_.id == 1)).head ctx.run(q.filter(_.id == 1)).head mustBe e } "Mapped encoding for CassandraType" in { - case class StrEntity(id: Int, texts: List[StrWrap]) + final case class StrEntity(id: Int, texts: List[StrWrap]) val e = StrEntity(1, List("1", "2").map(StrWrap.apply)) val q = quote(querySchema[StrEntity]("ListsEntity")) @@ -65,7 +66,7 @@ class ListsEncodingSpec extends CollectionsSpec { } "Mapped encoding for CassandraMapper types" in { - case class IntEntity(id: Int, ints: List[IntWrap]) + final case class IntEntity(id: Int, ints: List[IntWrap]) val e = IntEntity(1, List(1, 2).map(IntWrap.apply)) val q = quote(querySchema[IntEntity]("ListsEntity")) @@ -74,7 +75,7 @@ class ListsEncodingSpec extends CollectionsSpec { } "Blob (Array[Byte]) support" in { - case class BlobsEntity(id: Int, blobs: List[Array[Byte]]) + final case class BlobsEntity(id: Int, blobs: List[Array[Byte]]) val e = BlobsEntity(1, List(Array(1.toByte, 2.toByte), Array(2.toByte))) val q = quote(querySchema[BlobsEntity]("ListsEntity")) @@ -86,10 +87,10 @@ class ListsEncodingSpec extends CollectionsSpec { val e = ListFrozen(List(1, 2)) ctx.run(listFroz.insertValue(lift(e))) ctx.run(listFroz.filter(_.id == lift(List(1, 2)))) mustBe List(e) - ctx.run(listFroz.filter(_.id == lift(List(1)))) mustBe Nil + ctx.run(listFroz.filter(_.id == lift(List(1)))) mustBe List.empty ctx.run(listFroz.filter(_.id.contains(2)).allowFiltering) mustBe List(e) - ctx.run(listFroz.filter(_.id.contains(3)).allowFiltering) mustBe Nil + ctx.run(listFroz.filter(_.id.contains(3)).allowFiltering) mustBe List.empty } override protected def beforeEach(): Unit = { diff --git a/quill-cassandra/src/test/scala/io/getquill/context/cassandra/MapsEncodingSpec.scala b/quill-cassandra/src/test/scala/io/getquill/context/cassandra/MapsEncodingSpec.scala index b9314d1fdb..7f5da19e93 100644 --- a/quill-cassandra/src/test/scala/io/getquill/context/cassandra/MapsEncodingSpec.scala +++ b/quill-cassandra/src/test/scala/io/getquill/context/cassandra/MapsEncodingSpec.scala @@ -1,7 +1,7 @@ package io.getquill.context.cassandra import java.time.{Instant, LocalDate} -import java.util.{Date, UUID} +import java.util.UUID class MapsEncodingSpec extends CollectionsSpec { val ctx = testSyncDB @@ -15,7 +15,7 @@ class MapsEncodingSpec extends CollectionsSpec { boolDate: Map[Boolean, LocalDate], uuidTimestamp: Map[UUID, Instant] ) - val e = MapsEntity( + val e: MapsEntity = MapsEntity( 1, Map("1" -> BigDecimal(1)), Map(1 -> 1d, 2 -> 2d, 3 -> 3d), @@ -31,13 +31,13 @@ class MapsEncodingSpec extends CollectionsSpec { } "Empty maps and optional fields" in { - case class Entity( + final case class Entity( id: Int, textDecimal: Option[Map[String, BigDecimal]], intDouble: Option[Map[Int, Double]], longFloat: Map[Long, Float] ) - val e = Entity(1, Some(Map("1" -> BigDecimal(1))), None, Map()) + val e = Entity(1, Some(Map("1" -> BigDecimal(1))), None, Map.empty) val q = quote(querySchema[Entity]("MapsEntity")) ctx.run(q.insertValue(lift(e))) @@ -45,7 +45,7 @@ class MapsEncodingSpec extends CollectionsSpec { } "Mapped encoding for CassandraType" in { - case class StrEntity(id: Int, textDecimal: Map[StrWrap, BigDecimal]) + final case class StrEntity(id: Int, textDecimal: Map[StrWrap, BigDecimal]) val e = StrEntity(1, Map(StrWrap("1") -> BigDecimal(1))) val q = quote(querySchema[StrEntity]("MapsEntity")) @@ -54,7 +54,7 @@ class MapsEncodingSpec extends CollectionsSpec { } "Mapped encoding for CassandraMapper types" in { - case class IntEntity(id: Int, intDouble: Map[IntWrap, Double]) + final case class IntEntity(id: Int, intDouble: Map[IntWrap, Double]) val e = IntEntity(1, Map(IntWrap(1) -> 1d)) val q = quote(querySchema[IntEntity]("MapsEntity")) @@ -66,10 +66,10 @@ class MapsEncodingSpec extends CollectionsSpec { val e = MapFrozen(Map(1 -> true)) ctx.run(mapFroz.insertValue(lift(e))) ctx.run(mapFroz.filter(_.id == lift(Map(1 -> true)))) mustBe List(e) - ctx.run(mapFroz.filter(_.id == lift(Map(1 -> false)))) mustBe Nil + ctx.run(mapFroz.filter(_.id == lift(Map(1 -> false)))) mustBe List.empty ctx.run(mapFroz.filter(_.id.contains(1)).allowFiltering) mustBe List(e) - ctx.run(mapFroz.filter(_.id.contains(2)).allowFiltering) mustBe Nil + ctx.run(mapFroz.filter(_.id.contains(2)).allowFiltering) mustBe List.empty } "Map.containsValue" in { @@ -77,7 +77,7 @@ class MapsEncodingSpec extends CollectionsSpec { ctx.run(mapFroz.insertValue(lift(e))) ctx.run(mapFroz.filter(_.id.containsValue(true)).allowFiltering) mustBe List(e) - ctx.run(mapFroz.filter(_.id.containsValue(false)).allowFiltering) mustBe Nil + ctx.run(mapFroz.filter(_.id.containsValue(false)).allowFiltering) mustBe List.empty } override protected def beforeEach(): Unit = { diff --git a/quill-cassandra/src/test/scala/io/getquill/context/cassandra/PeopleCassandraSpec.scala b/quill-cassandra/src/test/scala/io/getquill/context/cassandra/PeopleCassandraSpec.scala index bff6e1f9e0..2f99aa7c71 100644 --- a/quill-cassandra/src/test/scala/io/getquill/context/cassandra/PeopleCassandraSpec.scala +++ b/quill-cassandra/src/test/scala/io/getquill/context/cassandra/PeopleCassandraSpec.scala @@ -9,7 +9,7 @@ class PeopleCassandraSpec extends Spec { case class Person(id: Int, name: String, age: Int) - override def beforeAll = { + override def beforeAll: Unit = { val entries = List( Person(1, "Bob", 30), Person(2, "Gus", 40), @@ -22,7 +22,7 @@ class PeopleCassandraSpec extends Spec { () } - val q = quote { (ids: Query[Int]) => + val q: Quoted[Query[Int] => EntityQuery[Person]] = quote { (ids: Query[Int]) => query[Person].filter(p => ids.contains(p.id)) } diff --git a/quill-cassandra/src/test/scala/io/getquill/context/cassandra/QueryResultTypeCassandraAsyncSpec.scala b/quill-cassandra/src/test/scala/io/getquill/context/cassandra/QueryResultTypeCassandraAsyncSpec.scala index c9c1910260..0c8c5db0c5 100644 --- a/quill-cassandra/src/test/scala/io/getquill/context/cassandra/QueryResultTypeCassandraAsyncSpec.scala +++ b/quill-cassandra/src/test/scala/io/getquill/context/cassandra/QueryResultTypeCassandraAsyncSpec.scala @@ -8,7 +8,7 @@ class QueryResultTypeCassandraAsyncSpec extends QueryResultTypeCassandraSpec { import context._ - override def beforeAll = { + override def beforeAll: Unit = { await(context.run(deleteAll)) await(context.run(liftQuery(entries).foreach(e => insert(e)))) () diff --git a/quill-cassandra/src/test/scala/io/getquill/context/cassandra/QueryResultTypeCassandraSpec.scala b/quill-cassandra/src/test/scala/io/getquill/context/cassandra/QueryResultTypeCassandraSpec.scala index fbb014e6fc..d30a1c1ae7 100644 --- a/quill-cassandra/src/test/scala/io/getquill/context/cassandra/QueryResultTypeCassandraSpec.scala +++ b/quill-cassandra/src/test/scala/io/getquill/context/cassandra/QueryResultTypeCassandraSpec.scala @@ -4,6 +4,7 @@ import io.getquill.context.cassandra.encoding.Encoders import io.getquill.context.cassandra.encoding.Decoders import io.getquill.Ord import io.getquill.base.Spec +import io.getquill.{ Delete, EntityQuery, Query, Quoted } trait QueryResultTypeCassandraSpec extends Spec { @@ -12,23 +13,23 @@ trait QueryResultTypeCassandraSpec extends Spec { case class OrderTestEntity(id: Int, i: Int) - val entries = List( + val entries: List[OrderTestEntity] = List( OrderTestEntity(1, 1), OrderTestEntity(2, 2), OrderTestEntity(3, 3) ) val insert = quote((e: OrderTestEntity) => query[OrderTestEntity].insertValue(e)) - val deleteAll = quote(query[OrderTestEntity].delete) - val selectAll = quote(query[OrderTestEntity]) - val map = quote(query[OrderTestEntity].map(_.id)) - val filter = quote(query[OrderTestEntity].filter(_.id == 1)) - val withFilter = quote(query[OrderTestEntity].withFilter(_.id == 1)) - val sortBy = quote(query[OrderTestEntity].filter(_.id == 1).sortBy(_.i)(Ord.asc)) - val take = quote(query[OrderTestEntity].take(10)) - val entitySize = quote(query[OrderTestEntity].size) - val parametrizedSize = quote { (id: Int) => + val deleteAll: Quoted[Delete[OrderTestEntity]] = quote(query[OrderTestEntity].delete) + val selectAll: Quoted[EntityQuery[OrderTestEntity]] = quote(query[OrderTestEntity]) + val map: Quoted[EntityQuery[Int]] = quote(query[OrderTestEntity].map(_.id)) + val filter: Quoted[EntityQuery[OrderTestEntity]] = quote(query[OrderTestEntity].filter(_.id == 1)) + val withFilter: Quoted[EntityQuery[OrderTestEntity]] = quote(query[OrderTestEntity].withFilter(_.id == 1)) + val sortBy: Quoted[Query[OrderTestEntity]] = quote(query[OrderTestEntity].filter(_.id == 1).sortBy(_.i)(Ord.asc)) + val take: Quoted[Query[OrderTestEntity]] = quote(query[OrderTestEntity].take(10)) + val entitySize: Quoted[Long] = quote(query[OrderTestEntity].size) + val parametrizedSize: Quoted[Int => Long] = quote { (id: Int) => query[OrderTestEntity].filter(_.id == id).size } - val distinct = quote(query[OrderTestEntity].map(_.id).distinct) + val distinct: Quoted[Query[Int]] = quote(query[OrderTestEntity].map(_.id).distinct) } diff --git a/quill-cassandra/src/test/scala/io/getquill/context/cassandra/QueryResultTypeCassandraSyncSpec.scala b/quill-cassandra/src/test/scala/io/getquill/context/cassandra/QueryResultTypeCassandraSyncSpec.scala index 49efff42f8..80c64b5d49 100644 --- a/quill-cassandra/src/test/scala/io/getquill/context/cassandra/QueryResultTypeCassandraSyncSpec.scala +++ b/quill-cassandra/src/test/scala/io/getquill/context/cassandra/QueryResultTypeCassandraSyncSpec.scala @@ -6,7 +6,7 @@ class QueryResultTypeCassandraSyncSpec extends QueryResultTypeCassandraSpec { import context._ - override def beforeAll = { + override def beforeAll: Unit = { context.run(deleteAll) context.run(liftQuery(entries).foreach(e => insert(e))) () diff --git a/quill-cassandra/src/test/scala/io/getquill/context/cassandra/SetsEncodingSpec.scala b/quill-cassandra/src/test/scala/io/getquill/context/cassandra/SetsEncodingSpec.scala index 27ab8997e0..fc7753b539 100644 --- a/quill-cassandra/src/test/scala/io/getquill/context/cassandra/SetsEncodingSpec.scala +++ b/quill-cassandra/src/test/scala/io/getquill/context/cassandra/SetsEncodingSpec.scala @@ -1,7 +1,7 @@ package io.getquill.context.cassandra import java.time.{Instant, LocalDate} -import java.util.{Date, UUID} +import java.util.UUID class SetsEncodingSpec extends CollectionsSpec { val ctx = testSyncDB @@ -20,7 +20,7 @@ class SetsEncodingSpec extends CollectionsSpec { timestamps: Set[Instant], uuids: Set[UUID] ) - val e = SetsEntity( + val e: SetsEntity = SetsEntity( 1, Set("c"), Set(BigDecimal(1.33)), @@ -41,8 +41,8 @@ class SetsEncodingSpec extends CollectionsSpec { } "Empty sets and optional fields" in { - case class Entity(id: Int, texts: Option[Set[String]], bools: Option[Set[Boolean]], ints: Set[Int]) - val e = Entity(1, Some(Set("1", "2")), None, Set()) + final case class Entity(id: Int, texts: Option[Set[String]], bools: Option[Set[Boolean]], ints: Set[Int]) + val e = Entity(1, Some(Set("1", "2")), None, Set.empty) val q = quote(querySchema[Entity]("SetsEntity")) ctx.run(q.insertValue(lift(e))) @@ -50,7 +50,7 @@ class SetsEncodingSpec extends CollectionsSpec { } "Mapped encoding for CassandraType" in { - case class StrEntity(id: Int, texts: Set[StrWrap]) + final case class StrEntity(id: Int, texts: Set[StrWrap]) val e = StrEntity(1, Set("1", "2").map(StrWrap.apply)) val q = quote(querySchema[StrEntity]("SetsEntity")) @@ -59,7 +59,7 @@ class SetsEncodingSpec extends CollectionsSpec { } "Mapped encoding for CassandraMapper types" in { - case class IntEntity(id: Int, ints: Set[IntWrap]) + final case class IntEntity(id: Int, ints: Set[IntWrap]) val e = IntEntity(1, Set(1, 2).map(IntWrap.apply)) val q = quote(querySchema[IntEntity]("SetsEntity")) @@ -68,7 +68,7 @@ class SetsEncodingSpec extends CollectionsSpec { } "Blob (Array[Byte]) support" in { - case class BlobsEntity(id: Int, blobs: Set[Array[Byte]]) + final case class BlobsEntity(id: Int, blobs: Set[Array[Byte]]) val e = BlobsEntity(1, Set(Array(1.toByte, 2.toByte), Array(2.toByte))) val q = quote(querySchema[BlobsEntity]("SetsEntity")) @@ -80,7 +80,7 @@ class SetsEncodingSpec extends CollectionsSpec { val e = SetFrozen(Set(1, 2)) ctx.run(setFroz.insertValue(lift(e))) ctx.run(setFroz.filter(_.id == lift(Set(1, 2)))) mustBe List(e) - ctx.run(setFroz.filter(_.id == lift(Set(1)))) mustBe List() + ctx.run(setFroz.filter(_.id == lift(Set(1)))) mustBe List.empty } override protected def beforeEach(): Unit = { diff --git a/quill-cassandra/src/test/scala/io/getquill/context/cassandra/cluster/SessionBuilderSpec.scala b/quill-cassandra/src/test/scala/io/getquill/context/cassandra/cluster/SessionBuilderSpec.scala index 061d35b18d..acf58f142a 100644 --- a/quill-cassandra/src/test/scala/io/getquill/context/cassandra/cluster/SessionBuilderSpec.scala +++ b/quill-cassandra/src/test/scala/io/getquill/context/cassandra/cluster/SessionBuilderSpec.scala @@ -9,7 +9,7 @@ import java.util import scala.jdk.CollectionConverters._ class SessionBuilderSpec extends Spec { - def envAddress = sys.env.get("CASSANDRA_CONTACT_POINT_0").get + def envAddress: String = sys.env.get("CASSANDRA_CONTACT_POINT_0").get "creates Builder" - { diff --git a/quill-cassandra/src/test/scala/io/getquill/context/cassandra/norm/RenamePropertiesSpec.scala b/quill-cassandra/src/test/scala/io/getquill/context/cassandra/norm/RenamePropertiesSpec.scala index f8b4403965..729ce912b2 100644 --- a/quill-cassandra/src/test/scala/io/getquill/context/cassandra/norm/RenamePropertiesSpec.scala +++ b/quill-cassandra/src/test/scala/io/getquill/context/cassandra/norm/RenamePropertiesSpec.scala @@ -8,11 +8,11 @@ class RenamePropertiesSpec extends Spec { import mirrorContext._ - val e = quote { + val e: Quoted[EntityQuery[TestEntity]] = quote { querySchema[TestEntity]("test_entity", _.s -> "field_s", _.i -> "field_i") } - val f = quote { + val f: Quoted[EntityQuery[TestEntity]] = quote { qr1.filter(t => t.i == 1) } diff --git a/quill-cassandra/src/test/scala/io/getquill/context/cassandra/ops/CassandraOpsSpec.scala b/quill-cassandra/src/test/scala/io/getquill/context/cassandra/ops/CassandraOpsSpec.scala index 3f8e2de5b1..fc1bd1f8ba 100644 --- a/quill-cassandra/src/test/scala/io/getquill/context/cassandra/ops/CassandraOpsSpec.scala +++ b/quill-cassandra/src/test/scala/io/getquill/context/cassandra/ops/CassandraOpsSpec.scala @@ -1,6 +1,5 @@ package io.getquill.context.cassandra.ops -import io.getquill._ import io.getquill.base.Spec import io.getquill.context.cassandra.mirrorContext diff --git a/quill-cassandra/src/test/scala/io/getquill/context/cassandra/package.scala b/quill-cassandra/src/test/scala/io/getquill/context/cassandra/package.scala index fb530a0f56..d07ca8cfa5 100644 --- a/quill-cassandra/src/test/scala/io/getquill/context/cassandra/package.scala +++ b/quill-cassandra/src/test/scala/io/getquill/context/cassandra/package.scala @@ -9,12 +9,12 @@ import io.getquill.Literal package object cassandra { - lazy val mirrorContext = new CassandraMirrorContext(Literal) with CassandraTestEntities - lazy val capsMirrorContext = new CassandraMirrorContext(UpperCaseNonDefault) with CassandraTestEntities + lazy val mirrorContext: CassandraMirrorContext[Literal.type] with CassandraTestEntities = new CassandraMirrorContext(Literal) with CassandraTestEntities + lazy val capsMirrorContext: CassandraMirrorContext[UpperCaseNonDefault.type] with CassandraTestEntities = new CassandraMirrorContext(UpperCaseNonDefault) with CassandraTestEntities - lazy val testSyncDB = new CassandraSyncContext(Literal, "testSyncDB") with CassandraTestEntities + lazy val testSyncDB: CassandraSyncContext[Literal.type] with CassandraTestEntities = new CassandraSyncContext(Literal, "testSyncDB") with CassandraTestEntities - lazy val testAsyncDB = new CassandraAsyncContext(Literal, "testAsyncDB") with CassandraTestEntities + lazy val testAsyncDB: CassandraAsyncContext[Literal.type] with CassandraTestEntities = new CassandraAsyncContext(Literal, "testAsyncDB") with CassandraTestEntities def await[T](f: Future[T]): T = Await.result(f, Duration.Inf) } diff --git a/quill-cassandra/src/test/scala/io/getquill/context/cassandra/udt/UdtEncodingMirrorContextSpec.scala b/quill-cassandra/src/test/scala/io/getquill/context/cassandra/udt/UdtEncodingMirrorContextSpec.scala index 33e9f1ab50..3cb439f4d8 100644 --- a/quill-cassandra/src/test/scala/io/getquill/context/cassandra/udt/UdtEncodingMirrorContextSpec.scala +++ b/quill-cassandra/src/test/scala/io/getquill/context/cassandra/udt/UdtEncodingMirrorContextSpec.scala @@ -26,12 +26,12 @@ class UdtEncodingMirrorContextSpec extends UdtSpec { } "Encode/decode UDT within entity" in { - case class User(id: Int, name: Name, names: List[Name]) + final case class User(id: Int, name: Name, names: List[Name]) mirrorContext.run(query[User]).string mustBe "SELECT id, name, names FROM User" mirrorContext .run( query[User] - .insertValue(lift(User(1, Name("1", None), Nil))) + .insertValue(lift(User(1, Name("1", None), List.empty))) ) .string mustBe "INSERT INTO User (id,name,names) VALUES (?, ?, ?)" } diff --git a/quill-cassandra/src/test/scala/io/getquill/context/cassandra/udt/UdtEncodingSessionContextSpec.scala b/quill-cassandra/src/test/scala/io/getquill/context/cassandra/udt/UdtEncodingSessionContextSpec.scala index ce5bbb93e7..5d73fbfe39 100644 --- a/quill-cassandra/src/test/scala/io/getquill/context/cassandra/udt/UdtEncodingSessionContextSpec.scala +++ b/quill-cassandra/src/test/scala/io/getquill/context/cassandra/udt/UdtEncodingSessionContextSpec.scala @@ -1,7 +1,7 @@ package io.getquill.context.cassandra.udt import com.datastax.oss.driver.api.core.CqlIdentifier -import com.typesafe.config.{ConfigValue, ConfigValueFactory} +import com.typesafe.config.ConfigValueFactory import io.getquill.{CassandraContextConfig, CassandraSyncContext, SnakeCase} import io.getquill.context.cassandra.testSyncDB import io.getquill.util.LoadConfig @@ -10,10 +10,10 @@ import io.getquill.Udt class UdtEncodingSessionContextSpec extends UdtSpec { val ctx1 = testSyncDB - val config0 = CassandraContextConfig( + val config0: CassandraContextConfig = CassandraContextConfig( LoadConfig("testSyncDB").withValue("keyspace", ConfigValueFactory.fromAnyRef("system")) ) - val config2 = CassandraContextConfig( + val config2: CassandraContextConfig = CassandraContextConfig( LoadConfig("testSyncDB").withValue("keyspace", ConfigValueFactory.fromAnyRef("quill_test_2")) ) val ctx2 = new CassandraSyncContext(SnakeCase, config2) @@ -39,8 +39,8 @@ class UdtEncodingSessionContextSpec extends UdtSpec { implicitly[Encoder[List[Personal]]] } "MappedEncoding" in { - case class FirstName(name: String) - case class MyName(firstName: FirstName) extends Udt + final case class FirstName(name: String) + final case class MyName(firstName: FirstName) extends Udt implicit val encodeFirstName = MappedEncoding[FirstName, String](_.name) implicit val decodeFirstName = MappedEncoding[String, FirstName](FirstName) @@ -55,7 +55,7 @@ class UdtEncodingSessionContextSpec extends UdtSpec { "Complete examples" - { import ctx1._ "without meta" in { - case class WithEverything(id: Int, personal: Personal, nameList: List[Name]) + final case class WithEverything(id: Int, personal: Personal, nameList: List[Name]) val e = WithEverything( 1, @@ -74,8 +74,8 @@ class UdtEncodingSessionContextSpec extends UdtSpec { ctx1.run(query[WithEverything].filter(_.id == 1)).headOption must contain(e) } "with meta" in { - case class MyName(first: String) extends Udt - case class WithEverything(id: Int, name: MyName, nameList: List[MyName]) + final case class MyName(first: String) extends Udt + final case class WithEverything(id: Int, name: MyName, nameList: List[MyName]) implicit val myNameMeta = udtMeta[MyName]("Name", _.first -> "firstName") val e = WithEverything(2, MyName("first"), List(MyName("first"))) @@ -107,7 +107,7 @@ class UdtEncodingSessionContextSpec extends UdtSpec { "naming strategy" in { import ctx2._ - case class WithUdt(id: Int, name: Name) + final case class WithUdt(id: Int, name: Name) val e = WithUdt(1, Name("first", Some("second"))) // quill_test_2 uses snake case ctx2.run(query[WithUdt].insertValue(lift(e))) diff --git a/quill-codegen-jdbc/src/test/scala/io/getquill/codegen/DagTest.scala b/quill-codegen-jdbc/src/test/scala/io/getquill/codegen/DagTest.scala index d500ca51f1..16e1fb77c5 100644 --- a/quill-codegen-jdbc/src/test/scala/io/getquill/codegen/DagTest.scala +++ b/quill-codegen-jdbc/src/test/scala/io/getquill/codegen/DagTest.scala @@ -16,7 +16,7 @@ class CodeGeneratorRunnerDagTest extends AnyFunSuite with BeforeAndAfter { case class TestCase[O](one: ClassTag[_], twos: Seq[ClassTag[_]], result: ClassTag[_]) - val cases = Seq( + val cases: Seq[TestCase[Nothing]] = Seq( TestCase(classTag[Int], Seq(classTag[Long]), classTag[Long]), TestCase(classTag[Long], Seq(classTag[Boolean], classTag[Int], classTag[Byte], classTag[Long]), classTag[Long]), TestCase(classTag[Int], Seq(classTag[Boolean], classTag[Int], classTag[Byte]), classTag[Int]), @@ -54,7 +54,7 @@ class CodeGeneratorRunnerDagTest extends AnyFunSuite with BeforeAndAfter { TestCase(classTag[UnknownClass], Seq(classTag[Int]), classTag[String]) ) - val casesIter = for { + val casesIter: Seq[(ClassTag[_$1], ClassTag[_$2], ClassTag[_$3]) forSome { type _$1; type _$2; type _$3 }] = for { cas <- cases two <- cas.twos } yield (cas.one, two, cas.result) diff --git a/quill-codegen-jdbc/src/test/scala/io/getquill/codegen/SimpleCodegenSpec.scala b/quill-codegen-jdbc/src/test/scala/io/getquill/codegen/SimpleCodegenSpec.scala index c1b3c73a42..b236c5f514 100644 --- a/quill-codegen-jdbc/src/test/scala/io/getquill/codegen/SimpleCodegenSpec.scala +++ b/quill-codegen-jdbc/src/test/scala/io/getquill/codegen/SimpleCodegenSpec.scala @@ -11,21 +11,21 @@ class SimpleCodegenSpec extends AnyFreeSpec with Matchers { case class FieldData(fieldName: String, dataType: String, columnName: String) case class FieldDataGroup(data: FieldData*) { - def ccList = data.map(fd => (fd.fieldName, fd.dataType)) + def ccList: Seq[(String, String)] = data.map(fd => (fd.fieldName, fd.dataType)) - def querySchemaList = data.map(fd => (fd.fieldName, fd.columnName)) + def querySchemaList: Seq[(String, String)] = data.map(fd => (fd.fieldName, fd.columnName)) } - def fdg(data: FieldData*) = FieldDataGroup(data: _*) + def fdg(data: FieldData*): FieldDataGroup = FieldDataGroup(data: _*) - def fdgConv(data: (String, String)*)(converter: String => String) = + def fdgConv(data: (String, String)*)(converter: String => String): FieldDataGroup = FieldDataGroup(data.map { case (field, dataType) => FieldData(field, dataType, converter(field)) }: _*) case class QuerySchema(defName: String, tableName: String, fields: Seq[(String, String)]) - def assertStandardObject(objectCode: String, objectName: String, ccName: String, querySchemas: Seq[QuerySchema]) = { + def assertStandardObject(objectCode: String, objectName: String, ccName: String, querySchemas: Seq[QuerySchema]): Unit = { val tb = runtimeMirror(this.getClass.getClassLoader).mkToolBox() val ob = tb.parse(objectCode) ob match { @@ -112,7 +112,7 @@ class SimpleCodegenSpec extends AnyFreeSpec with Matchers { } } - def assertCaseClass(generatedCode: String, className: String, fields: Seq[(String, String)]) = { + def assertCaseClass(generatedCode: String, className: String, fields: Seq[(String, String)]): Unit = { val tb = runtimeMirror(this.getClass.getClassLoader).mkToolBox() val cc = tb.parse(generatedCode) cc match { diff --git a/quill-codegen-jdbc/src/test/scala/io/getquill/codegen/StructuralTests.scala b/quill-codegen-jdbc/src/test/scala/io/getquill/codegen/StructuralTests.scala index 2f7381498c..7883442e9c 100644 --- a/quill-codegen-jdbc/src/test/scala/io/getquill/codegen/StructuralTests.scala +++ b/quill-codegen-jdbc/src/test/scala/io/getquill/codegen/StructuralTests.scala @@ -8,7 +8,7 @@ import io.getquill.codegen.util.SchemaConfig._ class StructuralTests extends SimpleCodegenSpec with WithStandardCodegen { - def LOG = Logger(getClass) + def LOG: Logger = Logger(getClass) override def defaultNamespace: String = "schema" "simple end to end tests" - { @@ -40,7 +40,7 @@ class StructuralTests extends SimpleCodegenSpec with WithStandardCodegen { gens(0).tableSchemasCode, "Person", "Person", - Seq(QuerySchema("person", "PUBLIC.PERSON", List())) + Seq(QuerySchema("person", "PUBLIC.PERSON", List.empty)) ) } @@ -55,7 +55,7 @@ class StructuralTests extends SimpleCodegenSpec with WithStandardCodegen { gens(0).tableSchemasCode, "Address", "Address", - Seq(QuerySchema("address", "PUBLIC.ADDRESS", List())) + Seq(QuerySchema("address", "PUBLIC.ADDRESS", List.empty)) ) assertCaseClass(gens(1).caseClassesCode, "Person", personData.ccList) @@ -63,7 +63,7 @@ class StructuralTests extends SimpleCodegenSpec with WithStandardCodegen { gens(1).tableSchemasCode, "Person", "Person", - Seq(QuerySchema("person", "PUBLIC.PERSON", List())) + Seq(QuerySchema("person", "PUBLIC.PERSON", List.empty)) ) } } @@ -188,7 +188,7 @@ class StructuralTests extends SimpleCodegenSpec with WithStandardCodegen { gens(0).tableSchemasCode, "address", "address", - Seq(QuerySchema("address", "PUBLIC.ADDRESS", List())) + Seq(QuerySchema("address", "PUBLIC.ADDRESS", List.empty)) ) assertCaseClass(gens(1).caseClassesCode, "person", personData.ccList) @@ -197,8 +197,8 @@ class StructuralTests extends SimpleCodegenSpec with WithStandardCodegen { "person", "person", Seq( - QuerySchema("alphaPerson", "PUBLIC.ALPHA_PERSON", List()), - QuerySchema("bravoPerson", "PUBLIC.BRAVO_PERSON", List()) + QuerySchema("alphaPerson", "PUBLIC.ALPHA_PERSON", List.empty), + QuerySchema("bravoPerson", "PUBLIC.BRAVO_PERSON", List.empty) ) ) } @@ -216,7 +216,7 @@ class StructuralTests extends SimpleCodegenSpec with WithStandardCodegen { gens(0).tableSchemasCode, "address", "address", - Seq(QuerySchema("address", "PUBLIC.ADDRESS", List())) + Seq(QuerySchema("address", "PUBLIC.ADDRESS", List.empty)) ) assertCaseClass(gens(1).caseClassesCode, "person", personData.ccList) @@ -225,8 +225,8 @@ class StructuralTests extends SimpleCodegenSpec with WithStandardCodegen { "person", "person", Seq( - QuerySchema("alphaPerson", "PUBLIC.ALPHA_PERSON", List()), - QuerySchema("bravoPerson", "PUBLIC.BRAVO_PERSON", List()) + QuerySchema("alphaPerson", "PUBLIC.ALPHA_PERSON", List.empty), + QuerySchema("bravoPerson", "PUBLIC.BRAVO_PERSON", List.empty) ) ) } @@ -260,7 +260,7 @@ class StructuralTests extends SimpleCodegenSpec with WithStandardCodegen { gens(0).tableSchemasCode, "Address", "Address", - Seq(QuerySchema("address", "PUBLIC.ADDRESS", List())) + Seq(QuerySchema("address", "PUBLIC.ADDRESS", List.empty)) ) assertCaseClass(gens(1).caseClassesCode, "Person", personData.ccList) @@ -269,8 +269,8 @@ class StructuralTests extends SimpleCodegenSpec with WithStandardCodegen { "Person", "Person", Seq( - QuerySchema("alphaPerson", "PUBLIC.ALPHA_PERSON", List()), - QuerySchema("bravoPerson", "PUBLIC.BRAVO_PERSON", List()) + QuerySchema("alphaPerson", "PUBLIC.ALPHA_PERSON", List.empty), + QuerySchema("bravoPerson", "PUBLIC.BRAVO_PERSON", List.empty) ) ) } @@ -307,7 +307,7 @@ class StructuralTests extends SimpleCodegenSpec with WithStandardCodegen { gens(0).tableSchemasCode, "Address", "Address", - Seq(QuerySchema("publicAddress", "PUBLIC.ADDRESS", List())) + Seq(QuerySchema("publicAddress", "PUBLIC.ADDRESS", List.empty)) ) assertCaseClass(gens(1).caseClassesCode, "Person", personData.ccList) @@ -316,8 +316,8 @@ class StructuralTests extends SimpleCodegenSpec with WithStandardCodegen { "Person", "Person", Seq( - QuerySchema("bravoPerson", "BRAVO.PERSON", List()), - QuerySchema("alphaPerson", "ALPHA.PERSON", List()) + QuerySchema("bravoPerson", "BRAVO.PERSON", List.empty), + QuerySchema("alphaPerson", "ALPHA.PERSON", List.empty) ) ) } diff --git a/quill-codegen-jdbc/src/test/scala/io/getquill/codegen/WithStandardCodegen.scala b/quill-codegen-jdbc/src/test/scala/io/getquill/codegen/WithStandardCodegen.scala index 4d48c224c8..6cd1d0e530 100644 --- a/quill-codegen-jdbc/src/test/scala/io/getquill/codegen/WithStandardCodegen.scala +++ b/quill-codegen-jdbc/src/test/scala/io/getquill/codegen/WithStandardCodegen.scala @@ -19,7 +19,7 @@ trait WithStandardCodegen { entityNamingStrategy: NameParser = LiteralNames, entityNamespacer: Namespacer[JdbcTableMeta] = ts => ts.tableSchema.getOrElse(defaultNamespace), entityMemberNamer: JdbcQuerySchemaNaming = ts => ts.tableName.snakeToLowerCamel - ) = + ): JdbcGeneratorBase = new JdbcGeneratorBase(() => { DriverManager.getConnection( s"jdbc:h2:mem:sample;INIT=RUNSCRIPT FROM 'classpath:h2_schema_precursor.sql'\\;RUNSCRIPT FROM 'classpath:${schemaConfig.fileName}'", diff --git a/quill-codegen-jdbc/src/test/scala/io/getquill/codegen/integration/CodegenTestCaseRunner.scala b/quill-codegen-jdbc/src/test/scala/io/getquill/codegen/integration/CodegenTestCaseRunner.scala index d8b01766a0..c935499fd8 100644 --- a/quill-codegen-jdbc/src/test/scala/io/getquill/codegen/integration/CodegenTestCaseRunner.scala +++ b/quill-codegen-jdbc/src/test/scala/io/getquill/codegen/integration/CodegenTestCaseRunner.scala @@ -8,6 +8,7 @@ import org.slf4j.LoggerFactory import scala.concurrent.duration.Duration import scala.concurrent.Await +import java.nio.file.Path object SchemaNames { val simpleSnake = `schema_snakecase` @@ -31,7 +32,7 @@ object CodegenTestCaseRunner { } } - def apply(dbPrefix: ConfigPrefix, path: String) = + def apply(dbPrefix: ConfigPrefix, path: String): List[Path] = CodegenTestCases(dbPrefix).map { gen => logger.info(s"Generating files for: ${dbPrefix.value} (${dbPrefix.packagePath}) with ${gen}") // Since auto-commit in enabled, need to wait for each test-case individually. Otherwise tests diff --git a/quill-codegen-jdbc/src/test/scala/io/getquill/codegen/integration/CodegenTestCases.scala b/quill-codegen-jdbc/src/test/scala/io/getquill/codegen/integration/CodegenTestCases.scala index 41df2b9528..c38f30e803 100644 --- a/quill-codegen-jdbc/src/test/scala/io/getquill/codegen/integration/CodegenTestCases.scala +++ b/quill-codegen-jdbc/src/test/scala/io/getquill/codegen/integration/CodegenTestCases.scala @@ -29,7 +29,7 @@ sealed trait CodegenTestCases { sym.name.decodedName.toString + "-lib" } - def schemaMakerCoordinates(dbPrefix: ConfigPrefix) = SchemaMakerCoordinates(dbPrefix, naming, schemaConfig) + def schemaMakerCoordinates(dbPrefix: ConfigPrefix): SchemaMakerCoordinates = SchemaMakerCoordinates(dbPrefix, naming, schemaConfig) def generateWithSchema(dbPrefix: ConfigPrefix, basePath: String): Future[Seq[Path]] = SchemaMaker.withContext(schemaMakerCoordinates(dbPrefix))({ @@ -37,22 +37,22 @@ sealed trait CodegenTestCases { }) protected def generate(dbPrefix: ConfigPrefix, basePath: String): Future[Seq[Path]] - protected def pathList(implicit dbPrefix: ConfigPrefix) = + protected def pathList(implicit dbPrefix: ConfigPrefix): List[String] = List("io", "getquill", "codegen", "generated", dbPrefix.packagePath) - protected def path(implicit dbPrefix: ConfigPrefix, basePath: String) = + protected def path(implicit dbPrefix: ConfigPrefix, basePath: String): String = (basePath +: pathList :+ testName).mkString("/") - protected def `package`(implicit dbPrefix: ConfigPrefix) = (pathList :+ s"`${testName}`").mkString(".") + protected def `package`(implicit dbPrefix: ConfigPrefix): String = (pathList :+ s"`${testName}`").mkString(".") } object CodegenTestCases { - trait `1-simple-snake` extends CodegenTestCases - trait `2-simple-literal` extends CodegenTestCases - trait `1-comp-sanity` extends CodegenTestCases - trait `2-comp-stereo-single` extends CodegenTestCases - trait `3-comp-stereo-oneschema` extends CodegenTestCases - trait `4-comp-stereo-twoschema` extends CodegenTestCases - trait `5-comp-non-stereo-allschema` extends CodegenTestCases + sealed trait `1-simple-snake` extends CodegenTestCases + sealed trait `2-simple-literal` extends CodegenTestCases + sealed trait `1-comp-sanity` extends CodegenTestCases + sealed trait `2-comp-stereo-single` extends CodegenTestCases + sealed trait `3-comp-stereo-oneschema` extends CodegenTestCases + sealed trait `4-comp-stereo-twoschema` extends CodegenTestCases + sealed trait `5-comp-non-stereo-allschema` extends CodegenTestCases case object `1-simple-snake` extends TestInfo(SnakeCase, simpleSnake) with `1-simple-snake` { override def generate(dbPrefix: ConfigPrefix, basePath: String) = { @@ -138,7 +138,7 @@ object CodegenTestCases { override def nameParser: NameParser = CustomNames() override def filter(tc: RawSchema[JdbcTableMeta, JdbcColumnMeta]): Boolean = schemaFilter(databaseType, tc) && super.filter(tc) - override def namespacer: Namespacer[JdbcTableMeta] = ts => "public" + override def namespacer: Namespacer[JdbcTableMeta] = _ => "public" override def querySchemaNaming: JdbcQuerySchemaNaming = ts => { val schema = super.namespacer(ts) (if (schema startsWith "codegenTest") "public" else schema) + ts.tableName.toLowerCase.capitalize diff --git a/quill-codegen-jdbc/src/test/scala/io/getquill/codegen/integration/DbHelper.scala b/quill-codegen-jdbc/src/test/scala/io/getquill/codegen/integration/DbHelper.scala index 61df0a8362..b060e56b5f 100644 --- a/quill-codegen-jdbc/src/test/scala/io/getquill/codegen/integration/DbHelper.scala +++ b/quill-codegen-jdbc/src/test/scala/io/getquill/codegen/integration/DbHelper.scala @@ -78,7 +78,7 @@ object DbHelper { } - def dropTables(ds: DataSource with Closeable) = { + def dropTables(ds: DataSource with Closeable): Unit = { val databaseType = getDatabaseType(ds) diff --git a/quill-codegen-jdbc/src/test/scala/io/getquill/codegen/util/ConfigPrefix.scala b/quill-codegen-jdbc/src/test/scala/io/getquill/codegen/util/ConfigPrefix.scala index ffb870719a..61ca3d3bfc 100644 --- a/quill-codegen-jdbc/src/test/scala/io/getquill/codegen/util/ConfigPrefix.scala +++ b/quill-codegen-jdbc/src/test/scala/io/getquill/codegen/util/ConfigPrefix.scala @@ -37,7 +37,7 @@ object ConfigPrefix { case object TestSqliteDB extends TestSqliteDB case object TestSqlServerDB extends TestSqlServerDB - def all = List( + def all: List[ConfigPrefix] = List( TestH2DB, TestMysqlDB, TestOracleDB, diff --git a/quill-codegen-jdbc/src/test/scala/io/getquill/codegen/util/OptionOps.scala b/quill-codegen-jdbc/src/test/scala/io/getquill/codegen/util/OptionOps.scala index e92ad77af2..c4ce013a1f 100644 --- a/quill-codegen-jdbc/src/test/scala/io/getquill/codegen/util/OptionOps.scala +++ b/quill-codegen-jdbc/src/test/scala/io/getquill/codegen/util/OptionOps.scala @@ -10,6 +10,6 @@ object OptionOps { } } implicit class StringOptionExt(opt: Option[String]) { - def andNotEmpty = opt.flatMap(s => if (s.trim.isEmpty) None else Some(s)) + def andNotEmpty: Option[String] = opt.flatMap(s => if (s.trim.isEmpty) None else Some(s)) } } diff --git a/quill-codegen-jdbc/src/test/scala/io/getquill/codegen/util/SchemaMaker.scala b/quill-codegen-jdbc/src/test/scala/io/getquill/codegen/util/SchemaMaker.scala index 4c5c830f5e..c6573062f2 100644 --- a/quill-codegen-jdbc/src/test/scala/io/getquill/codegen/util/SchemaMaker.scala +++ b/quill-codegen-jdbc/src/test/scala/io/getquill/codegen/util/SchemaMaker.scala @@ -18,7 +18,7 @@ abstract class CodegenSpec extends AnyFreeSpec with SchemaMaker { object SchemaMaker extends SchemaMaker -case class SchemaMakerCoordinates(dbPrefix: ConfigPrefix, naming: NamingStrategy, schemaConfig: SchemaConfig) +final case class SchemaMakerCoordinates(dbPrefix: ConfigPrefix, naming: NamingStrategy, schemaConfig: SchemaConfig) trait SchemaMaker { @@ -34,6 +34,6 @@ trait SchemaMaker { def withContext[T](coords: SchemaMakerCoordinates)(testCode: => T): T = { import coords._ - withDatasource(schemaConfig, dbPrefix)(ds => testCode) + withDatasource(schemaConfig, dbPrefix)(_ => testCode) } } diff --git a/quill-codegen/src/main/scala/io/getquill/codegen/util/StringUtil.scala b/quill-codegen/src/main/scala/io/getquill/codegen/util/StringUtil.scala index aa17ca91b6..ac8f30b29c 100644 --- a/quill-codegen/src/main/scala/io/getquill/codegen/util/StringUtil.scala +++ b/quill-codegen/src/main/scala/io/getquill/codegen/util/StringUtil.scala @@ -12,7 +12,7 @@ object StringUtil { implicit final class StringExtensions(private val str: String) extends AnyVal { def snakeToUpperCamel: String = str.split("_").map(_.toLowerCase).map(_.capitalize).mkString - def snakeToLowerCamel: String = str.split("_").map(_.toLowerCase).map(_.capitalize).mkString.uncapitalize + def snakeToLowerCamel: String = str.split("_").map(_.toLowerCase).map(_.capitalize).mkString.uncapitalize def lowerCamelToSnake: String = str.split("(?=[A-Z])").mkString("_").toLowerCase def uncapitalize = new String( diff --git a/quill-core/src/main/scala/io/getquill/monad/IOMonad.scala b/quill-core/src/main/scala/io/getquill/monad/IOMonad.scala index 6f0af6de56..9fc14ab807 100644 --- a/quill-core/src/main/scala/io/getquill/monad/IOMonad.scala +++ b/quill-core/src/main/scala/io/getquill/monad/IOMonad.scala @@ -11,9 +11,9 @@ import io.getquill.util.Messages.fail sealed trait Effect object Effect { - trait Read extends Effect - trait Write extends Effect - trait Transaction extends Effect + sealed trait Read extends Effect + sealed trait Write extends Effect + sealed trait Transaction extends Effect } trait IOMonad { diff --git a/quill-core/src/test/scala/io/getquill/AsyncMirrorContextSpec.scala b/quill-core/src/test/scala/io/getquill/AsyncMirrorContextSpec.scala index a2903c3eaf..e3705f59bc 100644 --- a/quill-core/src/test/scala/io/getquill/AsyncMirrorContextSpec.scala +++ b/quill-core/src/test/scala/io/getquill/AsyncMirrorContextSpec.scala @@ -36,7 +36,7 @@ class AsyncMirrorContextSpec extends Spec { } "prepare" in { - ctx.prepareParams("", (ps, session) => (Nil, ps.add("Sarah").add(127))) mustEqual List("'Sarah'", "127") + ctx.prepareParams("", (ps, _) => (List.empty, ps.add("Sarah").add(127))) mustEqual List("'Sarah'", "127") } "probe" in { diff --git a/quill-core/src/test/scala/io/getquill/MirrorContextSpec.scala b/quill-core/src/test/scala/io/getquill/MirrorContextSpec.scala index 4928fe33ea..8cc6004d6f 100644 --- a/quill-core/src/test/scala/io/getquill/MirrorContextSpec.scala +++ b/quill-core/src/test/scala/io/getquill/MirrorContextSpec.scala @@ -3,7 +3,7 @@ package io.getquill import io.getquill.base.Spec class MirrorContextSpec extends Spec { - val ctx = new MirrorContext(MirrorIdiom, Literal) with TestEntities + val ctx: MirrorContext[MirrorIdiom.type,Literal.type] with TestEntities = new MirrorContext(MirrorIdiom, Literal) with TestEntities "probe" in { ctx.probe("Ok").toOption mustBe defined diff --git a/quill-core/src/test/scala/io/getquill/OpsSpec.scala b/quill-core/src/test/scala/io/getquill/OpsSpec.scala index 69934dc5b2..b448a6229e 100644 --- a/quill-core/src/test/scala/io/getquill/OpsSpec.scala +++ b/quill-core/src/test/scala/io/getquill/OpsSpec.scala @@ -12,12 +12,12 @@ class OpsSpec extends Spec { val q = quote { query[TestEntity] } - q.ast mustEqual Entity("TestEntity", Nil, TestEntityQuat) + q.ast mustEqual Entity("TestEntity", List.empty, TestEntityQuat) } "implicitly" in { val q: Quoted[Query[TestEntity]] = query[TestEntity] - q.ast mustEqual Entity("TestEntity", Nil, TestEntityQuat) + q.ast mustEqual Entity("TestEntity", List.empty, TestEntityQuat) } } @@ -27,14 +27,14 @@ class OpsSpec extends Spec { unquote(qr1).map(t => t) } val quat = TestEntityQuat - q.ast mustEqual Map(Entity("TestEntity", Nil, quat), Ident("t", quat), Ident("t", quat)) + q.ast mustEqual Map(Entity("TestEntity", List.empty, quat), Ident("t", quat), Ident("t", quat)) } "implicitly" in { val q = quote { qr1.map(t => t) } val quat = TestEntityQuat - q.ast mustEqual Map(Entity("TestEntity", Nil, quat), Ident("t", quat), Ident("t", quat)) + q.ast mustEqual Map(Entity("TestEntity", List.empty, quat), Ident("t", quat), Ident("t", quat)) } } @@ -44,7 +44,7 @@ class OpsSpec extends Spec { val q = quote { sql"true".as[Boolean] } - q.ast mustEqual Infix(List("true"), Nil, false, false, Quat.BooleanValue) + q.ast mustEqual Infix(List("true"), List.empty, false, false, Quat.BooleanValue) } } "other values" - { @@ -52,13 +52,13 @@ class OpsSpec extends Spec { val q = quote { sql"1".as[Int] } - q.ast mustEqual Infix(List("1"), Nil, false, false, Quat.Value) + q.ast mustEqual Infix(List("1"), List.empty, false, false, Quat.Value) } "without `as`" in { val q = quote { sql"1" } - q.ast mustEqual Infix(List("1"), Nil, false, false, Quat.Value) + q.ast mustEqual Infix(List("1"), List.empty, false, false, Quat.Value) } } } @@ -74,24 +74,24 @@ class OpsSpec extends Spec { } implicit class QueryOps[Q <: Query[_]](q: Q) { - def allowFiltering = quote(sql"$q ALLOW FILTERING".as[Q]) + def allowFiltering: Quoted[Q] = quote(sql"$q ALLOW FILTERING".as[Q]) } "unquotes quoted function bodies automatically" - { "one param" in { - val q: Quoted[Int => EntityQuery[TestEntity]] = quote { (i: Int) => + val q: Quoted[Int => EntityQuery[TestEntity]] = quote { (_: Int) => query[TestEntity].allowFiltering } - val n = quote { (i: Int) => + val n = quote { (_: Int) => unquote(query[TestEntity].allowFiltering) } q.ast mustEqual n.ast } "multiple params" in { - val q: Quoted[(Int, Int, Int) => EntityQuery[TestEntity]] = quote { (i: Int, j: Int, k: Int) => + val q: Quoted[(Int, Int, Int) => EntityQuery[TestEntity]] = quote { (_: Int, _: Int, _: Int) => query[TestEntity].allowFiltering } - val n = quote { (i: Int, j: Int, k: Int) => + val n = quote { (_: Int, _: Int, _: Int) => unquote(query[TestEntity].allowFiltering) } q.ast mustEqual n.ast diff --git a/quill-core/src/test/scala/io/getquill/OptionalProductEncodingSpec.scala b/quill-core/src/test/scala/io/getquill/OptionalProductEncodingSpec.scala index 5a6326ca21..8ae6382e7c 100644 --- a/quill-core/src/test/scala/io/getquill/OptionalProductEncodingSpec.scala +++ b/quill-core/src/test/scala/io/getquill/OptionalProductEncodingSpec.scala @@ -9,9 +9,9 @@ class OptionalProductEncodingSpec extends Spec { import ctx._ "optional product with optional embedded row" in { - case class Name(first: String, last: Int) - case class Person(id: Int, name: Option[Name], age: Int) - case class Address(owner: Int, street: String) + final case class Name(first: String, last: Int) + final case class Person(id: Int, name: Option[Name], age: Int) + final case class Address(owner: Int, street: String) val result = ctx.run { @@ -45,10 +45,10 @@ class OptionalProductEncodingSpec extends Spec { } "optional product with multiple nested optional embeds" in { - case class InnerName(title: Int, last: String) - case class Name(first: String, last: Option[InnerName]) - case class Address(owner: Int, street: String) - case class Person(id: Int, name: Option[Name]) + final case class InnerName(title: Int, last: String) + final case class Name(first: String, last: Option[InnerName]) + final case class Address(owner: Int, street: String) + final case class Person(id: Int, name: Option[Name]) val result = ctx.run { @@ -69,9 +69,9 @@ class OptionalProductEncodingSpec extends Spec { } "optional product with nested optional with optional leaf" in { - case class Name(first: String, last: Option[Int]) - case class Address(owner: Int, street: String) - case class Person(id: Int, name: Option[Name], age: Int) + final case class Name(first: String, last: Option[Int]) + final case class Address(owner: Int, street: String) + final case class Person(id: Int, name: Option[Name], age: Int) val result = ctx.run { diff --git a/quill-core/src/test/scala/io/getquill/QueryProbingSpec.scala b/quill-core/src/test/scala/io/getquill/QueryProbingSpec.scala index bde499a7e1..4dd5589ecf 100644 --- a/quill-core/src/test/scala/io/getquill/QueryProbingSpec.scala +++ b/quill-core/src/test/scala/io/getquill/QueryProbingSpec.scala @@ -18,7 +18,7 @@ class QueryProbingSpec extends Spec { } "fails compilation if the query probing fails" in { - case class Fail() + final case class Fail() import mirrorContextWithQueryProbing._ "mirrorContextWithQueryProbing.run(query[Fail].delete)" mustNot compile } diff --git a/quill-core/src/test/scala/io/getquill/TestEntities.scala b/quill-core/src/test/scala/io/getquill/TestEntities.scala index 0fab009b40..14ddef3b26 100644 --- a/quill-core/src/test/scala/io/getquill/TestEntities.scala +++ b/quill-core/src/test/scala/io/getquill/TestEntities.scala @@ -8,12 +8,12 @@ trait TestEntities { case class TestEntity(s: String, i: Int, l: Long, o: Option[Int], b: Boolean) - lazy val testEntitySchemaMeta = schemaMeta[TestEntity]( + lazy val testEntitySchemaMeta: SchemaMeta[TestEntity] = schemaMeta[TestEntity]( "TestEntity", _.s -> "s" ) - lazy val testEntityQuerySchema = quote( + lazy val testEntityQuerySchema: Quoted[EntityQuery[TestEntity]] = quote( querySchema[TestEntity]( "TestEntity", _.s -> "s", @@ -36,37 +36,37 @@ trait TestEntities { private val QV = Quat.Value private val QBV = Quat.BooleanValue - val TestEntityQuat = Quat.Product("TestEntity", "s" -> QV, "i" -> QV, "l" -> QV, "o" -> QV, "b" -> QBV) - val TestEntityEmbQuat = + val TestEntityQuat: Quat.Product = Quat.Product("TestEntity", "s" -> QV, "i" -> QV, "l" -> QV, "o" -> QV, "b" -> QBV) + val TestEntityEmbQuat: Quat.Product = Quat.Product("TestEntityEmb", "emb" -> Quat.Product("Emb", "s" -> QV, "i" -> QV), "l" -> QV, "o" -> QV) - val TestEntity2Quat = Quat.Product("TestEntity2", "s" -> QV, "i" -> QV, "l" -> QV, "o" -> QV) - val TestEntity3Quat = Quat.Product("TestEntity3", "s" -> QV, "i" -> QV, "l" -> QV, "o" -> QV) - val TestEntity4Quat = Quat.Product("TestEntity4", "i" -> QV) - val TestEntity5Quat = Quat.Product("TestEntity5", "i" -> QV, "s" -> QV) - val TestEntity4EmbQuat = Quat.Product("TestEntity4Emb", "emb" -> Quat.Product("EmbSingle", "i" -> QV)) + val TestEntity2Quat: Quat.Product = Quat.Product("TestEntity2", "s" -> QV, "i" -> QV, "l" -> QV, "o" -> QV) + val TestEntity3Quat: Quat.Product = Quat.Product("TestEntity3", "s" -> QV, "i" -> QV, "l" -> QV, "o" -> QV) + val TestEntity4Quat: Quat.Product = Quat.Product("TestEntity4", "i" -> QV) + val TestEntity5Quat: Quat.Product = Quat.Product("TestEntity5", "i" -> QV, "s" -> QV) + val TestEntity4EmbQuat: Quat.Product = Quat.Product("TestEntity4Emb", "emb" -> Quat.Product("EmbSingle", "i" -> QV)) - val qr1 = quote { + val qr1: Quoted[EntityQuery[TestEntity]] = quote { query[TestEntity] } - val qr1Emb = quote { + val qr1Emb: Quoted[EntityQuery[TestEntityEmb]] = quote { querySchema[TestEntityEmb]("TestEntity") } - val qr2 = quote { + val qr2: Quoted[EntityQuery[TestEntity2]] = quote { query[TestEntity2] } - val qr3 = quote { + val qr3: Quoted[EntityQuery[TestEntity3]] = quote { query[TestEntity3] } - val qr4 = quote { + val qr4: Quoted[EntityQuery[TestEntity4]] = quote { query[TestEntity4] } - val qr5 = quote { + val qr5: Quoted[EntityQuery[TestEntity5]] = quote { query[TestEntity5] } - val qr4Emb = quote { + val qr4Emb: Quoted[EntityQuery[TestEntity4Emb]] = quote { querySchema[TestEntity4Emb]("TestEntity4") } - val qrRegular = quote { + val qrRegular: Quoted[EntityQuery[TestEntityRegular]] = quote { for { a <- query[TestEntity] } yield TestEntityRegular(a.s, a.l) diff --git a/quill-core/src/test/scala/io/getquill/UnlimitedOptionalEmbeddedSpec.scala b/quill-core/src/test/scala/io/getquill/UnlimitedOptionalEmbeddedSpec.scala index 8b6569ffa3..5bfb53f7fd 100644 --- a/quill-core/src/test/scala/io/getquill/UnlimitedOptionalEmbeddedSpec.scala +++ b/quill-core/src/test/scala/io/getquill/UnlimitedOptionalEmbeddedSpec.scala @@ -17,7 +17,7 @@ class UnlimitedOptionalEmbeddedSpec extends Spec { case class Emb1(e1: Emb2, e2: Option[Emb2]) case class OptEmd(e1: Emb1, e2: Option[Emb1]) - lazy val optEmdEnt = OptEmd( + lazy val optEmdEnt: OptEmd = OptEmd( Emb1( Emb2(Emb3("111"), Some(Emb3("112"))), Some(Emb2(Emb3("121"), Some(Emb3("122")))) @@ -30,7 +30,7 @@ class UnlimitedOptionalEmbeddedSpec extends Spec { ) ) - val qrOptEmd = quote { + val qrOptEmd: Quoted[EntityQuery[OptEmd]] = quote { querySchema[OptEmd]( "OptEmd", _.e1.e1.e1.value -> "value111", diff --git a/quill-core/src/test/scala/io/getquill/VIdent.scala b/quill-core/src/test/scala/io/getquill/VIdent.scala index 1a184170fd..647643a1bc 100644 --- a/quill-core/src/test/scala/io/getquill/VIdent.scala +++ b/quill-core/src/test/scala/io/getquill/VIdent.scala @@ -15,6 +15,6 @@ object VIdent { case _ => None } - def apply(value: String) = + def apply(value: String): Ident = Ident(value, Quat.Value) } diff --git a/quill-core/src/test/scala/io/getquill/ast/AstOpsSpec.scala b/quill-core/src/test/scala/io/getquill/ast/AstOpsSpec.scala index 34e82f1565..bb35727406 100644 --- a/quill-core/src/test/scala/io/getquill/ast/AstOpsSpec.scala +++ b/quill-core/src/test/scala/io/getquill/ast/AstOpsSpec.scala @@ -102,7 +102,7 @@ class AstOpsSpec extends Spec { "returning matcher" - { val insert = Insert( - Entity("Ent", List(), Quat.LeafProduct("prop")), + Entity("Ent", List.empty, Quat.LeafProduct("prop")), List(Assignment(VIdent("p"), Property(VIdent("p"), "prop"), Constant.auto(123))) ) val r = VIdent("r") diff --git a/quill-core/src/test/scala/io/getquill/ast/StatefulTransformerSpec.scala b/quill-core/src/test/scala/io/getquill/ast/StatefulTransformerSpec.scala index 6d6e892780..c928d86e7b 100644 --- a/quill-core/src/test/scala/io/getquill/ast/StatefulTransformerSpec.scala +++ b/quill-core/src/test/scala/io/getquill/ast/StatefulTransformerSpec.scala @@ -7,7 +7,7 @@ import io.getquill.base.Spec class StatefulTransformerSpec extends Spec { case class Subject(state: List[Ast], replace: (Ast, Ast)*) extends StatefulTransformer[List[Ast]] { - override def apply(e: Ast) = + override def apply(e: Ast): (Ast, StatefulTransformer[List[Ast]]) = replace.toMap.get(e) match { case Some(ast) => (ast, Subject(state :+ e, replace: _*)) case None => super.apply(e) @@ -17,8 +17,8 @@ class StatefulTransformerSpec extends Spec { "transforms asts using a transformation state" - { "query" - { "entity" in { - val ast: Ast = Entity("a", Nil, QEP) - Subject(Nil)(ast) match { + val ast: Ast = Entity("a", List.empty, QEP) + Subject(List.empty)(ast) match { case (at, att) => at mustEqual ast att.state mustEqual Nil @@ -26,7 +26,7 @@ class StatefulTransformerSpec extends Spec { } "filter" in { val ast: Ast = Filter(Ident("a"), Ident("b"), Ident("c")) - Subject(Nil, Ident("a") -> Ident("a'"), Ident("b") -> Ident("b'"), Ident("c") -> Ident("c'"))(ast) match { + Subject(List.empty, Ident("a") -> Ident("a'"), Ident("b") -> Ident("b'"), Ident("c") -> Ident("c'"))(ast) match { case (at, att) => at mustEqual Filter(Ident("a'"), Ident("b"), Ident("c'")) att.state mustEqual List(Ident("a"), Ident("c")) @@ -34,7 +34,7 @@ class StatefulTransformerSpec extends Spec { } "map" in { val ast: Ast = Map(Ident("a"), Ident("b"), Ident("c")) - Subject(Nil, Ident("a") -> Ident("a'"), Ident("b") -> Ident("b'"), Ident("c") -> Ident("c'"))(ast) match { + Subject(List.empty, Ident("a") -> Ident("a'"), Ident("b") -> Ident("b'"), Ident("c") -> Ident("c'"))(ast) match { case (at, att) => at mustEqual Map(Ident("a'"), Ident("b"), Ident("c'")) att.state mustEqual List(Ident("a"), Ident("c")) @@ -42,7 +42,7 @@ class StatefulTransformerSpec extends Spec { } "flatMap" in { val ast: Ast = FlatMap(Ident("a"), Ident("b"), Ident("c")) - Subject(Nil, Ident("a") -> Ident("a'"), Ident("b") -> Ident("b'"), Ident("c") -> Ident("c'"))(ast) match { + Subject(List.empty, Ident("a") -> Ident("a'"), Ident("b") -> Ident("b'"), Ident("c") -> Ident("c'"))(ast) match { case (at, att) => at mustEqual FlatMap(Ident("a'"), Ident("b"), Ident("c'")) att.state mustEqual List(Ident("a"), Ident("c")) @@ -50,7 +50,7 @@ class StatefulTransformerSpec extends Spec { } "concatMap" in { val ast: Ast = ConcatMap(Ident("a"), Ident("b"), Ident("c")) - Subject(Nil, Ident("a") -> Ident("a'"), Ident("b") -> Ident("b'"), Ident("c") -> Ident("c'"))(ast) match { + Subject(List.empty, Ident("a") -> Ident("a'"), Ident("b") -> Ident("b'"), Ident("c") -> Ident("c'"))(ast) match { case (at, att) => at mustEqual ConcatMap(Ident("a'"), Ident("b"), Ident("c'")) att.state mustEqual List(Ident("a"), Ident("c")) @@ -58,7 +58,7 @@ class StatefulTransformerSpec extends Spec { } "sortBy" in { val ast: Ast = SortBy(Ident("a"), Ident("b"), Ident("c"), AscNullsFirst) - Subject(Nil, Ident("a") -> Ident("a'"), Ident("b") -> Ident("b'"), Ident("c") -> Ident("c'"))(ast) match { + Subject(List.empty, Ident("a") -> Ident("a'"), Ident("b") -> Ident("b'"), Ident("c") -> Ident("c'"))(ast) match { case (at, att) => at mustEqual SortBy(Ident("a'"), Ident("b"), Ident("c'"), AscNullsFirst) att.state mustEqual List(Ident("a"), Ident("c")) @@ -66,7 +66,7 @@ class StatefulTransformerSpec extends Spec { } "groupBy" in { val ast: Ast = GroupBy(Ident("a"), Ident("b"), Ident("c")) - Subject(Nil, Ident("a") -> Ident("a'"), Ident("b") -> Ident("b'"), Ident("c") -> Ident("c'"))(ast) match { + Subject(List.empty, Ident("a") -> Ident("a'"), Ident("b") -> Ident("b'"), Ident("c") -> Ident("c'"))(ast) match { case (at, att) => at mustEqual GroupBy(Ident("a'"), Ident("b"), Ident("c'")) att.state mustEqual List(Ident("a"), Ident("c")) @@ -74,7 +74,7 @@ class StatefulTransformerSpec extends Spec { } "aggregation" in { val ast: Ast = Aggregation(AggregationOperator.max, Ident("a")) - Subject(Nil, Ident("a") -> Ident("a'"))(ast) match { + Subject(List.empty, Ident("a") -> Ident("a'"))(ast) match { case (at, att) => at mustEqual Aggregation(AggregationOperator.max, Ident("a'")) att.state mustEqual List(Ident("a")) @@ -82,7 +82,7 @@ class StatefulTransformerSpec extends Spec { } "take" in { val ast: Ast = Take(Ident("a"), Ident("b")) - Subject(Nil, Ident("a") -> Ident("a'"), Ident("b") -> Ident("b'"))(ast) match { + Subject(List.empty, Ident("a") -> Ident("a'"), Ident("b") -> Ident("b'"))(ast) match { case (at, att) => at mustEqual Take(Ident("a'"), Ident("b'")) att.state mustEqual List(Ident("a"), Ident("b")) @@ -90,7 +90,7 @@ class StatefulTransformerSpec extends Spec { } "drop" in { val ast: Ast = Drop(Ident("a"), Ident("b")) - Subject(Nil, Ident("a") -> Ident("a'"), Ident("b") -> Ident("b'"))(ast) match { + Subject(List.empty, Ident("a") -> Ident("a'"), Ident("b") -> Ident("b'"))(ast) match { case (at, att) => at mustEqual Drop(Ident("a'"), Ident("b'")) att.state mustEqual List(Ident("a"), Ident("b")) @@ -98,7 +98,7 @@ class StatefulTransformerSpec extends Spec { } "union" in { val ast: Ast = Union(Ident("a"), Ident("b")) - Subject(Nil, Ident("a") -> Ident("a'"), Ident("b") -> Ident("b'"))(ast) match { + Subject(List.empty, Ident("a") -> Ident("a'"), Ident("b") -> Ident("b'"))(ast) match { case (at, att) => at mustEqual Union(Ident("a'"), Ident("b'")) att.state mustEqual List(Ident("a"), Ident("b")) @@ -106,7 +106,7 @@ class StatefulTransformerSpec extends Spec { } "unionAll" in { val ast: Ast = UnionAll(Ident("a"), Ident("b")) - Subject(Nil, Ident("a") -> Ident("a'"), Ident("b") -> Ident("b'"))(ast) match { + Subject(List.empty, Ident("a") -> Ident("a'"), Ident("b") -> Ident("b'"))(ast) match { case (at, att) => at mustEqual UnionAll(Ident("a'"), Ident("b'")) att.state mustEqual List(Ident("a"), Ident("b")) @@ -114,7 +114,7 @@ class StatefulTransformerSpec extends Spec { } "outer join" in { val ast: Ast = Join(FullJoin, Ident("a"), Ident("b"), Ident("c"), Ident("d"), Ident("e")) - Subject(Nil, Ident("a") -> Ident("a'"), Ident("b") -> Ident("b'"), Ident("e") -> Ident("e'"))(ast) match { + Subject(List.empty, Ident("a") -> Ident("a'"), Ident("b") -> Ident("b'"), Ident("e") -> Ident("e'"))(ast) match { case (at, att) => at mustEqual Join(FullJoin, Ident("a'"), Ident("b'"), Ident("c"), Ident("d"), Ident("e'")) att.state mustEqual List(Ident("a"), Ident("b"), Ident("e")) @@ -122,7 +122,7 @@ class StatefulTransformerSpec extends Spec { } "distinct" in { val ast: Ast = Distinct(Ident("a")) - Subject(Nil, Ident("a") -> Ident("a'"))(ast) match { + Subject(List.empty, Ident("a") -> Ident("a'"))(ast) match { case (at, att) => at mustEqual Distinct(Ident("a'")) att.state mustEqual List(Ident("a")) @@ -133,7 +133,7 @@ class StatefulTransformerSpec extends Spec { "operation" - { "unary" in { val ast: Ast = UnaryOperation(BooleanOperator.`!`, Ident("a")) - Subject(Nil, Ident("a") -> Ident("a'"))(ast) match { + Subject(List.empty, Ident("a") -> Ident("a'"))(ast) match { case (at, att) => at mustEqual UnaryOperation(BooleanOperator.`!`, Ident("a'")) att.state mustEqual List(Ident("a")) @@ -141,7 +141,7 @@ class StatefulTransformerSpec extends Spec { } "binary" in { val ast: Ast = BinaryOperation(Ident("a"), BooleanOperator.`&&`, Ident("b")) - Subject(Nil, Ident("a") -> Ident("a'"), Ident("b") -> Ident("b'"))(ast) match { + Subject(List.empty, Ident("a") -> Ident("a'"), Ident("b") -> Ident("b'"))(ast) match { case (at, att) => at mustEqual BinaryOperation(Ident("a'"), BooleanOperator.`&&`, Ident("b'")) att.state mustEqual List(Ident("a"), Ident("b")) @@ -149,7 +149,7 @@ class StatefulTransformerSpec extends Spec { } "function apply" in { val ast: Ast = FunctionApply(Ident("a"), List(Ident("b"), Ident("c"))) - Subject(Nil, Ident("a") -> Ident("a'"), Ident("b") -> Ident("b'"), Ident("c") -> Ident("c'"))(ast) match { + Subject(List.empty, Ident("a") -> Ident("a'"), Ident("b") -> Ident("b'"), Ident("c") -> Ident("c'"))(ast) match { case (at, att) => at mustEqual FunctionApply(Ident("a'"), List(Ident("b'"), Ident("c'"))) att.state mustEqual List(Ident("a"), Ident("b"), Ident("c")) @@ -160,7 +160,7 @@ class StatefulTransformerSpec extends Spec { "value" - { "constant" in { val ast: Ast = Constant.auto("a") - Subject(Nil)(ast) match { + Subject(List.empty)(ast) match { case (at, att) => at mustEqual ast att.state mustEqual Nil @@ -168,7 +168,7 @@ class StatefulTransformerSpec extends Spec { } "null" in { val ast: Ast = NullValue - Subject(Nil)(ast) match { + Subject(List.empty)(ast) match { case (at, att) => at mustEqual ast att.state mustEqual Nil @@ -176,7 +176,7 @@ class StatefulTransformerSpec extends Spec { } "tuple" in { val ast: Ast = Tuple(List(Ident("a"), Ident("b"), Ident("c"))) - Subject(Nil, Ident("a") -> Ident("a'"), Ident("b") -> Ident("b'"), Ident("c") -> Ident("c'"))(ast) match { + Subject(List.empty, Ident("a") -> Ident("a'"), Ident("b") -> Ident("b'"), Ident("c") -> Ident("c'"))(ast) match { case (at, att) => at mustEqual Tuple(List(Ident("a'"), Ident("b'"), Ident("c'"))) att.state mustEqual List(Ident("a"), Ident("b"), Ident("c")) @@ -184,7 +184,7 @@ class StatefulTransformerSpec extends Spec { } "caseclass" in { val ast: Ast = CaseClass("CC", List(("foo", Ident("a")), ("bar", Ident("b")), ("baz", Ident("c")))) - Subject(Nil, Ident("a") -> Ident("a'"), Ident("b") -> Ident("b'"), Ident("c") -> Ident("c'"))(ast) match { + Subject(List.empty, Ident("a") -> Ident("a'"), Ident("b") -> Ident("b'"), Ident("c") -> Ident("c'"))(ast) match { case (at, att) => at mustEqual CaseClass("CC", List(("foo", Ident("a'")), ("bar", Ident("b'")), ("baz", Ident("c'")))) att.state mustEqual List(Ident("a"), Ident("b"), Ident("c")) @@ -196,7 +196,7 @@ class StatefulTransformerSpec extends Spec { "update" in { val ast: Ast = Update(Ident("a"), List(Assignment(Ident("b"), Ident("c"), Ident("d")))) Subject( - Nil, + List.empty, Ident("a") -> Ident("a'"), Ident("b") -> Ident("b'"), Ident("c") -> Ident("c'"), @@ -210,7 +210,7 @@ class StatefulTransformerSpec extends Spec { "insert" in { val ast: Ast = Insert(Ident("a"), List(Assignment(Ident("b"), Ident("c"), Ident("d")))) Subject( - Nil, + List.empty, Ident("a") -> Ident("a'"), Ident("b") -> Ident("b'"), Ident("c") -> Ident("c'"), @@ -223,15 +223,15 @@ class StatefulTransformerSpec extends Spec { } "delete" in { val ast: Ast = Delete(Ident("a")) - Subject(Nil, Ident("a") -> Ident("a'"))(ast) match { + Subject(List.empty, Ident("a") -> Ident("a'"))(ast) match { case (at, att) => at mustEqual Delete(Ident("a'")) att.state mustEqual List(Ident("a")) } } "onConflict" in { - val ast: Ast = OnConflict(Insert(Ident("a"), Nil), OnConflict.NoTarget, OnConflict.Ignore) - Subject(Nil, Ident("a") -> Ident("a'"))(ast) match { + val ast: Ast = OnConflict(Insert(Ident("a"), List.empty), OnConflict.NoTarget, OnConflict.Ignore) + Subject(List.empty, Ident("a") -> Ident("a'"))(ast) match { case (at, att) => at mustEqual OnConflict(Insert(Ident("a'"), Nil), OnConflict.NoTarget, OnConflict.Ignore) att.state mustEqual List(Ident("a")) @@ -242,7 +242,7 @@ class StatefulTransformerSpec extends Spec { "onConflict.target" - { "no" in { val target: OnConflict.Target = OnConflict.NoTarget - Subject(Nil)(target) match { + Subject(List.empty)(target) match { case (at, att) => at mustEqual target att.state mustEqual Nil @@ -250,7 +250,7 @@ class StatefulTransformerSpec extends Spec { } "properties" in { val target: OnConflict.Target = OnConflict.Properties(List(Property(Ident("a"), "b"))) - Subject(Nil, Ident("a") -> Ident("a'"))(target) match { + Subject(List.empty, Ident("a") -> Ident("a'"))(target) match { case (at, att) => at mustEqual OnConflict.Properties(List(Property(Ident("a'"), "b"))) att.state mustEqual List(Ident("a")) @@ -261,7 +261,7 @@ class StatefulTransformerSpec extends Spec { "onConflict.action" - { "ignore" in { val action: OnConflict.Action = OnConflict.Ignore - Subject(Nil)(action) match { + Subject(List.empty)(action) match { case (at, att) => at mustEqual action att.state mustEqual Nil @@ -271,7 +271,7 @@ class StatefulTransformerSpec extends Spec { val action: OnConflict.Action = OnConflict.Update(List(AssignmentDual(Ident("a1"), Ident("a2"), Ident("b"), Ident("c")))) Subject( - Nil, + List.empty, Ident("a1") -> Ident("a1'"), Ident("a2") -> Ident("a2'"), Ident("b") -> Ident("b'"), @@ -288,7 +288,7 @@ class StatefulTransformerSpec extends Spec { "onConflict.excluded" in { val ast: Ast = OnConflict.Excluded(Ident("a")) - Subject(Nil)(ast) match { + Subject(List.empty)(ast) match { case (at, att) => at mustEqual ast att.state mustEqual Nil @@ -297,7 +297,7 @@ class StatefulTransformerSpec extends Spec { "onConflict.existing" in { val ast: Ast = OnConflict.Existing(Ident("a")) - Subject(Nil)(ast) match { + Subject(List.empty)(ast) match { case (at, att) => at mustEqual ast att.state mustEqual Nil @@ -306,7 +306,7 @@ class StatefulTransformerSpec extends Spec { "function" in { val ast: Ast = Function(List(Ident("a")), Ident("a")) - Subject(Nil, Ident("a") -> Ident("a'"))(ast) match { + Subject(List.empty, Ident("a") -> Ident("a'"))(ast) match { case (at, att) => at mustEqual Function(List(Ident("a")), Ident("a'")) att.state mustEqual List(Ident("a")) @@ -315,7 +315,7 @@ class StatefulTransformerSpec extends Spec { "ident" in { val ast: Ast = Ident("a") - Subject(Nil, Ident("a") -> Ident("a'"))(ast) match { + Subject(List.empty, Ident("a") -> Ident("a'"))(ast) match { case (at, att) => at mustEqual Ident("a'") att.state mustEqual List(Ident("a")) @@ -324,7 +324,7 @@ class StatefulTransformerSpec extends Spec { "property" in { val ast: Ast = Property(Ident("a"), "b") - Subject(Nil, Ident("a") -> Ident("a'"))(ast) match { + Subject(List.empty, Ident("a") -> Ident("a'"))(ast) match { case (at, att) => at mustEqual Property(Ident("a'"), "b") att.state mustEqual List(Ident("a")) @@ -333,7 +333,7 @@ class StatefulTransformerSpec extends Spec { "property - fixed" in { val ast: Ast = Property.Opinionated(Ident("a"), "b", Fixed, Visible) - Subject(Nil, Ident("a") -> Ident("a'"))(ast) match { + Subject(List.empty, Ident("a") -> Ident("a'"))(ast) match { case (at, att) => at mustEqual Property.Opinionated(Ident("a'"), "b", Fixed, Visible) att.state mustEqual List(Ident("a")) @@ -342,7 +342,7 @@ class StatefulTransformerSpec extends Spec { "quotedReference" in { val ast: Ast = QuotedReference(null, Ident("a")) - Subject(Nil, Ident("a") -> Ident("a'"))(ast) match { + Subject(List.empty, Ident("a") -> Ident("a'"))(ast) match { case (at, att) => at mustEqual QuotedReference(null, Ident("a'")) att.state mustEqual List(Ident("a")) @@ -351,7 +351,7 @@ class StatefulTransformerSpec extends Spec { "sql" in { val ast: Ast = Infix(List("test"), List(Ident("a")), false, false, QV) - Subject(Nil, Ident("a") -> Ident("a'"))(ast) match { + Subject(List.empty, Ident("a") -> Ident("a'"))(ast) match { case (at, att) => at mustEqual Infix(List("test"), List(Ident("a'")), false, false, QV) att.state mustEqual List(Ident("a")) @@ -360,7 +360,7 @@ class StatefulTransformerSpec extends Spec { "infix - pure" in { val ast: Ast = Infix(List("test"), List(Ident("a")), true, false, QV) - Subject(Nil, Ident("a") -> Ident("a'"))(ast) match { + Subject(List.empty, Ident("a") -> Ident("a'"))(ast) match { case (at, att) => at mustEqual Infix(List("test"), List(Ident("a'")), true, false, QV) att.state mustEqual List(Ident("a")) @@ -369,7 +369,7 @@ class StatefulTransformerSpec extends Spec { "infix - transparent" in { val ast: Ast = Infix(List("test"), List(Ident("a")), false, true, QV) - Subject(Nil, Ident("a") -> Ident("a'"))(ast) match { + Subject(List.empty, Ident("a") -> Ident("a'"))(ast) match { case (at, att) => at mustEqual Infix(List("test"), List(Ident("a'")), false, true, QV) att.state mustEqual List(Ident("a")) @@ -379,7 +379,7 @@ class StatefulTransformerSpec extends Spec { "option operation" - { "flatten" in { val ast: Ast = OptionFlatten(Ident("a")) - Subject(Nil, Ident("a") -> Ident("a'"))(ast) match { + Subject(List.empty, Ident("a") -> Ident("a'"))(ast) match { case (at, att) => at mustEqual OptionFlatten(Ident("a'")) att.state mustEqual List(Ident("a")) @@ -387,7 +387,7 @@ class StatefulTransformerSpec extends Spec { } "Some" in { val ast: Ast = OptionSome(Ident("a")) - Subject(Nil, Ident("a") -> Ident("a'"))(ast) match { + Subject(List.empty, Ident("a") -> Ident("a'"))(ast) match { case (at, att) => at mustEqual OptionSome(Ident("a'")) att.state mustEqual List(Ident("a")) @@ -395,7 +395,7 @@ class StatefulTransformerSpec extends Spec { } "apply" in { val ast: Ast = OptionApply(Ident("a")) - Subject(Nil, Ident("a") -> Ident("a'"))(ast) match { + Subject(List.empty, Ident("a") -> Ident("a'"))(ast) match { case (at, att) => at mustEqual OptionApply(Ident("a'")) att.state mustEqual List(Ident("a")) @@ -403,7 +403,7 @@ class StatefulTransformerSpec extends Spec { } "orNull" in { val ast: Ast = OptionOrNull(Ident("a")) - Subject(Nil, Ident("a") -> Ident("a'"))(ast) match { + Subject(List.empty, Ident("a") -> Ident("a'"))(ast) match { case (at, att) => at mustEqual OptionOrNull(Ident("a'")) att.state mustEqual List(Ident("a")) @@ -411,7 +411,7 @@ class StatefulTransformerSpec extends Spec { } "getOrNull" in { val ast: Ast = OptionGetOrNull(Ident("a")) - Subject(Nil, Ident("a") -> Ident("a'"))(ast) match { + Subject(List.empty, Ident("a") -> Ident("a'"))(ast) match { case (at, att) => at mustEqual OptionGetOrNull(Ident("a'")) att.state mustEqual List(Ident("a")) @@ -419,7 +419,7 @@ class StatefulTransformerSpec extends Spec { } "None" in { val ast: Ast = OptionNone(QV) - Subject(Nil)(ast) match { + Subject(List.empty)(ast) match { case (at, att) => at mustEqual ast att.state mustEqual Nil @@ -427,7 +427,7 @@ class StatefulTransformerSpec extends Spec { } "getOrElse" in { val ast: Ast = OptionGetOrElse(Ident("a"), Ident("b")) - Subject(Nil, Ident("a") -> Ident("a'"), Ident("b") -> Ident("b'"))(ast) match { + Subject(List.empty, Ident("a") -> Ident("a'"), Ident("b") -> Ident("b'"))(ast) match { case (at, att) => at mustEqual OptionGetOrElse(Ident("a'"), Ident("b'")) att.state mustEqual List(Ident("a"), Ident("b")) @@ -435,7 +435,7 @@ class StatefulTransformerSpec extends Spec { } "orElse" in { val ast: Ast = OptionOrElse(Ident("a"), Ident("b")) - Subject(Nil, Ident("a") -> Ident("a'"), Ident("b") -> Ident("b'"))(ast) match { + Subject(List.empty, Ident("a") -> Ident("a'"), Ident("b") -> Ident("b'"))(ast) match { case (at, att) => at mustEqual OptionOrElse(Ident("a'"), Ident("b'")) att.state mustEqual List(Ident("a"), Ident("b")) @@ -443,7 +443,7 @@ class StatefulTransformerSpec extends Spec { } "flatMap - Unchecked" in { val ast: Ast = OptionTableFlatMap(Ident("a"), Ident("b"), Ident("c")) - Subject(Nil, Ident("a") -> Ident("a'"), Ident("b") -> Ident("b'"), Ident("c") -> Ident("c'"))(ast) match { + Subject(List.empty, Ident("a") -> Ident("a'"), Ident("b") -> Ident("b'"), Ident("c") -> Ident("c'"))(ast) match { case (at, att) => at mustEqual OptionTableFlatMap(Ident("a'"), Ident("b"), Ident("c'")) att.state mustEqual List(Ident("a"), Ident("c")) @@ -451,7 +451,7 @@ class StatefulTransformerSpec extends Spec { } "map - Unchecked" in { val ast: Ast = OptionTableMap(Ident("a"), Ident("b"), Ident("c")) - Subject(Nil, Ident("a") -> Ident("a'"), Ident("b") -> Ident("b'"), Ident("c") -> Ident("c'"))(ast) match { + Subject(List.empty, Ident("a") -> Ident("a'"), Ident("b") -> Ident("b'"), Ident("c") -> Ident("c'"))(ast) match { case (at, att) => at mustEqual OptionTableMap(Ident("a'"), Ident("b"), Ident("c'")) att.state mustEqual List(Ident("a"), Ident("c")) @@ -459,7 +459,7 @@ class StatefulTransformerSpec extends Spec { } "flatMap" in { val ast: Ast = OptionFlatMap(Ident("a"), Ident("b"), Ident("c")) - Subject(Nil, Ident("a") -> Ident("a'"), Ident("b") -> Ident("b'"), Ident("c") -> Ident("c'"))(ast) match { + Subject(List.empty, Ident("a") -> Ident("a'"), Ident("b") -> Ident("b'"), Ident("c") -> Ident("c'"))(ast) match { case (at, att) => at mustEqual OptionFlatMap(Ident("a'"), Ident("b"), Ident("c'")) att.state mustEqual List(Ident("a"), Ident("c")) @@ -467,7 +467,7 @@ class StatefulTransformerSpec extends Spec { } "map" in { val ast: Ast = OptionMap(Ident("a"), Ident("b"), Ident("c")) - Subject(Nil, Ident("a") -> Ident("a'"), Ident("b") -> Ident("b'"), Ident("c") -> Ident("c'"))(ast) match { + Subject(List.empty, Ident("a") -> Ident("a'"), Ident("b") -> Ident("b'"), Ident("c") -> Ident("c'"))(ast) match { case (at, att) => at mustEqual OptionMap(Ident("a'"), Ident("b"), Ident("c'")) att.state mustEqual List(Ident("a"), Ident("c")) @@ -475,7 +475,7 @@ class StatefulTransformerSpec extends Spec { } "forall" in { val ast: Ast = OptionForall(Ident("a"), Ident("b"), Ident("c")) - Subject(Nil, Ident("a") -> Ident("a'"), Ident("b") -> Ident("b'"), Ident("c") -> Ident("c'"))(ast) match { + Subject(List.empty, Ident("a") -> Ident("a'"), Ident("b") -> Ident("b'"), Ident("c") -> Ident("c'"))(ast) match { case (at, att) => at mustEqual OptionForall(Ident("a'"), Ident("b"), Ident("c'")) att.state mustEqual List(Ident("a"), Ident("c")) @@ -483,7 +483,7 @@ class StatefulTransformerSpec extends Spec { } "forall - Unchecked" in { val ast: Ast = OptionTableForall(Ident("a"), Ident("b"), Ident("c")) - Subject(Nil, Ident("a") -> Ident("a'"), Ident("b") -> Ident("b'"), Ident("c") -> Ident("c'"))(ast) match { + Subject(List.empty, Ident("a") -> Ident("a'"), Ident("b") -> Ident("b'"), Ident("c") -> Ident("c'"))(ast) match { case (at, att) => at mustEqual OptionTableForall(Ident("a'"), Ident("b"), Ident("c'")) att.state mustEqual List(Ident("a"), Ident("c")) @@ -491,7 +491,7 @@ class StatefulTransformerSpec extends Spec { } "exists - Unchecked" in { val ast: Ast = OptionTableExists(Ident("a"), Ident("b"), Ident("c")) - Subject(Nil, Ident("a") -> Ident("a'"), Ident("b") -> Ident("b'"), Ident("c") -> Ident("c'"))(ast) match { + Subject(List.empty, Ident("a") -> Ident("a'"), Ident("b") -> Ident("b'"), Ident("c") -> Ident("c'"))(ast) match { case (at, att) => at mustEqual OptionTableExists(Ident("a'"), Ident("b"), Ident("c'")) att.state mustEqual List(Ident("a"), Ident("c")) @@ -499,7 +499,7 @@ class StatefulTransformerSpec extends Spec { } "exists" in { val ast: Ast = OptionExists(Ident("a"), Ident("b"), Ident("c")) - Subject(Nil, Ident("a") -> Ident("a'"), Ident("b") -> Ident("b'"), Ident("c") -> Ident("c'"))(ast) match { + Subject(List.empty, Ident("a") -> Ident("a'"), Ident("b") -> Ident("b'"), Ident("c") -> Ident("c'"))(ast) match { case (at, att) => at mustEqual OptionExists(Ident("a'"), Ident("b"), Ident("c'")) att.state mustEqual List(Ident("a"), Ident("c")) @@ -507,7 +507,7 @@ class StatefulTransformerSpec extends Spec { } "contains" in { val ast: Ast = OptionContains(Ident("a"), Ident("c")) - Subject(Nil, Ident("a") -> Ident("a'"), Ident("c") -> Ident("c'"))(ast) match { + Subject(List.empty, Ident("a") -> Ident("a'"), Ident("c") -> Ident("c'"))(ast) match { case (at, att) => at mustEqual OptionContains(Ident("a'"), Ident("c'")) att.state mustEqual List(Ident("a"), Ident("c")) @@ -515,7 +515,7 @@ class StatefulTransformerSpec extends Spec { } "isEmpty" in { val ast: Ast = OptionIsEmpty(Ident("a")) - Subject(Nil, Ident("a") -> Ident("a'"))(ast) match { + Subject(List.empty, Ident("a") -> Ident("a'"))(ast) match { case (at, att) => at mustEqual OptionIsEmpty(Ident("a'")) att.state mustEqual List(Ident("a")) @@ -523,7 +523,7 @@ class StatefulTransformerSpec extends Spec { } "nonEmpty" in { val ast: Ast = OptionNonEmpty(Ident("a")) - Subject(Nil, Ident("a") -> Ident("a'"))(ast) match { + Subject(List.empty, Ident("a") -> Ident("a'"))(ast) match { case (at, att) => at mustEqual OptionNonEmpty(Ident("a'")) att.state mustEqual List(Ident("a")) @@ -531,7 +531,7 @@ class StatefulTransformerSpec extends Spec { } "isDefined" in { val ast: Ast = OptionIsDefined(Ident("a")) - Subject(Nil, Ident("a") -> Ident("a'"))(ast) match { + Subject(List.empty, Ident("a") -> Ident("a'"))(ast) match { case (at, att) => at mustEqual OptionIsDefined(Ident("a'")) att.state mustEqual List(Ident("a")) @@ -542,7 +542,7 @@ class StatefulTransformerSpec extends Spec { "traversable operations" - { "map.contains" in { val ast: Ast = MapContains(Ident("a"), Ident("c")) - Subject(Nil, Ident("a") -> Ident("a'"), Ident("c") -> Ident("c'"))(ast) match { + Subject(List.empty, Ident("a") -> Ident("a'"), Ident("c") -> Ident("c'"))(ast) match { case (at, att) => at mustEqual MapContains(Ident("a'"), Ident("c'")) att.state mustEqual List(Ident("a"), Ident("c")) @@ -550,7 +550,7 @@ class StatefulTransformerSpec extends Spec { } "set.contains" in { val ast: Ast = SetContains(Ident("a"), Ident("c")) - Subject(Nil, Ident("a") -> Ident("a'"), Ident("c") -> Ident("c'"))(ast) match { + Subject(List.empty, Ident("a") -> Ident("a'"), Ident("c") -> Ident("c'"))(ast) match { case (at, att) => at mustEqual SetContains(Ident("a'"), Ident("c'")) att.state mustEqual List(Ident("a"), Ident("c")) @@ -558,7 +558,7 @@ class StatefulTransformerSpec extends Spec { } "list.contains" in { val ast: Ast = ListContains(Ident("a"), Ident("c")) - Subject(Nil, Ident("a") -> Ident("a'"), Ident("c") -> Ident("c'"))(ast) match { + Subject(List.empty, Ident("a") -> Ident("a'"), Ident("c") -> Ident("c'"))(ast) match { case (at, att) => at mustEqual ListContains(Ident("a'"), Ident("c'")) att.state mustEqual List(Ident("a"), Ident("c")) @@ -568,7 +568,7 @@ class StatefulTransformerSpec extends Spec { "if" in { val ast: Ast = If(Ident("a"), Ident("b"), Ident("c")) - Subject(Nil, Ident("a") -> Ident("a'"), Ident("b") -> Ident("b'"), Ident("c") -> Ident("c'"))(ast) match { + Subject(List.empty, Ident("a") -> Ident("a'"), Ident("b") -> Ident("b'"), Ident("c") -> Ident("c'"))(ast) match { case (at, att) => at mustEqual If(Ident("a'"), Ident("b'"), Ident("c'")) att.state mustEqual List(Ident("a"), Ident("b"), Ident("c")) @@ -577,21 +577,21 @@ class StatefulTransformerSpec extends Spec { "dynamic" in { val ast: Ast = Dynamic(Ident("a")) - Subject(Nil, Ident("a") -> Ident("a'"))(ast) match { + Subject(List.empty, Ident("a") -> Ident("a'"))(ast) match { case (at, att) => at mustEqual ast - att.state mustEqual List() + att.state mustEqual List.empty } } "block" in { val ast: Ast = Block( List( - Val(Ident("a"), Entity("a", Nil, QEP)), - Val(Ident("b"), Entity("b", Nil, QEP)) + Val(Ident("a"), Entity("a", List.empty, QEP)), + Val(Ident("b"), Entity("b", List.empty, QEP)) ) ) - Subject(Nil, Entity("a", Nil, QEP) -> Entity("b", Nil, QEP), Entity("b", Nil, QEP) -> Entity("c", Nil, QEP))( + Subject(List.empty, Entity("a", List.empty, QEP) -> Entity("b", List.empty, QEP), Entity("b", List.empty, QEP) -> Entity("c", List.empty, QEP))( ast ) match { case (at, att) => @@ -606,8 +606,8 @@ class StatefulTransformerSpec extends Spec { } "val" in { - val ast: Ast = Val(Ident("a"), Entity("a", Nil, QEP)) - Subject(Nil, Entity("a", Nil, QEP) -> Entity("b", Nil, QEP))(ast) match { + val ast: Ast = Val(Ident("a"), Entity("a", List.empty, QEP)) + Subject(List.empty, Entity("a", List.empty, QEP) -> Entity("b", List.empty, QEP))(ast) match { case (at, att) => at mustEqual Val(Ident("a"), Entity("b", Nil, QEP)) att.state mustEqual List(Entity("a", Nil, QEP)) diff --git a/quill-core/src/test/scala/io/getquill/ast/StatelessTransformerSpec.scala b/quill-core/src/test/scala/io/getquill/ast/StatelessTransformerSpec.scala index d119409019..27d9155fdc 100644 --- a/quill-core/src/test/scala/io/getquill/ast/StatelessTransformerSpec.scala +++ b/quill-core/src/test/scala/io/getquill/ast/StatelessTransformerSpec.scala @@ -14,7 +14,7 @@ class StatelessTransformerSpec extends Spec { "transforms asts" - { "query" - { "entity" in { - val ast: Ast = Entity("a", Nil, QEP) + val ast: Ast = Entity("a", List.empty, QEP) Subject()(ast) mustEqual ast } "filter" in { @@ -161,9 +161,9 @@ class StatelessTransformerSpec extends Spec { Delete(Ident("a'")) } "onConflict" in { - val ast: Ast = OnConflict(Insert(Ident("a"), Nil), OnConflict.NoTarget, OnConflict.Ignore) + val ast: Ast = OnConflict(Insert(Ident("a"), List.empty), OnConflict.NoTarget, OnConflict.Ignore) Subject(Ident("a") -> Ident("a'"))(ast) mustEqual - OnConflict(Insert(Ident("a'"), Nil), OnConflict.NoTarget, OnConflict.Ignore) + OnConflict(Insert(Ident("a'"), List.empty), OnConflict.NoTarget, OnConflict.Ignore) } } @@ -383,25 +383,25 @@ class StatelessTransformerSpec extends Spec { "block" in { val ast: Ast = Block( List( - Val(Ident("a"), Entity("a", Nil, QEP)), - Val(Ident("b"), Entity("b", Nil, QEP)) + Val(Ident("a"), Entity("a", List.empty, QEP)), + Val(Ident("b"), Entity("b", List.empty, QEP)) ) ) - Subject(Entity("a", Nil, QEP) -> Entity("b", Nil, QEP), Entity("b", Nil, QEP) -> Entity("c", Nil, QEP))( + Subject(Entity("a", List.empty, QEP) -> Entity("b", List.empty, QEP), Entity("b", List.empty, QEP) -> Entity("c", List.empty, QEP))( ast ) mustEqual Block( List( - Val(Ident("a"), Entity("b", Nil, QEP)), - Val(Ident("b"), Entity("c", Nil, QEP)) + Val(Ident("a"), Entity("b", List.empty, QEP)), + Val(Ident("b"), Entity("c", List.empty, QEP)) ) ) } "val" in { - val ast: Ast = Val(Ident("a"), Entity("a", Nil, QEP)) - Subject(Entity("a", Nil, QEP) -> Entity("b", Nil, QEP))(ast) mustEqual - Val(Ident("a"), Entity("b", Nil, QEP)) + val ast: Ast = Val(Ident("a"), Entity("a", List.empty, QEP)) + Subject(Entity("a", List.empty, QEP) -> Entity("b", List.empty, QEP))(ast) mustEqual + Val(Ident("a"), Entity("b", List.empty, QEP)) } } } diff --git a/quill-core/src/test/scala/io/getquill/base/EncodingSpec.scala b/quill-core/src/test/scala/io/getquill/base/EncodingSpec.scala index e892a03ad9..0b93012739 100644 --- a/quill-core/src/test/scala/io/getquill/base/EncodingSpec.scala +++ b/quill-core/src/test/scala/io/getquill/base/EncodingSpec.scala @@ -3,6 +3,8 @@ package io.getquill.base import io.getquill.context.Context import java.util.Date +import io.getquill.{ Delete, Insert, Quoted } +import org.scalatest.Assertion trait EncodingSpec extends Spec { @@ -35,11 +37,11 @@ trait EncodingSpec extends Spec { o11: Option[Date] ) - val delete = quote { + val delete: Quoted[Delete[EncodingTestEntity]] = quote { query[EncodingTestEntity].delete } - val insert = quote { + val insert: Quoted[(String, BigDecimal, Boolean, Byte, Short, Int, Long, Float, Double, Array[Byte], Date, Option[String], Option[BigDecimal], Option[Boolean], Option[Byte], Option[Short], Option[Int], Option[Long], Option[Float], Option[Double], Option[Array[Byte]], Option[Date]) => Insert[EncodingTestEntity]] = quote { ( v1: String, v2: BigDecimal, @@ -90,7 +92,7 @@ trait EncodingSpec extends Spec { ) } - val insertValues = + val insertValues: List[(String, BigDecimal, Boolean, Byte, Short, Int, Long, Float, Double, Array[Byte], Date, Option[String], Option[BigDecimal], Option[Boolean], Option[Byte], Option[Short], Option[Int], Option[Long], Option[Float], Option[Double], Option[Array[Byte]], Option[Date])] = List[ ( String, @@ -167,7 +169,7 @@ trait EncodingSpec extends Spec { ) ) - def verify(result: List[EncodingTestEntity]) = + def verify(result: List[EncodingTestEntity]): Assertion = result match { case List(e1, e2) => e1.v1 mustEqual "s" diff --git a/quill-core/src/test/scala/io/getquill/base/Spec.scala b/quill-core/src/test/scala/io/getquill/base/Spec.scala index 6d4d47636d..c74025d404 100644 --- a/quill-core/src/test/scala/io/getquill/base/Spec.scala +++ b/quill-core/src/test/scala/io/getquill/base/Spec.scala @@ -10,14 +10,15 @@ import org.scalatest.matchers.must.Matchers import scala.concurrent.duration.Duration import scala.concurrent.{Await, Future} +import io.getquill.context.ExecutionType abstract class Spec extends AnyFreeSpec with Matchers with BeforeAndAfterAll { val QV = Quat.Value - val QEP = Quat.Product.empty("Product") - def QP(name: String, fields: String*) = Quat.LeafProduct(name, fields: _*) + val QEP: Quat.Product = Quat.Product.empty("Product") + def QP(name: String, fields: String*): Quat.Product = Quat.LeafProduct(name, fields: _*) // Used by various tests to replace temporary idents created by AttachToEntity with 'x' - val replaceTempIdent = new StatelessTransformer { + val replaceTempIdent: StatelessTransformer = new StatelessTransformer { override def applyIdent(id: Ident): Ident = id match { case TemporaryIdent(tid) => @@ -28,7 +29,7 @@ abstract class Spec extends AnyFreeSpec with Matchers with BeforeAndAfterAll { } implicit class QuatOps(quat: Quat) { - def productOrFail() = + def productOrFail(): Quat.Product = quat match { case p: Quat.Product => p case _ => throw new IllegalArgumentException(s"The quat ${quat} is expected to be a product but is not") @@ -38,7 +39,7 @@ abstract class Spec extends AnyFreeSpec with Matchers with BeforeAndAfterAll { def await[T](f: Future[T]): T = Await.result(f, Duration.Inf) implicit class MirrorContextOps(m: BatchActionMirrorGeneric[_]) { - def triple = { + def triple: (String, List[List[Any]], ExecutionType) = { if (m.groups.length != 1) fail(s"Expected all batch groups per design to only have one root element but has multiple ${m.groups}") val (queryString, prepares) = m.groups(0) @@ -55,7 +56,7 @@ abstract class Spec extends AnyFreeSpec with Matchers with BeforeAndAfterAll { ) } - def tripleBatchMulti = + def tripleBatchMulti: List[(String, List[List[Any]], ExecutionType)] = m.groups.map { case (queryString, prepares) => ( queryString, @@ -72,7 +73,7 @@ abstract class Spec extends AnyFreeSpec with Matchers with BeforeAndAfterAll { } implicit class MirrorReturningContextOps[E[_]](m: BatchActionReturningMirrorGeneric[_, _, E]) { - def triple = { + def triple: (String, List[List[Any]], ExecutionType) = { if (m.groups.length != 1) fail(s"Expected all batch groups per design to only have one root element but has multiple ${m.groups}") val (queryString, returnAction, prepares) = m.groups(0) @@ -89,7 +90,7 @@ abstract class Spec extends AnyFreeSpec with Matchers with BeforeAndAfterAll { ) } - def tripleBatchMulti = + def tripleBatchMulti: List[(String, List[List[Any]], ExecutionType)] = m.groups.map { case (queryString, returnAction, prepares) => ( queryString, diff --git a/quill-core/src/test/scala/io/getquill/context/ActionMacroSpec.scala b/quill-core/src/test/scala/io/getquill/context/ActionMacroSpec.scala index 6a75ea3093..01c92233a4 100644 --- a/quill-core/src/test/scala/io/getquill/context/ActionMacroSpec.scala +++ b/quill-core/src/test/scala/io/getquill/context/ActionMacroSpec.scala @@ -54,7 +54,7 @@ class ActionMacroSpec extends Spec { r.returningBehavior mustEqual ReturnRecord } "returning value - with single - should not compile" in testContext.withDialect(MirrorIdiomReturningSingle) { - ctx => + _ => "import ctx._; ctx.run(qr1.insert(t => t.i -> 1).returning(t => t.l))" mustNot compile } "returning value - with multi" in testContext.withDialect(MirrorIdiomReturningMulti) { ctx => @@ -88,7 +88,7 @@ class ActionMacroSpec extends Spec { } "returning generated value - with single - multi should not compile" in testContext.withDialect( MirrorIdiomReturningSingle - ) { ctx => + ) { _ => "import ctx._; ctx.run(qr1.insert(t => t.i -> 1).returningGenerated(t => (t.l, t.i))" mustNot compile } "returning generated value - with multi" in testContext.withDialect(MirrorIdiomReturningMulti) { ctx => @@ -103,7 +103,7 @@ class ActionMacroSpec extends Spec { } "returning generated value - with multi - operation in clause should not compile" in testContext.withDialect( MirrorIdiomReturningMulti - ) { ctx => + ) { _ => "import ctx._; ctx.run(qr1.insert(t => t.i -> 1).returningGenerated(t => (t.l, t.i + 1)))" mustNot compile } "returning generated value - with multi - single" in testContext.withDialect(MirrorIdiomReturningMulti) { ctx => @@ -174,7 +174,7 @@ class ActionMacroSpec extends Spec { r.returningBehavior mustEqual ReturnRecord } "returning value - with single - should not compile" in testContext.withDialect(MirrorIdiomReturningSingle) { - ctx => + _ => "import ctx._; ctx.run(qr1.update(t => t.i -> 1).returning(t => t.l))" mustNot compile } "returning value - with multi" in testContext.withDialect(MirrorIdiomReturningMulti) { ctx => @@ -227,7 +227,7 @@ class ActionMacroSpec extends Spec { r.returningBehavior mustEqual ReturnRecord } "returning value - with single - should not compile" in testContext.withDialect(MirrorIdiomReturningSingle) { - ctx => + _ => "import ctx._; ctx.delete.returning(t => t.l))" mustNot compile } "returning value - with multi" in testContext.withDialect(MirrorIdiomReturningMulti) { ctx => diff --git a/quill-core/src/test/scala/io/getquill/context/BindMacroSpec.scala b/quill-core/src/test/scala/io/getquill/context/BindMacroSpec.scala index 7ccd2ff4fb..9ab6293926 100644 --- a/quill-core/src/test/scala/io/getquill/context/BindMacroSpec.scala +++ b/quill-core/src/test/scala/io/getquill/context/BindMacroSpec.scala @@ -7,7 +7,7 @@ import io.getquill.MirrorContexts.testContext class BindMacroSpec extends Spec { - val session = MirrorSession("test") + val session: MirrorSession = MirrorSession("test") "binds non-batched action" - { "normal" in { diff --git a/quill-core/src/test/scala/io/getquill/context/ContextInstanceSpec.scala b/quill-core/src/test/scala/io/getquill/context/ContextInstanceSpec.scala index 0aba3c57af..5c382abd62 100644 --- a/quill-core/src/test/scala/io/getquill/context/ContextInstanceSpec.scala +++ b/quill-core/src/test/scala/io/getquill/context/ContextInstanceSpec.scala @@ -5,16 +5,16 @@ import io.getquill.context.mirror.{MirrorSession, Row} import io.getquill.MirrorContexts.testContext import io.getquill.MirrorContexts.testContext._ -case class ValueClass(value: Int) extends AnyVal +final case class ValueClass(value: Int) extends AnyVal -case class GenericValueClass[T](value: T) extends AnyVal +final case class GenericValueClass[T](value: T) extends AnyVal class ContextInstanceSpec extends Spec { "provides mapped encoding" - { - case class StringValue(s: String) - case class Entity(s: StringValue) + final case class StringValue(s: String) + final case class Entity(s: StringValue) "context-based" - { "encoding" in { @@ -54,7 +54,7 @@ class ContextInstanceSpec extends Spec { } "encoding set" in { - case class Entity(i: Int) + final case class Entity(i: Int) val q = quote { query[Entity].filter(e => liftQuery(Set(1)).contains(e.i)) } @@ -62,7 +62,7 @@ class ContextInstanceSpec extends Spec { } "encodes value class" - { - case class Entity(x: ValueClass, s: String) + final case class Entity(x: ValueClass, s: String) "encoding" in { val q = quote { @@ -81,7 +81,7 @@ class ContextInstanceSpec extends Spec { } "encodes generic value class" - { - case class Entity(x: GenericValueClass[Int], s: String) + final case class Entity(x: GenericValueClass[Int], s: String) "encoding" in { val q = quote { diff --git a/quill-core/src/test/scala/io/getquill/context/ContextMacroSpec.scala b/quill-core/src/test/scala/io/getquill/context/ContextMacroSpec.scala index 305eabdf8f..e37226830a 100644 --- a/quill-core/src/test/scala/io/getquill/context/ContextMacroSpec.scala +++ b/quill-core/src/test/scala/io/getquill/context/ContextMacroSpec.scala @@ -184,7 +184,7 @@ class ContextMacroSpec extends Spec { } "value class" in { - case class Entity(x: ValueClass) + final case class Entity(x: ValueClass) val q = quote { query[Entity].filter(t => t.x == lift(ValueClass(1))) } @@ -193,7 +193,7 @@ class ContextMacroSpec extends Spec { r.prepareRow mustEqual Row(1) } "generic value class" in { - case class Entity(x: GenericValueClass[Int]) + final case class Entity(x: GenericValueClass[Int]) val q = quote { query[Entity].filter(t => t.x == lift(GenericValueClass(1))) } @@ -219,7 +219,7 @@ class ContextMacroSpec extends Spec { } "dynamic type param" in { def test[T: SchemaMeta: QueryMeta] = quote { - query[T].map(t => lift(1)) + query[T].map(_ => lift(1)) } val r = testContext.run(test[TestEntity]) r.string mustEqual """querySchema("TestEntity").map(t => ?)""" @@ -274,7 +274,7 @@ class ContextMacroSpec extends Spec { } "value class" in { - case class Entity(x: ValueClass) + final case class Entity(x: ValueClass) val q = quote { query[Entity].filter(t => t.x == lift(ValueClass(1))) } @@ -282,7 +282,7 @@ class ContextMacroSpec extends Spec { """querySchema("Entity").filter(t => t.x == 1)""" } "generic value class" in { - case class Entity(x: GenericValueClass[Int]) + final case class Entity(x: GenericValueClass[Int]) val q = quote { query[Entity].filter(t => t.x == lift(GenericValueClass(1))) } @@ -304,7 +304,7 @@ class ContextMacroSpec extends Spec { } "dynamic type param" in { def test[T: SchemaMeta: QueryMeta] = quote { - query[T].map(t => lift(1)) + query[T].map(_ => lift(1)) } testContext.translate(test[TestEntity]) mustEqual """querySchema("TestEntity").map(t => 1)""" @@ -320,7 +320,7 @@ class ContextMacroSpec extends Spec { } "fails if there's a free variable" in { - val q = { + { val i = 1 quote { qr1.filter(_.i == i) diff --git a/quill-core/src/test/scala/io/getquill/context/EncodeBindVariablesSpec.scala b/quill-core/src/test/scala/io/getquill/context/EncodeBindVariablesSpec.scala index 25effb5683..3f2220b14a 100644 --- a/quill-core/src/test/scala/io/getquill/context/EncodeBindVariablesSpec.scala +++ b/quill-core/src/test/scala/io/getquill/context/EncodeBindVariablesSpec.scala @@ -27,8 +27,8 @@ class EncodeBindVariablesSpec extends Spec { } "fails if there isn't an encoder for the bound value" in { - val q = quote { (i: Thread) => - qr1.map(t => i) + quote { (i: Thread) => + qr1.map(_ => i) } "testContext.run(q)(new Thread)" mustNot compile } @@ -37,15 +37,15 @@ class EncodeBindVariablesSpec extends Spec { implicit val doubleEncoder = testContext.encoder[Double] val d = 1d val q = quote { - qr1.map(t => lift(d)) + qr1.map(_ => lift(d)) } testContext.run(q).prepareRow mustEqual Row(1d) } "fails for not value class without encoder" in { - case class NotValueClass(value: Int) - case class Entity(x: NotValueClass) - val q = quote { (x: NotValueClass) => + final case class NotValueClass(value: Int) + final case class Entity(x: NotValueClass) + quote { (x: NotValueClass) => query[Entity].filter(_.x == x) } "testContext.run(q)(NotValueClass(1))" mustNot compile diff --git a/quill-core/src/test/scala/io/getquill/context/QueryMacroSpec.scala b/quill-core/src/test/scala/io/getquill/context/QueryMacroSpec.scala index 01102af11e..be7a75f7af 100644 --- a/quill-core/src/test/scala/io/getquill/context/QueryMacroSpec.scala +++ b/quill-core/src/test/scala/io/getquill/context/QueryMacroSpec.scala @@ -137,7 +137,7 @@ class QueryMacroSpec extends Spec { val q = quote { qr1.filter(t => t.i == lift(1) && t.s == lift("a")).map(t => t.i) } - val r = testContext.translate(q.dynamic) mustEqual + testContext.translate(q.dynamic) mustEqual """querySchema("TestEntity").filter(t => (t.i == 1) && (t.s == 'a')).map(t => t.i)""" } "nested" in { diff --git a/quill-core/src/test/scala/io/getquill/context/mirror/MirrorIdiomSpec.scala b/quill-core/src/test/scala/io/getquill/context/mirror/MirrorIdiomSpec.scala index 4f4656fa39..506b11e170 100644 --- a/quill-core/src/test/scala/io/getquill/context/mirror/MirrorIdiomSpec.scala +++ b/quill-core/src/test/scala/io/getquill/context/mirror/MirrorIdiomSpec.scala @@ -37,7 +37,7 @@ class MirrorIdiomSpec extends Spec { "shows queries" - { "complex" in { val q = quote { - query[TestEntity].filter(t => t.s == "test").flatMap(t => query[TestEntity]).drop(9).take(10).map(t => t) + query[TestEntity].filter(t => t.s == "test").flatMap(_ => query[TestEntity]).drop(9).take(10).map(t => t) } stmt"${(q.ast: Ast).token}" mustEqual stmt"""querySchema("TestEntity").filter(t => t.s == "test").flatMap(t => querySchema("TestEntity")).drop(9).take(10).map(t => t)""" @@ -92,7 +92,7 @@ class MirrorIdiomSpec extends Spec { } "flat join" in { val q = quote { - qr1.join(x => true) + qr1.join(_ => true) } stmt"${(q.ast: Ast).token}" mustEqual stmt"""querySchema("TestEntity").join((x) => true)""" @@ -466,7 +466,7 @@ class MirrorIdiomSpec extends Spec { stmt"$t.onConflictIgnore(_.i, _.s)" } "onConflictUpdate(assigns*)" in { - stmt"${(i.onConflictUpdate((t, e) => t.s -> e.s, (t, e) => t.i -> (t.i + 1)).ast: Ast).token}" mustEqual + stmt"${(i.onConflictUpdate((t, e) => t.s -> e.s, (t, _) => t.i -> (t.i + 1)).ast: Ast).token}" mustEqual stmt"$t.onConflictUpdate((t, e) => t.s -> e.s, (t, e) => t.i -> (t.i + 1))" } "onConflictUpdate(targets*)(assigns*)" in { @@ -479,7 +479,7 @@ class MirrorIdiomSpec extends Spec { "shows sql" - { "as part of the query" in { val q = quote { - qr1.filter(t => sql"true".as[Boolean]) + qr1.filter(_ => sql"true".as[Boolean]) } stmt"${(q.ast: Ast).token}" mustEqual stmt"""querySchema("TestEntity").filter(t => sql"true")""" @@ -513,7 +513,7 @@ class MirrorIdiomSpec extends Spec { } "shows option operations" - { - case class Row(id: Int, value: String) + final case class Row(id: Int, value: String) "getOrElse" in { val q = quote { (o: Option[Int]) => @@ -701,7 +701,7 @@ class MirrorIdiomSpec extends Spec { "liftTokenizer" in { val q = quote { - qr1.map(x => lift(1)) + qr1.map(_ => lift(1)) } q.ast.toString mustEqual """querySchema("TestEntity").map(x => ?)""" } diff --git a/quill-core/src/test/scala/io/getquill/dsl/EncodingDslSpec.scala b/quill-core/src/test/scala/io/getquill/dsl/EncodingDslSpec.scala index 092a0c3568..82d53752ba 100644 --- a/quill-core/src/test/scala/io/getquill/dsl/EncodingDslSpec.scala +++ b/quill-core/src/test/scala/io/getquill/dsl/EncodingDslSpec.scala @@ -7,9 +7,9 @@ import io.getquill.MirrorContexts.testContext._ import scala.language.reflectiveCalls -case class CustomValue(i: Int) extends AnyVal +final case class CustomValue(i: Int) extends AnyVal -case class CustomGenericValue[T](v: T) extends AnyVal +final case class CustomGenericValue[T](v: T) extends AnyVal class CustomPrivateConstructorValue private (val i: Int) extends AnyVal @@ -18,9 +18,9 @@ object CustomPrivateConstructorValue { } // Tests self lifting of `AnyVal` -case class Address(id: AddressId) +final case class Address(id: AddressId) -case class AddressId(value: Long) extends AnyVal { +final case class AddressId(value: Long) extends AnyVal { def `inside quotation` = quote { query[Address].filter(_.id == lift(this)) diff --git a/quill-core/src/test/scala/io/getquill/dsl/MetaDslSpec.scala b/quill-core/src/test/scala/io/getquill/dsl/MetaDslSpec.scala index f8cedb50fe..ce78f8833b 100644 --- a/quill-core/src/test/scala/io/getquill/dsl/MetaDslSpec.scala +++ b/quill-core/src/test/scala/io/getquill/dsl/MetaDslSpec.scala @@ -4,7 +4,6 @@ import io.getquill.MirrorContexts.testContext._ import io.getquill.context.mirror.{MirrorSession, Row} import io.getquill.Query import io.getquill.base.Spec -import io.getquill.util.PrintMac class MetaDslSpec extends Spec { @@ -53,12 +52,12 @@ class MetaDslSpec extends Spec { meta.entity.toString mustEqual """`querySchema`("test_entity", _.i -> "ii")""" } "custom with embedded" in { - case class Entity(emb: EmbValue) + final case class Entity(emb: EmbValue) val meta = schemaMeta[Entity]("test_entity", _.emb.i -> "ii") meta.entity.toString mustEqual """`querySchema`("test_entity", _.emb.i -> "ii")""" } "custom with optional embedded" in { - case class Entity(emb: Option[EmbValue]) + final case class Entity(emb: Option[EmbValue]) val meta = schemaMeta[Entity]("test_entity", _.emb.map(_.i) -> "ii") meta.entity.toString mustEqual """`querySchema`("test_entity", _.emb.i -> "ii")""" } @@ -67,13 +66,13 @@ class MetaDslSpec extends Spec { "query meta" - { "materialized" - { "simple" in { - case class Entity(a: String, b: Int) + final case class Entity(a: String, b: Int) val meta = materializeQueryMeta[Entity] meta.extract(Row("1", 2), MirrorSession.default) mustEqual Entity("1", 2) } "with embedded" in { - case class Nested(i: Int, l: Long) - case class Entity(a: String, b: Nested) + final case class Nested(i: Int, l: Long) + final case class Entity(a: String, b: Nested) val meta = materializeQueryMeta[Entity] meta.extract(Row("1", 2, 3L), MirrorSession.default) mustEqual Entity("1", Nested(2, 3L)) } @@ -82,41 +81,41 @@ class MetaDslSpec extends Spec { meta.extract(Row("1", 2), MirrorSession.default) mustEqual (("1", 2)) } "tuple + embedded" in { - case class Nested(i: Int, l: Long) + final case class Nested(i: Int, l: Long) val meta = materializeQueryMeta[(String, Nested)] meta.extract(Row("1", 2, 3L), MirrorSession.default) mustEqual (("1", Nested(2, 3L))) } "tuple + nested embedded" in { - case class Nested(i: Int, l: Long) - case class Entity(a: String, b: Nested) + final case class Nested(i: Int, l: Long) + final case class Entity(a: String, b: Nested) val meta = materializeQueryMeta[(String, Entity)] meta.extract(Row("a", "1", 2, 3L), MirrorSession.default) mustEqual (("a", Entity("1", Nested(2, 3L)))) } "optional nested" - { "extracts Some if all columns are defined" in { - case class Entity(a: String, b: Int) + final case class Entity(a: String, b: Int) val meta = materializeQueryMeta[(String, Option[Entity])] meta.extract(Row("a", "1", 2), MirrorSession.default) mustEqual (("a", Some(Entity("1", 2)))) } "extracts Some if at least one column is defined" in { - case class Entity(a: String, b: Int) + final case class Entity(a: String, b: Int) val meta = materializeQueryMeta[(String, Option[Entity])] meta.extract(Row("a", "1", null), MirrorSession.default) mustEqual (("a", Some(Entity("1", 0)))) } "extracts Some if at least one column is defined - alternate" in { - case class Entity(a: String, b: Int) + final case class Entity(a: String, b: Int) val meta = materializeQueryMeta[(String, Option[Entity])] meta.extract(Row("a", null, 2), MirrorSession.default) mustEqual (("a", Some(Entity(null, 2)))) } "extracts None if no columns are defined" in { - case class Entity(a: String, b: Int) + final case class Entity(a: String, b: Int) val meta = materializeQueryMeta[(String, Option[Entity])] meta.extract(Row("a", null, null), MirrorSession.default) mustEqual (("a", None)) } } "optional deep nested" - { - case class Entity1(a: String, b: Int) - case class Entity2(a: Option[Int]) + final case class Entity1(a: String, b: Int) + final case class Entity2(a: Option[Int]) val meta = materializeQueryMeta[(String, Option[(Entity1, Entity2)])] "extracts Some if all columns are defined" in { @@ -144,8 +143,8 @@ class MetaDslSpec extends Spec { } } "custom" in { - case class Person(id: Int, name: String, age: Int, phone: String) - case class Contact(personId: Int, phone: String) + final case class Person(id: Int, name: String, age: Int, phone: String) + final case class Contact(personId: Int, phone: String) implicit val meta = queryMeta((q: Query[Person]) => for { @@ -164,13 +163,13 @@ class MetaDslSpec extends Spec { "update meta" - { "materialized" - { "simple" in { - case class Entity(a: String, b: Int) + final case class Entity(a: String, b: Int) val meta = materializeUpdateMeta[Entity] meta.expand.toString mustEqual "(q, value) => q.update(v => v.a -> value.a, v => v.b -> value.b)" } "with embedded" in { - case class Nested(i: Int, l: Long) - case class Entity(a: String, b: Nested) + final case class Nested(i: Int, l: Long) + final case class Entity(a: String, b: Nested) val meta = materializeUpdateMeta[Entity] meta.expand.toString mustEqual "(q, value) => q.update(v => v.a -> value.a, v => v.b.i -> value.b.i, v => v.b.l -> value.b.l)" } @@ -179,18 +178,18 @@ class MetaDslSpec extends Spec { meta.expand.toString mustEqual "(q, value) => q.update(v => v._1 -> value._1, v => v._2 -> value._2)" } "tuple + embedded" in { - case class Nested(i: Int, l: Long) + final case class Nested(i: Int, l: Long) val meta = materializeUpdateMeta[(String, Nested)] meta.expand.toString mustEqual "(q, value) => q.update(v => v._1 -> value._1, v => v._2.i -> value._2.i, v => v._2.l -> value._2.l)" } "tuple + nested embedded" in { - case class Nested(i: Int, l: Long) - case class Entity(a: String, b: Nested) + final case class Nested(i: Int, l: Long) + final case class Entity(a: String, b: Nested) val meta = materializeUpdateMeta[(String, Entity)] meta.expand.toString mustEqual "(q, value) => q.update(v => v._1 -> value._1, v => v._2.a -> value._2.a, v => v._2.b.i -> value._2.b.i, v => v._2.b.l -> value._2.b.l)" } "optional nested" in { - case class Entity(a: String, b: Int) + final case class Entity(a: String, b: Int) val meta = materializeUpdateMeta[(String, Option[Entity])] meta.expand.toString mustEqual "(q, value) => q.update(v => v._1 -> value._1, v => v._2.map((v) => v.a) -> value._2.map((v) => v.a), v => v._2.map((v) => v.b) -> value._2.map((v) => v.b))" } @@ -200,8 +199,8 @@ class MetaDslSpec extends Spec { } } "custom" - { - case class Nested(i: Int, l: Long) - case class Entity(a: String, b: Nested, c: Option[Nested]) + final case class Nested(i: Int, l: Long) + final case class Entity(a: String, b: Nested, c: Option[Nested]) "exclude column" in { val meta = updateMeta[Entity](_.a) @@ -234,13 +233,13 @@ class MetaDslSpec extends Spec { "insert meta" - { "materialized" - { "simple" in { - case class Entity(a: String, b: Int) + final case class Entity(a: String, b: Int) val meta = materializeInsertMeta[Entity] meta.expand.toString mustEqual "(q, value) => q.insert(v => v.a -> value.a, v => v.b -> value.b)" } "with embedded" in { - case class Nested(i: Int, l: Long) - case class Entity(a: String, b: Nested) + final case class Nested(i: Int, l: Long) + final case class Entity(a: String, b: Nested) val meta = materializeInsertMeta[Entity] meta.expand.toString mustEqual "(q, value) => q.insert(v => v.a -> value.a, v => v.b.i -> value.b.i, v => v.b.l -> value.b.l)" } @@ -249,18 +248,18 @@ class MetaDslSpec extends Spec { meta.expand.toString mustEqual "(q, value) => q.insert(v => v._1 -> value._1, v => v._2 -> value._2)" } "tuple + embedded" in { - case class Nested(i: Int, l: Long) + final case class Nested(i: Int, l: Long) val meta = materializeInsertMeta[(String, Nested)] meta.expand.toString mustEqual "(q, value) => q.insert(v => v._1 -> value._1, v => v._2.i -> value._2.i, v => v._2.l -> value._2.l)" } "tuple + nested embedded" in { - case class Nested(i: Int, l: Long) - case class Entity(a: String, b: Nested) + final case class Nested(i: Int, l: Long) + final case class Entity(a: String, b: Nested) val meta = materializeInsertMeta[(String, Entity)] meta.expand.toString mustEqual "(q, value) => q.insert(v => v._1 -> value._1, v => v._2.a -> value._2.a, v => v._2.b.i -> value._2.b.i, v => v._2.b.l -> value._2.b.l)" } "optional nested" in { - case class Entity(a: String, b: Int) + final case class Entity(a: String, b: Int) val meta = materializeInsertMeta[(String, Option[Entity])] meta.expand.toString mustEqual "(q, value) => q.insert(v => v._1 -> value._1, v => v._2.map((v) => v.a) -> value._2.map((v) => v.a), v => v._2.map((v) => v.b) -> value._2.map((v) => v.b))" } @@ -270,8 +269,8 @@ class MetaDslSpec extends Spec { } } "custom" - { - case class Nested(i: Int, l: Long) - case class Entity(a: String, b: Nested, c: Option[Nested]) + final case class Nested(i: Int, l: Long) + final case class Entity(a: String, b: Nested, c: Option[Nested]) "exclude column" in { val meta = insertMeta[Entity](_.a) diff --git a/quill-core/src/test/scala/io/getquill/monad/IOMonadSpec.scala b/quill-core/src/test/scala/io/getquill/monad/IOMonadSpec.scala index 4365589894..5d2dccc68d 100644 --- a/quill-core/src/test/scala/io/getquill/monad/IOMonadSpec.scala +++ b/quill-core/src/test/scala/io/getquill/monad/IOMonadSpec.scala @@ -171,7 +171,7 @@ trait IOMonadSpec extends Spec { "empty" in { val ios = List.empty[IO[Int, Effect]] val io = IO.traverse(ios)(IO.successful) - eval(io) mustEqual List() + eval(io) mustEqual List.empty } "success" in { val ints = List(1, 2) diff --git a/quill-core/src/test/scala/io/getquill/monad/ScalaFutureIOMonadSpec.scala b/quill-core/src/test/scala/io/getquill/monad/ScalaFutureIOMonadSpec.scala index caea63c38d..72a19c06c0 100644 --- a/quill-core/src/test/scala/io/getquill/monad/ScalaFutureIOMonadSpec.scala +++ b/quill-core/src/test/scala/io/getquill/monad/ScalaFutureIOMonadSpec.scala @@ -8,7 +8,7 @@ class ScalaFutureIOMonadSpec extends IOMonadSpec { override val ctx = io.getquill.MirrorContexts.testAsyncContext import ctx._ - override def eval[T](io: IO[T, _]) = + override def eval[T](io: IO[T, _]): T = ctx.eval(ctx.performIO(io)) override def resultValue[T](x: T): Result[T] = Future.successful(x) diff --git a/quill-core/src/test/scala/io/getquill/monad/SyncIOMonadSpec.scala b/quill-core/src/test/scala/io/getquill/monad/SyncIOMonadSpec.scala index ff3efe41bc..a7c54cda82 100644 --- a/quill-core/src/test/scala/io/getquill/monad/SyncIOMonadSpec.scala +++ b/quill-core/src/test/scala/io/getquill/monad/SyncIOMonadSpec.scala @@ -7,7 +7,7 @@ class SyncIOMonadSpec extends IOMonadSpec { override val ctx = MirrorContexts.testContext import ctx._ - override def eval[T](io: IO[T, _]) = + override def eval[T](io: IO[T, _]): T = performIO[T](io) override def resultValue[T](x: T): Result[T] = x diff --git a/quill-core/src/test/scala/io/getquill/norm/AdHocReductionSpec.scala b/quill-core/src/test/scala/io/getquill/norm/AdHocReductionSpec.scala index e3053b98cf..056f02a0b6 100644 --- a/quill-core/src/test/scala/io/getquill/norm/AdHocReductionSpec.scala +++ b/quill-core/src/test/scala/io/getquill/norm/AdHocReductionSpec.scala @@ -26,37 +26,37 @@ class AdHocReductionSpec extends Spec { "flatMap.*" - { "a.flatMap(b => c).map(d => e)" in { val q = quote { - qr1.flatMap(b => qr2).map(d => d.s) + qr1.flatMap(_ => qr2).map(d => d.s) } val n = quote { - qr1.flatMap(b => qr2.map(d => d.s)) + qr1.flatMap(_ => qr2.map(d => d.s)) } AdHocReduction.unapply(q.ast) mustEqual Some(n.ast) } "a.flatMap(b => c).filter(d => e)" in { val q = quote { - qr1.flatMap(b => qr2).filter(d => d.s == "s2") + qr1.flatMap(_ => qr2).filter(d => d.s == "s2") } val n = quote { - qr1.flatMap(b => qr2.filter(d => d.s == "s2")) + qr1.flatMap(_ => qr2.filter(d => d.s == "s2")) } AdHocReduction.unapply(q.ast) mustEqual Some(n.ast) } "a.flatMap(b => c.union(d))" in { val q = quote { - qr1.flatMap(b => qr2.filter(t => t.i == 1).union(qr2.filter(t => t.s == "s"))) + qr1.flatMap(_ => qr2.filter(t => t.i == 1).union(qr2.filter(t => t.s == "s"))) } val n = quote { - qr1.flatMap(b => qr2.filter(t => t.i == 1)).union(qr1.flatMap(b => qr2.filter(t => t.s == "s"))) + qr1.flatMap(_ => qr2.filter(t => t.i == 1)).union(qr1.flatMap(_ => qr2.filter(t => t.s == "s"))) } AdHocReduction.unapply(q.ast) mustEqual Some(n.ast) } "a.flatMap(b => c.unionAll(d))" in { val q = quote { - qr1.flatMap(b => qr2.filter(t => t.i == 1).unionAll(qr2.filter(t => t.s == "s"))) + qr1.flatMap(_ => qr2.filter(t => t.i == 1).unionAll(qr2.filter(t => t.s == "s"))) } val n = quote { - qr1.flatMap(b => qr2.filter(t => t.i == 1)).unionAll(qr1.flatMap(b => qr2.filter(t => t.s == "s"))) + qr1.flatMap(_ => qr2.filter(t => t.i == 1)).unionAll(qr1.flatMap(_ => qr2.filter(t => t.s == "s"))) } AdHocReduction.unapply(q.ast) mustEqual Some(n.ast) } diff --git a/quill-core/src/test/scala/io/getquill/norm/AttachToEntitySpec.scala b/quill-core/src/test/scala/io/getquill/norm/AttachToEntitySpec.scala index c290a15dc5..a9ce1b88ac 100644 --- a/quill-core/src/test/scala/io/getquill/norm/AttachToEntitySpec.scala +++ b/quill-core/src/test/scala/io/getquill/norm/AttachToEntitySpec.scala @@ -4,16 +4,18 @@ import io.getquill.ast.{AscNullsFirst, Constant, Ident, Map, SortBy} import io.getquill.MirrorContexts.testContext._ import io.getquill.Query import io.getquill.base.Spec +import io.getquill.Quoted +import io.getquill.ast.Ast class AttachToEntitySpec extends Spec { - val attachToEntity = + val attachToEntity: Ast => Ast = (AttachToEntity(SortBy(_, _, Constant.auto(1), AscNullsFirst)) _).andThen(replaceTempIdent.apply _) "attaches clause to the root of the query (entity)" - { "query is the entity" in { val n = quote { - qr1.sortBy(x => 1) + qr1.sortBy(_ => 1) } attachToEntity(qr1.ast) mustEqual n.ast } @@ -23,16 +25,16 @@ class AttachToEntitySpec extends Spec { qr1.filter(t => t.i == 1).map(t => t.s) } val n = quote { - qr1.sortBy(t => 1).filter(t => t.i == 1).map(t => t.s) + qr1.sortBy(_ => 1).filter(t => t.i == 1).map(t => t.s) } attachToEntity(q.ast) mustEqual n.ast } "flatMap" in { val q = quote { - qr1.filter(t => t.i == 1).flatMap(t => qr2) + qr1.filter(t => t.i == 1).flatMap(_ => qr2) } val n = quote { - qr1.sortBy(t => 1).filter(t => t.i == 1).flatMap(t => qr2) + qr1.sortBy(_ => 1).filter(t => t.i == 1).flatMap(_ => qr2) } attachToEntity(q.ast) mustEqual n.ast } @@ -41,7 +43,7 @@ class AttachToEntitySpec extends Spec { qr1.filter(t => t.i == 1).concatMap(t => t.s.split(" ")) } val n = quote { - qr1.sortBy(t => 1).filter(t => t.i == 1).concatMap(t => t.s.split(" ")) + qr1.sortBy(_ => 1).filter(t => t.i == 1).concatMap(t => t.s.split(" ")) } attachToEntity(q.ast) mustEqual n.ast } @@ -50,7 +52,7 @@ class AttachToEntitySpec extends Spec { qr1.filter(t => t.i == 1).filter(t => t.s == "s1") } val n = quote { - qr1.sortBy(t => 1).filter(t => t.i == 1).filter(t => t.s == "s1") + qr1.sortBy(_ => 1).filter(t => t.i == 1).filter(t => t.s == "s1") } attachToEntity(q.ast) mustEqual n.ast } @@ -59,7 +61,7 @@ class AttachToEntitySpec extends Spec { qr1.sortBy(t => t.s) } val n = quote { - qr1.sortBy(t => 1).sortBy(t => t.s) + qr1.sortBy(_ => 1).sortBy(t => t.s) } attachToEntity(q.ast) mustEqual n.ast } @@ -68,7 +70,7 @@ class AttachToEntitySpec extends Spec { qr1.sortBy(b => b.s).take(1) } val n = quote { - qr1.sortBy(b => 1).sortBy(b => b.s).take(1) + qr1.sortBy(_ => 1).sortBy(b => b.s).take(1) } attachToEntity(q.ast) mustEqual n.ast } @@ -77,7 +79,7 @@ class AttachToEntitySpec extends Spec { qr1.sortBy(b => b.s).drop(1) } val n = quote { - qr1.sortBy(b => 1).sortBy(b => b.s).drop(1) + qr1.sortBy(_ => 1).sortBy(b => b.s).drop(1) } attachToEntity(q.ast) mustEqual n.ast } @@ -86,21 +88,21 @@ class AttachToEntitySpec extends Spec { qr1.sortBy(b => b.s).drop(1).distinct } val n = quote { - qr1.sortBy(b => 1).sortBy(b => b.s).drop(1).distinct + qr1.sortBy(_ => 1).sortBy(b => b.s).drop(1).distinct } attachToEntity(q.ast) mustEqual n.ast } } } - val iqr1 = quote { + val iqr1: Quoted[Query[TestEntity]] = quote { sql"$qr1".as[Query[TestEntity]] } "attaches clause to the root of the query (infix)" - { "query is the entity" in { val n = quote { - iqr1.sortBy(x => 1) + iqr1.sortBy(_ => 1) } attachToEntity(iqr1.ast) mustEqual n.ast } @@ -110,16 +112,16 @@ class AttachToEntitySpec extends Spec { iqr1.filter(t => t.i == 1).map(t => t.s) } val n = quote { - iqr1.sortBy(t => 1).filter(t => t.i == 1).map(t => t.s) + iqr1.sortBy(_ => 1).filter(t => t.i == 1).map(t => t.s) } attachToEntity(q.ast) mustEqual n.ast } "flatMap" in { val q = quote { - iqr1.filter(t => t.i == 1).flatMap(t => qr2) + iqr1.filter(t => t.i == 1).flatMap(_ => qr2) } val n = quote { - iqr1.sortBy(t => 1).filter(t => t.i == 1).flatMap(t => qr2) + iqr1.sortBy(_ => 1).filter(t => t.i == 1).flatMap(_ => qr2) } attachToEntity(q.ast) mustEqual n.ast } @@ -128,7 +130,7 @@ class AttachToEntitySpec extends Spec { iqr1.filter(t => t.i == 1).concatMap(t => t.s.split(" ")) } val n = quote { - iqr1.sortBy(t => 1).filter(t => t.i == 1).concatMap(t => t.s.split(" ")) + iqr1.sortBy(_ => 1).filter(t => t.i == 1).concatMap(t => t.s.split(" ")) } attachToEntity(q.ast) mustEqual n.ast } @@ -137,7 +139,7 @@ class AttachToEntitySpec extends Spec { iqr1.filter(t => t.i == 1).filter(t => t.s == "s1") } val n = quote { - iqr1.sortBy(t => 1).filter(t => t.i == 1).filter(t => t.s == "s1") + iqr1.sortBy(_ => 1).filter(t => t.i == 1).filter(t => t.s == "s1") } attachToEntity(q.ast) mustEqual n.ast } @@ -146,7 +148,7 @@ class AttachToEntitySpec extends Spec { iqr1.sortBy(t => t.s) } val n = quote { - iqr1.sortBy(t => 1).sortBy(t => t.s) + iqr1.sortBy(_ => 1).sortBy(t => t.s) } attachToEntity(q.ast) mustEqual n.ast } @@ -155,7 +157,7 @@ class AttachToEntitySpec extends Spec { iqr1.sortBy(b => b.s).take(1) } val n = quote { - iqr1.sortBy(b => 1).sortBy(b => b.s).take(1) + iqr1.sortBy(_ => 1).sortBy(b => b.s).take(1) } attachToEntity(q.ast) mustEqual n.ast } @@ -164,7 +166,7 @@ class AttachToEntitySpec extends Spec { iqr1.sortBy(b => b.s).drop(1) } val n = quote { - iqr1.sortBy(b => 1).sortBy(b => b.s).drop(1) + iqr1.sortBy(_ => 1).sortBy(b => b.s).drop(1) } attachToEntity(q.ast) mustEqual n.ast } @@ -173,7 +175,7 @@ class AttachToEntitySpec extends Spec { iqr1.sortBy(b => b.s).drop(1).distinct } val n = quote { - iqr1.sortBy(b => 1).sortBy(b => b.s).drop(1).distinct + iqr1.sortBy(_ => 1).sortBy(b => b.s).drop(1).distinct } attachToEntity(q.ast) mustEqual n.ast } @@ -186,7 +188,7 @@ class AttachToEntitySpec extends Spec { qr1.union(qr2) } val n = quote { - qr1.union(qr2).sortBy(x => 1) + qr1.union(qr2).sortBy(_ => 1) } attachToEntity(q.ast) mustEqual n.ast } @@ -195,25 +197,25 @@ class AttachToEntitySpec extends Spec { qr1.unionAll(qr2) } val n = quote { - qr1.unionAll(qr2).sortBy(x => 1) + qr1.unionAll(qr2).sortBy(_ => 1) } attachToEntity(q.ast) mustEqual n.ast } "outer join" in { val q = quote { - qr1.leftJoin(qr2).on((a, b) => true) + qr1.leftJoin(qr2).on((_, _) => true) } val n = quote { - qr1.leftJoin(qr2).on((a, b) => true).sortBy(x => 1) + qr1.leftJoin(qr2).on((_, _) => true).sortBy(_ => 1) } attachToEntity(q.ast) mustEqual n.ast } "groupBy.map" in { val q = quote { - qr1.groupBy(a => a.i).map(a => 1) + qr1.groupBy(a => a.i).map(_ => 1) } val n = quote { - qr1.groupBy(a => a.i).map(a => 1).sortBy(x => 1) + qr1.groupBy(a => a.i).map(_ => 1).sortBy(_ => 1) } attachToEntity(q.ast) mustEqual n.ast } diff --git a/quill-core/src/test/scala/io/getquill/norm/BetaReductionSpec.scala b/quill-core/src/test/scala/io/getquill/norm/BetaReductionSpec.scala index 07756973e6..c84787f70a 100644 --- a/quill-core/src/test/scala/io/getquill/norm/BetaReductionSpec.scala +++ b/quill-core/src/test/scala/io/getquill/norm/BetaReductionSpec.scala @@ -49,7 +49,7 @@ class BetaReductionSpec extends Spec { OnConflict.Existing(Ident("a'")) } "with inline" - { - val entity = Entity("a", Nil, QEP) + val entity = Entity("a", List.empty, QEP) // Entity Idents val (aE, bE, cE, dE) = (Ident("a", QEP), Ident("b", QEP), Ident("c", QEP), Ident("d", QEP)) // Value Idents diff --git a/quill-core/src/test/scala/io/getquill/norm/ExpandReturningSpec.scala b/quill-core/src/test/scala/io/getquill/norm/ExpandReturningSpec.scala index 9981dcf556..d516dee277 100644 --- a/quill-core/src/test/scala/io/getquill/norm/ExpandReturningSpec.scala +++ b/quill-core/src/test/scala/io/getquill/norm/ExpandReturningSpec.scala @@ -13,7 +13,7 @@ class ExpandReturningSpec extends Spec { case class Person(name: String, age: Int) case class Foo(bar: String, baz: Int) - val quat = Quat.Product("TestQuat", "name" -> QV, "age" -> QV) + val quat: Quat.Product = Quat.Product("TestQuat", "name" -> QV, "age" -> QV) "inner apply" - { val mi = MirrorIdiom @@ -155,7 +155,7 @@ class ExpandReturningSpec extends Spec { def insert = Insert( Map( - Entity.Opinionated("Person", List(), QEP, renameable), + Entity.Opinionated("Person", List.empty, QEP, renameable), Ident("p"), Tuple( List( diff --git a/quill-core/src/test/scala/io/getquill/norm/FlattenOptionOperationSpec.scala b/quill-core/src/test/scala/io/getquill/norm/FlattenOptionOperationSpec.scala index 116b43cdd1..9740cc8f4f 100644 --- a/quill-core/src/test/scala/io/getquill/norm/FlattenOptionOperationSpec.scala +++ b/quill-core/src/test/scala/io/getquill/norm/FlattenOptionOperationSpec.scala @@ -10,15 +10,15 @@ import io.getquill.util.TraceConfig class FlattenOptionOperationSpec extends Spec { // hello - def o = Ident("o") - def c1 = Constant.auto(1) - def c2 = Constant.auto(2) - def cFoo = Constant.auto("foo") - def cBar = Constant.auto("bar") - def cValue = Constant.auto("value") + def o: Ident = Ident("o") + def c1: Constant = Constant.auto(1) + def c2: Constant = Constant.auto(2) + def cFoo: Constant = Constant.auto("foo") + def cBar: Constant = Constant.auto("bar") + def cValue: Constant = Constant.auto("value") "transforms option operations into simple properties" - { - case class Row(id: Int, value: String) + final case class Row(id: Int, value: String) "getOrElse" in { val q = quote { (o: Option[Int]) => diff --git a/quill-core/src/test/scala/io/getquill/norm/NormalizeCachingSpec.scala b/quill-core/src/test/scala/io/getquill/norm/NormalizeCachingSpec.scala index 88417f0b67..9c7fa665ce 100644 --- a/quill-core/src/test/scala/io/getquill/norm/NormalizeCachingSpec.scala +++ b/quill-core/src/test/scala/io/getquill/norm/NormalizeCachingSpec.scala @@ -1,11 +1,12 @@ package io.getquill.norm import io.getquill.base.Spec +import io.getquill.ast.Ast class NormalizeCachingSpec extends Spec { val normalize = new Normalize(TranspileConfig.Empty) - val cached = NormalizeCaching(normalize.apply) + val cached: Ast => Ast = NormalizeCaching(normalize.apply) val gen = new QueryGenerator(1) "Cached normalization" - { diff --git a/quill-core/src/test/scala/io/getquill/norm/NormalizeNestedStructuresSpec.scala b/quill-core/src/test/scala/io/getquill/norm/NormalizeNestedStructuresSpec.scala index e32e69adbb..65cb6d6159 100644 --- a/quill-core/src/test/scala/io/getquill/norm/NormalizeNestedStructuresSpec.scala +++ b/quill-core/src/test/scala/io/getquill/norm/NormalizeNestedStructuresSpec.scala @@ -6,14 +6,15 @@ import io.getquill.MirrorContexts.testContext.qr1 import io.getquill.MirrorContexts.testContext.qr2 import io.getquill.MirrorContexts.testContext.quote import io.getquill.MirrorContexts.testContext.unquote +import io.getquill.Quoted class NormalizeNestedStructuresSpec extends Spec { - val unnormalized = quote { + val unnormalized: Quoted[Long] = quote { qr1.map(x => x.i).take(1).size } - val normalized = quote { + val normalized: Quoted[Long] = quote { qr1.take(1).map(x => x.i).size } @@ -22,10 +23,10 @@ class NormalizeNestedStructuresSpec extends Spec { "returns Some if a nested structure changes" - { "flatMap" in { val q = quote { - qr1.flatMap(x => qr2.map(y => y.s).filter(s => s == "s")) + qr1.flatMap(_ => qr2.map(y => y.s).filter(s => s == "s")) } val n = quote { - qr1.flatMap(x => qr2.filter(y => y.s == "s").map(y => y.s)) + qr1.flatMap(_ => qr2.filter(y => y.s == "s").map(y => y.s)) } NormalizeNestedStructures.unapply(q.ast) mustEqual Some(n.ast) } @@ -40,120 +41,120 @@ class NormalizeNestedStructuresSpec extends Spec { } "filter" in { val q = quote { - qr1.filter(x => qr2.map(y => y.s).filter(s => s == "s").isEmpty) + qr1.filter(_ => qr2.map(y => y.s).filter(s => s == "s").isEmpty) } val n = quote { - qr1.filter(x => qr2.filter(y => y.s == "s").map(y => y.s).isEmpty) + qr1.filter(_ => qr2.filter(y => y.s == "s").map(y => y.s).isEmpty) } NormalizeNestedStructures.unapply(q.ast) mustEqual Some(n.ast) } "map" in { val q = quote { - qr1.map(x => qr2.map(y => y.s).filter(s => s == "s").isEmpty) + qr1.map(_ => qr2.map(y => y.s).filter(s => s == "s").isEmpty) } val n = quote { - qr1.map(x => qr2.filter(y => y.s == "s").map(y => y.s).isEmpty) + qr1.map(_ => qr2.filter(y => y.s == "s").map(y => y.s).isEmpty) } NormalizeNestedStructures.unapply(q.ast) mustEqual Some(n.ast) } "sortBy" in { val q = quote { - qr1.sortBy(t => unnormalized) + qr1.sortBy(_ => unnormalized) } val n = quote { - qr1.sortBy(t => normalized) + qr1.sortBy(_ => normalized) } NormalizeNestedStructures.unapply(q.ast) mustEqual Some(n.ast) } "groupBy" in { val q = quote { - qr1.groupBy(t => unnormalized) + qr1.groupBy(_ => unnormalized) } val n = quote { - qr1.groupBy(t => normalized) + qr1.groupBy(_ => normalized) } NormalizeNestedStructures.unapply(q.ast) mustEqual Some(n.ast) } "aggregation" in { val q = quote { - qr1.map(t => unnormalized).max + qr1.map(_ => unnormalized).max } val n = quote { - qr1.map(t => normalized).max + qr1.map(_ => normalized).max } NormalizeNestedStructures.unapply(q.ast) mustEqual Some(n.ast) } "take" in { val q = quote { - qr1.sortBy(t => unnormalized).take(1) + qr1.sortBy(_ => unnormalized).take(1) } val n = quote { - qr1.sortBy(t => normalized).take(1) + qr1.sortBy(_ => normalized).take(1) } NormalizeNestedStructures.unapply(q.ast) mustEqual Some(n.ast) } "drop" in { val q = quote { - qr1.sortBy(t => unnormalized).drop(1) + qr1.sortBy(_ => unnormalized).drop(1) } val n = quote { - qr1.sortBy(t => normalized).drop(1) + qr1.sortBy(_ => normalized).drop(1) } NormalizeNestedStructures.unapply(q.ast) mustEqual Some(n.ast) } "union" in { val q = quote { - qr1.filter(t => unnormalized == 1L).union(qr1) + qr1.filter(_ => unnormalized == 1L).union(qr1) } val n = quote { - qr1.filter(t => normalized == 1L).union(qr1) + qr1.filter(_ => normalized == 1L).union(qr1) } NormalizeNestedStructures.unapply(q.ast) mustEqual Some(n.ast) } "unionAll" in { val q = quote { - qr1.filter(t => unnormalized == 1L).unionAll(qr1) + qr1.filter(_ => unnormalized == 1L).unionAll(qr1) } val n = quote { - qr1.filter(t => normalized == 1L).unionAll(qr1) + qr1.filter(_ => normalized == 1L).unionAll(qr1) } NormalizeNestedStructures.unapply(q.ast) mustEqual Some(n.ast) } "outer join" - { "left" in { val q = quote { - qr1.filter(t => unnormalized == 1L).rightJoin(qr1).on((a, b) => a.s == b.s) + qr1.filter(_ => unnormalized == 1L).rightJoin(qr1).on((a, b) => a.s == b.s) } val n = quote { - qr1.filter(t => normalized == 1L).rightJoin(qr1).on((a, b) => a.s == b.s) + qr1.filter(_ => normalized == 1L).rightJoin(qr1).on((a, b) => a.s == b.s) } NormalizeNestedStructures.unapply(q.ast) mustEqual Some(n.ast) } "right" in { val q = quote { - qr1.rightJoin(qr1.filter(t => unnormalized == 1L)).on((a, b) => a.s == b.s) + qr1.rightJoin(qr1.filter(_ => unnormalized == 1L)).on((a, b) => a.s == b.s) } val n = quote { - qr1.rightJoin(qr1.filter(t => normalized == 1L)).on((a, b) => a.s == b.s) + qr1.rightJoin(qr1.filter(_ => normalized == 1L)).on((a, b) => a.s == b.s) } NormalizeNestedStructures.unapply(q.ast) mustEqual Some(n.ast) } "on" in { val q = quote { - qr1.rightJoin(qr1).on((a, b) => unnormalized == 1L) + qr1.rightJoin(qr1).on((_, _) => unnormalized == 1L) } val n = quote { - qr1.rightJoin(qr1).on((a, b) => normalized == 1L) + qr1.rightJoin(qr1).on((_, _) => normalized == 1L) } NormalizeNestedStructures.unapply(q.ast) mustEqual Some(n.ast) } } "distinct" in { val q = quote { - qr1.filter(t => unnormalized == 1L).distinct + qr1.filter(_ => unnormalized == 1L).distinct } val n = quote { - qr1.filter(t => normalized == 1L).distinct + qr1.filter(_ => normalized == 1L).distinct } NormalizeNestedStructures.unapply(q.ast) mustEqual Some(n.ast) } @@ -162,7 +163,7 @@ class NormalizeNestedStructuresSpec extends Spec { "returns None if none of the nested structures changes" - { "flatMap" in { val q = quote { - qr1.flatMap(x => qr2) + qr1.flatMap(_ => qr2) } NormalizeNestedStructures.unapply(q.ast) mustEqual None } diff --git a/quill-core/src/test/scala/io/getquill/norm/NormalizeReturningSpec.scala b/quill-core/src/test/scala/io/getquill/norm/NormalizeReturningSpec.scala index f8217291fe..e6a50c6b69 100644 --- a/quill-core/src/test/scala/io/getquill/norm/NormalizeReturningSpec.scala +++ b/quill-core/src/test/scala/io/getquill/norm/NormalizeReturningSpec.scala @@ -11,8 +11,8 @@ class NormalizeReturningSpec extends Spec { "do not remove assignment if embedded has columns with the same name" - { - case class EmbEntity(id: Int) - case class Entity(id: Int, emb: EmbEntity) + final case class EmbEntity(id: Int) + final case class Entity(id: Int, emb: EmbEntity) val e = Entity(1, EmbEntity(2)) val q = quote { @@ -27,7 +27,7 @@ class NormalizeReturningSpec extends Spec { } "when returning parent col - single - returning should not compile" in testContext.withDialect( MirrorIdiomReturningSingle - ) { ctx => + ) { _ => "ctx.run(query[Entity].insert(lift(e)).returning(p => p.id))" mustNot compile } "when returning parent col - single - returning generated" in testContext.withDialect(MirrorIdiomReturningSingle) { diff --git a/quill-core/src/test/scala/io/getquill/norm/NormalizeSpec.scala b/quill-core/src/test/scala/io/getquill/norm/NormalizeSpec.scala index 6c3bf54c67..a33dba6350 100644 --- a/quill-core/src/test/scala/io/getquill/norm/NormalizeSpec.scala +++ b/quill-core/src/test/scala/io/getquill/norm/NormalizeSpec.scala @@ -27,10 +27,10 @@ class NormalizeSpec extends Spec { "doesn't apply the avoid capture normalization to branches in isolation" in { val q = quote { - qr1.sortBy(t => t.i).flatMap(f => qr2.map(t => 1)) + qr1.sortBy(t => t.i).flatMap(_ => qr2.map(_ => 1)) } val n = quote { - qr1.sortBy(t => t.i).flatMap(t => qr2.map(t1 => 1)) + qr1.sortBy(t => t.i).flatMap(_ => qr2.map(_ => 1)) } normalize(q.ast) mustEqual n.ast } diff --git a/quill-core/src/test/scala/io/getquill/norm/OrderTermsSpec.scala b/quill-core/src/test/scala/io/getquill/norm/OrderTermsSpec.scala index 5486a119b6..cc26aff687 100644 --- a/quill-core/src/test/scala/io/getquill/norm/OrderTermsSpec.scala +++ b/quill-core/src/test/scala/io/getquill/norm/OrderTermsSpec.scala @@ -34,19 +34,19 @@ class OrderTermsSpec extends Spec { "a.flatMap(b => c).?.map(d => e)" - { "take" in { val q = quote { - qr1.flatMap(b => qr2).take(3).map(d => d.s) + qr1.flatMap(_ => qr2).take(3).map(d => d.s) } val n = quote { - qr1.flatMap(b => qr2).map(d => d.s).take(3) + qr1.flatMap(_ => qr2).map(d => d.s).take(3) } OrderTerms.unapply(q.ast) mustEqual Some(n.ast) } "drop" in { val q = quote { - qr1.flatMap(b => qr2).drop(3).map(d => d.s) + qr1.flatMap(_ => qr2).drop(3).map(d => d.s) } val n = quote { - qr1.flatMap(b => qr2).map(d => d.s).drop(3) + qr1.flatMap(_ => qr2).map(d => d.s).drop(3) } OrderTerms.unapply(q.ast) mustEqual Some(n.ast) } diff --git a/quill-core/src/test/scala/io/getquill/norm/QueryGenerator.scala b/quill-core/src/test/scala/io/getquill/norm/QueryGenerator.scala index fbf741ae7b..0d599a0c30 100644 --- a/quill-core/src/test/scala/io/getquill/norm/QueryGenerator.scala +++ b/quill-core/src/test/scala/io/getquill/norm/QueryGenerator.scala @@ -9,7 +9,7 @@ class QueryGenerator(seed: Int) { private val random = new Random(seed) implicit class IdentExt(id: Ident) { - def randomProperty = + def randomProperty: Ast = id.quat match { case Quat.Product(fields) => Property(id, fields.toList(random.nextInt(fields.size))._1) @@ -31,9 +31,9 @@ class QueryGenerator(seed: Int) { def apply(i: Int): Query = if (i <= 2) { - val quat = Quat.Product("Test") + Quat.Product("Test") val s = string(3) - Entity(s, Nil, Quat.Product("Test", (1 to 20).map(i => (string(3), Quat.Value)).toList.distinct: _*)) + Entity(s, List.empty, Quat.Product("Test", (1 to 20).map(_ => (string(3), Quat.Value)).toList.distinct: _*)) } else { random.nextInt(8) match { case 0 => map(i) @@ -99,9 +99,9 @@ class QueryGenerator(seed: Int) { } } -case class IsAggregated(state: Boolean = false) extends StatefulTransformer[Boolean] { +final case class IsAggregated(state: Boolean = false) extends StatefulTransformer[Boolean] { - override def apply(q: Query) = + override def apply(q: Query): (Query, StatefulTransformer[Boolean]) = q match { case q: Aggregation => (q, IsAggregated(true)) case other => super.apply(q) diff --git a/quill-core/src/test/scala/io/getquill/norm/SimplifyNullChecksSpec.scala b/quill-core/src/test/scala/io/getquill/norm/SimplifyNullChecksSpec.scala index 43b8255193..f3a42316cf 100644 --- a/quill-core/src/test/scala/io/getquill/norm/SimplifyNullChecksSpec.scala +++ b/quill-core/src/test/scala/io/getquill/norm/SimplifyNullChecksSpec.scala @@ -12,10 +12,10 @@ class SimplifyNullChecksSpec extends Spec { // remove the === matcher from scalatest so that we can test === in Context.extra override def convertToEqualizer[T](left: T): Equalizer[T] = new Equalizer(left) - val ia = Ident("a") - val ib = Ident("b") - val it = Ident("t") - val ca = Constant.auto("a") + val ia: Ident = Ident("a") + val ib: Ident = Ident("b") + val it: Ident = Ident("t") + val ca: Constant = Constant.auto("a") val SimplifyNullChecksAnsi = new SimplifyNullChecks(AnsiEquality) val SimplifyNullChecksNonAnsi = new SimplifyNullChecks(NonAnsiEquality) diff --git a/quill-core/src/test/scala/io/getquill/norm/SymbolicReductionSpec.scala b/quill-core/src/test/scala/io/getquill/norm/SymbolicReductionSpec.scala index c2bb9a11bd..818901511f 100644 --- a/quill-core/src/test/scala/io/getquill/norm/SymbolicReductionSpec.scala +++ b/quill-core/src/test/scala/io/getquill/norm/SymbolicReductionSpec.scala @@ -7,27 +7,28 @@ import io.getquill.MirrorContexts.testContext.qr3 import io.getquill.MirrorContexts.testContext.quote import io.getquill.MirrorContexts.testContext.unquote import io.getquill.util.TraceConfig +import io.getquill.ast.Query class SymbolicReductionSpec extends Spec { // hello - def symbolicReduction = (new SymbolicReduction(TraceConfig.Empty).unapply _).andThen(o => o.map(replaceTempIdent(_))) + def symbolicReduction: Query => Option[Query] = (new SymbolicReduction(TraceConfig.Empty).unapply _).andThen(o => o.map(replaceTempIdent(_))) "a.filter(b => c).flatMap(d => e.$)" - { "e is an entity" in { val q = quote { - qr1.filter(b => b.s == "s1").flatMap(d => qr2) + qr1.filter(b => b.s == "s1").flatMap(_ => qr2) } val n = quote { - qr1.flatMap(d => qr2.filter(x => d.s == "s1")) + qr1.flatMap(d => qr2.filter(_ => d.s == "s1")) } symbolicReduction(q.ast) mustEqual Some(n.ast) } "e isn't an entity" in { val q = quote { - qr1.filter(b => b.s == "s1").flatMap(d => qr2.map(f => f.s)) + qr1.filter(b => b.s == "s1").flatMap(_ => qr2.map(f => f.s)) } val n = quote { - qr1.flatMap(d => qr2.filter(f => d.s == "s1").map(f => f.s)) + qr1.flatMap(d => qr2.filter(_ => d.s == "s1").map(f => f.s)) } symbolicReduction(q.ast) mustEqual Some(n.ast) } @@ -35,30 +36,30 @@ class SymbolicReductionSpec extends Spec { // hello "a.flatMap(b => c).flatMap(d => e)" in { val q = quote { - qr1.flatMap(b => qr2).flatMap(d => qr3) + qr1.flatMap(_ => qr2).flatMap(_ => qr3) } val n = quote { - qr1.flatMap(b => qr2.flatMap(d => qr3)) + qr1.flatMap(_ => qr2.flatMap(_ => qr3)) } symbolicReduction(q.ast) mustEqual Some(n.ast) } "a.union(b).flatMap(c => d)" in { val q = quote { - qr1.union(qr1.filter(t => t.i == 1)).flatMap(c => qr2) + qr1.union(qr1.filter(t => t.i == 1)).flatMap(_ => qr2) } val n = quote { - qr1.flatMap(c => qr2).union(qr1.filter(t => t.i == 1).flatMap(c => qr2)) + qr1.flatMap(_ => qr2).union(qr1.filter(t => t.i == 1).flatMap(_ => qr2)) } symbolicReduction(q.ast) mustEqual Some(n.ast) } "a.unionAll(b).flatMap(c => d)" in { val q = quote { - qr1.unionAll(qr1.filter(t => t.i == 1)).flatMap(c => qr2) + qr1.unionAll(qr1.filter(t => t.i == 1)).flatMap(_ => qr2) } val n = quote { - qr1.flatMap(c => qr2).unionAll(qr1.filter(t => t.i == 1).flatMap(c => qr2)) + qr1.flatMap(_ => qr2).unionAll(qr1.filter(t => t.i == 1).flatMap(_ => qr2)) } symbolicReduction(q.ast) mustEqual Some(n.ast) } diff --git a/quill-core/src/test/scala/io/getquill/norm/capture/AvoidAliasConflictComplexSpec.scala b/quill-core/src/test/scala/io/getquill/norm/capture/AvoidAliasConflictComplexSpec.scala index 7cbce54fb5..9b1fee3a3a 100644 --- a/quill-core/src/test/scala/io/getquill/norm/capture/AvoidAliasConflictComplexSpec.scala +++ b/quill-core/src/test/scala/io/getquill/norm/capture/AvoidAliasConflictComplexSpec.scala @@ -10,12 +10,11 @@ class AvoidAliasConflictComplexSpec extends Spec { val normalize = new Normalize(TranspileConfig.Empty) "properly aliases explicit join sets" - { - import io.getquill.norm.Normalize import scala.language.reflectiveCalls - case class Person(id: Int, name: String) - case class Address(id: Int, ownerFk: Int, street: String) - case class Room(addressId: Int, stuff: String) + final case class Person(id: Int, name: String) + final case class Address(id: Int, ownerFk: Int, street: String) + final case class Room(addressId: Int, stuff: String) "in tail clause" in { def fun[T <: { def id: Int }] = quote { (tbl: Query[T]) => diff --git a/quill-core/src/test/scala/io/getquill/norm/capture/AvoidAliasConflictSpec.scala b/quill-core/src/test/scala/io/getquill/norm/capture/AvoidAliasConflictSpec.scala index 39a8d9f9d8..28b3d6b5d3 100644 --- a/quill-core/src/test/scala/io/getquill/norm/capture/AvoidAliasConflictSpec.scala +++ b/quill-core/src/test/scala/io/getquill/norm/capture/AvoidAliasConflictSpec.scala @@ -12,55 +12,55 @@ class AvoidAliasConflictSpec extends Spec { "renames alias to avoid conflict between entities during normalization" - { "flatMap" in { val q = quote { - qr1.flatMap(a => qr2.flatMap(a => qr3)) + qr1.flatMap(_ => qr2.flatMap(_ => qr3)) } val n = quote { - qr1.flatMap(a => qr2.flatMap(a1 => qr3)) + qr1.flatMap(_ => qr2.flatMap(_ => qr3)) } AvoidAliasConflict(q.ast) mustEqual n.ast } "concatMap" in { val q = quote { - qr1.flatMap(a => qr2.concatMap(a => a.s.split(" "))) + qr1.flatMap(_ => qr2.concatMap(a => a.s.split(" "))) } val n = quote { - qr1.flatMap(a => qr2.concatMap(a1 => a1.s.split(" "))) + qr1.flatMap(_ => qr2.concatMap(a1 => a1.s.split(" "))) } AvoidAliasConflict(q.ast) mustEqual n.ast } "map" in { val q = quote { - qr1.flatMap(a => qr2.map(a => a.s)) + qr1.flatMap(_ => qr2.map(a => a.s)) } val n = quote { - qr1.flatMap(a => qr2.map(a1 => a1.s)) + qr1.flatMap(_ => qr2.map(a1 => a1.s)) } AvoidAliasConflict(q.ast) mustEqual n.ast } "filter" in { val q = quote { - qr1.flatMap(a => qr2.filter(a => a.i == 1)) + qr1.flatMap(_ => qr2.filter(a => a.i == 1)) } val n = quote { - qr1.flatMap(a => qr2.filter(a1 => a1.i == 1)) + qr1.flatMap(_ => qr2.filter(a1 => a1.i == 1)) } AvoidAliasConflict(q.ast) mustEqual n.ast } "sortBy" in { val q = quote { - qr1.flatMap(a => qr2.sortBy(a => a.s)) + qr1.flatMap(_ => qr2.sortBy(a => a.s)) } val n = quote { - qr1.flatMap(a => qr2.sortBy(a1 => a1.s)) + qr1.flatMap(_ => qr2.sortBy(a1 => a1.s)) } AvoidAliasConflict(q.ast) mustEqual n.ast } "groupBy" in { val q = quote { - qr1.flatMap(a => qr2.groupBy(a => a.s)) + qr1.flatMap(_ => qr2.groupBy(a => a.s)) } val n = quote { - qr1.flatMap(a => qr2.groupBy(a1 => a1.s)) + qr1.flatMap(_ => qr2.groupBy(a1 => a1.s)) } AvoidAliasConflict(q.ast) mustEqual n.ast } @@ -159,7 +159,7 @@ class AvoidAliasConflictSpec extends Spec { .on((a, b) => a.i == b.i) .leftJoin(qr1) .on((a, b) => a._2.exists(v => v.i == b.i)) // - .map(t => 1) + .map(_ => 1) } val n = quote { qr1 @@ -167,7 +167,7 @@ class AvoidAliasConflictSpec extends Spec { .on((a, b) => a.i == b.i) .leftJoin(qr1) .on((a1, b1) => a1._2.exists(v => v.i == b1.i)) - .map(t => 1) + .map(_ => 1) } AvoidAliasConflict(q.ast) mustEqual n.ast } @@ -179,10 +179,10 @@ class AvoidAliasConflictSpec extends Spec { sql"$qr1".as[Query[TestEntity]] } val q = quote { - i.flatMap(a => qr2.flatMap(a => qr3)) + i.flatMap(_ => qr2.flatMap(_ => qr3)) } val n = quote { - i.flatMap(a => qr2.flatMap(a1 => qr3)) + i.flatMap(_ => qr2.flatMap(_ => qr3)) } AvoidAliasConflict(q.ast) mustEqual n.ast } @@ -190,65 +190,65 @@ class AvoidAliasConflictSpec extends Spec { "takes in consideration the aliases already defined" - { "flatMap" in { val q = quote { - qr1.flatMap(a => qr2.flatMap(a => qr3)) + qr1.flatMap(_ => qr2.flatMap(_ => qr3)) } val n = quote { - qr1.flatMap(a => qr2.flatMap(a1 => qr3)) + qr1.flatMap(_ => qr2.flatMap(_ => qr3)) } AvoidAliasConflict(q.ast) mustEqual n.ast } "map" in { val q = quote { - qr1.map(a => a.s).flatMap(s => qr2.map(a => a.s)) + qr1.map(a => a.s).flatMap(_ => qr2.map(a => a.s)) } val n = quote { - qr1.map(a => a.s).flatMap(s => qr2.map(a1 => a1.s)) + qr1.map(a => a.s).flatMap(_ => qr2.map(a1 => a1.s)) } AvoidAliasConflict(q.ast) mustEqual n.ast } "filter" in { val q = quote { - qr1.filter(a => a.s == "s").flatMap(s => qr2.map(a => a.s)) + qr1.filter(a => a.s == "s").flatMap(_ => qr2.map(a => a.s)) } val n = quote { - qr1.filter(a => a.s == "s").flatMap(s => qr2.map(a1 => a1.s)) + qr1.filter(a => a.s == "s").flatMap(_ => qr2.map(a1 => a1.s)) } AvoidAliasConflict(q.ast) mustEqual n.ast } "sortBy" in { val q = quote { - qr1.sortBy(a => a.s).flatMap(s => qr2.map(a => a.s)) + qr1.sortBy(a => a.s).flatMap(_ => qr2.map(a => a.s)) } val n = quote { - qr1.sortBy(a => a.s).flatMap(s => qr2.map(a1 => a1.s)) + qr1.sortBy(a => a.s).flatMap(_ => qr2.map(a1 => a1.s)) } AvoidAliasConflict(q.ast) mustEqual n.ast } "outer join" - { "left" in { val q = quote { - qr1.fullJoin(qr2.filter(a => a.i == 1)).on((b, c) => b.s == c.s).flatMap(d => qr2.map(b => b.s)) + qr1.fullJoin(qr2.filter(a => a.i == 1)).on((b, c) => b.s == c.s).flatMap(_ => qr2.map(b => b.s)) } val n = quote { - qr1.fullJoin(qr2.filter(a => a.i == 1)).on((b, c) => b.s == c.s).flatMap(d => qr2.map(b1 => b1.s)) + qr1.fullJoin(qr2.filter(a => a.i == 1)).on((b, c) => b.s == c.s).flatMap(_ => qr2.map(b1 => b1.s)) } AvoidAliasConflict(q.ast) mustEqual n.ast } "right" in { val q = quote { - qr1.filter(a => a.i == 1).fullJoin(qr2).on((b, c) => b.s == c.s).flatMap(d => qr2.map(c => c.s)) + qr1.filter(a => a.i == 1).fullJoin(qr2).on((b, c) => b.s == c.s).flatMap(_ => qr2.map(c => c.s)) } val n = quote { - qr1.filter(a => a.i == 1).fullJoin(qr2).on((b, c) => b.s == c.s).flatMap(d => qr2.map(c1 => c1.s)) + qr1.filter(a => a.i == 1).fullJoin(qr2).on((b, c) => b.s == c.s).flatMap(_ => qr2.map(c1 => c1.s)) } AvoidAliasConflict(q.ast) mustEqual n.ast } "both" in { val q = quote { - qr1.fullJoin(qr2).on((a, b) => a.s == b.s).flatMap(c => qr1.flatMap(a => qr2.map(b => b.s))) + qr1.fullJoin(qr2).on((a, b) => a.s == b.s).flatMap(_ => qr1.flatMap(_ => qr2.map(b => b.s))) } val n = quote { - qr1.fullJoin(qr2).on((a, b) => a.s == b.s).flatMap(c => qr1.flatMap(a1 => qr2.map(b1 => b1.s))) + qr1.fullJoin(qr2).on((a, b) => a.s == b.s).flatMap(_ => qr1.flatMap(_ => qr2.map(b1 => b1.s))) } AvoidAliasConflict(q.ast) mustEqual n.ast } @@ -272,17 +272,17 @@ class AvoidAliasConflictSpec extends Spec { "handles many alias conflicts" in { val q = quote { - qr1.flatMap(a => qr2.flatMap(a => qr2.flatMap(a => qr1))) + qr1.flatMap(_ => qr2.flatMap(_ => qr2.flatMap(_ => qr1))) } val n = quote { - qr1.flatMap(a => qr2.flatMap(a1 => qr2.flatMap(a2 => qr1))) + qr1.flatMap(_ => qr2.flatMap(_ => qr2.flatMap(_ => qr1))) } AvoidAliasConflict(q.ast) mustEqual n.ast } "doesn't change the query if it doesn't have conflicts" in { val q = quote { - qr1.flatMap(a => qr2.sortBy(b => b.s).filter(c => c.s == "s1")).flatMap(d => qr3.map(e => e.s)) + qr1.flatMap(_ => qr2.sortBy(b => b.s).filter(c => c.s == "s1")).flatMap(_ => qr3.map(e => e.s)) } AvoidAliasConflict(q.ast) mustEqual q.ast } diff --git a/quill-core/src/test/scala/io/getquill/norm/capture/AvoidCaptureSpec.scala b/quill-core/src/test/scala/io/getquill/norm/capture/AvoidCaptureSpec.scala index 544b32bab4..8a0cfad50b 100644 --- a/quill-core/src/test/scala/io/getquill/norm/capture/AvoidCaptureSpec.scala +++ b/quill-core/src/test/scala/io/getquill/norm/capture/AvoidCaptureSpec.scala @@ -12,11 +12,11 @@ class AvoidCaptureSpec extends Spec { "avoids capture of entities for normalization" in { val q = quote { - qr1.filter(u => u.s == "s1").flatMap(b => qr2.filter(u => u.s == "s1")).flatMap(c => qr3.map(u => u.s)) + qr1.filter(u => u.s == "s1").flatMap(_ => qr2.filter(u => u.s == "s1")).flatMap(_ => qr3.map(u => u.s)) } val n = quote { - qr1.filter(u => u.s == "s1").flatMap(u => qr2.filter(u1 => u1.s == "s1")).flatMap(u1 => qr3.map(u2 => u2.s)) + qr1.filter(u => u.s == "s1").flatMap(_ => qr2.filter(u1 => u1.s == "s1")).flatMap(_ => qr3.map(u2 => u2.s)) } - AvoidCapture(q.ast, TraceConfig(List())) mustEqual n.ast + AvoidCapture(q.ast, TraceConfig(List.empty)) mustEqual n.ast } } diff --git a/quill-core/src/test/scala/io/getquill/norm/capture/DealiasSpec.scala b/quill-core/src/test/scala/io/getquill/norm/capture/DealiasSpec.scala index 514b39f685..d08de68138 100644 --- a/quill-core/src/test/scala/io/getquill/norm/capture/DealiasSpec.scala +++ b/quill-core/src/test/scala/io/getquill/norm/capture/DealiasSpec.scala @@ -15,10 +15,10 @@ class DealiasSpec extends Spec { "ensures that each entity is referenced by the same alias" - { "flatMap" in { val q = quote { - qr1.filter(a => a.s == "s").flatMap(b => qr2) + qr1.filter(a => a.s == "s").flatMap(_ => qr2) } val n = quote { - qr1.filter(a => a.s == "s").flatMap(a => qr2) + qr1.filter(a => a.s == "s").flatMap(_ => qr2) } Dealias(q.ast) mustEqual n.ast } diff --git a/quill-core/src/test/scala/io/getquill/quat/QuatSpec.scala b/quill-core/src/test/scala/io/getquill/quat/QuatSpec.scala index 8a9be1f1d6..bf11515bbc 100644 --- a/quill-core/src/test/scala/io/getquill/quat/QuatSpec.scala +++ b/quill-core/src/test/scala/io/getquill/quat/QuatSpec.scala @@ -2,7 +2,6 @@ package io.getquill.quat import io.getquill._ import io.getquill.base.Spec -import io.getquill.norm.RepropagateQuats import io.getquill.quotation.QuatException import scala.language.reflectiveCalls @@ -13,7 +12,7 @@ class QuatSpec extends Spec { import testContext._ "boolean and optional boolean" in { - case class MyPerson(name: String, isHuman: Boolean, isRussian: Option[Boolean]) + final case class MyPerson(name: String, isHuman: Boolean, isRussian: Option[Boolean]) val MyPersonQuat = Quat.Product("MyPerson", "name" -> Quat.Value, "isHuman" -> Quat.BooleanValue, "isRussian" -> Quat.BooleanValue) @@ -22,7 +21,7 @@ class QuatSpec extends Spec { } "should support standard case class" in { - case class MyPerson(firstName: String, lastName: String, age: Int) + final case class MyPerson(firstName: String, lastName: String, age: Int) val MyPersonQuat = Quat.LeafProduct("MyPerson", "firstName", "lastName", "age") quote(query[MyPerson]).ast.quat mustEqual MyPersonQuat @@ -30,8 +29,8 @@ class QuatSpec extends Spec { } "should support embedded" in { - case class MyName(first: String, last: String) - case class MyPerson(name: MyName, age: Int) + final case class MyName(first: String, last: String) + final case class MyPerson(name: MyName, age: Int) val MyPersonQuat = Quat.Product("MyPerson", "name" -> Quat.LeafProduct("MyName", "first", "last"), "age" -> Quat.Value) @@ -40,7 +39,7 @@ class QuatSpec extends Spec { } "should refine quats from generic infixes" - { - case class MyPerson(name: String, age: Int) + final case class MyPerson(name: String, age: Int) val MyPersonQuat = Quat.Product("MyPerson", "name" -> Quat.Value, "age" -> Quat.Value) "propagating from transparent infixes in: extension methods" in { @@ -87,9 +86,9 @@ class QuatSpec extends Spec { } "should support multi-level embedded" in { - case class MyName(first: String, last: String) - case class MyId(name: MyName, memberNum: Int) - case class MyPerson(name: MyId, age: Int) + final case class MyName(first: String, last: String) + final case class MyId(name: MyName, memberNum: Int) + final case class MyPerson(name: MyId, age: Int) val MyPersonQuat = Quat.Product( "MyPerson", "name" -> Quat.Product("MyId", "name" -> Quat.LeafProduct("MyName", "first", "last"), "memberNum" -> Quat.Value), @@ -110,7 +109,7 @@ class QuatSpec extends Spec { "in query as" in { trait Animal { def name: String } - case class Cat(name: String, color: Int) extends Animal + final case class Cat(name: String, color: Int) extends Animal def isSpot[A <: Animal] = quote { (animals: Query[A]) => animals.filter(a => a.name == "Spot") @@ -136,7 +135,7 @@ class QuatSpec extends Spec { val p: Quat = Quat.Product("p", "foo" -> Quat.Value) val v: Quat = Quat.Value p.probit mustEqual p - val e = intercept[QuatException] { + intercept[QuatException] { v.probit } } @@ -160,7 +159,7 @@ class QuatSpec extends Spec { "rename field" in { prod.withRenames(List("bv" -> "bva", "p" -> "pa")).applyRenames mustEqual expect } - val e = intercept[QuatException] { + intercept[QuatException] { value.withRenames(List("foo" -> "bar")) } } @@ -215,14 +214,14 @@ class QuatSpec extends Spec { func.ast.quat mustEqual Quat.Generic } "case class" in { - case class MyPerson(name: String, isRussian: Boolean) + final case class MyPerson(name: String, isRussian: Boolean) def func = quote { (q: Query[MyPerson]) => q.filter(p => p.name == "Joe") } func.ast.quat mustEqual Quat.Product("MyPerson", "name" -> Quat.Value, "isRussian" -> Quat.BooleanValue) } "case class with boundary" in { - case class MyPerson(name: String, isRussian: Boolean) + final case class MyPerson(name: String, isRussian: Boolean) def func[T <: MyPerson] = quote { (q: Query[T]) => q.filter(p => p.name == "Joe") } @@ -314,14 +313,14 @@ class QuatSpec extends Spec { func.ast.quat mustEqual Quat.Product("T", "name" -> Quat.Value, "isRussian" -> Quat.BooleanValue) } "case class" in { - case class MyPerson(name: String, isRussian: Boolean) + final case class MyPerson(name: String, isRussian: Boolean) def func = quote { (q: MyPerson) => q } func.ast.quat mustEqual Quat.Product("MyPerson", "name" -> Quat.Value, "isRussian" -> Quat.BooleanValue) } "case class with boundary" in { - case class MyPerson(name: String, isRussian: Boolean) + final case class MyPerson(name: String, isRussian: Boolean) def func[T <: MyPerson] = quote { (q: T) => q } diff --git a/quill-core/src/test/scala/io/getquill/quotation/CompatibleDynamicQuerySpec.scala b/quill-core/src/test/scala/io/getquill/quotation/CompatibleDynamicQuerySpec.scala index d5cf31787b..85873d253e 100644 --- a/quill-core/src/test/scala/io/getquill/quotation/CompatibleDynamicQuerySpec.scala +++ b/quill-core/src/test/scala/io/getquill/quotation/CompatibleDynamicQuerySpec.scala @@ -95,7 +95,7 @@ class CompatibleDynamicQuerySpec extends Spec { cond = false test( quote(query[TestEntity]).dynamic.map(v0 => if (cond) quote(v0.i) else quote(1)), - query[TestEntity].map(v0 => 1) + query[TestEntity].map(_ => 1) ) } } @@ -103,19 +103,19 @@ class CompatibleDynamicQuerySpec extends Spec { "flatMap" - { "simple" in { test( - quote(query[TestEntity]).dynamic.flatMap(v0 => quote(query[TestEntity]).dynamic), - query[TestEntity].flatMap(v0 => query[TestEntity]) + quote(query[TestEntity]).dynamic.flatMap(_ => quote(query[TestEntity]).dynamic), + query[TestEntity].flatMap(_ => query[TestEntity]) ) } "mixed with static" in { test( - quote(query[TestEntity]).dynamic.flatMap(v0 => query[TestEntity]), - query[TestEntity].flatMap(v0 => query[TestEntity]) + quote(query[TestEntity]).dynamic.flatMap(_ => query[TestEntity]), + query[TestEntity].flatMap(_ => query[TestEntity]) ) test( - query[TestEntity].flatMap(v0 => quote(query[TestEntity]).dynamic), - query[TestEntity].flatMap(v0 => query[TestEntity]) + query[TestEntity].flatMap(_ => quote(query[TestEntity]).dynamic), + query[TestEntity].flatMap(_ => query[TestEntity]) ) } "with map" in { @@ -323,8 +323,8 @@ class CompatibleDynamicQuerySpec extends Spec { "size" in { test( - quote(query[TestEntity]).dynamic.map(v0 => quote(query[TestEntity]).dynamic.size), - query[TestEntity].map(v0 => query[TestEntity].size) + quote(query[TestEntity]).dynamic.map(_ => quote(query[TestEntity]).dynamic.size), + query[TestEntity].map(_ => query[TestEntity].size) ) } @@ -403,15 +403,15 @@ class CompatibleDynamicQuerySpec extends Spec { "nonEmpty" in { test( - quote(query[TestEntity]).dynamic.map(v0 => quote(query[TestEntity]).dynamic.nonEmpty), - query[TestEntity].map(v0 => query[TestEntity].nonEmpty) + quote(query[TestEntity]).dynamic.map(_ => quote(query[TestEntity]).dynamic.nonEmpty), + query[TestEntity].map(_ => query[TestEntity].nonEmpty) ) } "isEmpty" in { test( - quote(query[TestEntity]).dynamic.map(v0 => quote(query[TestEntity]).dynamic.isEmpty), - query[TestEntity].map(v0 => query[TestEntity].isEmpty) + quote(query[TestEntity]).dynamic.map(_ => quote(query[TestEntity]).dynamic.isEmpty), + query[TestEntity].map(_ => query[TestEntity].isEmpty) ) } @@ -426,8 +426,8 @@ class CompatibleDynamicQuerySpec extends Spec { } "value" in { test( - quote(query[TestEntity]).dynamic.map(v0 => quote(query[TestEntity]).dynamic.map(v1 => v1.i).contains(1)), - query[TestEntity].map(v0 => query[TestEntity].map(v1 => v1.i).contains(lift(1))) + quote(query[TestEntity]).dynamic.map(_ => quote(query[TestEntity]).dynamic.map(v1 => v1.i).contains(1)), + query[TestEntity].map(_ => query[TestEntity].map(v1 => v1.i).contains(lift(1))) ) } } diff --git a/quill-core/src/test/scala/io/getquill/quotation/DynamicQuerySpec.scala b/quill-core/src/test/scala/io/getquill/quotation/DynamicQuerySpec.scala index 35f3bab95e..102d914042 100644 --- a/quill-core/src/test/scala/io/getquill/quotation/DynamicQuerySpec.scala +++ b/quill-core/src/test/scala/io/getquill/quotation/DynamicQuerySpec.scala @@ -76,7 +76,7 @@ class DynamicQuerySpec extends Spec { "simple dynamic query succeeds" in { val s = dynamicQuerySchema[Person2]("Person2") - s.ast mustEqual Entity("Person2", List(), Quat.LeafProduct("firstName", "lastName")) + s.ast mustEqual Entity("Person2", List.empty, Quat.LeafProduct("firstName", "lastName")) } "dynamicQuery" in { @@ -137,7 +137,7 @@ class DynamicQuerySpec extends Spec { cond = false test( dynamicQuery[TestEntity].map(v0 => if (cond) quote(v0.i) else quote(1)), - query[TestEntity].map(v0 => 1) + query[TestEntity].map(_ => 1) ) } } @@ -145,19 +145,19 @@ class DynamicQuerySpec extends Spec { "flatMap" - { "simple" in { test( - dynamicQuery[TestEntity].flatMap(v0 => dynamicQuery[TestEntity]), - query[TestEntity].flatMap(v0 => query[TestEntity]) + dynamicQuery[TestEntity].flatMap(_ => dynamicQuery[TestEntity]), + query[TestEntity].flatMap(_ => query[TestEntity]) ) } "mixed with static" in { test( - dynamicQuery[TestEntity].flatMap(v0 => query[TestEntity]), - query[TestEntity].flatMap(v0 => query[TestEntity]) + dynamicQuery[TestEntity].flatMap(_ => query[TestEntity]), + query[TestEntity].flatMap(_ => query[TestEntity]) ) test( - query[TestEntity].flatMap(v0 => dynamicQuery[TestEntity]), - query[TestEntity].flatMap(v0 => query[TestEntity]) + query[TestEntity].flatMap(_ => dynamicQuery[TestEntity]), + query[TestEntity].flatMap(_ => query[TestEntity]) ) } "with map" in { @@ -363,8 +363,8 @@ class DynamicQuerySpec extends Spec { "size" in { test( - dynamicQuery[TestEntity].map(v0 => dynamicQuery[TestEntity].size), - query[TestEntity].map(v0 => query[TestEntity].size) + dynamicQuery[TestEntity].map(_ => dynamicQuery[TestEntity].size), + query[TestEntity].map(_ => query[TestEntity].size) ) } @@ -443,15 +443,15 @@ class DynamicQuerySpec extends Spec { "nonEmpty" in { test( - dynamicQuery[TestEntity].map(v0 => dynamicQuery[TestEntity].nonEmpty), - query[TestEntity].map(v0 => query[TestEntity].nonEmpty) + dynamicQuery[TestEntity].map(_ => dynamicQuery[TestEntity].nonEmpty), + query[TestEntity].map(_ => query[TestEntity].nonEmpty) ) } "isEmpty" in { test( - dynamicQuery[TestEntity].map(v0 => dynamicQuery[TestEntity].isEmpty), - query[TestEntity].map(v0 => query[TestEntity].isEmpty) + dynamicQuery[TestEntity].map(_ => dynamicQuery[TestEntity].isEmpty), + query[TestEntity].map(_ => query[TestEntity].isEmpty) ) } @@ -464,8 +464,8 @@ class DynamicQuerySpec extends Spec { } "value" in { test( - dynamicQuery[TestEntity].map(v0 => dynamicQuery[TestEntity].map(v1 => v1.i).contains(1)), - query[TestEntity].map(v0 => query[TestEntity].map(v1 => v1.i).contains(lift(1))) + dynamicQuery[TestEntity].map(_ => dynamicQuery[TestEntity].map(v1 => v1.i).contains(1)), + query[TestEntity].map(_ => query[TestEntity].map(v1 => v1.i).contains(lift(1))) ) } } diff --git a/quill-core/src/test/scala/io/getquill/quotation/FreeVariablesSpec.scala b/quill-core/src/test/scala/io/getquill/quotation/FreeVariablesSpec.scala index 546000ef78..7e11cc661a 100644 --- a/quill-core/src/test/scala/io/getquill/quotation/FreeVariablesSpec.scala +++ b/quill-core/src/test/scala/io/getquill/quotation/FreeVariablesSpec.scala @@ -20,7 +20,7 @@ class FreeVariablesSpec extends Spec { } "function" in { val q = - quote { (a: String) => + quote { (_: String) => s } FreeVariables(q.ast) mustEqual Set(IdentName("s")) @@ -78,7 +78,7 @@ class FreeVariablesSpec extends Spec { "conditional outer join" in { val q = quote { - qr1.leftJoin(qr2).on((a, b) => a.s == s) + qr1.leftJoin(qr2).on((a, _) => a.s == s) } FreeVariables(q.ast) mustEqual Set(IdentName("s")) } @@ -163,14 +163,14 @@ class FreeVariablesSpec extends Spec { } "option operators" - { "map" in { - val i = 1 + val q = quote { qr1.map(t => t.o.map(_ == t.i)) } FreeVariables(q.ast) mustBe empty } "forall" in { - val i = 1 + val q = quote { qr1.filter(t => t.o.forall(_ == t.i)) } @@ -178,14 +178,14 @@ class FreeVariablesSpec extends Spec { } "exists" in { - val i = 1 + val q = quote { qr1.filter(t => t.o.exists(_ == t.i)) } FreeVariables(q.ast) mustBe empty } "contains" in { - val i = 1 + val q = quote { qr1.filter(t => t.o.contains(t.i)) } diff --git a/quill-core/src/test/scala/io/getquill/quotation/QuotationSpec.scala b/quill-core/src/test/scala/io/getquill/quotation/QuotationSpec.scala index 48c7315409..cea9c719f2 100644 --- a/quill-core/src/test/scala/io/getquill/quotation/QuotationSpec.scala +++ b/quill-core/src/test/scala/io/getquill/quotation/QuotationSpec.scala @@ -15,8 +15,8 @@ import io.getquill.base.Spec import scala.math.BigDecimal.{double2bigDecimal, int2bigDecimal, javaBigDecimal2bigDecimal, long2bigDecimal} -case class CustomAnyValue(i: Int) extends AnyVal -case class EmbeddedValue(s: String, i: Int) +final case class CustomAnyValue(i: Int) extends AnyVal +final case class EmbeddedValue(s: String, i: Int) class QuotationSpec extends Spec { @@ -36,13 +36,13 @@ class QuotationSpec extends Spec { import io.getquill.quat.QuatOps.Implicits._ "without aliases" in { - quote(unquote(qr1)).ast mustEqual Entity("TestEntity", Nil, TestEntityQuat) + quote(unquote(qr1)).ast mustEqual Entity("TestEntity", List.empty, TestEntityQuat) } "with alias" in { val q = quote { querySchema[TestEntity]("SomeAlias") } - quote(unquote(q)).ast mustEqual Entity.Opinionated("SomeAlias", Nil, TestEntityQuat, Fixed) + quote(unquote(q)).ast mustEqual Entity.Opinionated("SomeAlias", List.empty, TestEntityQuat, Fixed) } "with property alias" in { import io.getquill.quat.QuatOps.Implicits._ @@ -53,7 +53,7 @@ class QuotationSpec extends Spec { quote(unquote(q)).ast mustEqual Entity.Opinionated( "SomeAlias", List(PropertyAlias(List("s"), "theS"), PropertyAlias(List("i"), "theI")), - quatOf[TestEntity].productOrFail().renameAtPath(Nil, List("s" -> "theS", "i" -> "theI")), + quatOf[TestEntity].productOrFail().renameAtPath(List.empty, List("s" -> "theS", "i" -> "theI")), Fixed ) } @@ -92,7 +92,7 @@ class QuotationSpec extends Spec { val q = quote { querySchema[TestEntity]("TestEntity", e => Predef.ArrowAssoc(e.s).->[String]("theS")) } - val renamedQuat = TestEntityQuat.renameAtPath(Nil, List("s" -> "theS")) + val renamedQuat = TestEntityQuat.renameAtPath(List.empty, List("s" -> "theS")) quote(unquote(q)).ast mustEqual Entity.Opinionated( "TestEntity", List(PropertyAlias(List("s"), "theS")), @@ -104,7 +104,7 @@ class QuotationSpec extends Spec { val q = quote { querySchema[TestEntity]("SomeAlias", _.s -> "theS", _.i -> "theI") } - val renamedQuat = TestEntityQuat.renameAtPath(Nil, List("s" -> "theS", "i" -> "theI")) + val renamedQuat = TestEntityQuat.renameAtPath(List.empty, List("s" -> "theS", "i" -> "theI")) quote(unquote(q)).ast mustEqual Entity.Opinionated( "SomeAlias", List(PropertyAlias(List("s"), "theS"), PropertyAlias(List("i"), "theI")), @@ -116,7 +116,7 @@ class QuotationSpec extends Spec { val q = quote { querySchema[TestEntity]("SomeAlias", _.s -> "theS").filter(t => t.s == "s" && t.i == 1) } - val renamedQuat = TestEntityQuat.renameAtPath(Nil, List("s" -> "theS")) + val renamedQuat = TestEntityQuat.renameAtPath(List.empty, List("s" -> "theS")) quote(unquote(q)).ast mustEqual ( Filter( Entity.Opinionated("SomeAlias", List(PropertyAlias(List("s"), "theS")), renamedQuat, Fixed), @@ -127,7 +127,7 @@ class QuotationSpec extends Spec { ) } - case class TableData(id: Int) + final case class TableData(id: Int) "with implicit property and generic" in { implicit class LimitQuery[T](q: Query[T]) { @@ -136,14 +136,14 @@ class QuotationSpec extends Spec { val q = quote(query[TableData].limitQuery) q.ast mustEqual Infix( List("", " LIMIT 1"), - List(Entity("TableData", List(), Quat.LeafProduct("id"))), + List(Entity("TableData", List.empty, Quat.LeafProduct("id"))), false, false, Quat.Generic ) quote(unquote(q)).ast mustEqual Infix( List("", " LIMIT 1"), - List(Entity("TableData", List(), Quat.LeafProduct("id"))), + List(Entity("TableData", List.empty, Quat.LeafProduct("id"))), false, false, Quat.LeafProduct("id") @@ -154,14 +154,14 @@ class QuotationSpec extends Spec { val q = quote(limitQuery(query[TableData])) q.ast mustEqual Infix( List("", " LIMIT 1"), - List(Entity("TableData", List(), Quat.LeafProduct("id"))), + List(Entity("TableData", List.empty, Quat.LeafProduct("id"))), false, false, Quat.Generic ) quote(unquote(q)).ast mustEqual Infix( List("", " LIMIT 1"), - List(Entity("TableData", List(), Quat.LeafProduct("id"))), + List(Entity("TableData", List.empty, Quat.LeafProduct("id"))), false, false, Quat.LeafProduct("id") @@ -172,14 +172,14 @@ class QuotationSpec extends Spec { val q = quote(limitQuery[TableData](query[TableData])) q.ast mustEqual Infix( List("", " LIMIT 1"), - List(Entity("TableData", List(), Quat.LeafProduct("id"))), + List(Entity("TableData", List.empty, Quat.LeafProduct("id"))), false, false, Quat.Generic ) quote(unquote(q)).ast mustEqual Infix( List("", " LIMIT 1"), - List(Entity("TableData", List(), Quat.LeafProduct("id"))), + List(Entity("TableData", List.empty, Quat.LeafProduct("id"))), false, false, Quat.LeafProduct("id") @@ -191,7 +191,7 @@ class QuotationSpec extends Spec { qr1.filter(t => t.s == "s") } quote(unquote(q)).ast mustEqual Filter( - Entity("TestEntity", Nil, TestEntityQuat), + Entity("TestEntity", List.empty, TestEntityQuat), Ident("t", TestEntityQuat), BinaryOperation(Property(Ident("t", TestEntityQuat), "s"), EqualityOperator.`_==`, Constant.auto("s")) ) @@ -201,7 +201,7 @@ class QuotationSpec extends Spec { qr1.withFilter(t => t.s == "s") } quote(unquote(q)).ast mustEqual Filter( - Entity("TestEntity", Nil, TestEntityQuat), + Entity("TestEntity", List.empty, TestEntityQuat), Ident("t"), BinaryOperation(Property(Ident("t"), "s"), EqualityOperator.`_==`, Constant.auto("s")) ) @@ -211,19 +211,19 @@ class QuotationSpec extends Spec { qr1.map(t => t.s) } quote(unquote(q)).ast mustEqual Map( - Entity("TestEntity", Nil, TestEntityQuat), + Entity("TestEntity", List.empty, TestEntityQuat), Ident("t"), Property(Ident("t"), "s") ) } "flatMap" in { val q = quote { - qr1.flatMap(t => qr2) + qr1.flatMap(_ => qr2) } quote(unquote(q)).ast mustEqual FlatMap( - Entity("TestEntity", Nil, TestEntityQuat), + Entity("TestEntity", List.empty, TestEntityQuat), Ident("t", TestEntityQuat), - Entity("TestEntity2", Nil, TestEntity2Quat) + Entity("TestEntity2", List.empty, TestEntity2Quat) ) } "concatMap" in { @@ -231,7 +231,7 @@ class QuotationSpec extends Spec { qr1.concatMap(t => t.s.split(" ")) } quote(unquote(q)).ast mustEqual ConcatMap( - Entity("TestEntity", Nil, TestEntityQuat), + Entity("TestEntity", List.empty, TestEntityQuat), Ident("t"), BinaryOperation(Property(Ident("t", TestEntityQuat), "s"), StringOperator.`split`, Constant.auto(" ")) ) @@ -242,7 +242,7 @@ class QuotationSpec extends Spec { qr1.sortBy(t => t.s) } quote(unquote(q)).ast mustEqual SortBy( - Entity("TestEntity", Nil, TestEntityQuat), + Entity("TestEntity", List.empty, TestEntityQuat), Ident("t", TestEntityQuat), Property(Ident("t"), "s"), AscNullsFirst @@ -253,7 +253,7 @@ class QuotationSpec extends Spec { qr1.sortBy(t => t.s)(Ord.asc) } quote(unquote(q)).ast mustEqual SortBy( - Entity("TestEntity", Nil, TestEntityQuat), + Entity("TestEntity", List.empty, TestEntityQuat), Ident("t"), Property(Ident("t"), "s"), Asc @@ -264,7 +264,7 @@ class QuotationSpec extends Spec { qr1.sortBy(t => t.s)(Ord.desc) } quote(unquote(q)).ast mustEqual SortBy( - Entity("TestEntity", Nil, TestEntityQuat), + Entity("TestEntity", List.empty, TestEntityQuat), Ident("t"), Property(Ident("t"), "s"), Desc @@ -275,7 +275,7 @@ class QuotationSpec extends Spec { qr1.sortBy(t => t.s)(Ord.ascNullsFirst) } quote(unquote(q)).ast mustEqual SortBy( - Entity("TestEntity", Nil, TestEntityQuat), + Entity("TestEntity", List.empty, TestEntityQuat), Ident("t"), Property(Ident("t"), "s"), AscNullsFirst @@ -286,7 +286,7 @@ class QuotationSpec extends Spec { qr1.sortBy(t => t.s)(Ord.descNullsFirst) } quote(unquote(q)).ast mustEqual SortBy( - Entity("TestEntity", Nil, TestEntityQuat), + Entity("TestEntity", List.empty, TestEntityQuat), Ident("t"), Property(Ident("t"), "s"), DescNullsFirst @@ -297,7 +297,7 @@ class QuotationSpec extends Spec { qr1.sortBy(t => t.s)(Ord.ascNullsLast) } quote(unquote(q)).ast mustEqual SortBy( - Entity("TestEntity", Nil, TestEntityQuat), + Entity("TestEntity", List.empty, TestEntityQuat), Ident("t"), Property(Ident("t"), "s"), AscNullsLast @@ -308,7 +308,7 @@ class QuotationSpec extends Spec { qr1.sortBy(t => t.s)(Ord.descNullsLast) } quote(unquote(q)).ast mustEqual SortBy( - Entity("TestEntity", Nil, TestEntityQuat), + Entity("TestEntity", List.empty, TestEntityQuat), Ident("t"), Property(Ident("t"), "s"), DescNullsLast @@ -320,7 +320,7 @@ class QuotationSpec extends Spec { qr1.sortBy(t => (t.s, t.i))(Ord.desc) } quote(unquote(q)).ast mustEqual SortBy( - Entity("TestEntity", Nil, TestEntityQuat), + Entity("TestEntity", List.empty, TestEntityQuat), Ident("t"), Tuple(List(Property(Ident("t"), "s"), Property(Ident("t"), "i"))), Desc @@ -331,7 +331,7 @@ class QuotationSpec extends Spec { qr1.sortBy(t => (t.s, t.i))(Ord(Ord.desc, Ord.asc)) } quote(unquote(q)).ast mustEqual SortBy( - Entity("TestEntity", Nil, TestEntityQuat), + Entity("TestEntity", List.empty, TestEntityQuat), Ident("t"), Tuple(List(Property(Ident("t"), "s"), Property(Ident("t"), "i"))), TupleOrdering(List(Desc, Asc)) @@ -344,7 +344,7 @@ class QuotationSpec extends Spec { qr1.groupBy(t => t.s) } quote(unquote(q)).ast mustEqual GroupBy( - Entity("TestEntity", Nil, TestEntityQuat), + Entity("TestEntity", List.empty, TestEntityQuat), Ident("t", TestEntityQuat), Property(Ident("t", TestEntityQuat), "s") ) @@ -358,7 +358,7 @@ class QuotationSpec extends Spec { quote(unquote(q)).ast mustEqual Aggregation( AggregationOperator.`min`, Map( - Entity("TestEntity", Nil, TestEntityQuat), + Entity("TestEntity", List.empty, TestEntityQuat), Ident("t", TestEntityQuat), Property(Ident("t", TestEntityQuat), "i") ) @@ -370,7 +370,7 @@ class QuotationSpec extends Spec { } quote(unquote(q)).ast mustEqual Aggregation( AggregationOperator.`max`, - Map(Entity("TestEntity", Nil, TestEntityQuat), Ident("t"), Property(Ident("t", TestEntityQuat), "i")) + Map(Entity("TestEntity", List.empty, TestEntityQuat), Ident("t"), Property(Ident("t", TestEntityQuat), "i")) ) } "avg" in { @@ -379,7 +379,7 @@ class QuotationSpec extends Spec { } quote(unquote(q)).ast mustEqual Aggregation( AggregationOperator.`avg`, - Map(Entity("TestEntity", Nil, TestEntityQuat), Ident("t"), Property(Ident("t", TestEntityQuat), "i")) + Map(Entity("TestEntity", List.empty, TestEntityQuat), Ident("t"), Property(Ident("t", TestEntityQuat), "i")) ) } "sum" in { @@ -388,7 +388,7 @@ class QuotationSpec extends Spec { } quote(unquote(q)).ast mustEqual Aggregation( AggregationOperator.`sum`, - Map(Entity("TestEntity", Nil, TestEntityQuat), Ident("t"), Property(Ident("t", TestEntityQuat), "i")) + Map(Entity("TestEntity", List.empty, TestEntityQuat), Ident("t"), Property(Ident("t", TestEntityQuat), "i")) ) } "size" in { @@ -397,7 +397,7 @@ class QuotationSpec extends Spec { } quote(unquote(q)).ast mustEqual Aggregation( AggregationOperator.`size`, - Map(Entity("TestEntity", Nil, TestEntityQuat), Ident("t"), Property(Ident("t", TestEntityQuat), "i")) + Map(Entity("TestEntity", List.empty, TestEntityQuat), Ident("t"), Property(Ident("t", TestEntityQuat), "i")) ) } } @@ -409,7 +409,7 @@ class QuotationSpec extends Spec { } quote(unquote(q)).ast mustEqual Aggregation( AggregationOperator.`min`, - Map(Entity("TestEntity", Nil, TestEntityQuat), Ident("t"), Property(Ident("t", TestEntityQuat), "s")) + Map(Entity("TestEntity", List.empty, TestEntityQuat), Ident("t"), Property(Ident("t", TestEntityQuat), "s")) ) } "max" in { @@ -418,7 +418,7 @@ class QuotationSpec extends Spec { } quote(unquote(q)).ast mustEqual Aggregation( AggregationOperator.`max`, - Map(Entity("TestEntity", Nil, TestEntityQuat), Ident("t"), Property(Ident("t", TestEntityQuat), "s")) + Map(Entity("TestEntity", List.empty, TestEntityQuat), Ident("t"), Property(Ident("t", TestEntityQuat), "s")) ) } } @@ -426,33 +426,33 @@ class QuotationSpec extends Spec { val q = quote { qr1.distinct } - quote(unquote(q)).ast mustEqual Distinct(Entity("TestEntity", Nil, TestEntityQuat)) + quote(unquote(q)).ast mustEqual Distinct(Entity("TestEntity", List.empty, TestEntityQuat)) } "nested" in { val q = quote { qr1.nested } - quote(unquote(q)).ast mustEqual Nested(Entity("TestEntity", Nil, TestEntityQuat)) + quote(unquote(q)).ast mustEqual Nested(Entity("TestEntity", List.empty, TestEntityQuat)) } "take" in { val q = quote { qr1.take(10) } - quote(unquote(q)).ast mustEqual Take(Entity("TestEntity", Nil, TestEntityQuat), Constant.auto(10)) + quote(unquote(q)).ast mustEqual Take(Entity("TestEntity", List.empty, TestEntityQuat), Constant.auto(10)) } "drop" in { val q = quote { qr1.drop(10) } - quote(unquote(q)).ast mustEqual Drop(Entity("TestEntity", Nil, TestEntityQuat), Constant.auto(10)) + quote(unquote(q)).ast mustEqual Drop(Entity("TestEntity", List.empty, TestEntityQuat), Constant.auto(10)) } "union" in { val q = quote { qr1.union(qr2) } quote(unquote(q)).ast mustEqual Union( - Entity("TestEntity", Nil, TestEntityQuat), - Entity("TestEntity2", Nil, TestEntity2Quat) + Entity("TestEntity", List.empty, TestEntityQuat), + Entity("TestEntity2", List.empty, TestEntity2Quat) ) } "unionAll" - { @@ -461,8 +461,8 @@ class QuotationSpec extends Spec { qr1.union(qr2) } quote(unquote(q)).ast mustEqual Union( - Entity("TestEntity", Nil, TestEntityQuat), - Entity("TestEntity2", Nil, TestEntity2Quat) + Entity("TestEntity", List.empty, TestEntityQuat), + Entity("TestEntity2", List.empty, TestEntity2Quat) ) } "++" in { @@ -470,8 +470,8 @@ class QuotationSpec extends Spec { qr1 ++ qr2 } quote(unquote(q)).ast mustEqual UnionAll( - Entity("TestEntity", Nil, TestEntityQuat), - Entity("TestEntity2", Nil, TestEntity2Quat) + Entity("TestEntity", List.empty, TestEntityQuat), + Entity("TestEntity2", List.empty, TestEntity2Quat) ) } } @@ -480,8 +480,8 @@ class QuotationSpec extends Spec { def tree(t: JoinType) = Join( t, - Entity("TestEntity", Nil, TestEntityQuat), - Entity("TestEntity2", Nil, TestEntity2Quat), + Entity("TestEntity", List.empty, TestEntityQuat), + Entity("TestEntity2", List.empty, TestEntity2Quat), Ident("a"), Ident("b"), BinaryOperation(Property(Ident("a"), "s"), EqualityOperator.`_==`, Property(Ident("b"), "s")) @@ -528,7 +528,7 @@ class QuotationSpec extends Spec { qr1.update(t => t.s -> "s") } quote(unquote(q)).ast mustEqual Update( - Entity("TestEntity", Nil, TestEntityQuat), + Entity("TestEntity", List.empty, TestEntityQuat), List(Assignment(Ident("t"), Property(Ident("t"), "s"), Constant.auto("s"))) ) } @@ -537,7 +537,7 @@ class QuotationSpec extends Spec { qr1.update(t => t.i -> (t.i + 1)) } quote(unquote(q)).ast mustEqual Update( - Entity("TestEntity", Nil, TestEntityQuat), + Entity("TestEntity", List.empty, TestEntityQuat), List( Assignment( Ident("t"), @@ -567,7 +567,7 @@ class QuotationSpec extends Spec { qr1.update(t => Predef.ArrowAssoc(t.s).->[String]("s")) } quote(unquote(q)).ast mustEqual Update( - Entity("TestEntity", Nil, TestEntityQuat), + Entity("TestEntity", List.empty, TestEntityQuat), List(Assignment(Ident("t"), Property(Ident("t"), "s"), Constant.auto("s"))) ) } @@ -584,7 +584,7 @@ class QuotationSpec extends Spec { qr1.insert(t => t.s -> "s") } quote(unquote(q)).ast mustEqual Insert( - Entity("TestEntity", Nil, TestEntityQuat), + Entity("TestEntity", List.empty, TestEntityQuat), List(Assignment(Ident("t"), Property(Ident("t"), "s"), Constant.auto("s"))) ) } @@ -633,7 +633,7 @@ class QuotationSpec extends Spec { val q = quote { qr1.delete } - quote(unquote(q)).ast mustEqual Delete(Entity("TestEntity", Nil, TestEntityQuat)) + quote(unquote(q)).ast mustEqual Delete(Entity("TestEntity", List.empty, TestEntityQuat)) } "fails if the assignment types don't match" in { """ @@ -697,7 +697,7 @@ class QuotationSpec extends Spec { } "fails if not case class property" - { "val" in { - case class T(s: String) { + final case class T(s: String) { val boom = 1 } """ @@ -707,7 +707,7 @@ class QuotationSpec extends Spec { """ mustNot compile } "def" in { - case class T(s: String) { + final case class T(s: String) { def boom = 1 } """ @@ -839,9 +839,9 @@ class QuotationSpec extends Spec { """ mustNot compile } "comparing types with subclassing" - { - case class Foo(id: Int) + final case class Foo(id: Int) trait Foot - case class Bar(id: Int) + final case class Bar(id: Int) trait Bart "succeeds when Option[T]/Option[T]" in { @@ -977,9 +977,9 @@ class QuotationSpec extends Spec { quote(unquote(q)).ast.body mustEqual BinaryOperation(Ident("a"), EqualityOperator.`_==`, Ident("b")) } - case class Foo(id: Int) + final case class Foo(id: Int) trait Foot - case class Bar(id: Int) + final case class Bar(id: Int) trait Bart "should succeed if right is subclass" in { @@ -1088,9 +1088,9 @@ class QuotationSpec extends Spec { """ mustNot compile } "comparing types with subclassing" - { - case class Foo(id: Int) + final case class Foo(id: Int) trait Foot - case class Bar(id: Int) + final case class Bar(id: Int) trait Bart "succeeds when Option[T]/Option[subclass T]" in { @@ -1359,21 +1359,21 @@ class QuotationSpec extends Spec { } quote(unquote(q)).ast mustEqual UnaryOperation( SetOperator.`nonEmpty`, - Entity("TestEntity", Nil, TestEntityQuat) + Entity("TestEntity", List.empty, TestEntityQuat) ) } "isEmpty" in { val q = quote { qr1.isEmpty } - quote(unquote(q)).ast mustEqual UnaryOperation(SetOperator.`isEmpty`, Entity("TestEntity", Nil, TestEntityQuat)) + quote(unquote(q)).ast mustEqual UnaryOperation(SetOperator.`isEmpty`, Entity("TestEntity", List.empty, TestEntityQuat)) } "toUpperCase" in { val q = quote { qr1.map(t => t.s.toUpperCase) } quote(unquote(q)).ast mustEqual Map( - Entity("TestEntity", Nil, TestEntityQuat), + Entity("TestEntity", List.empty, TestEntityQuat), Ident("t"), UnaryOperation(StringOperator.`toUpperCase`, Property(Ident("t"), "s")) ) @@ -1383,7 +1383,7 @@ class QuotationSpec extends Spec { qr1.map(t => t.s.toLowerCase) } quote(unquote(q)).ast mustEqual Map( - Entity("TestEntity", Nil, TestEntityQuat), + Entity("TestEntity", List.empty, TestEntityQuat), Ident("t"), UnaryOperation(StringOperator.`toLowerCase`, Property(Ident("t"), "s")) ) @@ -1393,7 +1393,7 @@ class QuotationSpec extends Spec { qr1.map(t => t.s.toLong) } quote(unquote(q)).ast mustEqual Map( - Entity("TestEntity", Nil, TestEntityQuat), + Entity("TestEntity", List.empty, TestEntityQuat), Ident("t"), UnaryOperation(StringOperator.`toLong`, Property(Ident("t"), "s")) ) @@ -1403,7 +1403,7 @@ class QuotationSpec extends Spec { qr1.map(t => t.s.toInt) } quote(unquote(q)).ast mustEqual Map( - Entity("TestEntity", Nil, TestEntityQuat), + Entity("TestEntity", List.empty, TestEntityQuat), Ident("t"), UnaryOperation(StringOperator.`toInt`, Property(Ident("t"), "s")) ) @@ -1414,7 +1414,7 @@ class QuotationSpec extends Spec { val q = quote { sql"true".as[Boolean] } - quote(unquote(q)).ast mustEqual Infix(List("true"), Nil, false, false, Quat.BooleanValue) + quote(unquote(q)).ast mustEqual Infix(List("true"), List.empty, false, false, Quat.BooleanValue) } "with params" in { val q = quote { (a: String, b: String) => @@ -1464,7 +1464,7 @@ class QuotationSpec extends Spec { val q = quote { sql"#$a".as[String] } - quote(unquote(q)).ast mustEqual Infix(List("dyn1"), List(), false, false, QV) + quote(unquote(q)).ast mustEqual Infix(List("dyn1"), List.empty, false, false, QV) } "sequential - pure" in { val a = "dyn1" @@ -1472,7 +1472,7 @@ class QuotationSpec extends Spec { val q = quote { sql"#$a#$b".pure.as[String] } - quote(unquote(q)).ast mustEqual Infix(List("dyn1dyn2"), List(), true, false, QV) + quote(unquote(q)).ast mustEqual Infix(List("dyn1dyn2"), List.empty, true, false, QV) } "sequential" in { val a = "dyn1" @@ -1480,22 +1480,22 @@ class QuotationSpec extends Spec { val q = quote { sql"#$a#$b".as[String] } - quote(unquote(q)).ast mustEqual Infix(List("dyn1dyn2"), List(), false, false, QV) + quote(unquote(q)).ast mustEqual Infix(List("dyn1dyn2"), List.empty, false, false, QV) } "non-string value" in { - case class Value(a: String) + final case class Value(a: String) val a = Value("dyn") val q = quote { sql"#$a".as[String] } - quote(unquote(q)).ast mustEqual Infix(List("Value(dyn)"), List(), false, false, QV) + quote(unquote(q)).ast mustEqual Infix(List("Value(dyn)"), List.empty, false, false, QV) } } } "option operation" - { import io.getquill.ast.Implicits._ - case class Row(id: Int, value: String) + final case class Row(id: Int, value: String) "map" - { "simple" in { @@ -1589,7 +1589,7 @@ class QuotationSpec extends Spec { quote(unquote(q)).ast.body mustEqual OptionForall(Ident("o"), Ident("v"), Ident("v")) } "embedded" in { - case class EmbeddedEntity(id: Int) + final case class EmbeddedEntity(id: Int) "quote((o: Option[EmbeddedEntity]) => o.forall(v => v.id == 1))" mustNot compile } } @@ -1601,7 +1601,7 @@ class QuotationSpec extends Spec { quote(unquote(q)).ast.body mustEqual FilterIfDefined(Ident("o"), Ident("v"), Ident("v")) } "embedded" in { - case class EmbeddedEntity(id: Int) + final case class EmbeddedEntity(id: Int) "quote((o: Option[EmbeddedEntity]) => o.filterIfDefined(v => v.id == 1))" mustNot compile } } @@ -1623,7 +1623,7 @@ class QuotationSpec extends Spec { ) } "embedded" in { - case class EmbeddedEntity(id: Int) + final case class EmbeddedEntity(id: Int) val q = quote { (o: Option[EmbeddedEntity]) => o.exists(v => v.id == 1) } @@ -1762,7 +1762,7 @@ class QuotationSpec extends Spec { quote(unquote(q)).ast mustEqual Constant.auto("a") } "nested" in { - case class Add(i: Quoted[Int]) { + final case class Add(i: Quoted[Int]) { def apply() = quote(i + 1) } val q = quote { @@ -1774,15 +1774,15 @@ class QuotationSpec extends Spec { "simple" in { def test[T: SchemaMeta] = quote(query[T]) - test[TestEntity].ast mustEqual Entity("TestEntity", Nil, TestEntityQuat) + test[TestEntity].ast mustEqual Entity("TestEntity", List.empty, TestEntityQuat) } "nested" in { - def test[T: SchemaMeta] = quote(query[T].map(t => 1)) - test[TestEntity].ast mustEqual Map(Entity("TestEntity", Nil, TestEntityQuat), Ident("t"), Constant.auto(1)) + def test[T: SchemaMeta] = quote(query[T].map(_ => 1)) + test[TestEntity].ast mustEqual Map(Entity("TestEntity", List.empty, TestEntityQuat), Ident("t"), Constant.auto(1)) } } "forced" in { - val q = qr1.dynamic + qr1.dynamic "q.ast: Query[_]" mustNot compile } } @@ -1836,7 +1836,7 @@ class QuotationSpec extends Spec { l.encoder mustEqual intEncoder } "property" in { - case class TestEntity(a: String) + final case class TestEntity(a: String) val t = TestEntity("a") val q = quote(lift(t.a)) @@ -1934,8 +1934,8 @@ class QuotationSpec extends Spec { } } "embedded" in { - case class EmbeddedTestEntity(id: String) - case class TestEntity(embedded: EmbeddedTestEntity) + final case class EmbeddedTestEntity(id: String) + final case class TestEntity(embedded: EmbeddedTestEntity) val t = TestEntity(EmbeddedTestEntity("test")) val q = quote { query[TestEntity].insertValue(lift(t)) @@ -2059,7 +2059,7 @@ class QuotationSpec extends Spec { } "ignores the ifrefutable call" in { - val q = quote { + quote { qr1.map(t => (t.i, t.l)) } """ @@ -2108,7 +2108,7 @@ class QuotationSpec extends Spec { "doesn't double quote" in { val q = quote(1) - val dq: Quoted[Int] = quote(q) + quote(q) } "doesn't a allow quotation of null" in { diff --git a/quill-core/src/test/scala/io/getquill/quotation/RebindSpec.scala b/quill-core/src/test/scala/io/getquill/quotation/RebindSpec.scala index bf128085b9..8ebe97169b 100644 --- a/quill-core/src/test/scala/io/getquill/quotation/RebindSpec.scala +++ b/quill-core/src/test/scala/io/getquill/quotation/RebindSpec.scala @@ -25,7 +25,7 @@ class RebindSpec extends Spec { } } - case class A(date: Option[Long] = None) + final case class A(date: Option[Long] = None) testContext.run(query[A].filter(a => a.date.valid)).string mustEqual s"""querySchema("A").filter(a => sql"($${a.date} IS NULL OR $${a.date} > $${?})")""" } diff --git a/quill-core/src/test/scala/io/getquill/util/CacheSpec.scala b/quill-core/src/test/scala/io/getquill/util/CacheSpec.scala index 775545ba32..10cf1be209 100644 --- a/quill-core/src/test/scala/io/getquill/util/CacheSpec.scala +++ b/quill-core/src/test/scala/io/getquill/util/CacheSpec.scala @@ -9,7 +9,7 @@ class CacheSpec extends Spec { class Value extends Closeable { var closes = 0 - override def close = closes += 1 + override def close: Unit = closes += 1 } "caches hits" in { diff --git a/quill-core/src/test/scala/io/getquill/util/InterpolatorSpec.scala b/quill-core/src/test/scala/io/getquill/util/InterpolatorSpec.scala index bfcdf422a4..b729c2878e 100644 --- a/quill-core/src/test/scala/io/getquill/util/InterpolatorSpec.scala +++ b/quill-core/src/test/scala/io/getquill/util/InterpolatorSpec.scala @@ -11,7 +11,7 @@ class InterpolatorSpec extends Spec { import interp._ case class Small(id: Int) - val small = Small(123) + val small: Small = Small(123) "traces small objects on single line - single" in { trace"small object: $small".generateString() mustEqual (("small object: Small(123) ", 0)) @@ -49,8 +49,8 @@ and bar $small""".generateString() mustEqual ( nine: String, ten: String ) - val vars = (0 until 10).map(i => (0 until i).map(_ => "Test").mkString("")).toList - val large = Large(123, vars(0), vars(1), vars(2), vars(3), vars(4), vars(5), vars(6), vars(7), vars(8), vars(9)) + val vars: List[String] = (0 until 10).map(i => (0 until i).map(_ => "Test").mkString("")).toList + val large: Large = Large(123, vars(0), vars(1), vars(2), vars(3), vars(4), vars(5), vars(6), vars(7), vars(8), vars(9)) "traces large objects on multiple line - single" in { trace"large object: $large".generateString() mustEqual (( diff --git a/quill-doobie/src/test/scala/io/getquill/doobie/PeopleZioReturningSpec.scala b/quill-doobie/src/test/scala/io/getquill/doobie/PeopleZioReturningSpec.scala index 238c683002..00c8e2ec68 100644 --- a/quill-doobie/src/test/scala/io/getquill/doobie/PeopleZioReturningSpec.scala +++ b/quill-doobie/src/test/scala/io/getquill/doobie/PeopleZioReturningSpec.scala @@ -4,9 +4,6 @@ import cats.effect._ import cats.syntax.all._ import doobie._ import doobie.implicits._ -import io.getquill._ -import org.scalatest.freespec.AnyFreeSpec -import org.scalatest.matchers.must.Matchers import io.getquill.Literal import io.getquill.context.sql.base.PeopleReturningSpec @@ -19,7 +16,7 @@ class PeopleZioReturningSpec extends PeopleReturningSpec { import cats.effect.unsafe.implicits.global // A transactor that always rolls back. - lazy val xa = Transactor.after + lazy val xa: Transactor[IO[A]] = Transactor.after .set( Transactor.fromDriverManager[IO]( "org.postgresql.Driver", diff --git a/quill-doobie/src/test/scala/io/getquill/doobie/PostgresDoobieContextSuite.scala b/quill-doobie/src/test/scala/io/getquill/doobie/PostgresDoobieContextSuite.scala index d1d4c23899..642959384e 100644 --- a/quill-doobie/src/test/scala/io/getquill/doobie/PostgresDoobieContextSuite.scala +++ b/quill-doobie/src/test/scala/io/getquill/doobie/PostgresDoobieContextSuite.scala @@ -17,7 +17,7 @@ class PostgresDoobieContextSuite extends AnyFreeSpec with Matchers { import cats.effect.unsafe.implicits.global // A transactor that always rolls back. - lazy val xa = Transactor.after + lazy val xa: Transactor[IO[A]] = Transactor.after .set( Transactor.fromDriverManager[IO]( "org.postgresql.Driver", @@ -75,7 +75,7 @@ class PostgresDoobieContextSuite extends AnyFreeSpec with Matchers { } // For these last two we need a new table with an auto-generated id, so we'll do a temp table. - val create = { + val create: ConnectionIO[Long] = { val q = quote { qsql""" CREATE TEMPORARY TABLE QuillTest ( diff --git a/quill-doobie/src/test/scala/io/getquill/doobie/issue/Issue1067.scala b/quill-doobie/src/test/scala/io/getquill/doobie/issue/Issue1067.scala index c5d25262aa..c4a96057d1 100644 --- a/quill-doobie/src/test/scala/io/getquill/doobie/issue/Issue1067.scala +++ b/quill-doobie/src/test/scala/io/getquill/doobie/issue/Issue1067.scala @@ -7,13 +7,14 @@ import io.getquill._ import org.scalatest.freespec.AnyFreeSpec import org.scalatest.matchers.must.Matchers import io.getquill.doobie.DoobieContext +import doobie.util.transactor // https://github.com/tpolecat/doobie/issues/1067 class Issue1067 extends AnyFreeSpec with Matchers { import cats.effect.unsafe.implicits.global - lazy val xa = Transactor.fromDriverManager[IO]( + lazy val xa: transactor.Transactor.Aux[IO,Unit] = Transactor.fromDriverManager[IO]( "org.postgresql.Driver", s"jdbc:postgresql://${System.getenv("POSTGRES_HOST")}:${System.getenv("POSTGRES_PORT")}/doobie_test", "postgres", diff --git a/quill-jasync-mysql/src/test/scala/io/getquill/context/jasync/mysql/MysqlJAsyncContextSpec.scala b/quill-jasync-mysql/src/test/scala/io/getquill/context/jasync/mysql/MysqlJAsyncContextSpec.scala index 60bef118b6..406a9f28c4 100644 --- a/quill-jasync-mysql/src/test/scala/io/getquill/context/jasync/mysql/MysqlJAsyncContextSpec.scala +++ b/quill-jasync-mysql/src/test/scala/io/getquill/context/jasync/mysql/MysqlJAsyncContextSpec.scala @@ -45,7 +45,7 @@ class MysqlJAsyncContextSpec extends Spec { super.extractActionResult(returningAction, returningExtractor)(result) } intercept[IllegalStateException] { - val v = ctx.extractActionResult(ReturnColumns(List("w/e")), (row, session) => 1)( + val v = ctx.extractActionResult(ReturnColumns(List("w/e")), (_, _) => 1)( new QueryResult(0, "w/e", ResultSetKt.getEMPTY_RESULT_SET) ) ctx.handleSingleResult("", v) @@ -54,14 +54,14 @@ class MysqlJAsyncContextSpec extends Spec { } "prepare" in { - testContext.prepareParams("", (ps, session) => (Nil, ps ++ List("Sarah", 127))) mustEqual List("'Sarah'", "127") + testContext.prepareParams("", (ps, _) => (List.empty, ps ++ List("Sarah", 127))) mustEqual List("'Sarah'", "127") } "provides transaction support" - { "success" in { await(for { _ <- testContext.run(qr4.delete) - _ <- testContext.transaction { implicit ec => + _ <- testContext.transaction { _ => testContext.run(qr4.insert(_.i -> 33)) } r <- testContext.run(qr4) @@ -87,7 +87,7 @@ class MysqlJAsyncContextSpec extends Spec { await(for { _ <- testContext.run(qr4.delete) _ <- testContext.transaction { implicit ec => - testContext.transaction { implicit ec => + testContext.transaction { _ => testContext.run(qr4.insert(_.i -> 33)) } } diff --git a/quill-jasync-mysql/src/test/scala/io/getquill/context/jasync/mysql/MysqlJAsyncEncodingSpec.scala b/quill-jasync-mysql/src/test/scala/io/getquill/context/jasync/mysql/MysqlJAsyncEncodingSpec.scala index d76542ca66..fa06f06839 100644 --- a/quill-jasync-mysql/src/test/scala/io/getquill/context/jasync/mysql/MysqlJAsyncEncodingSpec.scala +++ b/quill-jasync-mysql/src/test/scala/io/getquill/context/jasync/mysql/MysqlJAsyncEncodingSpec.scala @@ -30,19 +30,19 @@ class MysqlJAsyncEncodingSpec extends EncodingSpec { "decode byte to" - { "short" in { prepareEncodingTestEntity() - case class EncodingTestEntity(v3: Short) + final case class EncodingTestEntity(v3: Short) val v3List = Await.result(testContext.run(query[EncodingTestEntity]), Duration.Inf) v3List.map(_.v3) must contain theSameElementsAs List(1: Byte, 0: Byte) } "int" in { prepareEncodingTestEntity() - case class EncodingTestEntity(v3: Int) + final case class EncodingTestEntity(v3: Int) val v3List = Await.result(testContext.run(query[EncodingTestEntity]), Duration.Inf) v3List.map(_.v3) must contain theSameElementsAs List(1, 0) } "long" in { prepareEncodingTestEntity() - case class EncodingTestEntity(v3: Long) + final case class EncodingTestEntity(v3: Long) val v3List = Await.result(testContext.run(query[EncodingTestEntity]), Duration.Inf) v3List.map(_.v3) must contain theSameElementsAs List(1L, 0L) } @@ -50,32 +50,32 @@ class MysqlJAsyncEncodingSpec extends EncodingSpec { "decode short to" - { "int" in { prepareEncodingTestEntity() - case class EncodingTestEntity(v5: Int) + final case class EncodingTestEntity(v5: Int) val v5List = Await.result(testContext.run(query[EncodingTestEntity]), Duration.Inf) v5List.map(_.v5) must contain theSameElementsAs List(23, 0) } "long" in { prepareEncodingTestEntity() - case class EncodingTestEntity(v5: Long) + final case class EncodingTestEntity(v5: Long) val v5List = Await.result(testContext.run(query[EncodingTestEntity]), Duration.Inf) v5List.map(_.v5) must contain theSameElementsAs List(23L, 0L) } } "decode int to long" in { - case class EncodingTestEntity(v6: Long) + final case class EncodingTestEntity(v6: Long) val v6List = Await.result(testContext.run(query[EncodingTestEntity]), Duration.Inf) v6List.map(_.v6) must contain theSameElementsAs List(33L, 0L) } "decode and encode any numeric as boolean" in { - case class EncodingTestEntity(v3: Boolean, v4: Boolean, v6: Boolean, v7: Boolean) + final case class EncodingTestEntity(v3: Boolean, v4: Boolean, v6: Boolean, v7: Boolean) Await.result(testContext.run(query[EncodingTestEntity]), Duration.Inf) () } } "decode date types" in { - case class DateEncodingTestEntity(v1: Date, v2: Date, v3: Date) + final case class DateEncodingTestEntity(v1: Date, v2: Date, v3: Date) val entity = DateEncodingTestEntity(new Date, new Date, new Date) val r = for { _ <- testContext.run(query[DateEncodingTestEntity].delete) @@ -87,7 +87,7 @@ class MysqlJAsyncEncodingSpec extends EncodingSpec { } "decode LocalDate and LocalDateTime types" in { - case class DateEncodingTestEntity(v1: LocalDate, v2: LocalDateTime, v3: LocalDateTime) + final case class DateEncodingTestEntity(v1: LocalDate, v2: LocalDateTime, v3: LocalDateTime) val entity = DateEncodingTestEntity(LocalDate.now, LocalDateTime.now, LocalDateTime.now) val r = for { _ <- testContext.run(query[DateEncodingTestEntity].delete) @@ -100,15 +100,15 @@ class MysqlJAsyncEncodingSpec extends EncodingSpec { "fails if the column has the wrong type" - { "numeric" in { Await.result(testContext.run(liftQuery(insertValues).foreach(e => insert(e))), Duration.Inf) - case class EncodingTestEntity(v1: Int) - val e = intercept[IllegalStateException] { + final case class EncodingTestEntity(v1: Int) + intercept[IllegalStateException] { Await.result(testContext.run(query[EncodingTestEntity]), Duration.Inf) } } "non-numeric" in { Await.result(testContext.run(liftQuery(insertValues).foreach(e => insert(e))), Duration.Inf) - case class EncodingTestEntity(v1: Date) - val e = intercept[IllegalStateException] { + final case class EncodingTestEntity(v1: Date) + intercept[IllegalStateException] { Await.result(testContext.run(query[EncodingTestEntity]), Duration.Inf) } } diff --git a/quill-jasync-mysql/src/test/scala/io/getquill/context/jasync/mysql/ProductMysqlJAsyncSpec.scala b/quill-jasync-mysql/src/test/scala/io/getquill/context/jasync/mysql/ProductMysqlJAsyncSpec.scala index 2167b358fd..7d1a599938 100644 --- a/quill-jasync-mysql/src/test/scala/io/getquill/context/jasync/mysql/ProductMysqlJAsyncSpec.scala +++ b/quill-jasync-mysql/src/test/scala/io/getquill/context/jasync/mysql/ProductMysqlJAsyncSpec.scala @@ -11,7 +11,7 @@ class ProductMysqlJAsyncSpec extends ProductSpec { val context = testContext import testContext._ - override def beforeAll = { + override def beforeAll: Unit = { await(testContext.run(quote(query[Product].delete))) () } @@ -57,7 +57,7 @@ class ProductMysqlJAsyncSpec extends ProductSpec { } "Single insert with value class" in { - case class Product(id: Id, description: String, sku: Long) + final case class Product(id: Id, description: String, sku: Long) val prd = Product(Id(0L), "test2", 2L) val q1 = quote { query[Product].insert(_.sku -> lift(prd.sku), _.description -> lift(prd.description)).returningGenerated(_.id) @@ -76,7 +76,7 @@ class ProductMysqlJAsyncSpec extends ProductSpec { "supports casts from string to number" - { "toInt" in { - case class Product(id: Long, description: String, sku: Int) + final case class Product(id: Long, description: String, sku: Int) val queried = await { testContext.run { query[Product].filter(_.sku == lift("1004").toInt) diff --git a/quill-jasync-mysql/src/test/scala/io/getquill/context/jasync/mysql/QueryResultTypeMysqlJAsyncSpec.scala b/quill-jasync-mysql/src/test/scala/io/getquill/context/jasync/mysql/QueryResultTypeMysqlJAsyncSpec.scala index 52e914eb82..e07eef2b1c 100644 --- a/quill-jasync-mysql/src/test/scala/io/getquill/context/jasync/mysql/QueryResultTypeMysqlJAsyncSpec.scala +++ b/quill-jasync-mysql/src/test/scala/io/getquill/context/jasync/mysql/QueryResultTypeMysqlJAsyncSpec.scala @@ -14,7 +14,7 @@ class QueryResultTypeMysqlJAsyncSpec extends QueryResultTypeSpec { val insertedProducts = new ConcurrentLinkedQueue[Product] - override def beforeAll = { + override def beforeAll: Unit = { await(testContext.run(deleteAll)) val ids = await(testContext.run(liftQuery(productEntries).foreach(e => productInsert(e)))) val inserted = (ids zip productEntries).map { case (id, prod) => diff --git a/quill-jasync-postgres/src/test/scala/io/getquill/context/jasync/postgres/ArrayAsyncEncodingSpec.scala b/quill-jasync-postgres/src/test/scala/io/getquill/context/jasync/postgres/ArrayAsyncEncodingSpec.scala index 6ef5d0ced5..7ab3119f2e 100644 --- a/quill-jasync-postgres/src/test/scala/io/getquill/context/jasync/postgres/ArrayAsyncEncodingSpec.scala +++ b/quill-jasync-postgres/src/test/scala/io/getquill/context/jasync/postgres/ArrayAsyncEncodingSpec.scala @@ -22,7 +22,7 @@ class ArrayAsyncEncodingSpec extends ArrayEncodingBaseSpec { } "Java8 times" in { - case class Java8Times(timestamps: Seq[LocalDateTime], dates: Seq[LocalDate]) + final case class Java8Times(timestamps: Seq[LocalDateTime], dates: Seq[LocalDate]) val jE = Java8Times(Seq(LocalDateTime.now()), Seq(LocalDate.now())) val jQ = quote(querySchema[Java8Times]("ArraysTestEntity")) await(ctx.run(jQ.insertValue(lift(jE)))) @@ -43,13 +43,13 @@ class ArrayAsyncEncodingSpec extends ArrayEncodingBaseSpec { val actual2 = await(ctx.run(q.filter(_.texts == lift(List("test2"))))) baseEntityDeepCheck(actual1.head, e) actual1 mustEqual List(e) - actual2 mustEqual List() + actual2 mustEqual List.empty } // Need to have an actual value in the table in order for the decoder to go off. Previously, // there was guaranteed to be information there due to ordering of build artifacts but not anymore. "fail if found not an array" in { - case class RealEncodingTestEntity( + final case class RealEncodingTestEntity( v1: String, v2: BigDecimal, v3: Boolean, @@ -119,7 +119,7 @@ class ArrayAsyncEncodingSpec extends ArrayEncodingBaseSpec { } await(ctx.run(realEntity.insertValue(lift(insertValue)))) - case class EncodingTestEntity(v1: List[String]) + final case class EncodingTestEntity(v1: List[String]) intercept[IllegalStateException](await(ctx.run(query[EncodingTestEntity]))) } diff --git a/quill-jasync-postgres/src/test/scala/io/getquill/context/jasync/postgres/OptionalNestedAsyncSpec.scala b/quill-jasync-postgres/src/test/scala/io/getquill/context/jasync/postgres/OptionalNestedAsyncSpec.scala index bae7f18c5b..d634b4e05e 100644 --- a/quill-jasync-postgres/src/test/scala/io/getquill/context/jasync/postgres/OptionalNestedAsyncSpec.scala +++ b/quill-jasync-postgres/src/test/scala/io/getquill/context/jasync/postgres/OptionalNestedAsyncSpec.scala @@ -8,7 +8,7 @@ class OptionalProductEncodingJasyncSpec extends OptionalNestedSpec { val context: testContext.type = testContext import testContext._ - override protected def beforeEach() = { + override protected def beforeEach(): Unit = { import Setup._ await(testContext.run(query[Contact].delete)) () diff --git a/quill-jasync-postgres/src/test/scala/io/getquill/context/jasync/postgres/PostgresAsyncEncodingSpec.scala b/quill-jasync-postgres/src/test/scala/io/getquill/context/jasync/postgres/PostgresAsyncEncodingSpec.scala index f428040e1d..3995ee35cb 100644 --- a/quill-jasync-postgres/src/test/scala/io/getquill/context/jasync/postgres/PostgresAsyncEncodingSpec.scala +++ b/quill-jasync-postgres/src/test/scala/io/getquill/context/jasync/postgres/PostgresAsyncEncodingSpec.scala @@ -28,15 +28,15 @@ class PostgresAsyncEncodingSpec extends EncodingSpec { } "encodes and decodes uuids" in { - case class EncodingUUIDTestEntity(v1: UUID) + final case class EncodingUUIDTestEntity(v1: UUID) val testUUID = UUID.fromString("e5240c08-6ee7-474a-b5e4-91f79c48338f") // delete old values val q0 = quote(query[EncodingUUIDTestEntity].delete) - val rez0 = Await.result(testContext.run(q0), Duration.Inf) + Await.result(testContext.run(q0), Duration.Inf) // insert new uuid - val rez1 = Await.result( + Await.result( testContext.run(query[EncodingUUIDTestEntity].insertValue(lift(EncodingUUIDTestEntity(testUUID)))), Duration.Inf ) @@ -51,15 +51,15 @@ class PostgresAsyncEncodingSpec extends EncodingSpec { "fails if the column has the wrong type" - { "numeric" in { Await.result(testContext.run(liftQuery(insertValues).foreach(e => insert(e))), Duration.Inf) - case class EncodingTestEntity(v1: Int) - val e = intercept[IllegalStateException] { + final case class EncodingTestEntity(v1: Int) + intercept[IllegalStateException] { Await.result(testContext.run(query[EncodingTestEntity]), Duration.Inf) } } "non-numeric" in { Await.result(testContext.run(liftQuery(insertValues).foreach(e => insert(e))), Duration.Inf) - case class EncodingTestEntity(v1: Date) - val e = intercept[IllegalStateException] { + final case class EncodingTestEntity(v1: Date) + intercept[IllegalStateException] { Await.result(testContext.run(query[EncodingTestEntity]), Duration.Inf) } } @@ -91,7 +91,7 @@ class PostgresAsyncEncodingSpec extends EncodingSpec { } "decodes LocalDate and LocalDateTime types" in { - case class DateEncodingTestEntity(v1: LocalDate, v2: LocalDateTime) + final case class DateEncodingTestEntity(v1: LocalDate, v2: LocalDateTime) val entity = DateEncodingTestEntity(LocalDate.now, LocalDateTime.now) val r = for { _ <- testContext.run(query[DateEncodingTestEntity].delete) diff --git a/quill-jasync-postgres/src/test/scala/io/getquill/context/jasync/postgres/PostgresJAsyncContextSpec.scala b/quill-jasync-postgres/src/test/scala/io/getquill/context/jasync/postgres/PostgresJAsyncContextSpec.scala index 5a1abec040..10daad4673 100644 --- a/quill-jasync-postgres/src/test/scala/io/getquill/context/jasync/postgres/PostgresJAsyncContextSpec.scala +++ b/quill-jasync-postgres/src/test/scala/io/getquill/context/jasync/postgres/PostgresJAsyncContextSpec.scala @@ -52,7 +52,7 @@ class PostgresJAsyncContextSpec extends Spec { super.extractActionResult(returningAction, returningExtractor)(result) } intercept[IllegalStateException] { - val v = ctx.extractActionResult(ReturnColumns(List("w/e")), (row, session) => 1)( + val v = ctx.extractActionResult(ReturnColumns(List("w/e")), (_, _) => 1)( new QueryResult(0, "w/e", ResultSetKt.getEMPTY_RESULT_SET) ) ctx.handleSingleResult("", v) @@ -63,7 +63,7 @@ class PostgresJAsyncContextSpec extends Spec { "prepare" in { testContext.prepareParams( "", - (ps, session) => (Nil, ps ++ List("Sarah", 127)) + (ps, _) => (List.empty, ps ++ List("Sarah", 127)) ) mustEqual List("'Sarah'", "127") } @@ -71,7 +71,7 @@ class PostgresJAsyncContextSpec extends Spec { "success" in { await(for { _ <- testContext.run(qr4.delete) - _ <- testContext.transaction { implicit ec => + _ <- testContext.transaction { _ => testContext.run(qr4.insert(_.i -> 33)) } r <- testContext.run(qr4) @@ -97,7 +97,7 @@ class PostgresJAsyncContextSpec extends Spec { await(for { _ <- testContext.run(qr4.delete) _ <- testContext.transaction { implicit ec => - testContext.transaction { implicit ec => + testContext.transaction { _ => testContext.run(qr4.insert(_.i -> 33)) } } diff --git a/quill-jasync-postgres/src/test/scala/io/getquill/context/jasync/postgres/ProductPostgresAsyncSpec.scala b/quill-jasync-postgres/src/test/scala/io/getquill/context/jasync/postgres/ProductPostgresAsyncSpec.scala index 897e5faf93..f4e482bf85 100644 --- a/quill-jasync-postgres/src/test/scala/io/getquill/context/jasync/postgres/ProductPostgresAsyncSpec.scala +++ b/quill-jasync-postgres/src/test/scala/io/getquill/context/jasync/postgres/ProductPostgresAsyncSpec.scala @@ -11,7 +11,7 @@ class ProductPostgresAsyncSpec extends ProductSpec { val context = testContext import testContext._ - override def beforeAll = { + override def beforeAll: Unit = { await(testContext.run(quote(query[Product].delete))) () } @@ -66,7 +66,7 @@ class ProductPostgresAsyncSpec extends ProductSpec { } "Single insert with value class" in { - case class Product(id: Id, description: String, sku: Long) + final case class Product(id: Id, description: String, sku: Long) val prd = Product(Id(0L), "test2", 2L) val q1 = quote { query[Product].insert(_.sku -> lift(prd.sku), _.description -> lift(prd.description)).returning(_.id) @@ -76,7 +76,7 @@ class ProductPostgresAsyncSpec extends ProductSpec { "supports casts from string to number" - { "toInt" in { - case class Product(id: Long, description: String, sku: Int) + final case class Product(id: Long, description: String, sku: Int) val queried = await { testContext.run { query[Product].filter(_.sku == lift("1004").toInt) diff --git a/quill-jasync-postgres/src/test/scala/io/getquill/context/jasync/postgres/QueryResultTypePostgresAsyncSpec.scala b/quill-jasync-postgres/src/test/scala/io/getquill/context/jasync/postgres/QueryResultTypePostgresAsyncSpec.scala index a8e762ca17..8b2e93dfc5 100644 --- a/quill-jasync-postgres/src/test/scala/io/getquill/context/jasync/postgres/QueryResultTypePostgresAsyncSpec.scala +++ b/quill-jasync-postgres/src/test/scala/io/getquill/context/jasync/postgres/QueryResultTypePostgresAsyncSpec.scala @@ -14,7 +14,7 @@ class QueryResultTypePostgresAsyncSpec extends QueryResultTypeSpec { val insertedProducts = new ConcurrentLinkedQueue[Product] - override def beforeAll = { + override def beforeAll: Unit = { await(testContext.run(deleteAll)) val ids = await(testContext.run(liftQuery(productEntries).foreach(e => productInsert(e)))) val inserted = (ids zip productEntries).map { case (id, prod) => diff --git a/quill-jasync-zio-postgres/src/test/scala/io/getquill/context/qzio/jasync/postgres/ArrayAsyncEncodingSpec.scala b/quill-jasync-zio-postgres/src/test/scala/io/getquill/context/qzio/jasync/postgres/ArrayAsyncEncodingSpec.scala index 8d14a01c8c..5b766d80e4 100644 --- a/quill-jasync-zio-postgres/src/test/scala/io/getquill/context/qzio/jasync/postgres/ArrayAsyncEncodingSpec.scala +++ b/quill-jasync-zio-postgres/src/test/scala/io/getquill/context/qzio/jasync/postgres/ArrayAsyncEncodingSpec.scala @@ -19,7 +19,7 @@ class ArrayAsyncEncodingSpec extends ArrayEncodingBaseSpec with ZioSpec { } "Java8 times" in { - case class Java8Times(timestamps: Seq[LocalDateTime], dates: Seq[LocalDate]) + final 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.insertValue(lift(jE)))) @@ -40,13 +40,13 @@ class ArrayAsyncEncodingSpec extends ArrayEncodingBaseSpec with ZioSpec { val actual2 = runSyncUnsafe(context.run(q.filter(_.texts == lift(List("test2"))))) baseEntityDeepCheck(actual1.head, e) actual1 mustEqual List(e) - actual2 mustEqual List() + actual2 mustEqual List.empty } // Need to have an actual value in the table in order for the decoder to go off. Previously, // there was guaranteed to be information there due to ordering of build artifacts but not anymore. "fail if found not an array" in { - case class RealEncodingTestEntity( + final case class RealEncodingTestEntity( v1: String, v2: BigDecimal, v3: Boolean, @@ -116,7 +116,7 @@ class ArrayAsyncEncodingSpec extends ArrayEncodingBaseSpec with ZioSpec { } runSyncUnsafe(context.run(realEntity.insertValue(lift(insertValue)))) - case class EncodingTestEntity(v1: List[String]) + final case class EncodingTestEntity(v1: List[String]) intercept[IllegalStateException](runSyncUnsafe(context.run(query[EncodingTestEntity]))) } diff --git a/quill-jasync-zio-postgres/src/test/scala/io/getquill/context/qzio/jasync/postgres/CaseClassQueryAsyncSpec.scala b/quill-jasync-zio-postgres/src/test/scala/io/getquill/context/qzio/jasync/postgres/CaseClassQueryAsyncSpec.scala index 4d332cdc2f..770dae3e4d 100644 --- a/quill-jasync-zio-postgres/src/test/scala/io/getquill/context/qzio/jasync/postgres/CaseClassQueryAsyncSpec.scala +++ b/quill-jasync-zio-postgres/src/test/scala/io/getquill/context/qzio/jasync/postgres/CaseClassQueryAsyncSpec.scala @@ -7,7 +7,7 @@ class CaseClassQueryAsyncSpec extends CaseClassQuerySpec with ZioSpec { import context._ - override def beforeAll = + override def beforeAll: Unit = runSyncUnsafe { context.transaction { for { diff --git a/quill-jasync-zio-postgres/src/test/scala/io/getquill/context/qzio/jasync/postgres/PostgresAsyncEncodingSpec.scala b/quill-jasync-zio-postgres/src/test/scala/io/getquill/context/qzio/jasync/postgres/PostgresAsyncEncodingSpec.scala index 09ec7e74cb..8e9f0d6e06 100644 --- a/quill-jasync-zio-postgres/src/test/scala/io/getquill/context/qzio/jasync/postgres/PostgresAsyncEncodingSpec.scala +++ b/quill-jasync-zio-postgres/src/test/scala/io/getquill/context/qzio/jasync/postgres/PostgresAsyncEncodingSpec.scala @@ -23,16 +23,15 @@ class PostgresAsyncEncodingSpec extends EncodingSpec with ZioSpec { } "encodes and decodes uuids" in { - case class EncodingUUIDTestEntity(v1: UUID) + final case class EncodingUUIDTestEntity(v1: UUID) val testUUID = UUID.fromString("e5240c08-6ee7-474a-b5e4-91f79c48338f") // delete old values val q0 = quote(query[EncodingUUIDTestEntity].delete) - val rez0 = runSyncUnsafe(testContext.run(q0)) + runSyncUnsafe(testContext.run(q0)) // insert new uuid - val rez1 = - runSyncUnsafe(testContext.run(query[EncodingUUIDTestEntity].insertValue(lift(EncodingUUIDTestEntity(testUUID))))) + runSyncUnsafe(testContext.run(query[EncodingUUIDTestEntity].insertValue(lift(EncodingUUIDTestEntity(testUUID))))) // verify you can get the uuid back from the db val q2 = quote(query[EncodingUUIDTestEntity].map(p => p.v1)) @@ -44,15 +43,15 @@ class PostgresAsyncEncodingSpec extends EncodingSpec with ZioSpec { "fails if the column has the wrong type" - { "numeric" in { runSyncUnsafe(testContext.run(liftQuery(insertValues).foreach(e => insert(e)))) - case class EncodingTestEntity(v1: Int) - val e = intercept[IllegalStateException] { + final case class EncodingTestEntity(v1: Int) + intercept[IllegalStateException] { runSyncUnsafe(testContext.run(query[EncodingTestEntity])) } } "non-numeric" in { runSyncUnsafe(testContext.run(liftQuery(insertValues).foreach(e => insert(e)))) - case class EncodingTestEntity(v1: Date) - val e = intercept[IllegalStateException] { + final case class EncodingTestEntity(v1: Date) + intercept[IllegalStateException] { runSyncUnsafe(testContext.run(query[EncodingTestEntity])) } } @@ -82,7 +81,7 @@ class PostgresAsyncEncodingSpec extends EncodingSpec with ZioSpec { } "decodes LocalDate and LocalDateTime types" in { - case class DateEncodingTestEntity(v1: LocalDate, v2: LocalDateTime) + final case class DateEncodingTestEntity(v1: LocalDate, v2: LocalDateTime) val entity = DateEncodingTestEntity(LocalDate.now, LocalDateTime.now) val r = for { _ <- testContext.run(query[DateEncodingTestEntity].delete) diff --git a/quill-jasync-zio-postgres/src/test/scala/io/getquill/context/qzio/jasync/postgres/PostgresJAsyncContextSpec.scala b/quill-jasync-zio-postgres/src/test/scala/io/getquill/context/qzio/jasync/postgres/PostgresJAsyncContextSpec.scala index 6fd2ed5b08..9ac0c097d0 100644 --- a/quill-jasync-zio-postgres/src/test/scala/io/getquill/context/qzio/jasync/postgres/PostgresJAsyncContextSpec.scala +++ b/quill-jasync-zio-postgres/src/test/scala/io/getquill/context/qzio/jasync/postgres/PostgresJAsyncContextSpec.scala @@ -51,7 +51,7 @@ class PostgresJAsyncContextSpec extends Spec with ZioSpec { super.extractActionResult(returningAction, returningExtractor)(result) } intercept[IllegalStateException] { - val v = ctx.extractActionResult(ReturnColumns(List("w/e")), (row, session) => 1)( + val v = ctx.extractActionResult(ReturnColumns(List("w/e")), (_, _) => 1)( new QueryResult(0, "w/e", ResultSetKt.getEMPTY_RESULT_SET) ) ctx.handleSingleResult("", v) @@ -62,7 +62,7 @@ class PostgresJAsyncContextSpec extends Spec with ZioSpec { "prepare" in { testContext.prepareParams( "", - (ps, session) => (Nil, ps ++ List("Sarah", 127)) + (ps, _) => (List.empty, ps ++ List("Sarah", 127)) ) mustEqual List("'Sarah'", "127") } diff --git a/quill-jasync-zio-postgres/src/test/scala/io/getquill/context/qzio/jasync/postgres/ProductPostgresAsyncSpec.scala b/quill-jasync-zio-postgres/src/test/scala/io/getquill/context/qzio/jasync/postgres/ProductPostgresAsyncSpec.scala index 84320c16a5..ff92483979 100644 --- a/quill-jasync-zio-postgres/src/test/scala/io/getquill/context/qzio/jasync/postgres/ProductPostgresAsyncSpec.scala +++ b/quill-jasync-zio-postgres/src/test/scala/io/getquill/context/qzio/jasync/postgres/ProductPostgresAsyncSpec.scala @@ -7,7 +7,7 @@ class ProductPostgresAsyncSpec extends ProductSpec with ZioSpec { import context._ - override def beforeAll = { + override def beforeAll: Unit = { runSyncUnsafe(testContext.run(quote(query[Product].delete))) () } @@ -62,7 +62,7 @@ class ProductPostgresAsyncSpec extends ProductSpec with ZioSpec { } "Single insert with value class" in { - case class Product(id: Id, description: String, sku: Long) + final case class Product(id: Id, description: String, sku: Long) val prd = Product(Id(0L), "test2", 2L) val q1 = quote { query[Product].insert(_.sku -> lift(prd.sku), _.description -> lift(prd.description)).returning(_.id) @@ -72,7 +72,7 @@ class ProductPostgresAsyncSpec extends ProductSpec with ZioSpec { "supports casts from string to number" - { "toInt" in { - case class Product(id: Long, description: String, sku: Int) + final case class Product(id: Long, description: String, sku: Int) val queried = runSyncUnsafe { testContext.run { query[Product].filter(_.sku == lift("1004").toInt) diff --git a/quill-jasync-zio-postgres/src/test/scala/io/getquill/context/qzio/jasync/postgres/QueryResultTypePostgresAsyncSpec.scala b/quill-jasync-zio-postgres/src/test/scala/io/getquill/context/qzio/jasync/postgres/QueryResultTypePostgresAsyncSpec.scala index 805cf2ffe5..94f7bbd015 100644 --- a/quill-jasync-zio-postgres/src/test/scala/io/getquill/context/qzio/jasync/postgres/QueryResultTypePostgresAsyncSpec.scala +++ b/quill-jasync-zio-postgres/src/test/scala/io/getquill/context/qzio/jasync/postgres/QueryResultTypePostgresAsyncSpec.scala @@ -12,7 +12,7 @@ class QueryResultTypePostgresAsyncSpec extends QueryResultTypeSpec with ZioSpec val insertedProducts = new ConcurrentLinkedQueue[Product] - override def beforeAll = { + override def beforeAll: Unit = { runSyncUnsafe(testContext.run(deleteAll)) val ids = runSyncUnsafe(testContext.run(liftQuery(productEntries).foreach(e => productInsert(e)))) val inserted = (ids zip productEntries).map { case (id, prod) => diff --git a/quill-jasync-zio-postgres/src/test/scala/io/getquill/context/qzio/jasync/postgres/ZioSpec.scala b/quill-jasync-zio-postgres/src/test/scala/io/getquill/context/qzio/jasync/postgres/ZioSpec.scala index 668335c3f4..0b8cdecb94 100644 --- a/quill-jasync-zio-postgres/src/test/scala/io/getquill/context/qzio/jasync/postgres/ZioSpec.scala +++ b/quill-jasync-zio-postgres/src/test/scala/io/getquill/context/qzio/jasync/postgres/ZioSpec.scala @@ -27,17 +27,17 @@ trait ZioSpec extends Spec with BeforeAndAfterAll { } implicit class ZioAnyOps[T](qzio: ZIO[Any, Throwable, T]) { - def runSyncUnsafe() = + def runSyncUnsafe(): T = Unsafe.unsafe { implicit u => Runtime.default.unsafe.run(qzio).getOrThrow() } } implicit class ZStreamTestExt[T](stream: ZStream[ZioJAsyncConnection, Throwable, T]) { - def runSyncUnsafe() = collect[T](stream) + def runSyncUnsafe(): List[T] = collect[T](stream) } implicit class ZioTestExt[T](qzio: ZIO[ZioJAsyncConnection, Throwable, T]) { - def runSyncUnsafe() = ZioSpec.this.runSyncUnsafe[T](qzio) + def runSyncUnsafe(): T = ZioSpec.this.runSyncUnsafe[T](qzio) } } diff --git a/quill-jasync/src/test/scala/io/getquill/context/jasync/TransactionalExecutionContextSpec.scala b/quill-jasync/src/test/scala/io/getquill/context/jasync/TransactionalExecutionContextSpec.scala index deeedf53f7..ac187164a1 100644 --- a/quill-jasync/src/test/scala/io/getquill/context/jasync/TransactionalExecutionContextSpec.scala +++ b/quill-jasync/src/test/scala/io/getquill/context/jasync/TransactionalExecutionContextSpec.scala @@ -27,7 +27,7 @@ class TransactionalExecutionContextSpec extends Spec { val ec = new ExecutionContext { def execute(r: Runnable) = ??? def reportFailure(t: Throwable) = { - val r = reported += t + reported += t } } val exception = new IllegalStateException diff --git a/quill-jdbc-monix/src/test/scala/io/getquill/MonixSpec.scala b/quill-jdbc-monix/src/test/scala/io/getquill/MonixSpec.scala index 0612b7a5ba..7724882968 100644 --- a/quill-jdbc-monix/src/test/scala/io/getquill/MonixSpec.scala +++ b/quill-jdbc-monix/src/test/scala/io/getquill/MonixSpec.scala @@ -3,6 +3,7 @@ import io.getquill.base.Spec import io.getquill.context.monix.MonixJdbcContext import monix.execution.Scheduler import monix.reactive.Observable +import monix.eval.Task trait MonixSpec extends Spec { @@ -10,9 +11,9 @@ trait MonixSpec extends Spec { val context: MonixJdbcContext[_, _] with TestEntities - def accumulate[T](o: Observable[T]) = - o.foldLeft(List[T]()) { case (l, elem) => elem +: l }.firstL + def accumulate[T](o: Observable[T]): Task[List[T]] = + o.foldLeft(List.empty[T]) { case (l, elem) => elem +: l }.firstL - def collect[T](o: Observable[T]) = + def collect[T](o: Observable[T]): List[T] = accumulate(o).runSyncUnsafe() } diff --git a/quill-jdbc-monix/src/test/scala/io/getquill/PeopleMonixSpec.scala b/quill-jdbc-monix/src/test/scala/io/getquill/PeopleMonixSpec.scala index 340e648140..d43eb77af1 100644 --- a/quill-jdbc-monix/src/test/scala/io/getquill/PeopleMonixSpec.scala +++ b/quill-jdbc-monix/src/test/scala/io/getquill/PeopleMonixSpec.scala @@ -13,8 +13,8 @@ trait PeopleMonixSpec extends PeopleSpec { import context._ - def collect[T](o: Observable[T]) = - o.foldLeft(List[T]()) { case (l, elem) => elem +: l } + def collect[T](o: Observable[T]): List[T] = + o.foldLeft(List.empty[T]) { case (l, elem) => elem +: l } .firstL .runSyncUnsafe() diff --git a/quill-jdbc-monix/src/test/scala/io/getquill/PrepareMonixJdbcSpecBase.scala b/quill-jdbc-monix/src/test/scala/io/getquill/PrepareMonixJdbcSpecBase.scala index 7b43bcdf7f..e0d21f20b8 100644 --- a/quill-jdbc-monix/src/test/scala/io/getquill/PrepareMonixJdbcSpecBase.scala +++ b/quill-jdbc-monix/src/test/scala/io/getquill/PrepareMonixJdbcSpecBase.scala @@ -9,7 +9,7 @@ import org.scalactic.Equality trait PrepareMonixJdbcSpecBase extends ProductSpec { - implicit val productEq = new Equality[Product] { + implicit val productEq: Equality[Product] = new Equality[Product] { override def areEqual(a: Product, b: Any): Boolean = b match { case Product(_, desc, sku) => desc == a.description && sku == a.sku case _ => false @@ -18,17 +18,17 @@ trait PrepareMonixJdbcSpecBase extends ProductSpec { def productExtractor: (ResultSet, Connection) => Product - def withOrderedIds(products: List[Product]) = + def withOrderedIds(products: List[Product]): List[Product] = products.zipWithIndex.map { case (product, id) => product.copy(id = id.toLong + 1) } - def singleInsert(conn: => Connection)(prep: Connection => Task[PreparedStatement]) = + def singleInsert(conn: => Connection)(prep: Connection => Task[PreparedStatement]): Task[Boolean] = Task(conn).bracket { conn => prep(conn).bracket { stmt => Task(stmt.execute()) }(stmt => Task(stmt.close())) }(conn => Task(conn.close())) - def batchInsert(conn: => Connection)(prep: Connection => Task[List[PreparedStatement]]) = + def batchInsert(conn: => Connection)(prep: Connection => Task[List[PreparedStatement]]): Task[List[Boolean]] = Task(conn).bracket { conn => prep(conn).flatMap(stmts => Task.sequence( @@ -43,7 +43,7 @@ trait PrepareMonixJdbcSpecBase extends ProductSpec { def extractResults[T]( conn: => Connection - )(prep: Connection => Task[PreparedStatement])(extractor: (ResultSet, Connection) => T) = + )(prep: Connection => Task[PreparedStatement])(extractor: (ResultSet, Connection) => T): Task[List[T]] = Task(conn).bracket { conn => prep(conn).bracket { stmt => Task(stmt.executeQuery()).bracket { rs => @@ -52,6 +52,6 @@ trait PrepareMonixJdbcSpecBase extends ProductSpec { }(stmt => Task(stmt.close())) }(conn => Task(conn.close())) - def extractProducts(conn: => Connection)(prep: Connection => Task[PreparedStatement]) = + def extractProducts(conn: => Connection)(prep: Connection => Task[PreparedStatement]): Task[List[Product]] = extractResults(conn)(prep)(productExtractor) } diff --git a/quill-jdbc-monix/src/test/scala/io/getquill/ResultSetIteratorSpec.scala b/quill-jdbc-monix/src/test/scala/io/getquill/ResultSetIteratorSpec.scala index f55de8bf78..ad027402fb 100644 --- a/quill-jdbc-monix/src/test/scala/io/getquill/ResultSetIteratorSpec.scala +++ b/quill-jdbc-monix/src/test/scala/io/getquill/ResultSetIteratorSpec.scala @@ -10,10 +10,11 @@ import org.scalatest.matchers.must.Matchers import org.scalatest.matchers.should.Matchers._ import scala.collection.mutable.ArrayBuffer +import com.zaxxer.hikari.HikariDataSource class ResultSetIteratorSpec extends AnyFreeSpec with Matchers with BeforeAndAfterAll { - val ds = JdbcContextConfig(LoadConfig("testPostgresDB")).dataSource + val ds: HikariDataSource = JdbcContextConfig(LoadConfig("testPostgresDB")).dataSource implicit val scheduler = Scheduler.global val ctx = new PostgresMonixJdbcContext(Literal, ds, EffectWrapper.default) @@ -24,13 +25,13 @@ class ResultSetIteratorSpec extends AnyFreeSpec with Matchers with BeforeAndAfte val peopleInsert = quote((p: Person) => query[Person].insertValue(p)) - val peopleEntries = List( + val peopleEntries: List[Person] = List( Person("Alex", 60), Person("Bert", 55), Person("Cora", 33) ) - override def beforeAll = + override def beforeAll: Unit = ctx.transaction { for { _ <- ctx.run(query[Person].delete) @@ -44,7 +45,7 @@ class ResultSetIteratorSpec extends AnyFreeSpec with Matchers with BeforeAndAfte Task { val stmt = conn.prepareStatement("select * from person") val rs = - new ResultSetIterator[String](stmt.executeQuery(), conn, extractor = (rs, conn) => { rs.getString(1) }) + new ResultSetIterator[String](stmt.executeQuery(), conn, extractor = (rs, _) => { rs.getString(1) }) val accum = ArrayBuffer[String]() while (rs.hasNext) accum += rs.next() accum @@ -59,7 +60,7 @@ class ResultSetIteratorSpec extends AnyFreeSpec with Matchers with BeforeAndAfte Task(ds.getConnection).bracket { conn => Task { val stmt = conn.prepareStatement("select * from person where name = 'Alex'") - val rs = new ResultSetIterator(stmt.executeQuery(), conn, extractor = (rs, conn) => { rs.getString(1) }) + val rs = new ResultSetIterator(stmt.executeQuery(), conn, extractor = (rs, _) => { rs.getString(1) }) rs.head } }(conn => Task(conn.close())).runSyncUnsafe() diff --git a/quill-jdbc-monix/src/test/scala/io/getquill/RunnerSpec.scala b/quill-jdbc-monix/src/test/scala/io/getquill/RunnerSpec.scala index 3b20f7c543..25d0720eb3 100644 --- a/quill-jdbc-monix/src/test/scala/io/getquill/RunnerSpec.scala +++ b/quill-jdbc-monix/src/test/scala/io/getquill/RunnerSpec.scala @@ -13,8 +13,8 @@ class RunnerSpec extends Spec { class SideEffect { private var state = 0 - def apply() = state = 1 - def applied = state == 1 + def apply(): Unit = state = 1 + def applied: Boolean = state == 1 } implicit val scheduler = Scheduler.global diff --git a/quill-jdbc-monix/src/test/scala/io/getquill/h2/MonixJdbcContextSpec.scala b/quill-jdbc-monix/src/test/scala/io/getquill/h2/MonixJdbcContextSpec.scala index 917b559717..98a2293d7e 100644 --- a/quill-jdbc-monix/src/test/scala/io/getquill/h2/MonixJdbcContextSpec.scala +++ b/quill-jdbc-monix/src/test/scala/io/getquill/h2/MonixJdbcContextSpec.scala @@ -63,7 +63,7 @@ class MonixJdbcContextSpec extends MonixSpec { testContext .prepareParams( "select * from Person where name=? and age > ?", - (ps, session) => (List("Sarah", 127), ps) + (ps, _) => (List("Sarah", 127), ps) ) .runSyncUnsafe() mustEqual List("127", "'Sarah'") } diff --git a/quill-jdbc-monix/src/test/scala/io/getquill/h2/ProductJdbcSpec.scala b/quill-jdbc-monix/src/test/scala/io/getquill/h2/ProductJdbcSpec.scala index 67365950a0..66b7f1293a 100644 --- a/quill-jdbc-monix/src/test/scala/io/getquill/h2/ProductJdbcSpec.scala +++ b/quill-jdbc-monix/src/test/scala/io/getquill/h2/ProductJdbcSpec.scala @@ -10,7 +10,7 @@ class ProductJdbcSpec extends ProductSpec { implicit val scheduler = Scheduler.global - override def beforeAll = { + override def beforeAll: Unit = { testContext.run(quote(query[Product].delete)).runSyncUnsafe() () } diff --git a/quill-jdbc-monix/src/test/scala/io/getquill/h2/h2.scala b/quill-jdbc-monix/src/test/scala/io/getquill/h2/h2.scala index e893bfdab1..cc177f40ea 100644 --- a/quill-jdbc-monix/src/test/scala/io/getquill/h2/h2.scala +++ b/quill-jdbc-monix/src/test/scala/io/getquill/h2/h2.scala @@ -3,6 +3,6 @@ package io.getquill import monix.execution.Scheduler package object h2 { - private implicit val scheduler = Scheduler.global + Scheduler.global object testContext extends H2MonixJdbcContext(Literal, "testH2DB") with TestEntities } diff --git a/quill-jdbc-monix/src/test/scala/io/getquill/integration/StreamResultsOrBlowUpSpec.scala b/quill-jdbc-monix/src/test/scala/io/getquill/integration/StreamResultsOrBlowUpSpec.scala index 9925b48727..45e70adbbc 100644 --- a/quill-jdbc-monix/src/test/scala/io/getquill/integration/StreamResultsOrBlowUpSpec.scala +++ b/quill-jdbc-monix/src/test/scala/io/getquill/integration/StreamResultsOrBlowUpSpec.scala @@ -31,7 +31,7 @@ class StreamResultsOrBlowUpSpec extends Spec { // that will force jdbc to load the entire ResultSet into memory and crash this test. val doBlowUp = false - val ctx = new PostgresMonixJdbcContext(Literal, "testPostgresDB", EffectWrapper.default) { + val ctx: PostgresMonixJdbcContext[Literal.type] = new PostgresMonixJdbcContext(Literal, "testPostgresDB", EffectWrapper.default) { override protected def prepareStatementForStreaming(sql: String, conn: Connection, fetchSize: Option[Int]) = { val stmt = conn.prepareStatement( diff --git a/quill-jdbc-monix/src/test/scala/io/getquill/mock/Introspection.scala b/quill-jdbc-monix/src/test/scala/io/getquill/mock/Introspection.scala index 60796b63cc..52ef3950bb 100644 --- a/quill-jdbc-monix/src/test/scala/io/getquill/mock/Introspection.scala +++ b/quill-jdbc-monix/src/test/scala/io/getquill/mock/Introspection.scala @@ -6,16 +6,16 @@ import scala.reflect.runtime.{universe => ru} class Introspection[T](t: T)(implicit tt: ru.TypeTag[T], ct: ClassTag[T]) { import ru._ - val rm = runtimeMirror(getClass.getClassLoader) - val instanceMirror = rm.reflect(t) + val rm: Mirror = runtimeMirror(getClass.getClassLoader) + val instanceMirror: InstanceMirror = rm.reflect(t) - val fieldsAndValues = + val fieldsAndValues: List[(String, Any)] = typeOf[T].members.collect { case m: MethodSymbol if m.isCaseAccessor => m }.map(sym => (sym.name.toString, instanceMirror.reflectField(sym.asTerm).get)).toList.reverse val map = fieldsAndValues.toMap - def getIndex(i: Int) = fieldsAndValues(i - 1)._2 // Subtract 1 because DB result sets are 1-indexed - def getField(name: String) = map(name) + def getIndex(i: Int): Any = fieldsAndValues(i - 1)._2 // Subtract 1 because DB result sets are 1-indexed + def getField(name: String): Any = map(name) } diff --git a/quill-jdbc-monix/src/test/scala/io/getquill/mock/MockTests.scala b/quill-jdbc-monix/src/test/scala/io/getquill/mock/MockTests.scala index 2d01912cd7..71cb8f731f 100644 --- a/quill-jdbc-monix/src/test/scala/io/getquill/mock/MockTests.scala +++ b/quill-jdbc-monix/src/test/scala/io/getquill/mock/MockTests.scala @@ -14,19 +14,20 @@ import org.scalatest.matchers.should.Matchers._ import scala.reflect.ClassTag import scala.util.Try +import monix.execution.schedulers.SchedulerService class MockTests extends Spec with AsyncMockitoSugar { import scala.reflect.runtime.{universe => ru} - implicit val scheduler = Scheduler.io() + implicit val scheduler: SchedulerService = Scheduler.io() object MockResultSet { - def apply[T: ClassTag: ru.TypeTag](data: Seq[T]) = { + def apply[T: ClassTag: ru.TypeTag](data: Seq[T]): ResultSet = { val rs = mock[ResultSet] var rowIndex = -1 def introspection = new Introspection(data(rowIndex)) def getIndex(i: Int): Any = introspection.getIndex(i) - def getColumn(name: String): Any = introspection.getField(name) + when(rs.next()) thenAnswer { rowIndex += 1 @@ -89,11 +90,11 @@ class MockTests extends Spec with AsyncMockitoSugar { } "stream is correctly closed when ending conn.setAutoCommit returns error but is caught" in { - val people = List(Person("Joe", 11), Person("Jack", 22)) + List(Person("Joe", 11), Person("Jack", 22)) val ds = mock[MyDataSource] val conn = mock[Connection] - val stmt = mock[PreparedStatement] + mock[PreparedStatement] when(ds.getConnection) thenReturn conn when(conn.getAutoCommit) thenThrow (new SQLException(msg)) @@ -131,7 +132,7 @@ class MockTests extends Spec with AsyncMockitoSugar { when(conn.prepareStatement(any[String], any[Int], any[Int])) thenReturn stmt when(stmt.executeQuery()) thenReturn rs when(conn.getAutoCommit) thenReturn true - when(conn.setAutoCommit(any[Boolean])) thenAnswer ((f: Boolean) => ()) andThenThrow (new SQLException(msg)) + when(conn.setAutoCommit(any[Boolean])) thenAnswer ((_: Boolean) => ()) andThenThrow (new SQLException(msg)) val ctx = new PostgresMonixJdbcContext(Literal, ds, EffectWrapper.using(scheduler)) import ctx._ @@ -176,13 +177,13 @@ class MockTests extends Spec with AsyncMockitoSugar { when(conn.prepareStatement(any[String], any[Int], any[Int])) thenReturn stmt when(stmt.executeQuery()) thenReturn rs when(conn.getAutoCommit) thenReturn true - when(conn.setAutoCommit(any[Boolean])) thenAnswer ((f: Boolean) => ()) andThenThrow (new SQLException(msg)) + when(conn.setAutoCommit(any[Boolean])) thenAnswer ((_: Boolean) => ()) andThenThrow (new SQLException(msg)) val runner = new EffectWrapper { override def schedule[T](t: Task[T]): Task[T] = t.executeOn(scheduler, true) override def boundary[T](t: Task[T]): Task[T] = t.executeOn(scheduler, true) override def wrapClose(t: => Unit): Task[Unit] = - Task(t).onErrorHandle[Unit](e => ()) + Task(t).onErrorHandle[Unit](_ => ()) } val ctx = new PostgresMonixJdbcContext(Literal, ds, runner) diff --git a/quill-jdbc-monix/src/test/scala/io/getquill/mysql/MonixJdbcContextSpec.scala b/quill-jdbc-monix/src/test/scala/io/getquill/mysql/MonixJdbcContextSpec.scala index e1583d2ae3..a04531d124 100644 --- a/quill-jdbc-monix/src/test/scala/io/getquill/mysql/MonixJdbcContextSpec.scala +++ b/quill-jdbc-monix/src/test/scala/io/getquill/mysql/MonixJdbcContextSpec.scala @@ -63,7 +63,7 @@ class MonixJdbcContextSpec extends MonixSpec { testContext .prepareParams( "select * from Person where name=? and age > ?", - (ps, session) => (List("Sarah", 127), ps) + (ps, _) => (List("Sarah", 127), ps) ) .runSyncUnsafe() mustEqual List("127", "'Sarah'") } diff --git a/quill-jdbc-monix/src/test/scala/io/getquill/mysql/ProductJdbcSpec.scala b/quill-jdbc-monix/src/test/scala/io/getquill/mysql/ProductJdbcSpec.scala index 46775067c7..f00892c39b 100644 --- a/quill-jdbc-monix/src/test/scala/io/getquill/mysql/ProductJdbcSpec.scala +++ b/quill-jdbc-monix/src/test/scala/io/getquill/mysql/ProductJdbcSpec.scala @@ -10,7 +10,7 @@ class ProductJdbcSpec extends ProductSpec { implicit val scheduler = Scheduler.global - override def beforeAll = { + override def beforeAll: Unit = { testContext.run(quote(query[Product].delete)).runSyncUnsafe() () } diff --git a/quill-jdbc-monix/src/test/scala/io/getquill/mysql/mysql.scala b/quill-jdbc-monix/src/test/scala/io/getquill/mysql/mysql.scala index 64e9d54658..3ff21aa28b 100644 --- a/quill-jdbc-monix/src/test/scala/io/getquill/mysql/mysql.scala +++ b/quill-jdbc-monix/src/test/scala/io/getquill/mysql/mysql.scala @@ -3,6 +3,6 @@ package io.getquill import monix.execution.Scheduler package object mysql { - private implicit val scheduler = Scheduler.global + Scheduler.global object testContext extends MysqlMonixJdbcContext(Literal, "testMysqlDB") with TestEntities } diff --git a/quill-jdbc-monix/src/test/scala/io/getquill/oracle/MonixJdbcContextSpec.scala b/quill-jdbc-monix/src/test/scala/io/getquill/oracle/MonixJdbcContextSpec.scala index 726fe7167e..4848b11019 100644 --- a/quill-jdbc-monix/src/test/scala/io/getquill/oracle/MonixJdbcContextSpec.scala +++ b/quill-jdbc-monix/src/test/scala/io/getquill/oracle/MonixJdbcContextSpec.scala @@ -63,7 +63,7 @@ class MonixJdbcContextSpec extends MonixSpec { testContext .prepareParams( "select * from Person where name=? and age > ?", - (ps, session) => (List("Sarah", 127), ps) + (ps, _) => (List("Sarah", 127), ps) ) .runSyncUnsafe() mustEqual List("127", "'Sarah'") } diff --git a/quill-jdbc-monix/src/test/scala/io/getquill/oracle/ProductJdbcSpec.scala b/quill-jdbc-monix/src/test/scala/io/getquill/oracle/ProductJdbcSpec.scala index d5cc635f26..76aa7cd5b1 100644 --- a/quill-jdbc-monix/src/test/scala/io/getquill/oracle/ProductJdbcSpec.scala +++ b/quill-jdbc-monix/src/test/scala/io/getquill/oracle/ProductJdbcSpec.scala @@ -11,7 +11,7 @@ class ProductJdbcSpec extends ProductSpec { implicit val scheduler = Scheduler.global - override def beforeAll = { + override def beforeAll: Unit = { testContext.run(quote(query[Product].delete)).runSyncUnsafe() () } diff --git a/quill-jdbc-monix/src/test/scala/io/getquill/oracle/oracle.scala b/quill-jdbc-monix/src/test/scala/io/getquill/oracle/oracle.scala index b8c89b97d2..30df184097 100644 --- a/quill-jdbc-monix/src/test/scala/io/getquill/oracle/oracle.scala +++ b/quill-jdbc-monix/src/test/scala/io/getquill/oracle/oracle.scala @@ -3,6 +3,6 @@ package io.getquill import monix.execution.Scheduler package object oracle { - private implicit val scheduler = Scheduler.global + Scheduler.global object testContext extends OracleMonixJdbcContext(Literal, "testOracleDB") with TestEntities } diff --git a/quill-jdbc-monix/src/test/scala/io/getquill/postgres/ConnectionLeakTest.scala b/quill-jdbc-monix/src/test/scala/io/getquill/postgres/ConnectionLeakTest.scala index b6690553f0..20795b0b47 100644 --- a/quill-jdbc-monix/src/test/scala/io/getquill/postgres/ConnectionLeakTest.scala +++ b/quill-jdbc-monix/src/test/scala/io/getquill/postgres/ConnectionLeakTest.scala @@ -9,17 +9,18 @@ import io.getquill.util.LoadConfig import monix.execution.Scheduler import scala.util.Random +import com.zaxxer.hikari.HikariDataSource class ConnectionLeakTest extends ProductSpec { implicit val scheduler = Scheduler.global - val dataSource = JdbcContextConfig(LoadConfig("testPostgresLeakDB")).dataSource + val dataSource: HikariDataSource = JdbcContextConfig(LoadConfig("testPostgresLeakDB")).dataSource val context = new PostgresMonixJdbcContext(Literal, dataSource, EffectWrapper.default) import context._ - override def beforeAll = { + override def beforeAll: Unit = { context.run(quote(query[Product].delete)).runSyncUnsafe() () } diff --git a/quill-jdbc-monix/src/test/scala/io/getquill/postgres/MonixJdbcContextSpec.scala b/quill-jdbc-monix/src/test/scala/io/getquill/postgres/MonixJdbcContextSpec.scala index 37f5243c1e..0af8b0d969 100644 --- a/quill-jdbc-monix/src/test/scala/io/getquill/postgres/MonixJdbcContextSpec.scala +++ b/quill-jdbc-monix/src/test/scala/io/getquill/postgres/MonixJdbcContextSpec.scala @@ -63,7 +63,7 @@ class MonixJdbcContextSpec extends MonixSpec { testContext .prepareParams( "select * from Person where name=? and age > ?", - (ps, session) => (List("Sarah", 127), ps) + (ps, _) => (List("Sarah", 127), ps) ) .runSyncUnsafe() mustEqual List("127", "'Sarah'") } diff --git a/quill-jdbc-monix/src/test/scala/io/getquill/postgres/ProductJdbcSpec.scala b/quill-jdbc-monix/src/test/scala/io/getquill/postgres/ProductJdbcSpec.scala index ce3edda007..9bfc9d3fca 100644 --- a/quill-jdbc-monix/src/test/scala/io/getquill/postgres/ProductJdbcSpec.scala +++ b/quill-jdbc-monix/src/test/scala/io/getquill/postgres/ProductJdbcSpec.scala @@ -10,7 +10,7 @@ class ProductJdbcSpec extends ProductSpec { implicit val scheduler = Scheduler.global - override def beforeAll = { + override def beforeAll: Unit = { testContext.run(quote(query[Product].delete)).runSyncUnsafe() () } diff --git a/quill-jdbc-monix/src/test/scala/io/getquill/postgres/package.scala b/quill-jdbc-monix/src/test/scala/io/getquill/postgres/package.scala index 9bece21a16..f4617b5622 100644 --- a/quill-jdbc-monix/src/test/scala/io/getquill/postgres/package.scala +++ b/quill-jdbc-monix/src/test/scala/io/getquill/postgres/package.scala @@ -3,6 +3,6 @@ package io.getquill import monix.execution.Scheduler package object postgres { - private implicit val scheduler = Scheduler.global + Scheduler.global object testContext extends PostgresMonixJdbcContext(Literal, "testPostgresDB") with TestEntities } diff --git a/quill-jdbc-monix/src/test/scala/io/getquill/sqlite/MonixJdbcContextSpec.scala b/quill-jdbc-monix/src/test/scala/io/getquill/sqlite/MonixJdbcContextSpec.scala index afb56ec9db..93a0f63ff3 100644 --- a/quill-jdbc-monix/src/test/scala/io/getquill/sqlite/MonixJdbcContextSpec.scala +++ b/quill-jdbc-monix/src/test/scala/io/getquill/sqlite/MonixJdbcContextSpec.scala @@ -63,7 +63,7 @@ class MonixJdbcContextSpec extends MonixSpec { testContext .prepareParams( "select * from Person where name=? and age > ?", - (ps, session) => (List("Sarah", 127), ps) + (ps, _) => (List("Sarah", 127), ps) ) .runSyncUnsafe() mustEqual List("127", "'Sarah'") } diff --git a/quill-jdbc-monix/src/test/scala/io/getquill/sqlite/ProductJdbcSpec.scala b/quill-jdbc-monix/src/test/scala/io/getquill/sqlite/ProductJdbcSpec.scala index 255be4dd1d..08e1271390 100644 --- a/quill-jdbc-monix/src/test/scala/io/getquill/sqlite/ProductJdbcSpec.scala +++ b/quill-jdbc-monix/src/test/scala/io/getquill/sqlite/ProductJdbcSpec.scala @@ -11,7 +11,7 @@ class ProductJdbcSpec extends ProductSpec { implicit val scheduler = Scheduler.global - override def beforeAll = { + override def beforeAll: Unit = { testContext.run(quote(query[Product].delete)).runSyncUnsafe() () } diff --git a/quill-jdbc-monix/src/test/scala/io/getquill/sqlite/sqlite.scala b/quill-jdbc-monix/src/test/scala/io/getquill/sqlite/sqlite.scala index ee283bd44f..2652d49359 100644 --- a/quill-jdbc-monix/src/test/scala/io/getquill/sqlite/sqlite.scala +++ b/quill-jdbc-monix/src/test/scala/io/getquill/sqlite/sqlite.scala @@ -3,6 +3,6 @@ package io.getquill import monix.execution.Scheduler package object sqlite { - private implicit val scheduler = Scheduler.global + Scheduler.global object testContext extends SqliteMonixJdbcContext(Literal, "testSqliteDB") with TestEntities } diff --git a/quill-jdbc-monix/src/test/scala/io/getquill/sqlserver/MonixJdbcContextSpec.scala b/quill-jdbc-monix/src/test/scala/io/getquill/sqlserver/MonixJdbcContextSpec.scala index 0bc5f0816e..e43629a275 100644 --- a/quill-jdbc-monix/src/test/scala/io/getquill/sqlserver/MonixJdbcContextSpec.scala +++ b/quill-jdbc-monix/src/test/scala/io/getquill/sqlserver/MonixJdbcContextSpec.scala @@ -63,7 +63,7 @@ class MonixJdbcContextSpec extends MonixSpec { testContext .prepareParams( "select * from Person where name=? and age > ?", - (ps, conn) => (List("Sarah", 127), ps) + (ps, _) => (List("Sarah", 127), ps) ) .runSyncUnsafe() mustEqual List("127", "'Sarah'") } diff --git a/quill-jdbc-monix/src/test/scala/io/getquill/sqlserver/ProductJdbcSpec.scala b/quill-jdbc-monix/src/test/scala/io/getquill/sqlserver/ProductJdbcSpec.scala index a32c634b8e..1c456b5fc4 100644 --- a/quill-jdbc-monix/src/test/scala/io/getquill/sqlserver/ProductJdbcSpec.scala +++ b/quill-jdbc-monix/src/test/scala/io/getquill/sqlserver/ProductJdbcSpec.scala @@ -11,7 +11,7 @@ class ProductJdbcSpec extends ProductSpec { implicit val scheduler = Scheduler.global - override def beforeAll = { + override def beforeAll: Unit = { testContext.run(quote(query[Product].delete)).runSyncUnsafe() () } diff --git a/quill-jdbc-monix/src/test/scala/io/getquill/sqlserver/sqlserver.scala b/quill-jdbc-monix/src/test/scala/io/getquill/sqlserver/sqlserver.scala index c6396652b8..9feb4b62e6 100644 --- a/quill-jdbc-monix/src/test/scala/io/getquill/sqlserver/sqlserver.scala +++ b/quill-jdbc-monix/src/test/scala/io/getquill/sqlserver/sqlserver.scala @@ -3,6 +3,6 @@ package io.getquill import monix.execution.Scheduler package object sqlserver { - private implicit val scheduler = Scheduler.global + Scheduler.global object testContext extends SqlServerMonixJdbcContext(Literal, "testSqlServerDB") with TestEntities } diff --git a/quill-jdbc-zio/src/test/scala-2.13/io/getquill/examples/IdiomaticAppWithEncoders.scala b/quill-jdbc-zio/src/test/scala-2.13/io/getquill/examples/IdiomaticAppWithEncoders.scala index a09261c93e..26b2644b8c 100644 --- a/quill-jdbc-zio/src/test/scala-2.13/io/getquill/examples/IdiomaticAppWithEncoders.scala +++ b/quill-jdbc-zio/src/test/scala-2.13/io/getquill/examples/IdiomaticAppWithEncoders.scala @@ -5,35 +5,38 @@ import io.getquill.jdbczio.Quill import zio.Console.printLine import zio.json.{DeriveJsonDecoder, DeriveJsonEncoder, JsonDecoder, JsonEncoder} import zio.{ZIO, ZIOAppDefault, ZLayer} +import io.getquill.{ EntityQuery, Quoted } +import java.sql.SQLException +import javax.sql.DataSource object IdiomaticAppWithEncoders extends ZIOAppDefault { - case class Person(name: String, age: Int) - case class JsonbEntity(name: String, value: JsonbValue[Person]) + final case class Person(name: String, age: Int) + final case class JsonbEntity(name: String, value: JsonbValue[Person]) implicit val personEncoder: JsonEncoder[Person] = DeriveJsonEncoder.gen[Person] implicit val personDecoder: JsonDecoder[Person] = DeriveJsonDecoder.gen[Person] - case class App(quill: Quill.Postgres[Literal]) { + final case class App(quill: Quill.Postgres[Literal]) { import quill._ - val v = JsonbEntity("JoeEntity", JsonbValue(Person("Joe", 123))) + val v: JsonbEntity = JsonbEntity("JoeEntity", JsonbValue(Person("Joe", 123))) val setQuery = quote(query[JsonbEntity].insertValue(lift(v))) - val getQuery = quote(query[JsonbEntity]) - def get() = quill.run(getQuery) + val getQuery: Quoted[EntityQuery[JsonbEntity]] = quote(query[JsonbEntity]) + def get(): ZIO[Any,SQLException,List[JsonbEntity]] = quill.run(getQuery) def set() = quill.run(setQuery) } object App { - def get() = ZIO.serviceWithZIO[App](_.get()) - def set() = ZIO.serviceWithZIO[App](_.set()) + def get(): ZIO[App with App,SQLException,List[JsonbEntity]] = ZIO.serviceWithZIO[App](_.get()) + def set(): ZIO[App with App,Nothing,Nothing] = ZIO.serviceWithZIO[App](_.set()) } - val dsLive = Quill.DataSource.fromPrefix("testPostgresDB") - val pgLive = Quill.Postgres.fromNamingStrategy(Literal) - val appLive = ZLayer.fromFunction(App.apply _) + val dsLive: ZLayer[Any,Throwable,DataSource] = Quill.DataSource.fromPrefix("testPostgresDB") + val pgLive: ZLayer[DataSource,Nothing,Quill.Postgres[Literal.type]] = Quill.Postgres.fromNamingStrategy(Literal) + val appLive: ZLayer[Quill.Postgres[Literal],Nothing,App] = ZLayer.fromFunction(App.apply _) - override def run = + override def run: ZIO[Any,Throwable,Unit] = (for { _ <- App.set() ent <- App.get() diff --git a/quill-jdbc-zio/src/test/scala-2.13/io/getquill/postgres/PostgresJsonSpec.scala b/quill-jdbc-zio/src/test/scala-2.13/io/getquill/postgres/PostgresJsonSpec.scala index 13d3f04c5d..18ebb8a645 100644 --- a/quill-jdbc-zio/src/test/scala-2.13/io/getquill/postgres/PostgresJsonSpec.scala +++ b/quill-jdbc-zio/src/test/scala-2.13/io/getquill/postgres/PostgresJsonSpec.scala @@ -15,10 +15,10 @@ class PostgresJsonSpec extends ZioSpec { case class JsonEntity(name: String, value: JsonValue[PersonJson]) case class JsonbEntity(name: String, value: JsonbValue[PersonJsonb]) - val jsonJoe = JsonValue(PersonJson("Joe", 123)) - val jsonValue = JsonEntity("JoeEntity", jsonJoe) - val jsonbJoe = JsonbValue(PersonJsonb("Joe", 123)) - val jsonbValue = JsonbEntity("JoeEntity", jsonbJoe) + val jsonJoe: JsonValue[PersonJson] = JsonValue(PersonJson("Joe", 123)) + val jsonValue: JsonEntity = JsonEntity("JoeEntity", jsonJoe) + val jsonbJoe: JsonbValue[PersonJsonb] = JsonbValue(PersonJsonb("Joe", 123)) + val jsonbValue: JsonbEntity = JsonbEntity("JoeEntity", jsonbJoe) case class JsonAstEntity(name: String, value: JsonValue[Json]) case class JsonbAstEntity(name: String, value: JsonbValue[Json]) @@ -29,7 +29,7 @@ class PostgresJsonSpec extends ZioSpec { implicit val personJsonbEncoder: JsonEncoder[PersonJsonb] = DeriveJsonEncoder.gen[PersonJsonb] implicit val personJsonbDecoder: JsonDecoder[PersonJsonb] = DeriveJsonDecoder.gen[PersonJsonb] - override def beforeAll = { + override def beforeAll: Unit = { super.beforeAll() testContext.run(quote(query[JsonbEntity].delete)).runSyncUnsafe() testContext.run(quote(query[JsonEntity].delete)).runSyncUnsafe() diff --git a/quill-jdbc-zio/src/test/scala/io/getquill/PrepareZioJdbcSpecBase.scala b/quill-jdbc-zio/src/test/scala/io/getquill/PrepareZioJdbcSpecBase.scala index a9c6db519f..1e55e7bf55 100644 --- a/quill-jdbc-zio/src/test/scala/io/getquill/PrepareZioJdbcSpecBase.scala +++ b/quill-jdbc-zio/src/test/scala/io/getquill/PrepareZioJdbcSpecBase.scala @@ -12,7 +12,7 @@ import javax.sql.DataSource trait PrepareZioJdbcSpecBase extends ProductSpec with ZioProxySpec { - implicit val productEq = new Equality[Product] { + implicit val productEq: Equality[Product] = new Equality[Product] { override def areEqual(a: Product, b: Any): Boolean = b match { case Product(_, desc, sku) => desc == a.description && sku == a.sku case _ => false @@ -21,16 +21,16 @@ trait PrepareZioJdbcSpecBase extends ProductSpec with ZioProxySpec { def productExtractor: (ResultSet, Connection) => Product - def withOrderedIds(products: List[Product]) = + def withOrderedIds(products: List[Product]): List[Product] = products.zipWithIndex.map { case (product, id) => product.copy(id = id.toLong + 1) } - def singleInsert(prep: QCIO[PreparedStatement])(implicit runtime: Implicit[DataSource]) = + def singleInsert(prep: QCIO[PreparedStatement])(implicit runtime: Implicit[DataSource]): Boolean = prep .flatMap(stmt => ZIO.attempt(stmt).acquireReleaseWithAuto(stmt => ZIO.attempt(stmt.execute()))) .onDataSource .runSyncUnsafe() - def batchInsert(prep: QCIO[List[PreparedStatement]])(implicit runtime: Implicit[DataSource]) = + def batchInsert(prep: QCIO[List[PreparedStatement]])(implicit runtime: Implicit[DataSource]): List[Boolean] = prep .flatMap(stmts => ZIO.collectAll( @@ -42,7 +42,7 @@ trait PrepareZioJdbcSpecBase extends ProductSpec with ZioProxySpec { def extractResults[T]( prepareStatement: QCIO[PreparedStatement] - )(extractor: (ResultSet, Connection) => T)(implicit runtime: Implicit[DataSource]) = + )(extractor: (ResultSet, Connection) => T)(implicit runtime: Implicit[DataSource]): List[T] = (for { conn <- ZIO.service[Connection] result <- prepareStatement.provideEnvironment(ZEnvironment(conn)).acquireReleaseWithAuto { stmt => @@ -52,6 +52,6 @@ trait PrepareZioJdbcSpecBase extends ProductSpec with ZioProxySpec { } } yield result).onDataSource.runSyncUnsafe() - def extractProducts(prep: QCIO[PreparedStatement])(implicit runtime: Implicit[DataSource]) = + def extractProducts(prep: QCIO[PreparedStatement])(implicit runtime: Implicit[DataSource]): List[Product] = extractResults(prep)(productExtractor) } diff --git a/quill-jdbc-zio/src/test/scala/io/getquill/ResultSetIteratorSpec.scala b/quill-jdbc-zio/src/test/scala/io/getquill/ResultSetIteratorSpec.scala index 6965ff0f13..4fc6a210ba 100644 --- a/quill-jdbc-zio/src/test/scala/io/getquill/ResultSetIteratorSpec.scala +++ b/quill-jdbc-zio/src/test/scala/io/getquill/ResultSetIteratorSpec.scala @@ -9,7 +9,7 @@ import scala.collection.mutable.ArrayBuffer class ResultSetIteratorSpec extends ZioProxySpec { - implicit val pool = Implicit(io.getquill.postgres.pool) + implicit val pool: Implicit[DataSource] = Implicit(io.getquill.postgres.pool) val ctx = new PostgresZioJdbcContext(Literal) import ctx._ @@ -18,13 +18,13 @@ class ResultSetIteratorSpec extends ZioProxySpec { val peopleInsert = quote((p: Person) => query[Person].insertValue(p)) - val peopleEntries = List( + val peopleEntries: List[Person] = List( Person("Alex", 60), Person("Bert", 55), Person("Cora", 33) ) - override def beforeAll = { + override def beforeAll: Unit = { super.beforeAll() ctx.transaction { for { @@ -43,7 +43,7 @@ class ResultSetIteratorSpec extends ZioProxySpec { ZIO.attempt { val stmt = conn.prepareStatement("select * from person") val rs = - new ResultSetIterator[String](stmt.executeQuery(), conn, extractor = (rs, conn) => { rs.getString(1) }) + new ResultSetIterator[String](stmt.executeQuery(), conn, extractor = (rs, _) => { rs.getString(1) }) val accum = ArrayBuffer[String]() while (rs.hasNext) accum += rs.next() accum @@ -62,7 +62,7 @@ class ResultSetIteratorSpec extends ZioProxySpec { .acquireReleaseWithAuto { conn => ZIO.attempt { val stmt = conn.prepareStatement("select * from person where name = 'Alex'") - val rs = new ResultSetIterator(stmt.executeQuery(), conn, extractor = (rs, conn) => { rs.getString(1) }) + val rs = new ResultSetIterator(stmt.executeQuery(), conn, extractor = (rs, _) => { rs.getString(1) }) rs.head } } diff --git a/quill-jdbc-zio/src/test/scala/io/getquill/ZioSpec.scala b/quill-jdbc-zio/src/test/scala/io/getquill/ZioSpec.scala index 2bc14b8dac..4351da9f07 100644 --- a/quill-jdbc-zio/src/test/scala/io/getquill/ZioSpec.scala +++ b/quill-jdbc-zio/src/test/scala/io/getquill/ZioSpec.scala @@ -32,11 +32,11 @@ trait ZioSpec extends Spec with BeforeAndAfterAll { } implicit class ZStreamTestExt[T](stream: ZStream[Any, Throwable, T]) { - def runSyncUnsafe() = collect[T](stream) + def runSyncUnsafe(): List[T] = collect[T](stream) } implicit class ZioTestExt[T](qzio: ZIO[Any, Throwable, T]) { - def runSyncUnsafe() = collect[T](qzio) + def runSyncUnsafe(): T = collect[T](qzio) } } @@ -61,17 +61,17 @@ trait ZioProxySpec extends Spec with BeforeAndAfterAll { } implicit class ZioAnyOps[T](qzio: ZIO[Any, Throwable, T]) { - def runSyncUnsafe() = + def runSyncUnsafe(): T = Unsafe.unsafe { implicit u => Runtime.default.unsafe.run(qzio).getOrThrow() } } implicit class ZStreamTestExt[T](stream: ZStream[DataSource, Throwable, T])(implicit runtime: Implicit[DataSource]) { - def runSyncUnsafe() = collect[T](stream) + def runSyncUnsafe(): List[T] = collect[T](stream) } implicit class ZioTestExt[T](qzio: ZIO[DataSource, Throwable, T])(implicit runtime: Implicit[DataSource]) { - def runSyncUnsafe() = collect[T](qzio) + def runSyncUnsafe(): T = collect[T](qzio) } } diff --git a/quill-jdbc-zio/src/test/scala/io/getquill/examples/IdiomaticApp.scala b/quill-jdbc-zio/src/test/scala/io/getquill/examples/IdiomaticApp.scala index 38b603ccd4..1ed705ec26 100644 --- a/quill-jdbc-zio/src/test/scala/io/getquill/examples/IdiomaticApp.scala +++ b/quill-jdbc-zio/src/test/scala/io/getquill/examples/IdiomaticApp.scala @@ -6,15 +6,16 @@ import zio.Console.printLine import zio._ import java.sql.SQLException +import javax.sql.DataSource object IdiomaticApp extends ZIOAppDefault { - case class DataService(quill: Quill.Postgres[Literal]) { + final case class DataService(quill: Quill.Postgres[Literal]) { import quill._ - val people = quote(query[Person]) - def peopleByName = quote((name: String) => people.filter(p => p.name == name)) + val people: Quoted[EntityQuery[Person]] = quote(query[Person]) + def peopleByName: Quoted[String => EntityQuery[Person]] = quote((name: String) => people.filter(p => p.name == name)) } - case class ApplicationLive(dataService: DataService) { + final case class ApplicationLive(dataService: DataService) { import dataService.quill._ import dataService.quill def getPeopleByName(name: String): ZIO[Any, SQLException, List[Person]] = @@ -22,19 +23,19 @@ object IdiomaticApp extends ZIOAppDefault { def getAllPeople(): ZIO[Any, SQLException, List[Person]] = quill.run(dataService.people) } object Application { - def getPeopleByName(name: String) = + def getPeopleByName(name: String): ZIO[ApplicationLive with ApplicationLive,SQLException,List[Person]] = ZIO.serviceWithZIO[ApplicationLive](_.getPeopleByName(name)) - def getAllPeople() = + def getAllPeople(): ZIO[ApplicationLive with ApplicationLive,SQLException,List[Person]] = ZIO.serviceWithZIO[ApplicationLive](_.getAllPeople()) } - case class Person(name: String, age: Int) + final case class Person(name: String, age: Int) - val dataServiceLive = ZLayer.fromFunction(DataService.apply _) - val applicationLive = ZLayer.fromFunction(ApplicationLive.apply _) - val dataSourceLive = Quill.DataSource.fromPrefix("testPostgresDB") - val postgresLive = Quill.Postgres.fromNamingStrategy(Literal) + val dataServiceLive: ZLayer[Quill.Postgres[Literal],Nothing,DataService] = ZLayer.fromFunction(DataService.apply _) + val applicationLive: ZLayer[DataService,Nothing,ApplicationLive] = ZLayer.fromFunction(ApplicationLive.apply _) + val dataSourceLive: ZLayer[Any,Throwable,DataSource] = Quill.DataSource.fromPrefix("testPostgresDB") + val postgresLive: ZLayer[DataSource,Nothing,Quill.Postgres[Literal.type]] = Quill.Postgres.fromNamingStrategy(Literal) - override def run = + override def run: ZIO[Any,Throwable,Unit] = (for { joes <- Application.getPeopleByName("Joe") _ <- printLine(joes) diff --git a/quill-jdbc-zio/src/test/scala/io/getquill/examples/IdiomaticAppPlain.scala b/quill-jdbc-zio/src/test/scala/io/getquill/examples/IdiomaticAppPlain.scala index 3e70639a43..96c9256932 100644 --- a/quill-jdbc-zio/src/test/scala/io/getquill/examples/IdiomaticAppPlain.scala +++ b/quill-jdbc-zio/src/test/scala/io/getquill/examples/IdiomaticAppPlain.scala @@ -9,23 +9,23 @@ import java.sql.SQLException object IdiomaticAppPlain { - case class DataService(quill: Quill.Postgres[Literal]) { + final case class DataService(quill: Quill.Postgres[Literal]) { import quill._ - val people = quote(query[Person]) - def peopleByName = quote((name: String) => people.filter(p => p.name == name)) + val people: Quoted[EntityQuery[Person]] = quote(query[Person]) + def peopleByName: Quoted[String => EntityQuery[Person]] = quote((name: String) => people.filter(p => p.name == name)) } - case class ApplicationLive(dataService: DataService) { + final case class ApplicationLive(dataService: DataService) { import dataService.quill._ def getPeopleByName(name: String): ZIO[Any, SQLException, List[Person]] = run(dataService.peopleByName(lift(name))) def getAllPeople(): ZIO[Any, SQLException, List[Person]] = run(dataService.people) } object Application { - def getPeopleByName(name: String) = + def getPeopleByName(name: String): ZIO[ApplicationLive with ApplicationLive,SQLException,List[Person]] = ZIO.serviceWithZIO[ApplicationLive](_.getPeopleByName(name)) - def getAllPeople() = + def getAllPeople(): ZIO[ApplicationLive with ApplicationLive,SQLException,List[Person]] = ZIO.serviceWithZIO[ApplicationLive](_.getAllPeople()) } - case class Person(name: String, age: Int) + final case class Person(name: String, age: Int) def main(args: Array[String]): Unit = { val dataServiceLive = ZLayer.fromFunction(DataService.apply _) diff --git a/quill-jdbc-zio/src/test/scala/io/getquill/examples/other/PlainApp.scala b/quill-jdbc-zio/src/test/scala/io/getquill/examples/other/PlainApp.scala index 1847529e22..271e9bb51b 100644 --- a/quill-jdbc-zio/src/test/scala/io/getquill/examples/other/PlainApp.scala +++ b/quill-jdbc-zio/src/test/scala/io/getquill/examples/other/PlainApp.scala @@ -3,15 +3,17 @@ package io.getquill.examples.other import io.getquill.jdbczio.Quill import io.getquill.{Literal, PostgresZioJdbcContext} import zio.{Runtime, Unsafe} +import javax.sql.DataSource +import zio.ZLayer object PlainApp { object MyPostgresContext extends PostgresZioJdbcContext(Literal) import MyPostgresContext._ - case class Person(name: String, age: Int) + final case class Person(name: String, age: Int) - val zioDS = Quill.DataSource.fromPrefix("testPostgresDB") + val zioDS: ZLayer[Any,Throwable,DataSource] = Quill.DataSource.fromPrefix("testPostgresDB") def main(args: Array[String]): Unit = { val people = quote { diff --git a/quill-jdbc-zio/src/test/scala/io/getquill/examples/other/PlainAppDataSource.scala b/quill-jdbc-zio/src/test/scala/io/getquill/examples/other/PlainAppDataSource.scala index 42b696acca..24c5034346 100644 --- a/quill-jdbc-zio/src/test/scala/io/getquill/examples/other/PlainAppDataSource.scala +++ b/quill-jdbc-zio/src/test/scala/io/getquill/examples/other/PlainAppDataSource.scala @@ -6,17 +6,19 @@ import io.getquill.jdbczio.Quill import io.getquill.{JdbcContextConfig, Literal, PostgresZioJdbcContext} import zio.Console.printLine import zio.{Runtime, Unsafe} +import javax.sql.DataSource +import zio.ZLayer object PlainAppDataSource { object MyPostgresContext extends PostgresZioJdbcContext(Literal) import MyPostgresContext._ - case class Person(name: String, age: Int) + final case class Person(name: String, age: Int) - def config = JdbcContextConfig(LoadConfig("testPostgresDB")).dataSource + def config: HikariDataSource = JdbcContextConfig(LoadConfig("testPostgresDB")).dataSource - val zioDS = Quill.DataSource.fromDataSource(new HikariDataSource(config)) + val zioDS: ZLayer[Any,Throwable,DataSource] = Quill.DataSource.fromDataSource(new HikariDataSource(config)) def main(args: Array[String]): Unit = { val people = quote { diff --git a/quill-jdbc-zio/src/test/scala/io/getquill/examples/other/PlainAppDataSource2.scala b/quill-jdbc-zio/src/test/scala/io/getquill/examples/other/PlainAppDataSource2.scala index 0fd2de838c..a571d664a8 100644 --- a/quill-jdbc-zio/src/test/scala/io/getquill/examples/other/PlainAppDataSource2.scala +++ b/quill-jdbc-zio/src/test/scala/io/getquill/examples/other/PlainAppDataSource2.scala @@ -13,7 +13,7 @@ object PlainAppDataSource2 { object MyPostgresContext extends PostgresZioJdbcContext(Literal) import MyPostgresContext._ - case class Person(name: String, age: Int) + final case class Person(name: String, age: Int) def hikariConfig = new HikariConfig(JdbcContextConfig(LoadConfig("testPostgresDB")).configProperties) def hikariDataSource = new HikariDataSource(hikariConfig) diff --git a/quill-jdbc-zio/src/test/scala/io/getquill/examples/other/ServiceExample.scala b/quill-jdbc-zio/src/test/scala/io/getquill/examples/other/ServiceExample.scala index 978d8c8ee6..e695043093 100644 --- a/quill-jdbc-zio/src/test/scala/io/getquill/examples/other/ServiceExample.scala +++ b/quill-jdbc-zio/src/test/scala/io/getquill/examples/other/ServiceExample.scala @@ -7,14 +7,15 @@ import zio.{ZIO, ZIOAppDefault, ZLayer} import java.sql.SQLException import javax.sql.DataSource +import zio.{ ExitCode, URIO } object ServiceExample extends ZIOAppDefault { import DBModel._ - override def run = + override def run: URIO[Any,ExitCode] = runApp.provide(DBManager.live).exitCode - def runApp = + def runApp: ZIO[DBManager.Service,Throwable,Unit] = for { _ <- DBManager.deleteJoes _ <- DBManager.persist(Person("Joe", 123)) @@ -24,7 +25,7 @@ object ServiceExample extends ZIOAppDefault { } object DBModel { - case class Person(name: String, age: Int) + final case class Person(name: String, age: Int) } object DBManager { diff --git a/quill-jdbc-zio/src/test/scala/io/getquill/examples/other/ZioApp.scala b/quill-jdbc-zio/src/test/scala/io/getquill/examples/other/ZioApp.scala index 79750840e5..aa1fd4c324 100644 --- a/quill-jdbc-zio/src/test/scala/io/getquill/examples/other/ZioApp.scala +++ b/quill-jdbc-zio/src/test/scala/io/getquill/examples/other/ZioApp.scala @@ -4,17 +4,19 @@ import io.getquill._ import io.getquill.jdbczio.Quill import zio.Console.printLine import zio.ZIOAppDefault +import javax.sql.DataSource +import zio.{ ExitCode, URIO, ZLayer } object ZioApp extends ZIOAppDefault { object MyPostgresContext extends PostgresZioJdbcContext(Literal) import MyPostgresContext._ - case class Person(name: String, age: Int) + final case class Person(name: String, age: Int) - val zioDS = Quill.DataSource.fromPrefix("testPostgresDB") + val zioDS: ZLayer[Any,Throwable,DataSource] = Quill.DataSource.fromPrefix("testPostgresDB") - override def run = { + override def run: URIO[Any,ExitCode] = { val people = quote { query[Person].filter(p => p.name == "Alex") } diff --git a/quill-jdbc-zio/src/test/scala/io/getquill/examples/other/ZioAppDataSource.scala b/quill-jdbc-zio/src/test/scala/io/getquill/examples/other/ZioAppDataSource.scala index 0b1023f679..bdac12b7ad 100644 --- a/quill-jdbc-zio/src/test/scala/io/getquill/examples/other/ZioAppDataSource.scala +++ b/quill-jdbc-zio/src/test/scala/io/getquill/examples/other/ZioAppDataSource.scala @@ -4,17 +4,19 @@ import io.getquill._ import io.getquill.util.LoadConfig import zio.Console.printLine import zio.{ZEnvironment, ZIOAppDefault} +import com.zaxxer.hikari.HikariDataSource +import zio.{ ExitCode, URIO } object ZioAppDataSource extends ZIOAppDefault { object MyPostgresContext extends PostgresZioJdbcContext(Literal) import MyPostgresContext._ - case class Person(name: String, age: Int) + final case class Person(name: String, age: Int) - def dataSource = JdbcContextConfig(LoadConfig("testPostgresDB")).dataSource + def dataSource: HikariDataSource = JdbcContextConfig(LoadConfig("testPostgresDB")).dataSource - override def run = { + override def run: URIO[Any,ExitCode] = { val people = quote { query[Person].filter(p => p.name == "Alex") } diff --git a/quill-jdbc-zio/src/test/scala/io/getquill/examples/other/ZioAppExample.scala b/quill-jdbc-zio/src/test/scala/io/getquill/examples/other/ZioAppExample.scala index f220ce65e2..d8f260a8e2 100644 --- a/quill-jdbc-zio/src/test/scala/io/getquill/examples/other/ZioAppExample.scala +++ b/quill-jdbc-zio/src/test/scala/io/getquill/examples/other/ZioAppExample.scala @@ -5,33 +5,34 @@ import io.getquill.jdbczio.Quill import zio._ import javax.sql.DataSource +import java.sql.SQLException -case class Person(name: String, age: Int) +final case class Person(name: String, age: Int) object QuillContext extends PostgresZioJdbcContext(SnakeCase) { - val dataSourceLayer = Quill.DataSource.fromPrefix("testPostgresDB").orDie + val dataSourceLayer: ZLayer[Any,Nothing,DataSource] = Quill.DataSource.fromPrefix("testPostgresDB").orDie } object DataService { - def getPeople = + def getPeople: ZIO[DataServiceLive,Nothing,IO[SQLException,List[Person]]] = ZIO.serviceWith[DataServiceLive](_.getPeople) - def getPeopleOlderThan(age: Int) = + def getPeopleOlderThan(age: Int): ZIO[DataServiceLive,Nothing,Nothing] = ZIO.serviceWith[DataServiceLive](_.getPeopleOlderThan(age)) } object DataServiceLive { - val layer = ZLayer.fromFunction(DataServiceLive.apply _) + val layer: ZLayer[DataSource,Nothing,DataServiceLive] = ZLayer.fromFunction(DataServiceLive.apply _) } final case class DataServiceLive(dataSource: DataSource) { import QuillContext._ - def getPeople = run(query[Person]).provideEnvironment(ZEnvironment(dataSource)) + def getPeople: IO[SQLException,List[Person]] = run(query[Person]).provideEnvironment(ZEnvironment(dataSource)) def getPeopleOlderThan(age: Int) = run(query[Person].filter(p => p.age > lift(age))).provideEnvironment(ZEnvironment(dataSource)) } object ZioAppExample extends ZIOAppDefault { - override def run = + override def run: URIO[Any,ExitCode] = DataService.getPeople .provide(QuillContext.dataSourceLayer, DataServiceLive.layer) .debug("Results") diff --git a/quill-jdbc-zio/src/test/scala/io/getquill/examples/other/ZioAppImplicitEnv.scala b/quill-jdbc-zio/src/test/scala/io/getquill/examples/other/ZioAppImplicitEnv.scala index 58e56da29c..7922fa24fc 100644 --- a/quill-jdbc-zio/src/test/scala/io/getquill/examples/other/ZioAppImplicitEnv.scala +++ b/quill-jdbc-zio/src/test/scala/io/getquill/examples/other/ZioAppImplicitEnv.scala @@ -7,25 +7,28 @@ import zio.Console.printLine import zio.ZIOAppDefault import javax.sql.DataSource +import com.zaxxer.hikari.HikariDataSource +import java.sql.SQLException +import zio.{ ExitCode, IO, URIO } object ZioAppImplicitEnv extends ZIOAppDefault { object Ctx extends PostgresZioJdbcContext(Literal) - case class Person(name: String, age: Int) + final case class Person(name: String, age: Int) - def dataSource = JdbcContextConfig(LoadConfig("testPostgresDB")).dataSource + def dataSource: HikariDataSource = JdbcContextConfig(LoadConfig("testPostgresDB")).dataSource - case class MyQueryService(ds: DataSource) { + final case class MyQueryService(ds: DataSource) { import Ctx._ - implicit val env = Implicit(ds) + implicit val env: Implicit[DataSource] = Implicit(ds) - val joes = Ctx.run(query[Person].filter(p => p.name == "Joe")).implicitly - val jills = Ctx.run(query[Person].filter(p => p.name == "Jill")).implicitly - val alexes = Ctx.run(query[Person].filter(p => p.name == "Alex")).implicitly + val joes: IO[SQLException,List[Person]] = Ctx.run(query[Person].filter(p => p.name == "Joe")).implicitly + val jills: IO[SQLException,List[Person]] = Ctx.run(query[Person].filter(p => p.name == "Jill")).implicitly + val alexes: IO[SQLException,List[Person]] = Ctx.run(query[Person].filter(p => p.name == "Alex")).implicitly } - override def run = + override def run: URIO[Any,ExitCode] = MyQueryService(dataSource).joes .tap(result => printLine(result.toString)) .exitCode diff --git a/quill-jdbc-zio/src/test/scala/io/getquill/examples/other/ZioAppManual.scala b/quill-jdbc-zio/src/test/scala/io/getquill/examples/other/ZioAppManual.scala index fec1ab690b..d4558e38df 100644 --- a/quill-jdbc-zio/src/test/scala/io/getquill/examples/other/ZioAppManual.scala +++ b/quill-jdbc-zio/src/test/scala/io/getquill/examples/other/ZioAppManual.scala @@ -6,16 +6,17 @@ import zio.{ZIOAppDefault, ZLayer} import zio.Console.printLine import javax.sql.DataSource +import zio.{ ExitCode, URIO } object ZioAppManual extends ZIOAppDefault { object MyPostgresContext extends PostgresZioJdbcContext(Literal) import MyPostgresContext._ - case class Person(name: String, age: Int) + final case class Person(name: String, age: Int) lazy val ds: DataSource = JdbcContextConfig(LoadConfig("testPostgresDB")).dataSource - override def run = { + override def run: URIO[Any,ExitCode] = { val people = quote { query[Person].filter(p => p.name == "Alex") } diff --git a/quill-jdbc-zio/src/test/scala/io/getquill/h2/PrepareJdbcSpec.scala b/quill-jdbc-zio/src/test/scala/io/getquill/h2/PrepareJdbcSpec.scala index 6e349798d0..8724e83497 100644 --- a/quill-jdbc-zio/src/test/scala/io/getquill/h2/PrepareJdbcSpec.scala +++ b/quill-jdbc-zio/src/test/scala/io/getquill/h2/PrepareJdbcSpec.scala @@ -4,19 +4,22 @@ import java.sql.{Connection, ResultSet} import io.getquill.PrepareZioJdbcSpecBase import io.getquill.context.qzio.ImplicitSyntax.Implicit import org.scalatest.BeforeAndAfter +import io.getquill.context.ZioJdbc +import java.sql.PreparedStatement +import javax.sql.DataSource class PrepareJdbcSpec extends PrepareZioJdbcSpecBase with BeforeAndAfter { val context = testContext.underlying import context._ - implicit val implicitPool = Implicit(pool) + implicit val implicitPool: Implicit[DataSource] = Implicit(pool) before { testContext.run(query[Product].delete).runSyncUnsafe() } - def productExtractor = (rs: ResultSet, conn: Connection) => materializeQueryMeta[Product].extract(rs, conn) - val prepareQuery = prepare(query[Product]) + def productExtractor: (ResultSet, Connection) => Product = (rs: ResultSet, conn: Connection) => materializeQueryMeta[Product].extract(rs, conn) + val prepareQuery: ZioJdbc.QCIO[PreparedStatement] = prepare(query[Product]) "single" in { val prepareInsert = prepare(query[Product].insertValue(lift(productEntries.head))) diff --git a/quill-jdbc-zio/src/test/scala/io/getquill/h2/ProductJdbcSpec.scala b/quill-jdbc-zio/src/test/scala/io/getquill/h2/ProductJdbcSpec.scala index 300051c0ac..4c014f25bc 100644 --- a/quill-jdbc-zio/src/test/scala/io/getquill/h2/ProductJdbcSpec.scala +++ b/quill-jdbc-zio/src/test/scala/io/getquill/h2/ProductJdbcSpec.scala @@ -9,7 +9,7 @@ class ProductJdbcSpec extends ProductSpec with ZioSpec { val context = testContext import testContext._ - override def beforeAll = { + override def beforeAll: Unit = { super.beforeAll() testContext.run(quote(query[Product].delete)).runSyncUnsafe() () diff --git a/quill-jdbc-zio/src/test/scala/io/getquill/h2/ZioJdbcContextSpec.scala b/quill-jdbc-zio/src/test/scala/io/getquill/h2/ZioJdbcContextSpec.scala index 2fb72f82be..f34ea84b48 100644 --- a/quill-jdbc-zio/src/test/scala/io/getquill/h2/ZioJdbcContextSpec.scala +++ b/quill-jdbc-zio/src/test/scala/io/getquill/h2/ZioJdbcContextSpec.scala @@ -60,7 +60,7 @@ class ZioJdbcContextSpec extends ZioSpec { testContext .prepareParams( "select * from Person where name=? and age > ?", - (ps, session) => (List("Sarah", 127), ps) + (ps, _) => (List("Sarah", 127), ps) ) .runSyncUnsafe() mustEqual List("127", "'Sarah'") } diff --git a/quill-jdbc-zio/src/test/scala/io/getquill/h2/h2.scala b/quill-jdbc-zio/src/test/scala/io/getquill/h2/h2.scala index d879b14a1d..02d6b9bb8e 100644 --- a/quill-jdbc-zio/src/test/scala/io/getquill/h2/h2.scala +++ b/quill-jdbc-zio/src/test/scala/io/getquill/h2/h2.scala @@ -2,8 +2,9 @@ package io.getquill import io.getquill.ZioSpec.runLayerUnsafe import io.getquill.jdbczio.Quill +import javax.sql.DataSource package object h2 { - val pool = runLayerUnsafe(Quill.DataSource.fromPrefix("testH2DB")) + val pool: DataSource = runLayerUnsafe(Quill.DataSource.fromPrefix("testH2DB")) object testContext extends Quill.H2(Literal, pool) with TestEntities } diff --git a/quill-jdbc-zio/src/test/scala/io/getquill/integration/StreamResultsOrBlowUpSpec.scala b/quill-jdbc-zio/src/test/scala/io/getquill/integration/StreamResultsOrBlowUpSpec.scala index f62abe57b6..9cdc22054e 100644 --- a/quill-jdbc-zio/src/test/scala/io/getquill/integration/StreamResultsOrBlowUpSpec.scala +++ b/quill-jdbc-zio/src/test/scala/io/getquill/integration/StreamResultsOrBlowUpSpec.scala @@ -5,6 +5,7 @@ import org.scalatest.matchers.should.Matchers._ import io.getquill._ import io.getquill.context.ZioJdbc._ import io.getquill.context.qzio.ImplicitSyntax.Implicit +import javax.sql.DataSource /** * This is a long-running test that will cause a OutOfMemory exception if a @@ -18,7 +19,7 @@ import io.getquill.context.qzio.ImplicitSyntax.Implicit * As a default, this test will run as part of the suite without blowing up. */ class StreamResultsOrBlowUpSpec extends ZioProxySpec { - implicit val pool = Implicit(io.getquill.postgres.pool) + implicit val pool: Implicit[DataSource] = Implicit(io.getquill.postgres.pool) case class Person(name: String, age: Int) @@ -26,7 +27,7 @@ class StreamResultsOrBlowUpSpec extends ZioProxySpec { // that will force jdbc to load the entire ResultSet into memory and crash this test. val doBlowUp = false - val ctx = new PostgresZioJdbcContext.Underlying(Literal) { + val ctx: PostgresZioJdbcContext.Underlying[Literal.type] = new PostgresZioJdbcContext.Underlying(Literal) { override protected def prepareStatementForStreaming(sql: String, conn: Connection, fetchSize: Option[Int]) = { val stmt = conn.prepareStatement( @@ -40,11 +41,11 @@ class StreamResultsOrBlowUpSpec extends ZioProxySpec { } } import ctx.{run => runQuill, _} - val inserts = quote { (numRows: Long) => + val inserts: Quoted[Long => Insert[Int]] = quote { (numRows: Long) => sql"""insert into person (name, age) select md5(random()::text), random()*10+1 from generate_series(1, ${numRows}) s(i)""" .as[Insert[Int]] } - val deletes = runQuill(sql"TRUNCATE TABLE Person".as[Delete[Person]]) + val deletes: QCIO[Long] = runQuill(sql"TRUNCATE TABLE Person".as[Delete[Person]]) val numRows = 1000000L diff --git a/quill-jdbc-zio/src/test/scala/io/getquill/misc/ImplicitEnvPatternSpec.scala b/quill-jdbc-zio/src/test/scala/io/getquill/misc/ImplicitEnvPatternSpec.scala index 787e3ec65a..ffc0dcb8b8 100644 --- a/quill-jdbc-zio/src/test/scala/io/getquill/misc/ImplicitEnvPatternSpec.scala +++ b/quill-jdbc-zio/src/test/scala/io/getquill/misc/ImplicitEnvPatternSpec.scala @@ -24,7 +24,7 @@ class ImplicitEnvPatternSpec extends PeopleZioProxySpec { } case class MyService(ds: DataSource) { - implicit val env = Implicit(ds) + implicit val env: Implicit[DataSource] = Implicit(ds) def alexes = testContext.run(query[Person].filter(p => p.name == "Alex")) def berts = testContext.run(query[Person].filter(p => p.name == "Bert")) diff --git a/quill-jdbc-zio/src/test/scala/io/getquill/misc/OnDataSourceSpec.scala b/quill-jdbc-zio/src/test/scala/io/getquill/misc/OnDataSourceSpec.scala index 53bf82b506..2ea2890615 100644 --- a/quill-jdbc-zio/src/test/scala/io/getquill/misc/OnDataSourceSpec.scala +++ b/quill-jdbc-zio/src/test/scala/io/getquill/misc/OnDataSourceSpec.scala @@ -58,7 +58,7 @@ class OnDataSourceSpec extends PeopleZioProxySpec { "should work with additional dependency" in { // This is how you import the decoders of `underlying` context without importing things that will conflict // i.e. the quote and run methods - case class Service(ds: DataSource) { + final case class Service(ds: DataSource) { // Note that implicit Implicit(dataSource) is given by the package-level `pool` object // implicit val dsi = Implicit(ds) val people = @@ -78,7 +78,7 @@ class OnDataSourceSpec extends PeopleZioProxySpec { "should work" in { // This is how you import the decoders of `underlying` context without importing things that will conflict // i.e. the quote and run methods - case class Service(ds: DataSource) { + final case class Service(ds: DataSource) { // Note that implicit Implicit(dataSource) is given by the package-level `pool` object // implicit val dsi = Implicit(ds) val people = diff --git a/quill-jdbc-zio/src/test/scala/io/getquill/misc/ZioJdbcUnderlyingContextSpec.scala b/quill-jdbc-zio/src/test/scala/io/getquill/misc/ZioJdbcUnderlyingContextSpec.scala index 3c60f9fa98..0a215d34c3 100644 --- a/quill-jdbc-zio/src/test/scala/io/getquill/misc/ZioJdbcUnderlyingContextSpec.scala +++ b/quill-jdbc-zio/src/test/scala/io/getquill/misc/ZioJdbcUnderlyingContextSpec.scala @@ -86,7 +86,7 @@ class ZioJdbcUnderlyingContextSpec extends ZioProxySpec { testContext.underlying .prepareParams( "select * from Person where name=? and age > ?", - (ps, session) => (List("Sarah", 127), ps) + (ps, _) => (List("Sarah", 127), ps) ) .onDataSource .runSyncUnsafe() mustEqual List("127", "'Sarah'") diff --git a/quill-jdbc-zio/src/test/scala/io/getquill/misc/package.scala b/quill-jdbc-zio/src/test/scala/io/getquill/misc/package.scala index e0eded144d..a8bfae1330 100644 --- a/quill-jdbc-zio/src/test/scala/io/getquill/misc/package.scala +++ b/quill-jdbc-zio/src/test/scala/io/getquill/misc/package.scala @@ -1,8 +1,9 @@ package io.getquill import io.getquill.context.qzio.ImplicitSyntax.Implicit +import javax.sql.DataSource package object misc { - implicit val pool = Implicit(io.getquill.postgres.pool) + implicit val pool: Implicit[DataSource] = Implicit(io.getquill.postgres.pool) object testContext extends PostgresZioJdbcContext(Literal) with TestEntities } diff --git a/quill-jdbc-zio/src/test/scala/io/getquill/mock/Introspection.scala b/quill-jdbc-zio/src/test/scala/io/getquill/mock/Introspection.scala index 60796b63cc..52ef3950bb 100644 --- a/quill-jdbc-zio/src/test/scala/io/getquill/mock/Introspection.scala +++ b/quill-jdbc-zio/src/test/scala/io/getquill/mock/Introspection.scala @@ -6,16 +6,16 @@ import scala.reflect.runtime.{universe => ru} class Introspection[T](t: T)(implicit tt: ru.TypeTag[T], ct: ClassTag[T]) { import ru._ - val rm = runtimeMirror(getClass.getClassLoader) - val instanceMirror = rm.reflect(t) + val rm: Mirror = runtimeMirror(getClass.getClassLoader) + val instanceMirror: InstanceMirror = rm.reflect(t) - val fieldsAndValues = + val fieldsAndValues: List[(String, Any)] = typeOf[T].members.collect { case m: MethodSymbol if m.isCaseAccessor => m }.map(sym => (sym.name.toString, instanceMirror.reflectField(sym.asTerm).get)).toList.reverse val map = fieldsAndValues.toMap - def getIndex(i: Int) = fieldsAndValues(i - 1)._2 // Subtract 1 because DB result sets are 1-indexed - def getField(name: String) = map(name) + def getIndex(i: Int): Any = fieldsAndValues(i - 1)._2 // Subtract 1 because DB result sets are 1-indexed + def getField(name: String): Any = map(name) } diff --git a/quill-jdbc-zio/src/test/scala/io/getquill/mock/ZioMockSpec.scala b/quill-jdbc-zio/src/test/scala/io/getquill/mock/ZioMockSpec.scala index d29e28b6a4..8ec6c02150 100644 --- a/quill-jdbc-zio/src/test/scala/io/getquill/mock/ZioMockSpec.scala +++ b/quill-jdbc-zio/src/test/scala/io/getquill/mock/ZioMockSpec.scala @@ -15,13 +15,13 @@ class ZioMockSpec extends AnyFreeSpec with MockitoSugar { // with AsyncMockitoSu import scala.reflect.runtime.{universe => ru} object MockResultSet { - def apply[T: ClassTag: ru.TypeTag](data: Seq[T]) = { + def apply[T: ClassTag: ru.TypeTag](data: Seq[T]): ResultSet = { val rs = mock[ResultSet] var rowIndex = -1 def introspection = new Introspection(data(rowIndex)) def getIndex(i: Int): Any = introspection.getIndex(i) - def getColumn(name: String): Any = introspection.getField(name) + when(rs.next()) thenAnswer { rowIndex += 1 @@ -125,11 +125,11 @@ class ZioMockSpec extends AnyFreeSpec with MockitoSugar { // with AsyncMockitoSu } "stream is correctly closed when ending conn.setAutoCommit returns error but is caught" in { - val people = List(Person("Joe", 11), Person("Jack", 22)) + List(Person("Joe", 11), Person("Jack", 22)) val ds = mock[MyDataSource] val conn = mock[Connection] - val stmt = mock[PreparedStatement] + mock[PreparedStatement] when(ds.getConnection) thenReturn conn when(conn.getAutoCommit) thenThrow (new SQLException(msg)) @@ -170,7 +170,7 @@ class ZioMockSpec extends AnyFreeSpec with MockitoSugar { // with AsyncMockitoSu when(conn.prepareStatement(any[String], any[Int], any[Int])) thenReturn stmt when(stmt.executeQuery()) thenReturn rs when(conn.getAutoCommit) thenReturn true - when(conn.setAutoCommit(any[Boolean])) thenAnswer ((f: Boolean) => ()) andThenThrow (new SQLException(msg)) + when(conn.setAutoCommit(any[Boolean])) thenAnswer ((_: Boolean) => ()) andThenThrow (new SQLException(msg)) val ctx = new PostgresZioJdbcContext(Literal) import ctx._ diff --git a/quill-jdbc-zio/src/test/scala/io/getquill/mysql/ProductJdbcSpec.scala b/quill-jdbc-zio/src/test/scala/io/getquill/mysql/ProductJdbcSpec.scala index fb48d1184c..5588b09bfb 100644 --- a/quill-jdbc-zio/src/test/scala/io/getquill/mysql/ProductJdbcSpec.scala +++ b/quill-jdbc-zio/src/test/scala/io/getquill/mysql/ProductJdbcSpec.scala @@ -9,7 +9,7 @@ class ProductJdbcSpec extends ProductSpec with ZioSpec { val context = testContext import testContext._ - override def beforeAll = { + override def beforeAll: Unit = { super.beforeAll() testContext.run(quote(query[Product].delete)).runSyncUnsafe() () diff --git a/quill-jdbc-zio/src/test/scala/io/getquill/mysql/ZioJdbcContextSpec.scala b/quill-jdbc-zio/src/test/scala/io/getquill/mysql/ZioJdbcContextSpec.scala index 1b5df29987..23f36b1d34 100644 --- a/quill-jdbc-zio/src/test/scala/io/getquill/mysql/ZioJdbcContextSpec.scala +++ b/quill-jdbc-zio/src/test/scala/io/getquill/mysql/ZioJdbcContextSpec.scala @@ -72,7 +72,7 @@ class ZioJdbcContextSpec extends ZioSpec { testContext .prepareParams( "select * from Person where name=? and age > ?", - (ps, session) => (List("Sarah", 127), ps) + (ps, _) => (List("Sarah", 127), ps) ) .runSyncUnsafe() mustEqual List("127", "'Sarah'") } diff --git a/quill-jdbc-zio/src/test/scala/io/getquill/mysql/mysql.scala b/quill-jdbc-zio/src/test/scala/io/getquill/mysql/mysql.scala index dcb3f5c437..83e35b5c1b 100644 --- a/quill-jdbc-zio/src/test/scala/io/getquill/mysql/mysql.scala +++ b/quill-jdbc-zio/src/test/scala/io/getquill/mysql/mysql.scala @@ -2,8 +2,9 @@ package io.getquill import io.getquill.ZioSpec.runLayerUnsafe import io.getquill.jdbczio.Quill +import javax.sql.DataSource package object mysql { - implicit val pool = runLayerUnsafe(Quill.DataSource.fromPrefix("testMysqlDB")) + implicit val pool: DataSource = runLayerUnsafe(Quill.DataSource.fromPrefix("testMysqlDB")) object testContext extends Quill.Mysql(Literal, pool) with TestEntities } diff --git a/quill-jdbc-zio/src/test/scala/io/getquill/oracle/ProductJdbcSpec.scala b/quill-jdbc-zio/src/test/scala/io/getquill/oracle/ProductJdbcSpec.scala index 3df35ba298..5603d748b2 100644 --- a/quill-jdbc-zio/src/test/scala/io/getquill/oracle/ProductJdbcSpec.scala +++ b/quill-jdbc-zio/src/test/scala/io/getquill/oracle/ProductJdbcSpec.scala @@ -10,7 +10,7 @@ class ProductJdbcSpec extends ProductSpec with ZioSpec { val context = testContext import testContext._ - override def beforeAll = { + override def beforeAll: Unit = { super.beforeAll() testContext.run(quote(query[Product].delete)).runSyncUnsafe() () diff --git a/quill-jdbc-zio/src/test/scala/io/getquill/oracle/oracle.scala b/quill-jdbc-zio/src/test/scala/io/getquill/oracle/oracle.scala index d74abe43dd..de614d6374 100644 --- a/quill-jdbc-zio/src/test/scala/io/getquill/oracle/oracle.scala +++ b/quill-jdbc-zio/src/test/scala/io/getquill/oracle/oracle.scala @@ -2,8 +2,9 @@ package io.getquill import io.getquill.ZioSpec.runLayerUnsafe import io.getquill.jdbczio.Quill +import javax.sql.DataSource package object oracle { - implicit val pool = runLayerUnsafe(Quill.DataSource.fromPrefix("testOracleDB")) + implicit val pool: DataSource = runLayerUnsafe(Quill.DataSource.fromPrefix("testOracleDB")) object testContext extends Quill.Oracle(Literal, pool) with TestEntities } diff --git a/quill-jdbc-zio/src/test/scala/io/getquill/postgres/ConnectionLeakTest.scala b/quill-jdbc-zio/src/test/scala/io/getquill/postgres/ConnectionLeakTest.scala index af00c3932f..06bca83ca7 100644 --- a/quill-jdbc-zio/src/test/scala/io/getquill/postgres/ConnectionLeakTest.scala +++ b/quill-jdbc-zio/src/test/scala/io/getquill/postgres/ConnectionLeakTest.scala @@ -10,16 +10,19 @@ import io.getquill.jdbczio.Quill import zio.{Runtime, Unsafe} import scala.util.Random +import com.zaxxer.hikari.HikariDataSource +import javax.sql.DataSource +import zio.ZLayer class ConnectionLeakTest extends ProductSpec with ZioProxySpec { - implicit val pool = Implicit(Quill.DataSource.fromPrefix("testPostgresDB")) + implicit val pool: Implicit[ZLayer[Any,Throwable,DataSource]] = Implicit(Quill.DataSource.fromPrefix("testPostgresDB")) - val dataSource = JdbcContextConfig(LoadConfig("testPostgresLeakDB")).dataSource + val dataSource: HikariDataSource = JdbcContextConfig(LoadConfig("testPostgresLeakDB")).dataSource val context = new PostgresZioJdbcContext(Literal) import context._ - override def beforeAll = { + override def beforeAll: Unit = { super.beforeAll() context.run(quote(query[Product].delete)).provide(pool.env).runSyncUnsafe() () diff --git a/quill-jdbc-zio/src/test/scala/io/getquill/postgres/MultiLevelServiceSpec.scala b/quill-jdbc-zio/src/test/scala/io/getquill/postgres/MultiLevelServiceSpec.scala index 894784df96..11a52d745a 100644 --- a/quill-jdbc-zio/src/test/scala/io/getquill/postgres/MultiLevelServiceSpec.scala +++ b/quill-jdbc-zio/src/test/scala/io/getquill/postgres/MultiLevelServiceSpec.scala @@ -11,7 +11,7 @@ class MultiLevelServiceSpec extends PeopleZioSpec with ZioSpec { val context = testContext import testContext._ - val entries = List(Person("Joe", 1), Person("Jack", 2)) + val entries: List[Person] = List(Person("Joe", 1), Person("Jack", 2)) override def beforeAll = { super.beforeAll() @@ -25,9 +25,9 @@ class MultiLevelServiceSpec extends PeopleZioSpec with ZioSpec { case class DataService(quill: Quill[PostgresDialect, Literal]) { import quill.{run => qrun, _} - val people = quote(query[Person]) - def somePeopleByName = quote((ps: Query[Person], name: String) => ps.filter(p => p.name == name)) - def peopleByName = quote((name: String) => people.filter(p => p.name == name)) + val people: Quoted[EntityQuery[Person]] = quote(query[Person]) + def somePeopleByName: Quoted[(Query[Person], String) => Query[Person]] = quote((ps: Query[Person], name: String) => ps.filter(p => p.name == name)) + def peopleByName: Quoted[String => EntityQuery[Person]] = quote((name: String) => people.filter(p => p.name == name)) def getAllPeople(): ZIO[Any, SQLException, List[Person]] = qrun(people) def getPeopleByName(name: String): ZIO[Any, SQLException, List[Person]] = qrun(peopleByName(lift(name))) } @@ -35,7 +35,7 @@ class MultiLevelServiceSpec extends PeopleZioSpec with ZioSpec { import dataService._ import dataService.quill.{run => qrun, _} - val joes = quote(peopleByName("Joe")) + val joes: Quoted[EntityQuery[Person]] = quote(peopleByName("Joe")) def getJoes: ZIO[Any, SQLException, List[Person]] = qrun(joes) def getPeopleByName3(name: String): ZIO[Any, SQLException, List[Person]] = qrun( somePeopleByName(query[Person], lift(name)) @@ -44,15 +44,15 @@ class MultiLevelServiceSpec extends PeopleZioSpec with ZioSpec { def getPeopleByName(name: String): ZIO[Any, SQLException, List[Person]] = dataService.getPeopleByName(name) def getAllPeople(): ZIO[Any, SQLException, List[Person]] = dataService.getAllPeople() } - val dataServiceLive = ZLayer.fromFunction(DataService.apply _) - val applicationLive = ZLayer.fromFunction(ApplicationLive.apply _) + val dataServiceLive: ZLayer[Quill[PostgresDialect,Literal],Nothing,DataService] = ZLayer.fromFunction(DataService.apply _) + val applicationLive: ZLayer[DataService,Nothing,ApplicationLive] = ZLayer.fromFunction(ApplicationLive.apply _) object Application { - def getJoes() = ZIO.serviceWithZIO[ApplicationLive](_.getJoes) - def getPeopleByName3(name: String) = ZIO.serviceWithZIO[ApplicationLive](_.getPeopleByName3(name)) - def getPeopleByName2(name: String) = ZIO.serviceWithZIO[ApplicationLive](_.getPeopleByName2(name)) - def getPeopleByName(name: String) = ZIO.serviceWithZIO[ApplicationLive](_.getPeopleByName(name)) - def getAllPeople() = ZIO.serviceWithZIO[ApplicationLive](_.getAllPeople()) + def getJoes(): ZIO[ApplicationLive with ApplicationLive,SQLException,List[Person]] = ZIO.serviceWithZIO[ApplicationLive](_.getJoes) + def getPeopleByName3(name: String): ZIO[ApplicationLive with ApplicationLive,SQLException,List[Person]] = ZIO.serviceWithZIO[ApplicationLive](_.getPeopleByName3(name)) + def getPeopleByName2(name: String): ZIO[ApplicationLive with ApplicationLive,SQLException,List[Person]] = ZIO.serviceWithZIO[ApplicationLive](_.getPeopleByName2(name)) + def getPeopleByName(name: String): ZIO[ApplicationLive with ApplicationLive,SQLException,List[Person]] = ZIO.serviceWithZIO[ApplicationLive](_.getPeopleByName(name)) + def getAllPeople(): ZIO[ApplicationLive with ApplicationLive,SQLException,List[Person]] = ZIO.serviceWithZIO[ApplicationLive](_.getAllPeople()) } "All Composition variations must work" in { diff --git a/quill-jdbc-zio/src/test/scala/io/getquill/postgres/ProductJdbcSpec.scala b/quill-jdbc-zio/src/test/scala/io/getquill/postgres/ProductJdbcSpec.scala index 0634f2eed9..80bb906f92 100644 --- a/quill-jdbc-zio/src/test/scala/io/getquill/postgres/ProductJdbcSpec.scala +++ b/quill-jdbc-zio/src/test/scala/io/getquill/postgres/ProductJdbcSpec.scala @@ -8,7 +8,7 @@ class ProductJdbcSpec extends ProductSpec with ZioSpec { val context = testContext import testContext._ - override def beforeAll = { + override def beforeAll: Unit = { super.beforeAll() testContext.run(quote(query[Product].delete)).runSyncUnsafe() () diff --git a/quill-jdbc-zio/src/test/scala/io/getquill/postgres/QuillServiceSpec.scala b/quill-jdbc-zio/src/test/scala/io/getquill/postgres/QuillServiceSpec.scala index 7180422372..9691bfa15b 100644 --- a/quill-jdbc-zio/src/test/scala/io/getquill/postgres/QuillServiceSpec.scala +++ b/quill-jdbc-zio/src/test/scala/io/getquill/postgres/QuillServiceSpec.scala @@ -72,7 +72,7 @@ class QuillServiceSpec extends ZioSpec { testContext .prepareParams( "select * from Person where name=? and age > ?", - (ps, session) => (List("Sarah", 127), ps) + (ps, _) => (List("Sarah", 127), ps) ) .runSyncUnsafe() mustEqual List("127", "'Sarah'") } diff --git a/quill-jdbc-zio/src/test/scala/io/getquill/postgres/ZioJdbcContextSpec.scala b/quill-jdbc-zio/src/test/scala/io/getquill/postgres/ZioJdbcContextSpec.scala index dfb3a54c93..592b9b998d 100644 --- a/quill-jdbc-zio/src/test/scala/io/getquill/postgres/ZioJdbcContextSpec.scala +++ b/quill-jdbc-zio/src/test/scala/io/getquill/postgres/ZioJdbcContextSpec.scala @@ -72,7 +72,7 @@ class ZioJdbcContextSpec extends ZioSpec { testContext .prepareParams( "select * from Person where name=? and age > ?", - (ps, session) => (List("Sarah", 127), ps) + (ps, _) => (List("Sarah", 127), ps) ) .runSyncUnsafe() mustEqual List("127", "'Sarah'") } diff --git a/quill-jdbc-zio/src/test/scala/io/getquill/postgres/package.scala b/quill-jdbc-zio/src/test/scala/io/getquill/postgres/package.scala index f48a782da6..714a95ff0f 100644 --- a/quill-jdbc-zio/src/test/scala/io/getquill/postgres/package.scala +++ b/quill-jdbc-zio/src/test/scala/io/getquill/postgres/package.scala @@ -2,8 +2,9 @@ package io.getquill import io.getquill.ZioSpec.runLayerUnsafe import io.getquill.jdbczio.Quill +import javax.sql.DataSource package object postgres { - val pool = runLayerUnsafe(Quill.DataSource.fromPrefix("testPostgresDB")) + val pool: DataSource = runLayerUnsafe(Quill.DataSource.fromPrefix("testPostgresDB")) object testContext extends Quill.Postgres(Literal, pool) with TestEntities } diff --git a/quill-jdbc-zio/src/test/scala/io/getquill/sqlite/PrepareJdbcSpec.scala b/quill-jdbc-zio/src/test/scala/io/getquill/sqlite/PrepareJdbcSpec.scala index 21f5eee21a..6466d5a1c2 100644 --- a/quill-jdbc-zio/src/test/scala/io/getquill/sqlite/PrepareJdbcSpec.scala +++ b/quill-jdbc-zio/src/test/scala/io/getquill/sqlite/PrepareJdbcSpec.scala @@ -4,19 +4,22 @@ import java.sql.{Connection, ResultSet} import io.getquill.PrepareZioJdbcSpecBase import io.getquill.context.qzio.ImplicitSyntax.Implicit import org.scalatest.BeforeAndAfter +import io.getquill.context.ZioJdbc +import java.sql.PreparedStatement +import javax.sql.DataSource class PrepareJdbcSpec extends PrepareZioJdbcSpecBase with BeforeAndAfter { val context = testContext.underlying import context._ - implicit val implicitPool = Implicit(pool) + implicit val implicitPool: Implicit[DataSource] = Implicit(pool) before { testContext.run(query[Product].delete).runSyncUnsafe() } - def productExtractor = (rs: ResultSet, conn: Connection) => materializeQueryMeta[Product].extract(rs, conn) - val prepareQuery = prepare(query[Product]) + def productExtractor: (ResultSet, Connection) => Product = (rs: ResultSet, conn: Connection) => materializeQueryMeta[Product].extract(rs, conn) + val prepareQuery: ZioJdbc.QCIO[PreparedStatement] = prepare(query[Product]) "single" in { val prepareInsert = prepare(query[Product].insertValue(lift(productEntries.head))) diff --git a/quill-jdbc-zio/src/test/scala/io/getquill/sqlite/ProductJdbcSpec.scala b/quill-jdbc-zio/src/test/scala/io/getquill/sqlite/ProductJdbcSpec.scala index 790d87770b..24005b1f45 100644 --- a/quill-jdbc-zio/src/test/scala/io/getquill/sqlite/ProductJdbcSpec.scala +++ b/quill-jdbc-zio/src/test/scala/io/getquill/sqlite/ProductJdbcSpec.scala @@ -10,7 +10,7 @@ class ProductJdbcSpec extends ProductSpec with ZioSpec { val context = testContext import testContext._ - override def beforeAll = { + override def beforeAll: Unit = { super.beforeAll() testContext.run(quote(query[Product].delete)).runSyncUnsafe() () diff --git a/quill-jdbc-zio/src/test/scala/io/getquill/sqlite/ZioJdbcContextSpec.scala b/quill-jdbc-zio/src/test/scala/io/getquill/sqlite/ZioJdbcContextSpec.scala index 6698bf07b0..c4fc7d52a5 100644 --- a/quill-jdbc-zio/src/test/scala/io/getquill/sqlite/ZioJdbcContextSpec.scala +++ b/quill-jdbc-zio/src/test/scala/io/getquill/sqlite/ZioJdbcContextSpec.scala @@ -72,7 +72,7 @@ class ZioJdbcContextSpec extends ZioSpec { testContext .prepareParams( "select * from Person where name=? and age > ?", - (ps, session) => (List("Sarah", 127), ps) + (ps, _) => (List("Sarah", 127), ps) ) .runSyncUnsafe() mustEqual List("127", "'Sarah'") } diff --git a/quill-jdbc-zio/src/test/scala/io/getquill/sqlite/sqlite.scala b/quill-jdbc-zio/src/test/scala/io/getquill/sqlite/sqlite.scala index 6e16a54eb7..d3d56f7f09 100644 --- a/quill-jdbc-zio/src/test/scala/io/getquill/sqlite/sqlite.scala +++ b/quill-jdbc-zio/src/test/scala/io/getquill/sqlite/sqlite.scala @@ -2,8 +2,9 @@ package io.getquill import io.getquill.ZioSpec.runLayerUnsafe import io.getquill.jdbczio.Quill +import javax.sql.DataSource package object sqlite { - val pool = runLayerUnsafe(Quill.DataSource.fromPrefix("testSqliteDB")) + val pool: DataSource = runLayerUnsafe(Quill.DataSource.fromPrefix("testSqliteDB")) object testContext extends Quill.Sqlite(Literal, pool) with TestEntities } diff --git a/quill-jdbc-zio/src/test/scala/io/getquill/sqlserver/ProductJdbcSpec.scala b/quill-jdbc-zio/src/test/scala/io/getquill/sqlserver/ProductJdbcSpec.scala index 09ec22b264..4d84694c19 100644 --- a/quill-jdbc-zio/src/test/scala/io/getquill/sqlserver/ProductJdbcSpec.scala +++ b/quill-jdbc-zio/src/test/scala/io/getquill/sqlserver/ProductJdbcSpec.scala @@ -10,7 +10,7 @@ class ProductJdbcSpec extends ProductSpec with ZioSpec { val context = testContext import testContext._ - override def beforeAll = { + override def beforeAll: Unit = { super.beforeAll() testContext.run(quote(query[Product].delete)).runSyncUnsafe() () diff --git a/quill-jdbc-zio/src/test/scala/io/getquill/sqlserver/ZioJdbcContextSpec.scala b/quill-jdbc-zio/src/test/scala/io/getquill/sqlserver/ZioJdbcContextSpec.scala index da11076b33..05d7bfb863 100644 --- a/quill-jdbc-zio/src/test/scala/io/getquill/sqlserver/ZioJdbcContextSpec.scala +++ b/quill-jdbc-zio/src/test/scala/io/getquill/sqlserver/ZioJdbcContextSpec.scala @@ -72,7 +72,7 @@ class ZioJdbcContextSpec extends ZioSpec { testContext .prepareParams( "select * from Person where name=? and age > ?", - (ps, session) => (List("Sarah", 127), ps) + (ps, _) => (List("Sarah", 127), ps) ) .runSyncUnsafe() mustEqual List("127", "'Sarah'") } diff --git a/quill-jdbc-zio/src/test/scala/io/getquill/sqlserver/sqlserver.scala b/quill-jdbc-zio/src/test/scala/io/getquill/sqlserver/sqlserver.scala index 2ab2f907ac..92dba4961c 100644 --- a/quill-jdbc-zio/src/test/scala/io/getquill/sqlserver/sqlserver.scala +++ b/quill-jdbc-zio/src/test/scala/io/getquill/sqlserver/sqlserver.scala @@ -2,8 +2,9 @@ package io.getquill import io.getquill.ZioSpec.runLayerUnsafe import io.getquill.jdbczio.Quill +import javax.sql.DataSource package object sqlserver { - val pool = runLayerUnsafe(Quill.DataSource.fromPrefix("testSqlServerDB")) + val pool: DataSource = runLayerUnsafe(Quill.DataSource.fromPrefix("testSqlServerDB")) object testContext extends Quill.SqlServer(Literal, pool) with TestEntities } diff --git a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/PrepareJdbcSpecBase.scala b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/PrepareJdbcSpecBase.scala index 60d134a285..01e7f2715e 100644 --- a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/PrepareJdbcSpecBase.scala +++ b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/PrepareJdbcSpecBase.scala @@ -5,10 +5,11 @@ import io.getquill.context.sql.ProductSpec import io.getquill.util.Using.Manager import org.scalactic.Equality import scala.util.{Success, Failure} +import scala.util.Try trait PrepareJdbcSpecBase extends ProductSpec { - implicit val productEq = new Equality[Product] { + implicit val productEq: Equality[Product] = new Equality[Product] { override def areEqual(a: Product, b: Any): Boolean = b match { case Product(_, desc, sku) => desc == a.description && sku == a.sku case _ => false @@ -17,10 +18,10 @@ trait PrepareJdbcSpecBase extends ProductSpec { def productExtractor: (ResultSet, Connection) => Product - def withOrderedIds(products: List[Product]) = + def withOrderedIds(products: List[Product]): List[Product] = products.zipWithIndex.map { case (product, id) => product.copy(id = id.toLong + 1) } - def singleInsert(conn: => Connection)(prep: Connection => PreparedStatement) = { + def singleInsert(conn: => Connection)(prep: Connection => PreparedStatement): Boolean = { val flag = Manager { use => val c = use(conn) val s = use(prep(c)) @@ -32,7 +33,7 @@ trait PrepareJdbcSpecBase extends ProductSpec { } } - def batchInsert(conn: => Connection)(prep: Connection => List[PreparedStatement]) = { + def batchInsert(conn: => Connection)(prep: Connection => List[PreparedStatement]): List[Boolean] = { val r = Manager { use => val c = use(conn) val st = prep(c) @@ -46,7 +47,7 @@ trait PrepareJdbcSpecBase extends ProductSpec { def extractResults[T]( conn: => Connection - )(prep: Connection => PreparedStatement)(extractor: (ResultSet, Connection) => T) = { + )(prep: Connection => PreparedStatement)(extractor: (ResultSet, Connection) => T): List[T] = { val r = Manager { use => val c = use(conn) val st = use(prep(c)) @@ -62,7 +63,7 @@ trait PrepareJdbcSpecBase extends ProductSpec { def extractProducts(conn: => Connection)(prep: Connection => PreparedStatement): List[Product] = extractResults(conn)(prep)(productExtractor) - def appendExecuteSequence(actions: => List[PreparedStatement]) = + def appendExecuteSequence(actions: => List[PreparedStatement]): Try[List[Boolean]] = Manager { use => actions.map { stmt => val s = use(stmt) diff --git a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/h2/CaseClassQueryJdbcSpec.scala b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/h2/CaseClassQueryJdbcSpec.scala index 21dbaa30c2..31c7a737d0 100644 --- a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/h2/CaseClassQueryJdbcSpec.scala +++ b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/h2/CaseClassQueryJdbcSpec.scala @@ -8,7 +8,7 @@ class CaseClassQueryJdbcSpec extends CaseClassQuerySpec { val context = testContext import testContext._ - override def beforeAll = { + override def beforeAll: Unit = { testContext.transaction { testContext.run(query[Contact].delete) testContext.run(query[Address].delete) diff --git a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/h2/DepartmentsJdbcSpec.scala b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/h2/DepartmentsJdbcSpec.scala index a7c02ac1b4..ea8052165c 100644 --- a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/h2/DepartmentsJdbcSpec.scala +++ b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/h2/DepartmentsJdbcSpec.scala @@ -7,7 +7,7 @@ class DepartmentsJdbcSpec extends DepartmentsSpec { val context = testContext import testContext._ - override def beforeAll = { + override def beforeAll: Unit = { testContext.transaction { testContext.run(query[Department].delete) testContext.run(query[Employee].delete) diff --git a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/h2/DistinctJdbcSpec.scala b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/h2/DistinctJdbcSpec.scala index 694ccfc744..4fa966247a 100644 --- a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/h2/DistinctJdbcSpec.scala +++ b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/h2/DistinctJdbcSpec.scala @@ -8,7 +8,7 @@ class DistinctJdbcSpec extends DistinctSpec { val context = testContext import testContext._ - override def beforeAll = { + override def beforeAll: Unit = { testContext.transaction { testContext.run(query[Couple].delete) testContext.run(query[Person].delete) diff --git a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/h2/JdbcContextSpec.scala b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/h2/JdbcContextSpec.scala index 1f73e9738e..53844b5dd7 100644 --- a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/h2/JdbcContextSpec.scala +++ b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/h2/JdbcContextSpec.scala @@ -40,7 +40,7 @@ class JdbcContextSpec extends Spec { "prepare" in { testContext.prepareParams( "select * from Person where name=? and age > ?", - (ps, session) => (List("Sarah", 127), ps) + (ps, _) => (List("Sarah", 127), ps) ) mustEqual List("127", "'Sarah'") } } diff --git a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/h2/OptionJdbcSpec.scala b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/h2/OptionJdbcSpec.scala index 99dcae49f6..813e148bbb 100644 --- a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/h2/OptionJdbcSpec.scala +++ b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/h2/OptionJdbcSpec.scala @@ -8,7 +8,7 @@ class OptionJdbcSpec extends OptionQuerySpec { val context = testContext import testContext._ - override def beforeAll = { + override def beforeAll: Unit = { testContext.transaction { testContext.run(query[Contact].delete) testContext.run(query[Address].delete) diff --git a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/h2/PeopleJdbcSpec.scala b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/h2/PeopleJdbcSpec.scala index f59c2b55ef..ae7f1bd7d0 100644 --- a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/h2/PeopleJdbcSpec.scala +++ b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/h2/PeopleJdbcSpec.scala @@ -7,7 +7,7 @@ class PeopleJdbcSpec extends PeopleSpec { val context = testContext import testContext._ - override def beforeAll = { + override def beforeAll: Unit = { testContext.transaction { testContext.run(query[Couple].delete) testContext.run(query[Person].delete) diff --git a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/h2/ProductJdbcSpec.scala b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/h2/ProductJdbcSpec.scala index 2a9cc4a668..d1a8b9291c 100644 --- a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/h2/ProductJdbcSpec.scala +++ b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/h2/ProductJdbcSpec.scala @@ -7,7 +7,7 @@ class ProductJdbcSpec extends ProductSpec { val context = testContext import testContext._ - override def beforeAll = { + override def beforeAll: Unit = { testContext.run(quote(query[Product].delete)) () } @@ -65,7 +65,7 @@ class ProductJdbcSpec extends ProductSpec { "supports casts from string to number" - { "toInt" in { - case class Product(id: Long, description: String, sku: Int) + final case class Product(id: Long, description: String, sku: Int) val queried = testContext.run { query[Product].filter(_.sku == lift("1004").toInt) }.head diff --git a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/mysql/CaseClassQueryJdbcSpec.scala b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/mysql/CaseClassQueryJdbcSpec.scala index 6cfd66e1b5..13bfd78aa0 100644 --- a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/mysql/CaseClassQueryJdbcSpec.scala +++ b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/mysql/CaseClassQueryJdbcSpec.scala @@ -8,7 +8,7 @@ class CaseClassQueryJdbcSpec extends CaseClassQuerySpec { val context = testContext import testContext._ - override def beforeAll = { + override def beforeAll: Unit = { testContext.transaction { testContext.run(query[Contact].delete) testContext.run(query[Address].delete) diff --git a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/mysql/DepartmentsJdbcSpec.scala b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/mysql/DepartmentsJdbcSpec.scala index 4091205edf..7fb7a60e40 100644 --- a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/mysql/DepartmentsJdbcSpec.scala +++ b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/mysql/DepartmentsJdbcSpec.scala @@ -7,7 +7,7 @@ class DepartmentsJdbcSpec extends DepartmentsSpec { val context = testContext import testContext._ - override def beforeAll = { + override def beforeAll: Unit = { testContext.transaction { testContext.run(query[Department].delete) testContext.run(query[Employee].delete) diff --git a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/mysql/DistinctJdbcSpec.scala b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/mysql/DistinctJdbcSpec.scala index 1ff68e39e8..1e58767742 100644 --- a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/mysql/DistinctJdbcSpec.scala +++ b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/mysql/DistinctJdbcSpec.scala @@ -8,7 +8,7 @@ class DistinctJdbcSpec extends DistinctSpec { val context = testContext import testContext._ - override def beforeAll = { + override def beforeAll: Unit = { testContext.transaction { testContext.run(query[Couple].delete) testContext.run(query[Person].delete) diff --git a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/mysql/JdbcContextSpec.scala b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/mysql/JdbcContextSpec.scala index 9949d8a539..5c825a8da0 100644 --- a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/mysql/JdbcContextSpec.scala +++ b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/mysql/JdbcContextSpec.scala @@ -8,7 +8,7 @@ class JdbcContextSpec extends Spec { import testContext._ "probes sqls" in { - val p = testContext.probe("DELETE FROM TestEntity") + testContext.probe("DELETE FROM TestEntity") } "run non-batched action" in { @@ -48,7 +48,7 @@ class JdbcContextSpec extends Spec { "prepare" in { testContext.prepareParams( "select * from Person where name=? and age > ?", - (ps, session) => (List("Sarah", 127), ps) + (ps, _) => (List("Sarah", 127), ps) ) mustEqual List("127", "'Sarah'") } } diff --git a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/mysql/OptionJdbcSpec.scala b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/mysql/OptionJdbcSpec.scala index b6c88ba7d6..8ae1d3b5b2 100644 --- a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/mysql/OptionJdbcSpec.scala +++ b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/mysql/OptionJdbcSpec.scala @@ -8,7 +8,7 @@ class OptionJdbcSpec extends OptionQuerySpec { val context = testContext import testContext._ - override def beforeAll = { + override def beforeAll: Unit = { testContext.transaction { testContext.run(query[Contact].delete) testContext.run(query[Address].delete) diff --git a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/mysql/PeopleJdbcSpec.scala b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/mysql/PeopleJdbcSpec.scala index 98a39e507f..2105eaec15 100644 --- a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/mysql/PeopleJdbcSpec.scala +++ b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/mysql/PeopleJdbcSpec.scala @@ -7,7 +7,7 @@ class PeopleJdbcSpec extends PeopleSpec { val context = testContext import testContext._ - override def beforeAll = { + override def beforeAll: Unit = { testContext.transaction { testContext.run(query[Couple].delete) testContext.run(query[Person].delete) diff --git a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/mysql/ProductJdbcSpec.scala b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/mysql/ProductJdbcSpec.scala index b6edb6a0b7..e279dd7030 100644 --- a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/mysql/ProductJdbcSpec.scala +++ b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/mysql/ProductJdbcSpec.scala @@ -7,7 +7,7 @@ class ProductJdbcSpec extends ProductSpec { val context = testContext import testContext._ - override def beforeAll = { + override def beforeAll: Unit = { testContext.run(quote(query[Product].delete)) () } @@ -59,7 +59,7 @@ class ProductJdbcSpec extends ProductSpec { "supports casts from string to number" - { "toInt" in { - case class Product(id: Long, description: String, sku: Int) + final case class Product(id: Long, description: String, sku: Int) val queried = testContext.run { query[Product].filter(_.sku == lift("1004").toInt) }.head diff --git a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/mysql/QueryResultTypeJdbcSpec.scala b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/mysql/QueryResultTypeJdbcSpec.scala index cdeec8dfc0..378aa6ea3e 100644 --- a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/mysql/QueryResultTypeJdbcSpec.scala +++ b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/mysql/QueryResultTypeJdbcSpec.scala @@ -13,7 +13,7 @@ class QueryResultTypeJdbcSpec extends QueryResultTypeSpec { val insertedProducts = new ConcurrentLinkedQueue[Product] - override def beforeAll = { + override def beforeAll: Unit = { context.run(deleteAll) val ids = context.run(liftQuery(productEntries).foreach(p => productInsert(p))) val inserted = (ids zip productEntries).map { case (id, prod) => diff --git a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/oracle/CaseClassQueryJdbcSpec.scala b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/oracle/CaseClassQueryJdbcSpec.scala index 1072282c54..9532e35e65 100644 --- a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/oracle/CaseClassQueryJdbcSpec.scala +++ b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/oracle/CaseClassQueryJdbcSpec.scala @@ -9,7 +9,7 @@ class CaseClassQueryJdbcSpec extends CaseClassQuerySpec { val context = testContext import testContext._ - override def beforeAll = { + override def beforeAll: Unit = { testContext.transaction { testContext.run(sql"alter session set current_schema=quill_test".as[Update[Unit]]) testContext.run(query[Contact].delete) diff --git a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/oracle/DepartmentsJdbcSpec.scala b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/oracle/DepartmentsJdbcSpec.scala index 668a4c538c..68ca7cbde3 100644 --- a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/oracle/DepartmentsJdbcSpec.scala +++ b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/oracle/DepartmentsJdbcSpec.scala @@ -9,7 +9,7 @@ class DepartmentsJdbcSpec extends DepartmentsSpec { val context = testContext import testContext._ - override def beforeAll = { + override def beforeAll: Unit = { testContext.transaction { testContext.run(sql"alter session set current_schema=quill_test".as[Update[Unit]]) testContext.run(query[Department].delete) diff --git a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/oracle/DistinctJdbcSpec.scala b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/oracle/DistinctJdbcSpec.scala index 6b7dd4fa7d..71fb9bb622 100644 --- a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/oracle/DistinctJdbcSpec.scala +++ b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/oracle/DistinctJdbcSpec.scala @@ -8,7 +8,7 @@ class DistinctJdbcSpec extends DistinctSpec { val context = testContext import testContext._ - override def beforeAll = { + override def beforeAll: Unit = { testContext.transaction { testContext.run(query[Couple].delete) testContext.run(query[Person].delete) diff --git a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/oracle/JdbcContextSpec.scala b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/oracle/JdbcContextSpec.scala index 0b123289dd..ba56e039a0 100644 --- a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/oracle/JdbcContextSpec.scala +++ b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/oracle/JdbcContextSpec.scala @@ -11,7 +11,7 @@ class JdbcContextSpec extends Spec { } "probes sqls" in { - val p = testContext.probe("DELETE FROM TestEntity") + testContext.probe("DELETE FROM TestEntity") } "run non-batched action" in { @@ -73,7 +73,7 @@ class JdbcContextSpec extends Spec { } "with multiple columns - case class" in { - case class Return(id: Int, str: String, opt: Option[Int]) + final case class Return(id: Int, str: String, opt: Option[Int]) testContext.run(qr1.delete) val inserted = testContext.run { qr1.insertValue(lift(TestEntity("foo", 1, 18L, Some(123), true))).returning(r => Return(r.i, r.s, r.o)) @@ -106,7 +106,7 @@ class JdbcContextSpec extends Spec { } "with multiple columns - case class" in { - case class Return(id: Int, str: String, opt: Option[Int]) + final case class Return(id: Int, str: String, opt: Option[Int]) testContext.run(qr1.delete) testContext.run(qr1.insertValue(lift(TestEntity("baz", 6, 42L, Some(456), true)))) diff --git a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/oracle/JdbcEncodingSpec.scala b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/oracle/JdbcEncodingSpec.scala index f4b643c618..dfb15279e2 100644 --- a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/oracle/JdbcEncodingSpec.scala +++ b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/oracle/JdbcEncodingSpec.scala @@ -34,15 +34,15 @@ class JdbcEncodingSpec extends EncodingSpec { timeEntity mustEqual actual } - def emptyAsNull(e: EncodingTestType) = e.copy(value = if (e.value == "") null else e.value) - def emptyAsNull(str: String) = if (str == "") null else str - def emptyAsNull(bytes: Array[Byte]) = if (bytes == null || bytes.isEmpty) null else bytes + def emptyAsNull(e: EncodingTestType): EncodingTestType = e.copy(value = if (e.value == "") null else e.value) + def emptyAsNull(str: String): String = if (str == "") null else str + def emptyAsNull(bytes: Array[Byte]): Array[Byte] = if (bytes == null || bytes.isEmpty) null else bytes /** * Since oracle encodes "" as null, need to modify verification in order to * track this */ - override def verify(result: List[EncodingTestEntity]) = { + override def verify(result: List[EncodingTestEntity]): Unit = { result.size mustEqual insertValues.size result.zip(insertValues).foreach { case (e1, e2) => emptyAsNull(e2.v1) mustEqual emptyAsNull(e2.v1) diff --git a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/oracle/OptionJdbcSpec.scala b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/oracle/OptionJdbcSpec.scala index b252e1f234..229c544c2c 100644 --- a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/oracle/OptionJdbcSpec.scala +++ b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/oracle/OptionJdbcSpec.scala @@ -8,7 +8,7 @@ class OptionJdbcSpec extends OptionQuerySpec { val context = testContext import testContext._ - override def beforeAll = { + override def beforeAll: Unit = { testContext.transaction { testContext.run(query[Contact].delete) testContext.run(query[Address].delete) diff --git a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/oracle/PeopleJdbcSpec.scala b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/oracle/PeopleJdbcSpec.scala index 5384ca4585..9300f3bd85 100644 --- a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/oracle/PeopleJdbcSpec.scala +++ b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/oracle/PeopleJdbcSpec.scala @@ -8,7 +8,7 @@ class PeopleJdbcSpec extends PeopleSpec { val context = testContext import testContext._ - override def beforeAll = { + override def beforeAll: Unit = { testContext.transaction { testContext.run(sql"alter session set current_schema=quill_test".as[Update[Unit]]) testContext.run(query[Couple].delete) diff --git a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/oracle/ProductJdbcSpec.scala b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/oracle/ProductJdbcSpec.scala index 4d7c5ea69c..e68946117b 100644 --- a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/oracle/ProductJdbcSpec.scala +++ b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/oracle/ProductJdbcSpec.scala @@ -7,7 +7,7 @@ class ProductJdbcSpec extends ProductSpec { val context = testContext import testContext._ - override def beforeAll = { + override def beforeAll: Unit = { testContext.run(quote(query[Product].delete)) () } @@ -59,7 +59,7 @@ class ProductJdbcSpec extends ProductSpec { "supports casts from string to number" - { "toInt" in { - case class Product(id: Long, description: String, sku: Int) + final case class Product(id: Long, description: String, sku: Int) val queried = testContext.run { query[Product].filter(_.sku == lift("1004").toInt) }.head diff --git a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/oracle/QueryResultTypeJdbcSpec.scala b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/oracle/QueryResultTypeJdbcSpec.scala index 7e8b5c41d2..c94c76b825 100644 --- a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/oracle/QueryResultTypeJdbcSpec.scala +++ b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/oracle/QueryResultTypeJdbcSpec.scala @@ -3,7 +3,7 @@ package io.getquill.context.jdbc.oracle import io.getquill.context.sql.base.QueryResultTypeSpec import java.util.concurrent.ConcurrentLinkedQueue -import io.getquill.context.sql.{testContext => _, _} +import io.getquill.context.sql.{testContext => _} import scala.jdk.CollectionConverters._ @@ -16,7 +16,7 @@ class QueryResultTypeJdbcSpec extends QueryResultTypeSpec { val insertedProducts = new ConcurrentLinkedQueue[Product] - override def beforeAll = { + override def beforeAll: Unit = { context.run(deleteAll) val ids = context.run(liftQuery(productEntries).foreach(p => productInsert(p))) val inserted = (ids zip productEntries).map { case (id, prod) => diff --git a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/postgres/ArrayJdbcEncodingSpec.scala b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/postgres/ArrayJdbcEncodingSpec.scala index 5e324dea4c..e1687ae209 100644 --- a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/postgres/ArrayJdbcEncodingSpec.scala +++ b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/postgres/ArrayJdbcEncodingSpec.scala @@ -12,7 +12,7 @@ class ArrayJdbcEncodingSpec extends ArrayEncodingBaseSpec { import ctx._ val q = quote(query[ArraysTestEntity]) - val corrected = e.copy(timestamps = e.timestamps.map(d => new Timestamp(d.getTime))) + val corrected: ArraysTestEntity = e.copy(timestamps = e.timestamps.map(d => new Timestamp(d.getTime))) "Support all sql base types and `Seq` implementers" in { ctx.run(q.insertValue(lift(corrected))) @@ -28,7 +28,7 @@ class ArrayJdbcEncodingSpec extends ArrayEncodingBaseSpec { } "Timestamps" in { - case class Timestamps(timestamps: List[Timestamp]) + final case class Timestamps(timestamps: List[Timestamp]) val tE = Timestamps(List(new Timestamp(System.currentTimeMillis()))) val tQ = quote(querySchema[Timestamps]("ArraysTestEntity")) ctx.run(tQ.insertValue(lift(tE))) @@ -52,13 +52,12 @@ class ArrayJdbcEncodingSpec extends ArrayEncodingBaseSpec { } "Custom decoders/encoders" in { - case class Entity(uuids: List[UUID]) + final case class Entity(uuids: List[UUID]) val e = Entity(List(UUID.randomUUID(), UUID.randomUUID())) val q = quote(querySchema[Entity]("ArraysTestEntity")) - implicit def arrayUUIDEncoder[Col <: Seq[UUID]]: Encoder[Col] = arrayRawEncoder[UUID, Col]("uuid") - implicit def arrayUUIDDecoder[Col <: Seq[UUID]](implicit bf: CBF[UUID, Col]): Decoder[Col] = - arrayRawDecoder[UUID, Col] + + ctx.run(q.insertValue(lift(e))) ctx.run(q).head.uuids mustBe e.uuids @@ -69,15 +68,15 @@ class ArrayJdbcEncodingSpec extends ArrayEncodingBaseSpec { val actual1 = ctx.run(q.filter(_.texts == lift(List("test")))) val actual2 = ctx.run(q.filter(_.texts == lift(List("test2")))) actual1 mustEqual List(corrected) - actual2 mustEqual List() + actual2 mustEqual List.empty } "empty array on found null" in { - case class ArraysTestEntity(texts: Option[List[String]]) + final case class ArraysTestEntity(texts: Option[List[String]]) ctx.run(query[ArraysTestEntity].insertValue(lift(ArraysTestEntity(None)))) - case class E(texts: List[String]) - ctx.run(querySchema[E]("ArraysTestEntity")).headOption.map(_.texts) mustBe Some(Nil) + final case class E(texts: List[String]) + ctx.run(querySchema[E]("ArraysTestEntity")).headOption.map(_.texts) mustBe Some(List.empty) } override protected def beforeEach(): Unit = { diff --git a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/postgres/BatchUpdateJdbcSpec.scala b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/postgres/BatchUpdateJdbcSpec.scala index b7dab4c3b3..874ffc9591 100644 --- a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/postgres/BatchUpdateJdbcSpec.scala +++ b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/postgres/BatchUpdateJdbcSpec.scala @@ -1,8 +1,6 @@ package io.getquill.context.jdbc.postgres import io.getquill.context.sql.base.BatchUpdateValuesSpec -import io.getquill.norm.EnableTrace -import io.getquill.util.Messages.TraceType class BatchUpdateValuesJdbcSpec extends BatchUpdateValuesSpec { // diff --git a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/postgres/CaseClassQueryJdbcSpec.scala b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/postgres/CaseClassQueryJdbcSpec.scala index 1374eca6f6..a8fa09ab34 100644 --- a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/postgres/CaseClassQueryJdbcSpec.scala +++ b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/postgres/CaseClassQueryJdbcSpec.scala @@ -8,7 +8,7 @@ class CaseClassQueryJdbcSpec extends CaseClassQuerySpec { val context = testContext import testContext._ - override def beforeAll = { + override def beforeAll: Unit = { testContext.transaction { testContext.run(query[Contact].delete) testContext.run(query[Address].delete) diff --git a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/postgres/DepartmentsJdbcSpec.scala b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/postgres/DepartmentsJdbcSpec.scala index ad13f845cd..c5a07bb009 100644 --- a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/postgres/DepartmentsJdbcSpec.scala +++ b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/postgres/DepartmentsJdbcSpec.scala @@ -7,7 +7,7 @@ class DepartmentsJdbcSpec extends DepartmentsSpec { val context = testContext import testContext._ - override def beforeAll = { + override def beforeAll: Unit = { testContext.transaction { testContext.run(query[Department].delete) testContext.run(query[Employee].delete) diff --git a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/postgres/DistinctJdbcSpec.scala b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/postgres/DistinctJdbcSpec.scala index 30917a1861..c7353740ed 100644 --- a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/postgres/DistinctJdbcSpec.scala +++ b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/postgres/DistinctJdbcSpec.scala @@ -1,6 +1,5 @@ package io.getquill.context.jdbc.postgres -import io.getquill.Ord import io.getquill.context.sql.DistinctSpec import org.scalatest.matchers.should.Matchers._ @@ -9,7 +8,7 @@ class DistinctJdbcSpec extends DistinctSpec { val context = testContext import testContext._ - override def beforeAll = { + override def beforeAll: Unit = { testContext.transaction { testContext.run(query[Couple].delete) testContext.run(query[Person].delete) diff --git a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/postgres/JdbcContextSpec.scala b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/postgres/JdbcContextSpec.scala index 0a40aa778b..ec4884c311 100644 --- a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/postgres/JdbcContextSpec.scala +++ b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/postgres/JdbcContextSpec.scala @@ -8,7 +8,7 @@ class JdbcContextSpec extends Spec { import ctx._ "probes sqls" in { - val p = ctx.probe("DELETE FROM TestEntity") + ctx.probe("DELETE FROM TestEntity") } "run non-batched action" in { @@ -48,7 +48,7 @@ class JdbcContextSpec extends Spec { "prepare" in { ctx.prepareParams( "select * from Person where name=? and age > ?", - (ps, session) => (List("Sarah", 127), ps) + (ps, _) => (List("Sarah", 127), ps) ) mustEqual List("127", "'Sarah'") } } @@ -73,7 +73,7 @@ class JdbcContextSpec extends Spec { ctx.run(qr5.delete) val id = ctx.run(qr5.insertValue(lift(TestEntity5(0, "foo"))).returningGenerated(_.i)) val id2 = ctx.run { - qr5.insert(_.s -> "bar").returningGenerated(r => query[TestEntity5].filter(_.s == "foo").map(_.i).max) + qr5.insert(_.s -> "bar").returningGenerated(_ => query[TestEntity5].filter(_.s == "foo").map(_.i).max) }.get id mustBe id2 } @@ -145,7 +145,7 @@ class JdbcContextSpec extends Spec { } "with multiple columns - case class" in { - case class Return(id: Int, str: String, opt: Option[Int]) + final case class Return(id: Int, str: String, opt: Option[Int]) ctx.run(qr1.delete) val inserted = ctx.run { qr1.insertValue(lift(TestEntity("foo", 1, 18L, Some(123), true))).returning(r => Return(r.i, r.s, r.o)) @@ -231,7 +231,7 @@ class JdbcContextSpec extends Spec { } "with multiple columns - case class" in { - case class Return(id: Int, str: String, opt: Option[Int]) + final case class Return(id: Int, str: String, opt: Option[Int]) ctx.run(qr1.delete) ctx.run(qr1.insertValue(lift(TestEntity("one", 1, 18L, Some(1), true)))) @@ -311,7 +311,7 @@ class JdbcContextSpec extends Spec { } "with multiple columns - case class" in { - case class Return(id: Int, str: String, opt: Option[Int]) + final case class Return(id: Int, str: String, opt: Option[Int]) ctx.run(qr1.delete) ctx.run(qr1.insertValue(lift(TestEntity("one", 1, 18L, Some(123), true)))) diff --git a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/postgres/JdbcEncodingSpec.scala b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/postgres/JdbcEncodingSpec.scala index 603bcf25ad..0291d91ee1 100644 --- a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/postgres/JdbcEncodingSpec.scala +++ b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/postgres/JdbcEncodingSpec.scala @@ -32,7 +32,7 @@ class JdbcEncodingSpec extends EncodingSpec { } "LocalDateTime" in { - case class EncodingTestEntity(v11: Option[LocalDateTime]) + final case class EncodingTestEntity(v11: Option[LocalDateTime]) val now = LocalDateTime.now() val e1 = EncodingTestEntity(Some(now)) val e2 = EncodingTestEntity(None) diff --git a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/postgres/OnConflictJdbcSpec.scala b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/postgres/OnConflictJdbcSpec.scala index 6c1f065c2a..b1c49d862e 100644 --- a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/postgres/OnConflictJdbcSpec.scala +++ b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/postgres/OnConflictJdbcSpec.scala @@ -34,7 +34,7 @@ class OnConflictJdbcSpec extends OnConflictSpec { } "ON CONFLICT (i) DO UPDATE with schemaMeta ..." in { - case class TestEntityRename(s2: String, i2: Int, l2: Long, o2: Option[Int]) + final case class TestEntityRename(s2: String, i2: Int, l2: Long, o2: Option[Int]) def testQuery(e: TestEntityRename) = quote { querySchema[TestEntityRename]( diff --git a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/postgres/OptionJdbcSpec.scala b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/postgres/OptionJdbcSpec.scala index f6a57f696e..a70579596b 100644 --- a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/postgres/OptionJdbcSpec.scala +++ b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/postgres/OptionJdbcSpec.scala @@ -8,7 +8,7 @@ class OptionJdbcSpec extends OptionQuerySpec { val context = testContext import testContext._ - override def beforeAll = { + override def beforeAll: Unit = { testContext.transaction { testContext.run(query[Contact].delete) testContext.run(query[Address].delete) diff --git a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/postgres/OptionalNestedJdbcSpec.scala b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/postgres/OptionalNestedJdbcSpec.scala index d7fd6862be..9e241f2ce3 100644 --- a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/postgres/OptionalNestedJdbcSpec.scala +++ b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/postgres/OptionalNestedJdbcSpec.scala @@ -7,7 +7,7 @@ class OptionalProductEncodingJdbcSpec extends OptionalNestedSpec { val context = testContext import testContext._ - override protected def beforeEach() = { + override protected def beforeEach(): Unit = { import Setup._ testContext.run(query[Contact].delete) () diff --git a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/postgres/PeopleJdbcAggregationSpec.scala b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/postgres/PeopleJdbcAggregationSpec.scala index 8dce4b20ca..6c402d9f05 100644 --- a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/postgres/PeopleJdbcAggregationSpec.scala +++ b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/postgres/PeopleJdbcAggregationSpec.scala @@ -7,7 +7,7 @@ class PeopleJdbcAggregationSpec extends PeopleAggregationSpec { val context = testContext import testContext._ - override def beforeAll = { + override def beforeAll: Unit = { testContext.transaction { testContext.run(query[Contact].delete) testContext.run(query[Address].delete) diff --git a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/postgres/PeopleJdbcSpec.scala b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/postgres/PeopleJdbcSpec.scala index d83cdd8038..dee6d61fbb 100644 --- a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/postgres/PeopleJdbcSpec.scala +++ b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/postgres/PeopleJdbcSpec.scala @@ -7,7 +7,7 @@ class PeopleJdbcSpec extends PeopleSpec { val context = testContext import testContext._ - override def beforeAll = { + override def beforeAll: Unit = { testContext.transaction { testContext.run(query[Couple].delete) testContext.run(query[Person].delete) diff --git a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/postgres/ProductJdbcSpec.scala b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/postgres/ProductJdbcSpec.scala index 4857500117..112806260f 100644 --- a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/postgres/ProductJdbcSpec.scala +++ b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/postgres/ProductJdbcSpec.scala @@ -7,7 +7,7 @@ class ProductJdbcSpec extends ProductSpec { val context = testContext import testContext._ - override def beforeAll = { + override def beforeAll: Unit = { testContext.run(quote(query[Product].delete)) () } @@ -27,7 +27,7 @@ class ProductJdbcSpec extends ProductSpec { product.id mustEqual inserted } - case class Foo(id: Long, description: String, sku: Long) + final case class Foo(id: Long, description: String, sku: Long) "Single insert with inlined free variable" in { val prd = Product(0L, "test1", 1L) @@ -63,7 +63,7 @@ class ProductJdbcSpec extends ProductSpec { "supports casts from string to number" - { "toInt" in { - case class Product(id: Long, description: String, sku: Int) + final case class Product(id: Long, description: String, sku: Int) val queried = testContext.run { query[Product].filter(_.sku == lift("1004").toInt) }.head diff --git a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/sqlite/BatchValuesJdbcSpec.scala b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/sqlite/BatchValuesJdbcSpec.scala index 03d0f75e7b..8b4f082cc1 100644 --- a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/sqlite/BatchValuesJdbcSpec.scala +++ b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/sqlite/BatchValuesJdbcSpec.scala @@ -1,7 +1,6 @@ package io.getquill.context.jdbc.sqlite import io.getquill.context.sql.base.BatchValuesSpec -import io.getquill._ class BatchValuesJdbcSpec extends BatchValuesSpec { // diff --git a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/sqlite/CaseClassQueryJdbcSpec.scala b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/sqlite/CaseClassQueryJdbcSpec.scala index 1f0183ed62..8cdc6c734b 100644 --- a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/sqlite/CaseClassQueryJdbcSpec.scala +++ b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/sqlite/CaseClassQueryJdbcSpec.scala @@ -8,7 +8,7 @@ class CaseClassQueryJdbcSpec extends CaseClassQuerySpec { val context = testContext import testContext._ - override def beforeAll = { + override def beforeAll: Unit = { testContext.transaction { testContext.run(query[Contact].delete) testContext.run(query[Address].delete) diff --git a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/sqlite/DepartmentsJdbcSpec.scala b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/sqlite/DepartmentsJdbcSpec.scala index 91878ffb5c..3e7edd1377 100644 --- a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/sqlite/DepartmentsJdbcSpec.scala +++ b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/sqlite/DepartmentsJdbcSpec.scala @@ -7,7 +7,7 @@ class DepartmentsJdbcSpec extends DepartmentsSpec { val context = testContext import testContext._ - override def beforeAll = { + override def beforeAll: Unit = { testContext.transaction { testContext.run(query[Department].delete) testContext.run(query[Employee].delete) diff --git a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/sqlite/DistinctJdbcSpec.scala b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/sqlite/DistinctJdbcSpec.scala index 63e0c4f6c7..09a6c2f93e 100644 --- a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/sqlite/DistinctJdbcSpec.scala +++ b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/sqlite/DistinctJdbcSpec.scala @@ -8,7 +8,7 @@ class DistinctJdbcSpec extends DistinctSpec { val context = testContext import testContext._ - override def beforeAll = { + override def beforeAll: Unit = { testContext.transaction { testContext.run(query[Couple].delete) testContext.run(query[Person].delete) diff --git a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/sqlite/JdbcContextSpec.scala b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/sqlite/JdbcContextSpec.scala index 236ea24751..2d9d440b48 100644 --- a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/sqlite/JdbcContextSpec.scala +++ b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/sqlite/JdbcContextSpec.scala @@ -40,7 +40,7 @@ class JdbcContextSpec extends Spec { "prepare" in { testContext.prepareParams( "select * from Person where name=? and age > ?", - (ps, session) => (List("Sarah", 127), ps) + (ps, _) => (List("Sarah", 127), ps) ) mustEqual List("127", "'Sarah'") } } diff --git a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/sqlite/OptionJdbcSpec.scala b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/sqlite/OptionJdbcSpec.scala index 96510f3a8d..125815a03e 100644 --- a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/sqlite/OptionJdbcSpec.scala +++ b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/sqlite/OptionJdbcSpec.scala @@ -8,7 +8,7 @@ class OptionJdbcSpec extends OptionQuerySpec { val context = testContext import testContext._ - override def beforeAll = { + override def beforeAll: Unit = { testContext.transaction { testContext.run(query[Contact].delete) testContext.run(query[Address].delete) diff --git a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/sqlite/PeopleJdbcSpec.scala b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/sqlite/PeopleJdbcSpec.scala index fb7bea030d..7ee1b864aa 100644 --- a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/sqlite/PeopleJdbcSpec.scala +++ b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/sqlite/PeopleJdbcSpec.scala @@ -6,7 +6,7 @@ class PeopleJdbcSpec extends PeopleSpec { val context = testContext import testContext._ - override def beforeAll = { + override def beforeAll: Unit = { testContext.transaction { testContext.run(query[Couple].delete) testContext.run(query[Person].delete) diff --git a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/sqlite/ProductJdbcSpec.scala b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/sqlite/ProductJdbcSpec.scala index e8af4dc8d1..bb9c858d81 100644 --- a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/sqlite/ProductJdbcSpec.scala +++ b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/sqlite/ProductJdbcSpec.scala @@ -7,7 +7,7 @@ class ProductJdbcSpec extends ProductSpec { val context = testContext import testContext._ - override def beforeAll = { + override def beforeAll: Unit = { testContext.run(quote(query[Product].delete)) () } @@ -72,7 +72,7 @@ class ProductJdbcSpec extends ProductSpec { "supports casts from string to number" - { "toInt" in { - case class Product(id: Long, description: String, sku: Int) + final case class Product(id: Long, description: String, sku: Int) val queried = testContext.run { query[Product].filter(_.sku == lift("1004").toInt) }.head diff --git a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/sqlserver/BatchValuesJdbcSpec.scala b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/sqlserver/BatchValuesJdbcSpec.scala index f5237466a3..b3f269aba1 100644 --- a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/sqlserver/BatchValuesJdbcSpec.scala +++ b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/sqlserver/BatchValuesJdbcSpec.scala @@ -28,7 +28,7 @@ class BatchValuesJdbcSpec extends BatchValuesSpec { "Ex 2B - Batch Insert Returning - whole row" in { import `Ex 2 - Batch Insert Returning`._ - implicit def meta = insertMeta[Product](_.id) + def op = quote { liftQuery(products).foreach(p => query[Product].insertValue(p).returning(p => p)) } diff --git a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/sqlserver/DepartmentsJdbcSpec.scala b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/sqlserver/DepartmentsJdbcSpec.scala index 4dbe39535c..5b6ddffeb2 100644 --- a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/sqlserver/DepartmentsJdbcSpec.scala +++ b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/sqlserver/DepartmentsJdbcSpec.scala @@ -7,7 +7,7 @@ class DepartmentsJdbcSpec extends DepartmentsSpec { val context = testContext import testContext._ - override def beforeAll = { + override def beforeAll: Unit = { testContext.transaction { testContext.run(query[Department].delete) testContext.run(query[Employee].delete) diff --git a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/sqlserver/DistinctJdbcSpec.scala b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/sqlserver/DistinctJdbcSpec.scala index 0041dfd780..9e573f6d9f 100644 --- a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/sqlserver/DistinctJdbcSpec.scala +++ b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/sqlserver/DistinctJdbcSpec.scala @@ -8,7 +8,7 @@ class DistinctJdbcSpec extends DistinctSpec { val context = testContext import testContext._ - override def beforeAll = { + override def beforeAll: Unit = { testContext.transaction { testContext.run(query[Couple].delete) testContext.run(query[Person].delete) diff --git a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/sqlserver/JdbcContextSpec.scala b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/sqlserver/JdbcContextSpec.scala index 69ab91d682..de7ef7fb83 100644 --- a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/sqlserver/JdbcContextSpec.scala +++ b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/sqlserver/JdbcContextSpec.scala @@ -9,7 +9,7 @@ class JdbcContextSpec extends Spec { import ctx._ "probes sqls" in { - val p = ctx.probe("DELETE FROM TestEntity") + ctx.probe("DELETE FROM TestEntity") } "run non-batched action" in { @@ -49,7 +49,7 @@ class JdbcContextSpec extends Spec { "prepare" in { ctx.prepareParams( "select * from Person where name=? and age > ?", - (ps, session) => (List("Sarah", 127), ps) + (ps, _) => (List("Sarah", 127), ps) ) mustEqual List("127", "'Sarah'") } } @@ -97,7 +97,7 @@ class JdbcContextSpec extends Spec { } "with multiple columns - case class" in { - case class Return(id: Int, str: String, opt: Option[Int]) + final case class Return(id: Int, str: String, opt: Option[Int]) ctx.run(qr1.delete) val inserted = ctx.run { qr1.insertValue(lift(TestEntity("foo", 1, 18L, Some(123), true))).returning(r => Return(r.i, r.s, r.o)) @@ -140,7 +140,7 @@ class JdbcContextSpec extends Spec { } "with multiple columns - case class" in { - case class Return(id: Int, str: String, opt: Option[Int]) + final case class Return(id: Int, str: String, opt: Option[Int]) ctx.run(qr1.delete) ctx.run(qr1.insertValue(lift(TestEntity("baz", 6, 42L, Some(456), true)))) @@ -183,7 +183,7 @@ class JdbcContextSpec extends Spec { } "with multiple columns - case class" in { - case class Return(id: Int, str: String, opt: Option[Int]) + final case class Return(id: Int, str: String, opt: Option[Int]) ctx.run(qr1.delete) ctx.run(qr1.insertValue(lift(TestEntity("foo", 2, 42L, Some(222), true)))) diff --git a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/sqlserver/OptionJdbcSpec.scala b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/sqlserver/OptionJdbcSpec.scala index c0937baa54..ba0006a081 100644 --- a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/sqlserver/OptionJdbcSpec.scala +++ b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/sqlserver/OptionJdbcSpec.scala @@ -8,7 +8,7 @@ class OptionJdbcSpec extends OptionQuerySpec { val context = testContext import testContext._ - override def beforeAll = { + override def beforeAll: Unit = { testContext.transaction { testContext.run(query[Contact].delete) testContext.run(query[Address].delete) diff --git a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/sqlserver/PeopleJdbcSpec.scala b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/sqlserver/PeopleJdbcSpec.scala index 65560c2051..49d48eaab4 100644 --- a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/sqlserver/PeopleJdbcSpec.scala +++ b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/sqlserver/PeopleJdbcSpec.scala @@ -7,7 +7,7 @@ class PeopleJdbcSpec extends PeopleSpec { val context = testContext import testContext._ - override def beforeAll = { + override def beforeAll: Unit = { testContext.transaction { testContext.run(query[Couple].delete) testContext.run(query[Person].delete) diff --git a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/sqlserver/ProductJdbcSpec.scala b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/sqlserver/ProductJdbcSpec.scala index 5ad2d99656..37dc943cf7 100644 --- a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/sqlserver/ProductJdbcSpec.scala +++ b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/sqlserver/ProductJdbcSpec.scala @@ -7,7 +7,7 @@ class ProductJdbcSpec extends ProductSpec { val context = testContext import testContext._ - override def beforeAll = { + override def beforeAll: Unit = { testContext.run(quote(query[Product].delete)) () } @@ -62,7 +62,7 @@ class ProductJdbcSpec extends ProductSpec { "supports casts from string to number" - { "toInt" in { - case class Product(id: Long, description: String, sku: Int) + final case class Product(id: Long, description: String, sku: Int) val queried = testContext.run { query[Product].filter(_.sku == lift("1004").toInt) }.head diff --git a/quill-orientdb/src/test/scala/io/getquill/context/orientdb/CaseClassQueryOrientSpec.scala b/quill-orientdb/src/test/scala/io/getquill/context/orientdb/CaseClassQueryOrientSpec.scala index 1d3d6b9795..8068983952 100644 --- a/quill-orientdb/src/test/scala/io/getquill/context/orientdb/CaseClassQueryOrientSpec.scala +++ b/quill-orientdb/src/test/scala/io/getquill/context/orientdb/CaseClassQueryOrientSpec.scala @@ -13,7 +13,7 @@ class CaseClassQueryOrientSpec extends Spec { val peopleInsert = quote((p: Contact) => query[Contact].insertValue(p)) - val peopleEntries = List( + val peopleEntries: List[Contact] = List( Contact(1, "Alex", "Jones", 60, 2, "foo"), Contact(2, "Bert", "James", 55, 3, "bar"), Contact(3, "Cora", "Jasper", 33, 3, "baz") @@ -22,7 +22,7 @@ class CaseClassQueryOrientSpec extends Spec { val addressInsert = quote((c: Address) => query[Address].insertValue(c)) - val addressEntries = List( + val addressEntries: List[Address] = List( Address(1, "123 Fake Street", 11234, "something"), Address(2, "456 Old Street", 45678, "something else"), Address(3, "789 New Street", 89010, "another thing") diff --git a/quill-orientdb/src/test/scala/io/getquill/context/orientdb/DecodeNullSpec.scala b/quill-orientdb/src/test/scala/io/getquill/context/orientdb/DecodeNullSpec.scala index 79469e12e9..e86ef84a1c 100644 --- a/quill-orientdb/src/test/scala/io/getquill/context/orientdb/DecodeNullSpec.scala +++ b/quill-orientdb/src/test/scala/io/getquill/context/orientdb/DecodeNullSpec.scala @@ -24,5 +24,5 @@ class DecodeNullSpec extends Spec { case class DecodeNullTestWriteEntity(id: Int, value: Option[Int]) - val insertValue = DecodeNullTestWriteEntity(0, None) + val insertValue: DecodeNullTestWriteEntity = DecodeNullTestWriteEntity(0, None) } diff --git a/quill-orientdb/src/test/scala/io/getquill/context/orientdb/EncodingSpec.scala b/quill-orientdb/src/test/scala/io/getquill/context/orientdb/EncodingSpec.scala index 88cb86864a..9e33ea9e4a 100644 --- a/quill-orientdb/src/test/scala/io/getquill/context/orientdb/EncodingSpec.scala +++ b/quill-orientdb/src/test/scala/io/getquill/context/orientdb/EncodingSpec.scala @@ -22,10 +22,10 @@ class EncodingSpec extends Spec { val ctx = orientdb.testSyncDB import ctx._ // 100% coverage - case class A() - case class B() - val a1: Encoder[A] = encoder((b, c, d) => d) - val a2: Decoder[A] = decoder(b => c => A()) + final case class A() + final case class B() + val a1: Encoder[A] = encoder((_, _, d) => d) + val a2: Decoder[A] = decoder(_ => _ => A()) mappedDecoder(MappedEncoding[A, B](_ => B()), a2).isInstanceOf[OrientDBDecoder[B]] mustBe true mappedEncoder(MappedEncoding[B, A](_ => A()), a1).isInstanceOf[OrientDBEncoder[B]] mustBe true } @@ -103,7 +103,7 @@ class EncodingSpec extends Spec { o10: Option[Byte] ) - val insertValues = + val insertValues: List[EncodingTestEntity] = List( EncodingTestEntity( id = 1, diff --git a/quill-orientdb/src/test/scala/io/getquill/context/orientdb/ListsEncodingSpec.scala b/quill-orientdb/src/test/scala/io/getquill/context/orientdb/ListsEncodingSpec.scala index 98f4789b39..e54b4baf0c 100644 --- a/quill-orientdb/src/test/scala/io/getquill/context/orientdb/ListsEncodingSpec.scala +++ b/quill-orientdb/src/test/scala/io/getquill/context/orientdb/ListsEncodingSpec.scala @@ -16,7 +16,7 @@ class ListsEncodingSpec extends Spec { doubles: List[Double], timestamps: List[Date] ) - val e = ListsEntity(1, List("c"), List(true), List(1, 2), List(2, 3), List(1.2f, 3.2f), List(5.1d), List(new Date())) + val e: ListsEntity = ListsEntity(1, List("c"), List(true), List(1, 2), List(2, 3), List(1.2f, 3.2f), List(5.1d), List(new Date())) private def verify(expected: ListsEntity, actual: ListsEntity): Boolean = { expected.id mustEqual actual.id @@ -49,7 +49,7 @@ class ListsEncodingSpec extends Spec { "Empty Lists and optional fields" in { val ctx = orientdb.testSyncDB import ctx._ - case class Entity(id: Int, texts: Option[List[String]], bools: Option[List[Boolean]]) + final case class Entity(id: Int, texts: Option[List[String]], bools: Option[List[Boolean]]) val e = Entity(1, Some(List("1", "2")), None) val q = quote(querySchema[Entity]("ListEntity")) @@ -62,7 +62,7 @@ class ListsEncodingSpec extends Spec { "Blob (Array[Byte]) support" ignore { val ctx = orientdb.testSyncDB import ctx._ - case class BlobsEntity(id: Int, blobs: List[Array[Byte]]) + final case class BlobsEntity(id: Int, blobs: List[Array[Byte]]) val e = BlobsEntity(1, List(Array(1.toByte, 2.toByte), Array(2.toByte))) val q = quote(querySchema[BlobsEntity]("BlobsEntity")) @@ -74,12 +74,12 @@ class ListsEncodingSpec extends Spec { "List in where clause" in { val ctx = orientdb.testSyncDB import ctx._ - case class ListFrozen(id: List[Int]) + final case class ListFrozen(id: List[Int]) val e = ListFrozen(List(1, 2)) val q = quote(query[ListFrozen]) ctx.run(q.delete) ctx.run(q.insertValue(lift(e))) ctx.run(q.filter(p => liftQuery(Set(1)).contains(p.id))) mustBe List(e) - ctx.run(q.filter(_.id == lift(List(1)))) mustBe Nil + ctx.run(q.filter(_.id == lift(List(1)))) mustBe List.empty } } diff --git a/quill-orientdb/src/test/scala/io/getquill/context/orientdb/MapsEncodingSpec.scala b/quill-orientdb/src/test/scala/io/getquill/context/orientdb/MapsEncodingSpec.scala index 2420dff0ed..d9f7b9a2f0 100644 --- a/quill-orientdb/src/test/scala/io/getquill/context/orientdb/MapsEncodingSpec.scala +++ b/quill-orientdb/src/test/scala/io/getquill/context/orientdb/MapsEncodingSpec.scala @@ -12,7 +12,7 @@ class MapsEncodingSpec extends Spec { intDouble: Map[Int, Double], boolDate: Map[Boolean, Date] ) - val e = MapsEntity(1, Map(1L -> 1.1), Map(1 -> 1.1d), Map(true -> new Date())) + val e: MapsEntity = MapsEntity(1, Map(1L -> 1.1), Map(1 -> 1.1d), Map(true -> new Date())) private def verify(expected: MapsEntity, actual: MapsEntity): Boolean = { expected.id mustEqual actual.id @@ -42,7 +42,7 @@ class MapsEncodingSpec extends Spec { "Empty maps and optional fields" in { val ctx = orientdb.testSyncDB import ctx._ - case class Entity( + final case class Entity( id: Int, intDouble: Option[Map[Int, Double]], longDouble: Option[Map[Long, Double]] @@ -58,7 +58,7 @@ class MapsEncodingSpec extends Spec { "Map in where clause" in { val ctx = orientdb.testSyncDB import ctx._ - case class MapFrozen(id: Map[Int, Boolean]) + final case class MapFrozen(id: Map[Int, Boolean]) val e = MapFrozen(Map(1 -> true)) val q = quote(query[MapFrozen]) ctx.run(q.delete) diff --git a/quill-orientdb/src/test/scala/io/getquill/context/orientdb/OrientDBContextMacroSpec.scala b/quill-orientdb/src/test/scala/io/getquill/context/orientdb/OrientDBContextMacroSpec.scala index 69b48fd6db..8cee0b6b12 100644 --- a/quill-orientdb/src/test/scala/io/getquill/context/orientdb/OrientDBContextMacroSpec.scala +++ b/quill-orientdb/src/test/scala/io/getquill/context/orientdb/OrientDBContextMacroSpec.scala @@ -44,7 +44,7 @@ class OrientDBContextMacroSpec extends Spec { val mirrorContext = orientdb.mirrorContext import mirrorContext._ val q = quote { - qr1.filter(t => t.i == lift(1)).map(t => lift(2L)) + qr1.filter(t => t.i == lift(1)).map(_ => lift(2L)) } val mirror = mirrorContext.run(q) mirror.string mustEqual "SELECT ? FROM TestEntity WHERE i = ?" diff --git a/quill-orientdb/src/test/scala/io/getquill/context/orientdb/OrientDBContextSpec.scala b/quill-orientdb/src/test/scala/io/getquill/context/orientdb/OrientDBContextSpec.scala index 103ad22ea8..4961d12867 100644 --- a/quill-orientdb/src/test/scala/io/getquill/context/orientdb/OrientDBContextSpec.scala +++ b/quill-orientdb/src/test/scala/io/getquill/context/orientdb/OrientDBContextSpec.scala @@ -8,18 +8,18 @@ class OrientDBContextSpec extends Spec { "sync" in { val ctx = orientdb.testSyncDB import ctx._ - case class TestEntity(id: Int, s: String, i: Int, l: Long, o: Int) + final case class TestEntity(id: Int, s: String, i: Int, l: Long, o: Int) val select = quote { query[TestEntity].filter(_.id == lift(1)) } - ctx.run(select) mustEqual List() + ctx.run(select) mustEqual List.empty } } "run non-batched action" in { val ctx = orientdb.testSyncDB import ctx._ - case class TestEntity(id: Int, s: String, i: Int, l: Long, o: Int) + final case class TestEntity(id: Int, s: String, i: Int, l: Long, o: Int) val update = quote { query[TestEntity].filter(_.id == lift(1)).update(_.i -> lift(1)) } @@ -29,7 +29,7 @@ class OrientDBContextSpec extends Spec { "performIO" in { val ctx = orientdb.testSyncDB import ctx._ - case class TestEntity(id: Int) + final case class TestEntity(id: Int) performIO(runIO(quote(query[TestEntity].filter(_.id == lift(1)))).transactional) } @@ -37,8 +37,8 @@ class OrientDBContextSpec extends Spec { val ctx = orientdb.testSyncDB import ctx._ val e: Extractor[Int] = (_, _) => 1 - intercept[IllegalStateException](executeActionReturning("", (x, session) => (Nil, x), e, "")).getMessage mustBe - intercept[IllegalStateException](executeBatchActionReturning(Nil, e)).getMessage + intercept[IllegalStateException](executeActionReturning("", (x, _) => (List.empty, x), e, "")).getMessage mustBe + intercept[IllegalStateException](executeBatchActionReturning(List.empty, e)).getMessage } "probe" in { diff --git a/quill-orientdb/src/test/scala/io/getquill/context/orientdb/OrientDBIdiomSpec.scala b/quill-orientdb/src/test/scala/io/getquill/context/orientdb/OrientDBIdiomSpec.scala index 6ba79c1b82..b79724e15a 100644 --- a/quill-orientdb/src/test/scala/io/getquill/context/orientdb/OrientDBIdiomSpec.scala +++ b/quill-orientdb/src/test/scala/io/getquill/context/orientdb/OrientDBIdiomSpec.scala @@ -43,7 +43,7 @@ class OrientDBIdiomSpec extends Spec { "distinct" - { "simple" in { - val q = quote { + quote { qr1.distinct } "mirrorContext.run(q).string" mustNot compile @@ -57,7 +57,7 @@ class OrientDBIdiomSpec extends Spec { } "distinct tuple" in { - val q = quote { + quote { qr1.map(i => (i.i, i.l)).distinct } "mirrorContext.run(q).string" mustNot compile @@ -118,13 +118,13 @@ class OrientDBIdiomSpec extends Spec { "SELECT s, i, l, o, b FROM TestEntity WHERE i = 1" } "unary (not supported)" in { - val q = quote { + quote { qr1.filter(t => !(t.i == 1)) } "mirrorContext.run(q)" mustNot compile } "function apply (not supported)" in { - val q = quote { + quote { qr1.filter(t => sql"f".as[Int => Boolean](t.i)) } "mirrorContext.run(q)" mustNot compile @@ -236,7 +236,7 @@ class OrientDBIdiomSpec extends Spec { "SELECT s, i, l, o, b FROM TestEntity WHERE s = 'a'" } "unit" in { - case class Test(u: Unit) + final case class Test(u: Unit) val q = quote { query[Test].filter(t => t.u == (())).size } @@ -258,7 +258,7 @@ class OrientDBIdiomSpec extends Spec { "SELECT i _1, s _2 FROM TestEntity" } "caseclass" in { - case class IntString(intProp: Int, stringProp: String) + final case class IntString(intProp: Int, stringProp: String) val q = quote { qr1.map(t => new IntString(t.i, t.s)) } diff --git a/quill-orientdb/src/test/scala/io/getquill/context/orientdb/OrientDBQuerySpec.scala b/quill-orientdb/src/test/scala/io/getquill/context/orientdb/OrientDBQuerySpec.scala index 731e5b56b3..921bc30b99 100644 --- a/quill-orientdb/src/test/scala/io/getquill/context/orientdb/OrientDBQuerySpec.scala +++ b/quill-orientdb/src/test/scala/io/getquill/context/orientdb/OrientDBQuerySpec.scala @@ -4,7 +4,7 @@ import io.getquill.ast.{Action => AstAction, Query => AstQuery, _} import io.getquill.context.sql._ import io.getquill.idiom.StatementInterpolator._ import io.getquill.idiom.StringToken -import io.getquill.{IdiomContext, Literal, Ord} +import io.getquill.{Literal, Ord} import io.getquill.base.Spec import io.getquill.quat.Quat import io.getquill.util.TraceConfig @@ -34,7 +34,7 @@ class OrientDBQuerySpec extends Spec { } "other" in { val q = quote { - qr1.map(t => "s") + qr1.map(_ => "s") } mirrorContext.run(q).string mustEqual "SELECT 's' FROM TestEntity" @@ -185,7 +185,7 @@ class OrientDBQuerySpec extends Spec { import OrientDBIdiom._ implicit val n = Literal - val i = Ident("i") + val i: Ident = Ident("i") "tokenizers" - { "if" in { @@ -198,11 +198,11 @@ class OrientDBQuerySpec extends Spec { } "query" in { val t = implicitly[Tokenizer[AstQuery]] - t.token(Entity("name", Nil, QEP)) mustBe new SqlQueryApply(TraceConfig.Empty)(Entity("name", Nil, QEP)).token + t.token(Entity("name", List.empty, QEP)) mustBe new SqlQueryApply(TraceConfig.Empty)(Entity("name", List.empty, QEP)).token } "sql query" in { val t = implicitly[Tokenizer[SqlQuery]] - val e = FlattenSqlQuery(select = Nil)(Quat.Value) + val e = FlattenSqlQuery(select = List.empty)(Quat.Value) t.token(e) mustBe stmt"SELECT *" @@ -215,7 +215,7 @@ class OrientDBQuerySpec extends Spec { t.token(e.copy(select = List(x, x), distinct = DistinctKind.Distinct)(Quat.Value)) ).getMessage mustBe "OrientDB DISTINCT with multiple columns is not supported" - val tb = TableContext(Entity("tb", Nil, QEP), "x1") + val tb = TableContext(Entity("tb", List.empty, QEP), "x1") t.token(e.copy(from = List(tb, tb))(Quat.Value)) mustBe stmt"SELECT * FROM tb" val jn = FlatJoinContext(InnerJoin, tb.copy(alias = "x2"), Ident("x")) @@ -242,7 +242,7 @@ class OrientDBQuerySpec extends Spec { t.token(BinaryOperation(NullValue, EqualityOperator.`_!=`, i)) mustBe stmt"i IS NOT NULL" t.token(BinaryOperation(i, NumericOperator.`+`, i)) mustBe stmt"i + i" intercept[IllegalStateException](t.token(BinaryOperation(i, EqualityOperator.`_!=`, i))) - intercept[IllegalStateException](t.token(FunctionApply(i, Nil))) + intercept[IllegalStateException](t.token(FunctionApply(i, List.empty))) } "set operation" in { val t = implicitly[Tokenizer[SetOperation]] @@ -253,7 +253,7 @@ class OrientDBQuerySpec extends Spec { val t = implicitly[Tokenizer[SelectValue]] t.token(SelectValue(Ident("?"))) mustBe "?".token t.token( - SelectValue(Aggregation(AggregationOperator.`max`, Entity("t", Nil, QEP)), Some("x")) + SelectValue(Aggregation(AggregationOperator.`max`, Entity("t", List.empty, QEP)), Some("x")) ) mustBe stmt"(SELECT MAX(*) FROM t) x" } "prop" in { @@ -271,12 +271,12 @@ class OrientDBQuerySpec extends Spec { val t = implicitly[Tokenizer[AstAction]] intercept[IllegalStateException](t.token(null: AstAction)) def ins(a: String) = - Insert(Entity("tb", Nil, QEP), List(Assignment(i, Property(Property(i, "x"), a), i))) + Insert(Entity("tb", List.empty, QEP), List(Assignment(i, Property(Property(i, "x"), a), i))) t.token(ins("isEmpty")) mustBe stmt"INSERT INTO tb (x IS NULL) VALUES(i)" t.token(ins("isDefined")) mustBe stmt"INSERT INTO tb (x IS NOT NULL) VALUES(i)" t.token(ins("nonEmpty")) mustBe stmt"INSERT INTO tb (x IS NOT NULL) VALUES(i)" t.token( - Insert(Entity("tb", Nil, QEP), List(Assignment(i, Property(i, "i"), i))) + Insert(Entity("tb", List.empty, QEP), List(Assignment(i, Property(i, "i"), i))) ) mustBe stmt"INSERT INTO tb (i) VALUES(i)" } // not actually used anywhere but doing a sanity check here diff --git a/quill-orientdb/src/test/scala/io/getquill/context/orientdb/QueryResultTypeOrientDBSync.scala b/quill-orientdb/src/test/scala/io/getquill/context/orientdb/QueryResultTypeOrientDBSync.scala index 9ca28d0573..ce06a00872 100644 --- a/quill-orientdb/src/test/scala/io/getquill/context/orientdb/QueryResultTypeOrientDBSync.scala +++ b/quill-orientdb/src/test/scala/io/getquill/context/orientdb/QueryResultTypeOrientDBSync.scala @@ -7,7 +7,7 @@ class QueryResultTypeOrientDBSync extends Spec { case class OrderTestEntity(id: Int, i: Int) - val entries = List( + val entries: List[OrderTestEntity] = List( OrderTestEntity(1, 1), OrderTestEntity(2, 2), OrderTestEntity(3, 3) diff --git a/quill-orientdb/src/test/scala/io/getquill/context/orientdb/SetsEncodingSpec.scala b/quill-orientdb/src/test/scala/io/getquill/context/orientdb/SetsEncodingSpec.scala index 248d694f0f..3e11d7f246 100644 --- a/quill-orientdb/src/test/scala/io/getquill/context/orientdb/SetsEncodingSpec.scala +++ b/quill-orientdb/src/test/scala/io/getquill/context/orientdb/SetsEncodingSpec.scala @@ -16,7 +16,7 @@ class SetsEncodingSpec extends Spec { timestamps: Set[Date] ) - val e = SetsEntity(1, Set("c"), Set(true), Set(1), Set(2), Set(5.5d), Set(new Date())) + val e: SetsEntity = SetsEntity(1, Set("c"), Set(true), Set(1), Set(2), Set(5.5d), Set(new Date())) private def verify(expected: SetsEntity, actual: SetsEntity): Boolean = { expected.id mustEqual actual.id @@ -48,7 +48,7 @@ class SetsEncodingSpec extends Spec { "Empty Lists and optional fields" in { val ctx = orientdb.testSyncDB import ctx._ - case class Entity(id: Int, texts: Option[List[String]], bools: Option[List[String]]) + final case class Entity(id: Int, texts: Option[List[String]], bools: Option[List[String]]) val e = Entity(1, Some(List("1", "2")), None) val q = quote(querySchema[Entity]("ListEntity")) @@ -60,7 +60,7 @@ class SetsEncodingSpec extends Spec { "Blob (Array[Byte]) support" ignore { val ctx = orientdb.testSyncDB import ctx._ - case class BlobsEntity(id: Int, blobs: List[Array[Byte]]) + final case class BlobsEntity(id: Int, blobs: List[Array[Byte]]) val e = BlobsEntity(1, List(Array(1.toByte, 2.toByte), Array(2.toByte))) val q = quote(querySchema[BlobsEntity]("BlobsEntity")) @@ -72,12 +72,12 @@ class SetsEncodingSpec extends Spec { "Set in where clause" in { val ctx = orientdb.testSyncDB import ctx._ - case class ListFrozen(id: List[Int]) + final case class ListFrozen(id: List[Int]) val e = ListFrozen(List(1, 2)) val q = quote(query[ListFrozen]) ctx.run(q.delete) ctx.run(q.insertValue(lift(e))) ctx.run(q.filter(p => liftQuery(Set(1)).contains(p.id))) mustBe List(e) - ctx.run(q.filter(_.id == lift(List(1)))) mustBe Nil + ctx.run(q.filter(_.id == lift(List(1)))) mustBe List.empty } } diff --git a/quill-orientdb/src/test/scala/io/getquill/context/orientdb/orientdb.scala b/quill-orientdb/src/test/scala/io/getquill/context/orientdb/orientdb.scala index 119ad8d735..9545b0028c 100644 --- a/quill-orientdb/src/test/scala/io/getquill/context/orientdb/orientdb.scala +++ b/quill-orientdb/src/test/scala/io/getquill/context/orientdb/orientdb.scala @@ -49,12 +49,12 @@ object orientdb { () } - def mirrorContext = { + def mirrorContext: OrientDBMirrorContext[Literal.type] with TestEntities = { if (!setupDone) { setup(); setupDone = true } new OrientDBMirrorContext(Literal) with TestEntities } - def testSyncDB = { + def testSyncDB: OrientDBSyncContext[Literal.type] = { if (!setupDone) { setup(); setupDone = true } new OrientDBSyncContext(Literal, "ctx") } diff --git a/quill-spark/src/test/scala/io/getquill/context/spark/AliasNestedQueryColumnsSpec.scala b/quill-spark/src/test/scala/io/getquill/context/spark/AliasNestedQueryColumnsSpec.scala index 3e9d0d2505..b71449a366 100644 --- a/quill-spark/src/test/scala/io/getquill/context/spark/AliasNestedQueryColumnsSpec.scala +++ b/quill-spark/src/test/scala/io/getquill/context/spark/AliasNestedQueryColumnsSpec.scala @@ -2,14 +2,14 @@ package io.getquill.context.spark import io.getquill.base.Spec -case class Test(i: Int, j: Int, s: String) +final case class Test(i: Int, j: Int, s: String) class AliasNestedQueryColumnsSpec extends Spec { import testContext._ import sqlContext.implicits._ - val entities = Seq(Test(1, 2, "3")) + val entities: Seq[Test] = Seq(Test(1, 2, "3")) val qr1 = liftQuery(entities.toDS) val qr2 = liftQuery(entities.toDS) @@ -31,7 +31,7 @@ class AliasNestedQueryColumnsSpec extends Spec { } "unary operation" in { val q = quote { - qr1.filter(t => qr2.nested.nonEmpty) + qr1.filter(_ => qr2.nested.nonEmpty) } testContext.run(q).collect.toList mustEqual entities diff --git a/quill-spark/src/test/scala/io/getquill/context/spark/CaseClassQuerySpec.scala b/quill-spark/src/test/scala/io/getquill/context/spark/CaseClassQuerySpec.scala index efa5de6b32..9232ce1f9a 100644 --- a/quill-spark/src/test/scala/io/getquill/context/spark/CaseClassQuerySpec.scala +++ b/quill-spark/src/test/scala/io/getquill/context/spark/CaseClassQuerySpec.scala @@ -4,25 +4,25 @@ import io.getquill.base.Spec import org.apache.spark.sql.Dataset import org.scalatest.matchers.should.Matchers._ -case class Contact(firstName: String, lastName: String, age: Int, addressFk: Int, extraInfo: String) -case class Address(id: Int, street: String, zip: Int, otherExtraInfo: String) -case class AddressableContact(firstName: String, lastName: String, age: Int, street: String, zip: Int) +final case class Contact(firstName: String, lastName: String, age: Int, addressFk: Int, extraInfo: String) +final case class Address(id: Int, street: String, zip: Int, otherExtraInfo: String) +final case class AddressableContact(firstName: String, lastName: String, age: Int, street: String, zip: Int) -case class ContactSimplifiedWithAddress(firstName: String, lastName: String, addressFk: Int) -case class ContactSimplifiedRenamed(firstName: String, lastNameRenamed: String, firstReverse: String) -case class ContactSimplifiedMapped(firstNameMapped: String, lastNameMapped: String, firstReverseMapped: String) +final case class ContactSimplifiedWithAddress(firstName: String, lastName: String, addressFk: Int) +final case class ContactSimplifiedRenamed(firstName: String, lastNameRenamed: String, firstReverse: String) +final case class ContactSimplifiedMapped(firstNameMapped: String, lastNameMapped: String, firstReverseMapped: String) -case class ContactAndAddress(c: Contact, a: Address) -case class AddressAndOptionalContext(a: Address, c: Option[Contact]) -case class OptionalContextAndOptionalContext(c1: Option[Contact], c2: Option[Contact]) -case class AddressAndOptionalContextHolder(i: Int, aoc: Option[AddressAndOptionalContext]) -case class Note(owner: String, content: String) +final case class ContactAndAddress(c: Contact, a: Address) +final case class AddressAndOptionalContext(a: Address, c: Option[Contact]) +final case class OptionalContextAndOptionalContext(c1: Option[Contact], c2: Option[Contact]) +final case class AddressAndOptionalContextHolder(i: Int, aoc: Option[AddressAndOptionalContext]) +final case class Note(owner: String, content: String) class CaseClassQuerySpec extends Spec { val context = io.getquill.context.sql.testContext // hello - val expectedData = Seq( + val expectedData: Seq[ContactSimplifiedRenamed] = Seq( ContactSimplifiedRenamed("Alex", "Jones", "Alex".reverse), ContactSimplifiedRenamed("Bert", "James", "Bert".reverse), ContactSimplifiedRenamed("Cora", "Jasper", "Cora".reverse) @@ -31,21 +31,21 @@ class CaseClassQuerySpec extends Spec { import testContext._ import sqlContext.implicits._ - val peopleList = Seq( + val peopleList: Seq[Contact] = Seq( Contact("Alex", "Jones", 60, 2, "foo"), Contact("Bert", "James", 55, 3, "bar"), Contact("Cora", "Jasper", 33, 3, "baz") ) val peopleEntries = liftQuery(peopleList.toDS()) - val addressList = Seq( + val addressList: Seq[Address] = Seq( Address(1, "123 Fake Street", 11234, "something"), Address(2, "456 Old Street", 45678, "something else"), Address(3, "789 New Street", 89010, "another thing") ) val addressEntries = liftQuery(addressList.toDS()) - val noteList = Seq( + val noteList: Seq[Note] = Seq( Note("Alex", "Foo"), Note("Alex", "Bar"), Note("Bert", "Baz"), @@ -652,5 +652,5 @@ class CaseClassQuerySpec extends Spec { } } -case class Person1(id: Long, name: String, age: Long, numeric: Long) -case class PersonTotalNumerics(id: Long, name: String, numeric: Long) +final case class Person1(id: Long, name: String, age: Long, numeric: Long) +final case class PersonTotalNumerics(id: Long, name: String, numeric: Long) diff --git a/quill-spark/src/test/scala/io/getquill/context/spark/DepartmentsSparkSpec.scala b/quill-spark/src/test/scala/io/getquill/context/spark/DepartmentsSparkSpec.scala index d69a1948e0..bc4e418a27 100644 --- a/quill-spark/src/test/scala/io/getquill/context/spark/DepartmentsSparkSpec.scala +++ b/quill-spark/src/test/scala/io/getquill/context/spark/DepartmentsSparkSpec.scala @@ -3,9 +3,9 @@ package io.getquill.context.spark import io.getquill.Query import io.getquill.base.Spec -case class Department(dpt: String) -case class Employee(emp: String, dpt: String) -case class Task(emp: String, tsk: String) +final case class Department(dpt: String) +final case class Employee(emp: String, dpt: String) +final case class Task(emp: String, tsk: String) class DepartmentsSparkSpec extends Spec { diff --git a/quill-spark/src/test/scala/io/getquill/context/spark/EncodingSparkSpec.scala b/quill-spark/src/test/scala/io/getquill/context/spark/EncodingSparkSpec.scala index 81ddcff9ee..805773b66e 100644 --- a/quill-spark/src/test/scala/io/getquill/context/spark/EncodingSparkSpec.scala +++ b/quill-spark/src/test/scala/io/getquill/context/spark/EncodingSparkSpec.scala @@ -1,8 +1,10 @@ package io.getquill.context.spark import io.getquill.base.Spec +import io.getquill.{ Query, Quoted } +import org.scalatest.Assertion -case class EncodingTestEntity( +final case class EncodingTestEntity( v1: String, v2: BigDecimal, v3: Boolean, @@ -145,17 +147,17 @@ class EncodingSparkSpec extends Spec { val q = quote { entities.filter(_.o8.exists(lift(v).contains(_))).map(_.o8) } - testContext.run(q).collect.toList mustEqual List() + testContext.run(q).collect.toList mustEqual List.empty } } "mapped encoding" in { - case class Temp(i: Int) + final case class Temp(i: Int) implicit val enc = MappedEncoding[Temp, Int](_.i) implicitly[Encoder[Temp]] } - val entities = liftQuery { + val entities: Quoted[Query[EncodingTestEntity]] = liftQuery { Seq( EncodingTestEntity( "s", @@ -200,7 +202,7 @@ class EncodingSparkSpec extends Spec { ).toDS } - def verify(result: List[EncodingTestEntity]) = + def verify(result: List[EncodingTestEntity]): Assertion = result match { case List(e1, e2) => e1.v1 mustEqual "s" diff --git a/quill-spark/src/test/scala/io/getquill/context/spark/MiscQueriesSpec.scala b/quill-spark/src/test/scala/io/getquill/context/spark/MiscQueriesSpec.scala index 44eb8322e2..ee4753eaf5 100644 --- a/quill-spark/src/test/scala/io/getquill/context/spark/MiscQueriesSpec.scala +++ b/quill-spark/src/test/scala/io/getquill/context/spark/MiscQueriesSpec.scala @@ -2,10 +2,10 @@ package io.getquill.context.spark import io.getquill.base.Spec -case class Inner(i: Int) -case class Outer(inner: Inner) -case class Original(id: Long, name: String, age: Long, numeric: Long) -case class MapTo(id: Long, name: String, numeric: Long) +final case class Inner(i: Int) +final case class Outer(inner: Inner) +final case class Original(id: Long, name: String, age: Long, numeric: Long) +final case class MapTo(id: Long, name: String, numeric: Long) class MiscQueriesSpec extends Spec { diff --git a/quill-spark/src/test/scala/io/getquill/context/spark/PeopleSparkSpec.scala b/quill-spark/src/test/scala/io/getquill/context/spark/PeopleSparkSpec.scala index aa9cfd0047..24daa5ee44 100644 --- a/quill-spark/src/test/scala/io/getquill/context/spark/PeopleSparkSpec.scala +++ b/quill-spark/src/test/scala/io/getquill/context/spark/PeopleSparkSpec.scala @@ -3,8 +3,8 @@ package io.getquill.context.spark import io.getquill.base.Spec import io.getquill.{Query, Quoted} -case class Person(name: String, age: Int) -case class Couple(her: String, him: String) +final case class Person(name: String, age: Int) +final case class Couple(her: String, him: String) class PeopleJdbcSpec extends Spec { @@ -148,8 +148,7 @@ class PeopleJdbcSpec extends Spec { List(("Alex", 5), ("Cora", 2)) } "should throw Exception" in { - val q = - """ quote { + """ quote { for { c <- couples w <- people.join(w => c.her == w.name).distinct @@ -185,8 +184,7 @@ class PeopleJdbcSpec extends Spec { List(("Alex", 5), ("Cora", 2)) } "should throw Exception" in { - val q = - """ quote { + """ quote { for { c <- couples w <- people.join(w => c.her == w.name).nested diff --git a/quill-spark/src/test/scala/io/getquill/context/spark/QuestionMarkSpec.scala b/quill-spark/src/test/scala/io/getquill/context/spark/QuestionMarkSpec.scala index baf1b6918e..2d55d27c5e 100644 --- a/quill-spark/src/test/scala/io/getquill/context/spark/QuestionMarkSpec.scala +++ b/quill-spark/src/test/scala/io/getquill/context/spark/QuestionMarkSpec.scala @@ -8,12 +8,12 @@ class QuestionMarkSpec extends Spec { import testContext._ import sqlContext.implicits._ - val peopleList = Seq( + val peopleList: Seq[Contact] = Seq( Contact("Alex", "Jones", 60, 2, "?"), Contact("Bert", "James", 55, 3, "bar") ) - val addressList = Seq( + val addressList: Seq[Address] = Seq( Address(1, "123 Fake Street", 11234, "?") ) diff --git a/quill-spark/src/test/scala/io/getquill/context/spark/QuillSparkContextSpec.scala b/quill-spark/src/test/scala/io/getquill/context/spark/QuillSparkContextSpec.scala index 7c372cfd31..89b28d163f 100644 --- a/quill-spark/src/test/scala/io/getquill/context/spark/QuillSparkContextSpec.scala +++ b/quill-spark/src/test/scala/io/getquill/context/spark/QuillSparkContextSpec.scala @@ -8,7 +8,7 @@ class QuillSparkContextSpec extends Spec { import sqlContext.implicits._ import testContext._ - val entities = Seq(Test(1, 2, "3")) + val entities: Seq[Test] = Seq(Test(1, 2, "3")) "toQuery" in { testContext.run(liftQuery(entities.toDS)).collect.toList mustEqual diff --git a/quill-spark/src/test/scala/io/getquill/context/spark/SparkDialectSpec.scala b/quill-spark/src/test/scala/io/getquill/context/spark/SparkDialectSpec.scala index be50691d2f..15d92acbc0 100644 --- a/quill-spark/src/test/scala/io/getquill/context/spark/SparkDialectSpec.scala +++ b/quill-spark/src/test/scala/io/getquill/context/spark/SparkDialectSpec.scala @@ -38,7 +38,7 @@ class SparkDialectSpec extends Spec { } "escapes ' " in { - val ast = query[Test].map(t => "test'").ast + val ast = query[Test].map(_ => "test'").ast val (norm, stmt, _) = SparkDialect.translate(ast, Quat.Unknown, ExecutionType.Unknown, IdiomContext.Empty)(Literal) norm mustEqual ast stmt.toString mustEqual "SELECT 'test\\'' AS x FROM Test t" @@ -46,8 +46,8 @@ class SparkDialectSpec extends Spec { // More comprehensive test in MiscQueriesSpec "nested property" in { - case class Inner(i: Int) - case class Outer(inner: Inner) + final case class Inner(i: Int) + final case class Outer(inner: Inner) val ast = query[Outer].filter(t => t.inner.i == 1).ast val (norm, stmt, _) = SparkDialect.translate(ast, Quat.Unknown, ExecutionType.Unknown, IdiomContext.Empty)(Literal) norm mustEqual ast diff --git a/quill-spark/src/test/scala/io/getquill/context/spark/TypeMemberJoinSpec.scala b/quill-spark/src/test/scala/io/getquill/context/spark/TypeMemberJoinSpec.scala index a9a1dd3908..2b19cb2fe2 100644 --- a/quill-spark/src/test/scala/io/getquill/context/spark/TypeMemberJoinSpec.scala +++ b/quill-spark/src/test/scala/io/getquill/context/spark/TypeMemberJoinSpec.scala @@ -6,9 +6,9 @@ import org.apache.spark.sql.Dataset import scala.language.reflectiveCalls -case class Parent(name: String, childId: Int) -case class Child(name: String, id: Int) -case class GrandChild(name: String, parentId: Int) +final case class Parent(name: String, childId: Int) +final case class Child(name: String, id: Int) +final case class GrandChild(name: String, parentId: Int) class TypeMemberJoinSpec extends Spec { @@ -39,9 +39,9 @@ class TypeMemberJoinSpec extends Spec { } object Data { - val parent = Parent("Joe", 1) - val child = Child("Jack", 1) - val grandChild = GrandChild("James", 1) + val parent: Parent = Parent("Joe", 1) + val child: Child = Child("Jack", 1) + val grandChild: GrandChild = GrandChild("James", 1) } val parents = List(Data.parent).toDS val childrenBase = List(Data.child).toDS diff --git a/quill-spark/src/test/scala/io/getquill/context/spark/VariableShadowSpec.scala b/quill-spark/src/test/scala/io/getquill/context/spark/VariableShadowSpec.scala index 7b6e72ea96..7a345b1d15 100644 --- a/quill-spark/src/test/scala/io/getquill/context/spark/VariableShadowSpec.scala +++ b/quill-spark/src/test/scala/io/getquill/context/spark/VariableShadowSpec.scala @@ -2,37 +2,38 @@ package io.getquill.context.spark import io.getquill.Query import io.getquill.base.Spec +import io.getquill.Quoted -case class American(firstName: String, lastName: String, addressId: Int) -case class Address1(id: Int, street: String, city: String) -case class HumanoidLivingSomewhere(called: String, alsoCalled: String, whereHeLives_id: Int) +final case class American(firstName: String, lastName: String, addressId: Int) +final case class Address1(id: Int, street: String, city: String) +final case class HumanoidLivingSomewhere(called: String, alsoCalled: String, whereHeLives_id: Int) class VariableShadowSpec extends Spec { import sqlContext.implicits._ import testContext._ - val americansList = List( + val americansList: List[American] = List( American("John", "James", 1), American("Joe", "Bloggs", 2), American("Roe", "Roggs", 3) ) - val addressesList = List( + val addressesList: List[Address1] = List( Address1(1, "1st Ave", "New York"), Address1(2, "2st Ave", "New Jersey") ) - val americans = quote(liftQuery(americansList.toDS())) - val addresses = quote(liftQuery(addressesList.toDS())) + val americans: Quoted[Query[American]] = quote(liftQuery(americansList.toDS())) + val addresses: Quoted[Query[Address1]] = quote(liftQuery(addressesList.toDS())) - val addressToSomeone = quote { (hum: Query[HumanoidLivingSomewhere]) => + val addressToSomeone: Quoted[Query[HumanoidLivingSomewhere] => Query[HumanoidLivingSomewhere]] = quote { (hum: Query[HumanoidLivingSomewhere]) => for { t <- hum a <- addresses if (a.id == t.whereHeLives_id) } yield t } - val americanClients = quote { + val americanClients: Quoted[Query[HumanoidLivingSomewhere]] = quote { addressToSomeone(americans.map(a => HumanoidLivingSomewhere(a.firstName, a.lastName, a.addressId))) // hellooo } diff --git a/quill-spark/src/test/scala/io/getquill/context/spark/examples/GitHubExample.scala b/quill-spark/src/test/scala/io/getquill/context/spark/examples/GitHubExample.scala index 0073e708a7..3113f0e21c 100644 --- a/quill-spark/src/test/scala/io/getquill/context/spark/examples/GitHubExample.scala +++ b/quill-spark/src/test/scala/io/getquill/context/spark/examples/GitHubExample.scala @@ -11,8 +11,10 @@ import io.getquill.QuillSparkContext._ import scala.concurrent.ExecutionContext.Implicits._ import scala.concurrent.duration._ import scala.concurrent.{Await, Future} +import io.getquill.{ Query, Quoted } +import org.apache.spark.sql.SQLContext -case class User( +final case class User( id: String, login: String, gravatar_id: String, @@ -20,13 +22,13 @@ case class User( avatar_url: String ) -case class Repo( +final case class Repo( id: String, name: String, url: String ) -case class Activity( +final case class Activity( id: String, `type`: String, actor: User, @@ -37,7 +39,7 @@ case class Activity( object GitHubExample extends App { - val files = + val files: IndexedSeq[String] = for { year <- 2017 to 2017 month <- 10 to 10 @@ -45,7 +47,7 @@ object GitHubExample extends App { hour <- 0 to 23 } yield "%04d-%02d-%02d-%d".format(year, month, day, hour) - val f = Future.traverse(files) { name => + val f: Future[IndexedSeq[Any]] = Future.traverse(files) { name => Future { val file = new File(s"$name.json.gz") if (!file.exists()) { @@ -57,7 +59,7 @@ object GitHubExample extends App { Await.result(f, 30.seconds) - implicit val sqlContext = + implicit val sqlContext: SQLContext = SparkSession .builder() .master("local[*]") @@ -67,9 +69,9 @@ object GitHubExample extends App { import sqlContext.implicits._ - val activities = liftQuery(sqlContext.read.json(files.map(n => s"$n.json.gz"): _*).as[Activity]) + val activities: Quoted[Query[Activity]] = liftQuery(sqlContext.read.json(files.map(n => s"$n.json.gz"): _*).as[Activity]) - val topStargazers = quote { + val topStargazers: Quoted[Query[(String, Long)]] = quote { activities .groupBy(_.actor) .map { case (actor, list) => @@ -80,7 +82,7 @@ object GitHubExample extends App { }(Ord.desc) } - val topProjects = quote { + val topProjects: Quoted[Query[(String, Long)]] = quote { activities .filter(_.`type` == "WatchEvent") .groupBy(_.repo) diff --git a/quill-spark/src/test/scala/io/getquill/context/spark/examples/TopHashtagsExample.scala b/quill-spark/src/test/scala/io/getquill/context/spark/examples/TopHashtagsExample.scala index 92f605b18f..f6f11026f4 100644 --- a/quill-spark/src/test/scala/io/getquill/context/spark/examples/TopHashtagsExample.scala +++ b/quill-spark/src/test/scala/io/getquill/context/spark/examples/TopHashtagsExample.scala @@ -8,10 +8,11 @@ import org.apache.spark.sql.functions.{count => fcount, _} import io.getquill.QuillSparkContext._ import org.apache.spark.rdd.RDD import org.apache.spark.sql.Dataset +import org.apache.spark.sql.{ Row, SQLContext } object TopHashtagsExample extends App { - implicit val sqlContext = + implicit val sqlContext: SQLContext = SparkSession .builder() .master("local[*]") @@ -19,7 +20,7 @@ object TopHashtagsExample extends App { .getOrCreate() .sqlContext - case class Tweet(text: String) + final case class Tweet(text: String) import sqlContext.implicits._ @@ -80,12 +81,12 @@ object TopHashtagsExample extends App { } } - val tweets = List(Tweet("some #hashTAG #h2"), Tweet("dds #h2 #hashtag #h2 #h3")).toDS() + val tweets: Dataset[Tweet] = List(Tweet("some #hashTAG #h2"), Tweet("dds #h2 #hashtag #h2 #h3")).toDS() - val rddR = rdd.topHashtags(tweets.rdd, 10).toList - val dfR = dataframe.topHashtags(tweets.toDF(), 10).rdd.toLocalIterator.toList - val dsR = dataset.topHashtags(tweets, 10).rdd.toLocalIterator.toList - val qR = quill.topHashtags(tweets, 10).rdd.toLocalIterator.toList + val rddR: List[(String, BigInt)] = rdd.topHashtags(tweets.rdd, 10).toList + val dfR: List[Row] = dataframe.topHashtags(tweets.toDF(), 10).rdd.toLocalIterator.toList + val dsR: List[(String, BigInt)] = dataset.topHashtags(tweets, 10).rdd.toLocalIterator.toList + val qR: List[(String, Long)] = quill.topHashtags(tweets, 10).rdd.toLocalIterator.toList println("rddR: " + rddR) println("dfR: " + dfR) diff --git a/quill-spark/src/test/scala/io/getquill/context/spark/norm/ExpandEntityIdsSpec.scala b/quill-spark/src/test/scala/io/getquill/context/spark/norm/ExpandEntityIdsSpec.scala index 47f5537a34..583037e6e9 100644 --- a/quill-spark/src/test/scala/io/getquill/context/spark/norm/ExpandEntityIdsSpec.scala +++ b/quill-spark/src/test/scala/io/getquill/context/spark/norm/ExpandEntityIdsSpec.scala @@ -2,37 +2,38 @@ package io.getquill.context.spark.norm import io.getquill.base.Spec import io.getquill.context.spark.{sqlContext, testContext} +import io.getquill.{ Query, Quoted } -case class Test(i: Int, j: Int, s: String) -case class TestHolder(ta: Test, tb: Test) -case class TestHolderOtherData(ta: Test, otherData: String) -case class TestHolderHolder(tha: TestHolder, thb: TestHolder) -case class TestHolderHolderOneSide(tha: TestHolder, tbb: Test) -case class TupleHolderTest(tup: (Int, Int), otherData: String) -case class NestedTupleHolderTest(tup: (Int, Test), otherData: String) -case class ParentNestedTupleHolderTest(tup: NestedTupleHolderTest, otherData: String) -case class SuperParentNestedTupleHolderTest(tup: (NestedTupleHolderTest, Test), otherData: String) -case class SingleElement(i: Int) -case class SingleElementSingleHolder(sma: SingleElement) -case class SingleElementMultiHolder(t: Test, sm: SingleElement) +final case class Test(i: Int, j: Int, s: String) +final case class TestHolder(ta: Test, tb: Test) +final case class TestHolderOtherData(ta: Test, otherData: String) +final case class TestHolderHolder(tha: TestHolder, thb: TestHolder) +final case class TestHolderHolderOneSide(tha: TestHolder, tbb: Test) +final case class TupleHolderTest(tup: (Int, Int), otherData: String) +final case class NestedTupleHolderTest(tup: (Int, Test), otherData: String) +final case class ParentNestedTupleHolderTest(tup: NestedTupleHolderTest, otherData: String) +final case class SuperParentNestedTupleHolderTest(tup: (NestedTupleHolderTest, Test), otherData: String) +final case class SingleElement(i: Int) +final case class SingleElementSingleHolder(sma: SingleElement) +final case class SingleElementMultiHolder(t: Test, sm: SingleElement) class ExpandEntityIdsSpec extends Spec { import testContext._ import sqlContext.implicits._ - val ent = Test(1, 2, "3") - val entities = Seq(ent) + val ent: Test = Test(1, 2, "3") + val entities: Seq[Test] = Seq(ent) - val qr1 = liftQuery(entities.toDS) - val qr2 = liftQuery(entities.toDS) - val qr3 = liftQuery(entities.toDS) - val qr4 = liftQuery(entities.toDS) + val qr1: Quoted[Query[Test]] = liftQuery(entities.toDS) + val qr2: Quoted[Query[Test]] = liftQuery(entities.toDS) + val qr3: Quoted[Query[Test]] = liftQuery(entities.toDS) + val qr4: Quoted[Query[Test]] = liftQuery(entities.toDS) - val s0 = liftQuery(Seq(Tuple1(1), Tuple1(2)).toDS) - val s1 = liftQuery(Seq(SingleElement(1), SingleElement(2)).toDS) - val s2 = liftQuery(Seq(SingleElementSingleHolder(SingleElement(1)), SingleElementSingleHolder(SingleElement(2))).toDS) - val s3 = liftQuery( + val s0: Quoted[Query[Tuple1[Int]]] = liftQuery(Seq(Tuple1(1), Tuple1(2)).toDS) + val s1: Quoted[Query[SingleElement]] = liftQuery(Seq(SingleElement(1), SingleElement(2)).toDS) + val s2: Quoted[Query[SingleElementSingleHolder]] = liftQuery(Seq(SingleElementSingleHolder(SingleElement(1)), SingleElementSingleHolder(SingleElement(2))).toDS) + val s3: Quoted[Query[SingleElementMultiHolder]] = liftQuery( Seq( SingleElementMultiHolder(Test(1, 2, "3"), SingleElement(1)), SingleElementMultiHolder(Test(1, 2, "3"), SingleElement(2)) diff --git a/quill-spark/src/test/scala/io/getquill/context/spark/norm/QuestionMarkEscaperSpec.scala b/quill-spark/src/test/scala/io/getquill/context/spark/norm/QuestionMarkEscaperSpec.scala index 4658227f7e..9c5e20826f 100644 --- a/quill-spark/src/test/scala/io/getquill/context/spark/norm/QuestionMarkEscaperSpec.scala +++ b/quill-spark/src/test/scala/io/getquill/context/spark/norm/QuestionMarkEscaperSpec.scala @@ -14,14 +14,14 @@ class QuestionMarkEscaperSpec extends Spec { unescape(escape(str)) must equal(str) } - def plug1(str: String) = pluginValueSafe(str, "<1>") - def plug2(str: String) = pluginValueSafe(plug1(str), "<2>") - def plug3(str: String) = pluginValueSafe(plug2(str), "<3>") - def plug4(str: String) = pluginValueSafe(plug3(str), "<4>") - - def plug2Q(str: String) = pluginValueSafe(plug1(str), "<2?>") - def plug3QN(str: String) = pluginValueSafe(plug2Q(str), "<3>") - def plug4Q(str: String) = pluginValueSafe(plug3QN(str), "<4?>") + def plug1(str: String): String = pluginValueSafe(str, "<1>") + def plug2(str: String): String = pluginValueSafe(plug1(str), "<2>") + def plug3(str: String): String = pluginValueSafe(plug2(str), "<3>") + def plug4(str: String): String = pluginValueSafe(plug3(str), "<4>") + + def plug2Q(str: String): String = pluginValueSafe(plug1(str), "<2?>") + def plug3QN(str: String): String = pluginValueSafe(plug2Q(str), "<3>") + def plug4Q(str: String): String = pluginValueSafe(plug3QN(str), "<4?>") "should escape and replace variables correctly" in { val str = "foo ? bar ? ?" diff --git a/quill-spark/src/test/scala/io/getquill/context/spark/package.scala b/quill-spark/src/test/scala/io/getquill/context/spark/package.scala index 8458701a43..ef8bc0268e 100644 --- a/quill-spark/src/test/scala/io/getquill/context/spark/package.scala +++ b/quill-spark/src/test/scala/io/getquill/context/spark/package.scala @@ -5,7 +5,7 @@ import io.getquill.QuillSparkContext package object spark { - val sparkSession = + val sparkSession: SparkSession = SparkSession .builder() .config("spark.sql.shuffle.partitions", 2) // Default shuffle partitions is 200, too much for tests diff --git a/quill-sql/src/test/scala/io/getquill/context/sql/AggregationSpec.scala b/quill-sql/src/test/scala/io/getquill/context/sql/AggregationSpec.scala index fedca52c96..a6d44292db 100644 --- a/quill-sql/src/test/scala/io/getquill/context/sql/AggregationSpec.scala +++ b/quill-sql/src/test/scala/io/getquill/context/sql/AggregationSpec.scala @@ -12,7 +12,7 @@ class AggregationSpec extends Spec { // remove the === matcher from scalatest so that we can test === in Context.extra override def convertToEqualizer[T](left: T): Equalizer[T] = new Equalizer(left) - val ctx = new SqlMirrorContext(MirrorSqlDialect, Literal) with TestEntities + val ctx: SqlMirrorContext[MirrorSqlDialect.type,Literal.type] with TestEntities = new SqlMirrorContext(MirrorSqlDialect, Literal) with TestEntities import ctx._ // an issue heavily related to the ability to use an aggregator and then a .nested after which @@ -168,7 +168,7 @@ class AggregationSpec extends Spec { "SELECT p.x FROM (SELECT MAX(p.age) AS x FROM (SELECT p.age FROM Person p) AS p GROUP BY p.age) AS p WHERE p.x > 1000" } - case class NameAge(name: String, age: Int) + final case class NameAge(name: String, age: Int) "work with map(product).filter.groupByMap.filter" in { ctx.run { @@ -192,9 +192,9 @@ class AggregationSpec extends Spec { } "work in a for-comprehension" in { // // - case class Address(id: Int, owner: Int, street: String) - case class Furniture(owner: Int, location: Int) - case class PersonInfo(id: Int, maxAge: Int) + final case class Address(id: Int, owner: Int, street: String) + final case class Furniture(owner: Int, location: Int) + final case class PersonInfo(id: Int, maxAge: Int) import extras._ ctx.run { diff --git a/quill-sql/src/test/scala/io/getquill/context/sql/DistinctSpec.scala b/quill-sql/src/test/scala/io/getquill/context/sql/DistinctSpec.scala index dca50343f6..71a5850d52 100644 --- a/quill-sql/src/test/scala/io/getquill/context/sql/DistinctSpec.scala +++ b/quill-sql/src/test/scala/io/getquill/context/sql/DistinctSpec.scala @@ -15,7 +15,7 @@ trait DistinctSpec extends Spec { val peopleInsert = quote((p: Person) => query[Person].insertValue(p)) - val peopleEntries = List( + val peopleEntries: List[Person] = List( Person("A", 1), Person("B", 2), Person("X", 10), @@ -26,7 +26,7 @@ trait DistinctSpec extends Spec { val couplesInsert = quote((c: Couple) => query[Couple].insertValue(c)) - val couplesEntries = List( + val couplesEntries: List[Couple] = List( Couple("B", "X"), Couple("B", "Y"), Couple("B", "Z"), diff --git a/quill-sql/src/test/scala/io/getquill/context/sql/EmbeddedSpec.scala b/quill-sql/src/test/scala/io/getquill/context/sql/EmbeddedSpec.scala index 9d40fe0fa4..b81d428b9b 100644 --- a/quill-sql/src/test/scala/io/getquill/context/sql/EmbeddedSpec.scala +++ b/quill-sql/src/test/scala/io/getquill/context/sql/EmbeddedSpec.scala @@ -5,13 +5,13 @@ import io.getquill.base.Spec class EmbeddedSpec extends Spec { - val ctx = new SqlMirrorContext(MirrorSqlDialect, Literal) with TestEntities + val ctx: SqlMirrorContext[MirrorSqlDialect.type,Literal.type] with TestEntities = new SqlMirrorContext(MirrorSqlDialect, Literal) with TestEntities import ctx._ "queries with embedded entities should" - { "function property inside of nested distinct queries" in { - case class Parent(id: Int, emb1: Emb) - case class Emb(a: Int, b: Int) + final case class Parent(id: Int, emb1: Emb) + final case class Emb(a: Int, b: Int) val q = quote { query[Emb].map(e => Parent(1, e)).distinct } @@ -19,8 +19,8 @@ class EmbeddedSpec extends Spec { } "function property inside of nested distinct queries - tuple" in { - case class Parent(id: Int, emb1: Emb) - case class Emb(a: Int, b: Int) + final case class Parent(id: Int, emb1: Emb) + final case class Emb(a: Int, b: Int) val q = quote { query[Emb].map(e => Parent(1, e)).distinct.map(p => (2, p)).distinct } @@ -28,8 +28,8 @@ class EmbeddedSpec extends Spec { } "function property inside of nested distinct queries through tuples" in { - case class Parent(id: Int, emb1: Emb) - case class Emb(a: Int, b: Int) + final case class Parent(id: Int, emb1: Emb) + final case class Emb(a: Int, b: Int) val q = quote { query[Emb].map(e => (1, e)).distinct.map(t => Parent(t._1, t._2)).distinct } @@ -37,9 +37,9 @@ class EmbeddedSpec extends Spec { } "function property inside of nested distinct queries - twice" in { - case class Grandparent(idG: Int, par: Parent) - case class Parent(idP: Int, emb1: Emb) - case class Emb(a: Int, b: Int) + final case class Grandparent(idG: Int, par: Parent) + final case class Parent(idP: Int, emb1: Emb) + final case class Emb(a: Int, b: Int) val q = quote { query[Emb].map(e => Parent(1, e)).distinct.map(p => Grandparent(2, p)).distinct } @@ -47,9 +47,9 @@ class EmbeddedSpec extends Spec { } "function property inside of nested distinct queries - twice - into tuple" in { - case class Grandparent(idG: Int, par: Parent) - case class Parent(idP: Int, emb1: Emb) - case class Emb(a: Int, b: Int) + final case class Grandparent(idG: Int, par: Parent) + final case class Parent(idP: Int, emb1: Emb) + final case class Emb(a: Int, b: Int) val q = quote { query[Emb].map(e => Parent(1, e)).distinct.map(p => Grandparent(2, p)).distinct.map(g => (3, g)).distinct } diff --git a/quill-sql/src/test/scala/io/getquill/context/sql/EncodingSpec.scala b/quill-sql/src/test/scala/io/getquill/context/sql/EncodingSpec.scala index 8bdc3b3527..108a1115d2 100644 --- a/quill-sql/src/test/scala/io/getquill/context/sql/EncodingSpec.scala +++ b/quill-sql/src/test/scala/io/getquill/context/sql/EncodingSpec.scala @@ -2,12 +2,9 @@ package io.getquill.context.sql import io.getquill.base.Spec -import java.time import java.time.{ - Instant, LocalDate, LocalDateTime, - LocalTime, OffsetDateTime, OffsetTime, ZoneId, @@ -15,10 +12,12 @@ import java.time.{ ZonedDateTime } import java.util.{Date, UUID} +import io.getquill.{ Delete, Quoted } +import org.scalatest.Assertion -case class EncodingTestType(value: String) +final case class EncodingTestType(value: String) -case class Number(value: String) extends AnyVal +final case class Number(value: String) extends AnyVal object Number { def withValidation(value: String): Option[Number] = @@ -65,12 +64,12 @@ trait EncodingSpec extends Spec { object TimeEntity { case class TimeEntityInput(year: Int, month: Int, day: Int, hour: Int, minute: Int, second: Int, nano: Int) { - def toLocalDate = LocalDateTime.of(year, month, day, hour, minute, second, nano) + def toLocalDate: LocalDateTime = LocalDateTime.of(year, month, day, hour, minute, second, nano) } object TimeEntityInput { def default = new TimeEntityInput(2022, 1, 2, 3, 4, 6, 0) } - def make(zoneIdRaw: ZoneId, timeEntity: TimeEntityInput = TimeEntityInput.default) = { + def make(zoneIdRaw: ZoneId, timeEntity: TimeEntityInput = TimeEntityInput.default): TimeEntity = { val zoneId = zoneIdRaw.normalized() // Millisecond precisions in SQL Server and many contexts are wrong so not using them val nowInstant = timeEntity.toLocalDate.atZone(zoneId).toInstant @@ -125,7 +124,7 @@ trait EncodingSpec extends Spec { o15: Option[Number] ) - val delete = quote { + val delete: Quoted[Delete[EncodingTestEntity]] = quote { query[EncodingTestEntity].delete } @@ -133,7 +132,7 @@ trait EncodingSpec extends Spec { query[EncodingTestEntity].insertValue(e) } - val insertValues = + val insertValues: Seq[EncodingTestEntity] = Seq( EncodingTestEntity( "s", @@ -199,7 +198,7 @@ trait EncodingSpec extends Spec { ) ) - def verify(result: List[EncodingTestEntity]) = { + def verify(result: List[EncodingTestEntity]): Unit = { result.size mustEqual insertValues.size result.zip(insertValues).foreach { case (e1, e2) => e1.v1 mustEqual e2.v1 @@ -238,9 +237,9 @@ trait EncodingSpec extends Spec { case class BarCode(description: String, uuid: Option[UUID] = None) val insertBarCode = quote((b: BarCode) => query[BarCode].insertValue(b).returningGenerated(_.uuid)) - val barCodeEntry = BarCode("returning UUID") + val barCodeEntry: BarCode = BarCode("returning UUID") def findBarCodeByUuid(uuid: UUID) = quote(query[BarCode].filter(_.uuid.forall(_ == lift(uuid)))) - def verifyBarcode(barCode: BarCode) = barCode.description mustEqual "returning UUID" + def verifyBarcode(barCode: BarCode): Assertion = barCode.description mustEqual "returning UUID" } diff --git a/quill-sql/src/test/scala/io/getquill/context/sql/GroupBySpec.scala b/quill-sql/src/test/scala/io/getquill/context/sql/GroupBySpec.scala index 170ed53018..56e7f11e78 100644 --- a/quill-sql/src/test/scala/io/getquill/context/sql/GroupBySpec.scala +++ b/quill-sql/src/test/scala/io/getquill/context/sql/GroupBySpec.scala @@ -6,14 +6,14 @@ import io.getquill.base.Spec import io.getquill.context.sql.util.StringOps._ class GroupBySpec extends Spec { - implicit val naming = new Literal {} + implicit val naming: Literal = new Literal {} import io.getquill.norm.{DisablePhase, OptionalPhase} import io.getquill.norm.ConfigList._ "groupBy table expansion" - { - case class Country(id: Int, name: String) - case class City(name: String, countryId: Int) + final case class Country(id: Int, name: String) + final case class City(name: String, countryId: Int) "basic" in { val q = quote( @@ -71,9 +71,9 @@ class GroupBySpec extends Spec { } "Embedded entity expansion" - { - case class Language(name: String, dialect: String) - case class Country(countryCode: String, language: Language) - case class City(countryCode: String, name: String) + final case class Language(name: String, dialect: String) + final case class Country(countryCode: String, language: Language) + final case class City(countryCode: String, name: String) "simple" in { val q = quote( @@ -201,8 +201,8 @@ class GroupBySpec extends Spec { } "after join" in { - case class CountryLanguage(countryCode: String, language: String) - case class City(id: Int, name: String, countryCode: String) + final case class CountryLanguage(countryCode: String, language: String) + final case class City(id: Int, name: String, countryCode: String) val q = quote( query[City] @@ -216,7 +216,7 @@ class GroupBySpec extends Spec { } "map(transform).groupBy should work with" - { - case class Person(id: Int, name: String, age: Int) + final case class Person(id: Int, name: String, age: Int) "work with a groupBy(to-leaf).map.filter" in { testContext.run { diff --git a/quill-sql/src/test/scala/io/getquill/context/sql/InfixSpec.scala b/quill-sql/src/test/scala/io/getquill/context/sql/InfixSpec.scala index d638a1db88..a9b39b7187 100644 --- a/quill-sql/src/test/scala/io/getquill/context/sql/InfixSpec.scala +++ b/quill-sql/src/test/scala/io/getquill/context/sql/InfixSpec.scala @@ -5,8 +5,6 @@ import io.getquill.MirrorSqlDialect import io.getquill.TestEntities import io.getquill.Literal import io.getquill.base.Spec -import io.getquill.norm.EnableTrace -import io.getquill.util.Messages.TraceType class InfixSpec extends Spec { // // @@ -15,8 +13,8 @@ class InfixSpec extends Spec { // // val ctx = new SqlMirrorContext(MirrorSqlDialect, Literal) with TestEntities import ctx._ - case class Data(id: Int) - case class TwoValue(id: Int, value: Int) + final case class Data(id: Int) + final case class TwoValue(id: Int, value: Int) "preserve nesting where needed" in { val q = quote { @@ -36,7 +34,7 @@ class InfixSpec extends Spec { // // "preserve nesting with single value" in { val q = quote { - query[Data].map(e => sql"RAND()".as[Int]).filter(r => r > 10).map(r => r + 1) + query[Data].map(_ => sql"RAND()".as[Int]).filter(r => r > 10).map(r => r + 1) } ctx.run(q).string mustEqual "SELECT e.x + 1 FROM (SELECT RAND() AS x FROM Data e) AS e WHERE e.x > 10" } @@ -54,14 +52,14 @@ class InfixSpec extends Spec { // // "preserve nesting with single value binary op" in { val q = quote { - query[Data].map(e => sql"RAND()".as[Int] + 1).filter(r => r > 10).map(r => r + 1) + query[Data].map(_ => sql"RAND()".as[Int] + 1).filter(r => r > 10).map(r => r + 1) } ctx.run(q).string mustEqual "SELECT e.x + 1 FROM (SELECT RAND() + 1 AS x FROM Data e) AS e WHERE e.x > 10" } "preserve nesting with single value unary op" in { val q = quote { - query[Data].map(e => !sql"RAND()".as[Boolean]).filter(r => r == true).map(r => !r) + query[Data].map(_ => !sql"RAND()".as[Boolean]).filter(r => r == true).map(r => !r) } ctx.run(q).string mustEqual "SELECT NOT (e.x) FROM (SELECT NOT (RAND()) AS x FROM Data e) AS e WHERE e.x = true" } @@ -88,7 +86,7 @@ class InfixSpec extends Spec { // // } "preserve nesting of query in query" in { - case class ThreeData(id: Int, value: Int, secondValue: Int) + final case class ThreeData(id: Int, value: Int, secondValue: Int) val q1 = quote { for { @@ -105,7 +103,7 @@ class InfixSpec extends Spec { // // } "excluded infix values" - { - case class Person(id: Int, name: String, other: String, other2: String) + final case class Person(id: Int, name: String, other: String, other2: String) "should not be dropped" in { val q = quote { diff --git a/quill-sql/src/test/scala/io/getquill/context/sql/NestedDistinctSpec.scala b/quill-sql/src/test/scala/io/getquill/context/sql/NestedDistinctSpec.scala index b0e8a8cc8a..c6d67bbb73 100644 --- a/quill-sql/src/test/scala/io/getquill/context/sql/NestedDistinctSpec.scala +++ b/quill-sql/src/test/scala/io/getquill/context/sql/NestedDistinctSpec.scala @@ -13,8 +13,8 @@ class NestedDistinctSpec extends Spec { import ctx._ "first operation" - { - case class MyEmb(name: String) - case class MyParent(myEmb: MyEmb) + final case class MyEmb(name: String) + final case class MyParent(myEmb: MyEmb) "first operation nesting with filter" in { val q = quote { @@ -47,8 +47,8 @@ class NestedDistinctSpec extends Spec { } "first operation nesting with filter before and after - groupBy" in { // hello - case class MyEmb(name: Int) - case class MyParent(myEmb: MyEmb) + final case class MyEmb(name: Int) + final case class MyParent(myEmb: MyEmb) val q = quote { query[MyParent] @@ -120,8 +120,8 @@ class NestedDistinctSpec extends Spec { } "works with querySchema" in { - case class SimpleEnt(a: Int, b: String) - case class SimpleEnt2(aa: Int, bb: String) + final case class SimpleEnt(a: Int, b: String) + final case class SimpleEnt2(aa: Int, bb: String) val qschema = quote { querySchema[SimpleEnt]("CustomEnt", _.a -> "field_a") @@ -138,8 +138,8 @@ class NestedDistinctSpec extends Spec { } "works with explicitly nested infixes" in { - case class SimpleEnt(a: Int, b: String) - case class SimpleEnt2(aa: Int, bb: String) + final case class SimpleEnt(a: Int, b: String) + final case class SimpleEnt2(aa: Int, bb: String) val qschema = quote { querySchema[SimpleEnt]("CustomEnt", _.a -> "field_a") @@ -157,8 +157,8 @@ class NestedDistinctSpec extends Spec { } "works with implicitly nested infixes" in { - case class SimpleEnt(a: Int, b: String) - case class SimpleEnt2(aa: Int, bb: String) + final case class SimpleEnt(a: Int, b: String) + final case class SimpleEnt2(aa: Int, bb: String) val qschema = quote { querySchema[SimpleEnt]("CustomEnt", _.a -> "field_a") @@ -175,8 +175,8 @@ class NestedDistinctSpec extends Spec { } "embedded entity from parent" - { - case class Emb(id: Int, name: String) - case class Parent(idP: Int, emb: Emb) + final case class Emb(id: Int, name: String) + final case class Parent(idP: Int, emb: Emb) implicit val parentMeta = schemaMeta[Parent]("Parent", _.emb.name -> "theName") "embedded can be propagated across distinct inside tuple with naming intact" in { @@ -188,7 +188,7 @@ class NestedDistinctSpec extends Spec { } "embedded can be propagated across distinct inside case class with naming intact" in { - case class SuperParent(emb: Emb, id: Int) + final case class SuperParent(emb: Emb, id: Int) val q = quote { query[Parent].map(p => SuperParent(p.emb, 1)).distinct.map(e => (e.emb.name, e.emb.id)) @@ -264,9 +264,9 @@ class NestedDistinctSpec extends Spec { } "double embedded entity from parent" - { - case class Emb(id: Int, name: String) - case class Parent(id: Int, name: String, emb: Emb) - case class GrandParent(id: Int, par: Parent) + final case class Emb(id: Int, name: String) + final case class Parent(id: Int, name: String, emb: Emb) + final case class GrandParent(id: Int, par: Parent) implicit val parentMeta = schemaMeta[GrandParent]("GrandParent", _.par.emb.name -> "theName", _.par.name -> "theParentName") @@ -662,9 +662,9 @@ class NestedDistinctSpec extends Spec { "adversarial tests" - { "should correctly rename the right property when multiple nesting layers have the same one" in { - case class Emb(name: String, id: Int) - case class Parent(name: String, emb1: Emb, emb2: Emb) - case class GrandParent(name: String, par: Parent) + final case class Emb(name: String, id: Int) + final case class Parent(name: String, emb1: Emb, emb2: Emb) + final case class GrandParent(name: String, par: Parent) val norm = quote(query[Emb]) val mod = quote(querySchema[Emb]("CustomEmb", _.name -> "theName")) @@ -691,9 +691,9 @@ class NestedDistinctSpec extends Spec { } "entities re-ordered in a subschema should have correct naming" in { - case class Ent(name: String) - case class Foo(fame: String) - case class Bar(bame: String) + final case class Ent(name: String) + final case class Foo(fame: String) + final case class Bar(bame: String) implicit val entSchema = schemaMeta[Ent]("TheEnt", _.name -> "theName") @@ -741,9 +741,9 @@ class NestedDistinctSpec extends Spec { } "entities swapped in a subschema should have correct naming" in { // This was a big issue with previous implementation of RenameProperties. See #1618 for more detail. - case class Ent(name: String) - case class WrongEnt(name: String) - case class Bar(bame: String) + final case class Ent(name: String) + final case class WrongEnt(name: String) + final case class Bar(bame: String) implicit val entSchema = schemaMeta[Ent]("TheEnt", _.name -> "theName") // helloooooooooo @@ -794,9 +794,9 @@ class NestedDistinctSpec extends Spec { } "query with single embedded element" - { - case class Emb(a: Int, b: Int) - case class Parent(id: Int, emb1: Emb) - case class Parent2(emb1: Emb, id: Int) + final case class Emb(a: Int, b: Int) + final case class Parent(id: Int, emb1: Emb) + final case class Parent2(emb1: Emb, id: Int) "should not use override from parent schema level - single" in { implicit val parentSchema = schemaMeta[Parent]("ParentTable", _.emb1.a -> "field_a") @@ -850,13 +850,13 @@ class NestedDistinctSpec extends Spec { } "query with multiple embedded elements with same names" - { - case class Emb(name: String, id: Int) - case class Parent(name: String, emb1: Emb, emb2: Emb) - case class GrandParent(name: String, par: Parent) + final case class Emb(name: String, id: Int) + final case class Parent(name: String, emb1: Emb, emb2: Emb) + final case class GrandParent(name: String, par: Parent) - case class One(name: String, id: Int) - case class Two(name: String, id: Int) - case class Dual(one: One, two: Two) + final case class One(name: String, id: Int) + final case class Two(name: String, id: Int) + final case class Dual(one: One, two: Two) // Try parent and embedded children with same name, schema on parent "schema on parent should not override children" in { diff --git a/quill-sql/src/test/scala/io/getquill/context/sql/OptionQuerySpec.scala b/quill-sql/src/test/scala/io/getquill/context/sql/OptionQuerySpec.scala index 8184e74dd6..2798f5d52c 100644 --- a/quill-sql/src/test/scala/io/getquill/context/sql/OptionQuerySpec.scala +++ b/quill-sql/src/test/scala/io/getquill/context/sql/OptionQuerySpec.scala @@ -1,6 +1,7 @@ package io.getquill.context.sql import io.getquill.base.Spec +import io.getquill.Quoted trait OptionQuerySpec extends Spec { @@ -17,7 +18,7 @@ trait OptionQuerySpec extends Spec { val peopleInsert = quote((p: Contact) => query[Contact].insertValue(p)) - val peopleEntries = List( + val peopleEntries: List[Contact] = List( Contact("Alex", "Jones", 60, Option(1), "foo"), Contact("Bert", "James", 55, Option(2), "bar"), Contact("Cora", "Jasper", 33, None, "baz") @@ -26,7 +27,7 @@ trait OptionQuerySpec extends Spec { val addressInsert = quote((c: Address) => query[Address].insertValue(c)) - val addressEntries = List( + val addressEntries: List[Address] = List( Address(1, "123 Fake Street", 11234, Some("something")), Address(2, "456 Old Street", 45678, Some("something else")), Address(3, "789 New Street", 89010, None), @@ -35,7 +36,7 @@ trait OptionQuerySpec extends Spec { val taskInsert = quote((t: Task) => query[Task].insertValue(t)) - val taskEntries = List( + val taskEntries: List[Task] = List( Task(Some("Feed the dogs"), Some("Feed the cats")), Task(Some("Feed the dogs"), None), Task(None, Some("Feed the cats")), @@ -119,7 +120,7 @@ trait OptionQuerySpec extends Spec { case class NormalizedContact(name: String, addressFk: Option[Int]) - def normalizeAddress = quote { (addressFk: Option[Int]) => + def normalizeAddress: Quoted[Option[Int] => Int] = quote { (addressFk: Option[Int]) => addressFk.getOrElse(111) } diff --git a/quill-sql/src/test/scala/io/getquill/context/sql/OptionSqlSpec.scala b/quill-sql/src/test/scala/io/getquill/context/sql/OptionSqlSpec.scala index a18b3e4665..00ee8b187a 100644 --- a/quill-sql/src/test/scala/io/getquill/context/sql/OptionSqlSpec.scala +++ b/quill-sql/src/test/scala/io/getquill/context/sql/OptionSqlSpec.scala @@ -1,7 +1,7 @@ package io.getquill.context.sql import io.getquill.base.Spec -import io.getquill.{MirrorSqlDialectWithBooleanLiterals, Query, Quoted} +import io.getquill.MirrorSqlDialectWithBooleanLiterals class OptionSqlSpec extends Spec { import testContext._ @@ -50,7 +50,7 @@ class OptionSqlSpec extends Spec { "SELECT s1.name FROM Someone q INNER JOIN Someone s1 ON s1.name IS NULL AND q.name IS NULL OR s1.name = q.name" } - case class Node(name: String, uptime: Long) + final case class Node(name: String, uptime: Long) "table foreach" in { testContext.run(query[Node].map(n => Some(n)).map(n => n.exists(nn => nn.uptime > 123))).string mustEqual diff --git a/quill-sql/src/test/scala/io/getquill/context/sql/OrderBySpec.scala b/quill-sql/src/test/scala/io/getquill/context/sql/OrderBySpec.scala index 3593ede20b..60e18dc9c9 100644 --- a/quill-sql/src/test/scala/io/getquill/context/sql/OrderBySpec.scala +++ b/quill-sql/src/test/scala/io/getquill/context/sql/OrderBySpec.scala @@ -5,7 +5,7 @@ import io.getquill.base.Spec class OrderBySpec extends Spec { - implicit val naming = new Literal {} + implicit val naming: Literal = new Literal {} case class Country(id: Int, name: String) case class City(name: String, countryId: Int) diff --git a/quill-sql/src/test/scala/io/getquill/context/sql/PrepareSpec.scala b/quill-sql/src/test/scala/io/getquill/context/sql/PrepareSpec.scala index a77a6107e9..4ce4a08663 100644 --- a/quill-sql/src/test/scala/io/getquill/context/sql/PrepareSpec.scala +++ b/quill-sql/src/test/scala/io/getquill/context/sql/PrepareSpec.scala @@ -48,7 +48,7 @@ class PrepareSpec extends Spec { "with outer join" in { val q = quote { for { - (a, b) <- qr1 join qr2 on ((a, b) => a.i == a.i) + (a, b) <- qr1 join qr2 on ((a, _) => a.i == a.i) c <- qr1 rightJoin (c => c.i == a.i) } yield (a, b, c.map(c => c.i)) } diff --git a/quill-sql/src/test/scala/io/getquill/context/sql/ProductSpec.scala b/quill-sql/src/test/scala/io/getquill/context/sql/ProductSpec.scala index 8c70cc3a3f..867dde11d3 100644 --- a/quill-sql/src/test/scala/io/getquill/context/sql/ProductSpec.scala +++ b/quill-sql/src/test/scala/io/getquill/context/sql/ProductSpec.scala @@ -2,8 +2,9 @@ package io.getquill.context.sql import io.getquill.Query import io.getquill.base.Spec +import io.getquill.{ ActionReturning, EntityQuery, Quoted } -case class Id(value: Long) extends AnyVal +final case class Id(value: Long) extends AnyVal trait ProductSpec extends Spec { @@ -13,7 +14,7 @@ trait ProductSpec extends Spec { case class Product(id: Long, description: String, sku: Long) - val product = quote { + val product: Quoted[EntityQuery[Product]] = quote { query[Product] } @@ -25,17 +26,17 @@ trait ProductSpec extends Spec { b.foreach(p => productInsert.apply(p)) } - def productById = quote { (id: Long) => + def productById: Quoted[Long => EntityQuery[Product]] = quote { (id: Long) => product.filter(_.id == id) } - val productEntries = List( + val productEntries: List[Product] = List( Product(0L, "Notebook", 1001L), Product(0L, "Soap", 1002L), Product(0L, "Pencil", 1003L) ) - val productSingleInsert = quote { + val productSingleInsert: Quoted[ActionReturning[Product,Long]] = quote { product.insert(_.id -> 0, _.description -> "Window", _.sku -> 1004L).returningGenerated(_.id) } } diff --git a/quill-sql/src/test/scala/io/getquill/context/sql/QuerySchemaSpec.scala b/quill-sql/src/test/scala/io/getquill/context/sql/QuerySchemaSpec.scala index af637c029f..aab5e7a9fe 100644 --- a/quill-sql/src/test/scala/io/getquill/context/sql/QuerySchemaSpec.scala +++ b/quill-sql/src/test/scala/io/getquill/context/sql/QuerySchemaSpec.scala @@ -5,11 +5,11 @@ import io.getquill.{Literal, PostgresDialect, SqlMirrorContext, TestEntities} class QuerySchemaSpec extends Spec { - val ctx = new SqlMirrorContext(PostgresDialect, Literal) with TestEntities + val ctx: SqlMirrorContext[PostgresDialect.type,Literal.type] with TestEntities = new SqlMirrorContext(PostgresDialect, Literal) with TestEntities import ctx._ "OnConflict Should work correct with" - { - case class Person(id: Long, name: String) + final case class Person(id: Long, name: String) val p = Person(1, "Joe") "querySchema" in { diff --git a/quill-sql/src/test/scala/io/getquill/context/sql/SqlActionMacroSpec.scala b/quill-sql/src/test/scala/io/getquill/context/sql/SqlActionMacroSpec.scala index 79550bd60d..f8e17a6270 100644 --- a/quill-sql/src/test/scala/io/getquill/context/sql/SqlActionMacroSpec.scala +++ b/quill-sql/src/test/scala/io/getquill/context/sql/SqlActionMacroSpec.scala @@ -107,15 +107,15 @@ class SqlActionMacroSpec extends Spec { mirror.string mustEqual "INSERT INTO TestEntity DEFAULT VALUES" mirror.returningBehavior mustEqual ReturnColumns(List("s", "i", "l", "o", "b")) } - "multi - should fail on operation" in testContext.withDialect(MirrorSqlDialectWithReturnMulti) { ctx => + "multi - should fail on operation" in testContext.withDialect(MirrorSqlDialectWithReturnMulti) { _ => """import ctx._; quote { qr1.insert(lift(TestEntity("s", 0, 1L, None))).returningGenerated(r => (r.i, r.l + 1)) }""" mustNot compile } "multi - should fail on operation inside case class" in testContext.withDialect(MirrorSqlDialectWithReturnMulti) { - ctx => - case class Foo(one: Int, two: Long) + _ => + final case class Foo(one: Int, two: Long) """import ctx._; quote { qr1.insert(lift(TestEntity("s", 0, 1L, None))).returningGenerated(r => Foo(r.i, r.l + 1)) }""" mustNot compile } - "no return - should fail on property" in testContext.withDialect(MirrorSqlDialectWithNoReturn) { ctx => + "no return - should fail on property" in testContext.withDialect(MirrorSqlDialectWithNoReturn) { _ => """import ctx._; quote { qr1.insert(lift(TestEntity("s", 0, 1L, None))).returningGenerated(r => r.i) }""" mustNot compile } "returning clause - single" in testContext.withDialect(MirrorSqlDialectWithReturnClause) { ctx => @@ -174,7 +174,7 @@ class SqlActionMacroSpec extends Spec { mirror.returningBehavior mustEqual ReturnRecord } "returning clause - embedded" - { - case class Dummy(i: Int) + final case class Dummy(i: Int) "embedded property" in testContext.withDialect(MirrorSqlDialectWithReturnClause) { ctx => // import ctx._ @@ -209,16 +209,16 @@ class SqlActionMacroSpec extends Spec { } } "with returning clause - query" - { - case class Dummy(i: Int) - case class DummyS(s: String) - case class Dummy2(i: Int, s: String) + final case class Dummy(i: Int) + final case class DummyS(s: String) + final case class Dummy2(i: Int, s: String) "simple not using id - id not excluded" in testContext.withDialect(MirrorSqlDialectWithReturnClause) { ctx => import ctx._ val q = quote { qr1 .insertValue(lift(TestEntity("s", 0, 1L, None, true))) - .returningGenerated(r => (query[Dummy].map(d => d.i).value)) + .returningGenerated(_ => (query[Dummy].map(d => d.i).value)) } val mirror = ctx.run(q) mirror.string mustEqual "INSERT INTO TestEntity AS r (s,i,l,o,b) VALUES (?, ?, ?, ?, ?) RETURNING (SELECT d.i FROM Dummy d)" @@ -279,7 +279,7 @@ class SqlActionMacroSpec extends Spec { val q = quote { qr1 .insertValue(lift(TestEntity("s", 0, 1L, None, true))) - .returningGenerated(r => (query[Dummy].filter(r => r.i == lift(value)).max)) + .returningGenerated(_ => (query[Dummy].filter(r => r.i == lift(value)).max)) } val mirror = ctx.run(q) mirror.string mustEqual "INSERT INTO TestEntity AS r (s,i,l,o,b) VALUES (?, ?, ?, ?, ?) RETURNING (SELECT MAX(r1.*) FROM Dummy r1 WHERE r1.i = ?)" @@ -291,7 +291,7 @@ class SqlActionMacroSpec extends Spec { val q = quote { qr1 .insertValue(lift(TestEntity("s", 0, 1L, None, true))) - .returningGenerated(r => (query[Dummy].map(r => r.i).max)) + .returningGenerated(_ => (query[Dummy].map(r => r.i).max)) } val mirror = ctx.run(q) mirror.string mustEqual "INSERT INTO TestEntity AS r (s,i,l,o,b) VALUES (?, ?, ?, ?, ?) RETURNING (SELECT MAX(r1.i) FROM Dummy r1)" @@ -302,7 +302,7 @@ class SqlActionMacroSpec extends Spec { val q = quote { qr1 .insertValue(lift(TestEntity("s", 0, 1L, None, true))) - .returningGenerated(r => + .returningGenerated(_ => ( query[Dummy].join(query[Dummy]).on((r, x) => r.i == x.i).map(_._1.i).max ) @@ -318,7 +318,7 @@ class SqlActionMacroSpec extends Spec { val q = quote { qr1 .insertValue(lift(TestEntity("s", 0, 1L, None, true))) - .returningGenerated(r => + .returningGenerated(_ => ( query[Dummy].flatMap(r => query[Dummy].filter(s => r.i == s.i)).map(_.i).max ) @@ -334,7 +334,7 @@ class SqlActionMacroSpec extends Spec { val q = quote { qr1 .insertValue(lift(TestEntity("s", 0, 1L, None, true))) - .returningGenerated(r => + .returningGenerated(_ => ( query[DummyS].concatMap(r => r.s.split(" ")).max ) @@ -350,7 +350,7 @@ class SqlActionMacroSpec extends Spec { val q = quote { qr1 .insertValue(lift(TestEntity("s", 0, 1L, None, true))) - .returningGenerated(r => query[Dummy].groupBy(r => r.i).map(_._2.map(_.i).min).value) + .returningGenerated(_ => query[Dummy].groupBy(r => r.i).map(_._2.map(_.i).min).value) } val mirror = ctx.run(q) mirror.string mustEqual "INSERT INTO TestEntity AS r (s,i,l,o,b) VALUES (?, ?, ?, ?, ?) RETURNING (SELECT MIN(r1.i) FROM Dummy r1 GROUP BY r1.i)" @@ -362,7 +362,7 @@ class SqlActionMacroSpec extends Spec { val q = quote { qr1 .insertValue(lift(TestEntity("s", 0, 1L, None, true))) - .returningGenerated(r => + .returningGenerated(_ => { for { d <- query[Dummy] @@ -381,7 +381,7 @@ class SqlActionMacroSpec extends Spec { val q = quote { qr1 .insertValue(lift(TestEntity("s", 0, 1L, None, true))) - .returningGenerated(r => query[Dummy].sortBy(r => r.i).max) + .returningGenerated(_ => query[Dummy].sortBy(r => r.i).max) } val mirror = ctx.run(q) mirror.string mustEqual "INSERT INTO TestEntity AS r (s,i,l,o,b) VALUES (?, ?, ?, ?, ?) RETURNING (SELECT MAX(r1.*) FROM Dummy r1 ORDER BY r1.i ASC NULLS FIRST)" @@ -394,7 +394,7 @@ class SqlActionMacroSpec extends Spec { val q = quote { qr1 .insertValue(lift(TestEntity("s", 0, 1L, None, true))) - .returningGenerated(r => + .returningGenerated(_ => (query[Dummy] .filter(r => r.i == r.i /* always true since r overridden! */ ) @@ -486,7 +486,7 @@ class SqlActionMacroSpec extends Spec { mirror.returningBehavior mustEqual ReturnRecord } "output clause - embedded" - { - case class Dummy(i: Int) + final case class Dummy(i: Int) "embedded property" in testContext.withDialect(MirrorSqlDialectWithOutputClause) { ctx => import ctx._ @@ -509,7 +509,7 @@ class SqlActionMacroSpec extends Spec { } "output clause - naming strategy renames INSERTED clause with correct column naming" in testContextSnake .withDialect(MirrorSqlDialectWithOutputClause) { ctx => - case class Person(firstName: String, age: Int) + final case class Person(firstName: String, age: Int) import ctx._ val q = quote { query[Person].insertValue(lift(Person("Joe", 123))).returning(p => p.firstName) @@ -519,7 +519,7 @@ class SqlActionMacroSpec extends Spec { mirror.string mustEqual "INSERT INTO person (first_name,age) OUTPUT INSERTED.first_name VALUES (?, ?)" mirror.returningBehavior mustEqual ReturnRecord } - "output clause - should fail on query" in testContext.withDialect(MirrorSqlDialectWithOutputClause) { ctx => + "output clause - should fail on query" in testContext.withDialect(MirrorSqlDialectWithOutputClause) { _ => """import ctx._; quote { qr4.insert(lift(TestEntity4(1L))).returningGenerated(r => query[TestEntity4].filter(t => t.i == r.i)) }""" mustNot compile } } @@ -535,10 +535,10 @@ class SqlActionMacroSpec extends Spec { mirror.string mustEqual "INSERT INTO TestEntity (s,i,l,o,b) VALUES (?, ?, ?, ?, ?)" mirror.returningBehavior mustEqual ReturnColumns(List("l")) } - "multi - should fail on operation" in testContext.withDialect(MirrorSqlDialectWithReturnMulti) { ctx => + "multi - should fail on operation" in testContext.withDialect(MirrorSqlDialectWithReturnMulti) { _ => """import ctx._; quote { qr1.insert(lift(TestEntity("s", 0, 1L, None))).returning(r => (r.i, r.l + 1)) }""" mustNot compile } - "no return - should fail on property" in testContext.withDialect(MirrorSqlDialectWithNoReturn) { ctx => + "no return - should fail on property" in testContext.withDialect(MirrorSqlDialectWithNoReturn) { _ => """import ctx._; quote { qr1.insert(lift(TestEntity("s", 0, 1L, None))).returning(r => r.i) }""" mustNot compile } "returning clause - single" in testContext.withDialect(MirrorSqlDialectWithReturnClause) { ctx => @@ -570,7 +570,7 @@ class SqlActionMacroSpec extends Spec { mirror.returningBehavior mustEqual ReturnRecord } "returning clause - embedded" - { - case class Dummy(i: Int) + final case class Dummy(i: Int) "embedded property" in testContext.withDialect(MirrorSqlDialectWithReturnClause) { ctx => import ctx._ @@ -605,14 +605,14 @@ class SqlActionMacroSpec extends Spec { } } "with returning clause - query" - { - case class Dummy(i: Int) + final case class Dummy(i: Int) "simple not using id - id not excluded" in testContext.withDialect(MirrorSqlDialectWithReturnClause) { ctx => import ctx._ val q = quote { qr1 .insertValue(lift(TestEntity("s", 0, 1L, None, true))) - .returning(r => (query[Dummy].map(d => d.i).max)) + .returning(_ => (query[Dummy].map(d => d.i).max)) } val mirror = ctx.run(q) mirror.string mustEqual "INSERT INTO TestEntity AS r (s,i,l,o,b) VALUES (?, ?, ?, ?, ?) RETURNING (SELECT MAX(d.i) FROM Dummy d)" @@ -651,7 +651,7 @@ class SqlActionMacroSpec extends Spec { val q = quote { qr1 .insertValue(lift(TestEntity("s", 0, 1L, None, true))) - .returning(r => (query[Dummy].map(r => r.i).max)) + .returning(_ => (query[Dummy].map(r => r.i).max)) } val mirror = ctx.run(q) mirror.string mustEqual "INSERT INTO TestEntity AS r (s,i,l,o,b) VALUES (?, ?, ?, ?, ?) RETURNING (SELECT MAX(r1.i) FROM Dummy r1)" @@ -664,7 +664,7 @@ class SqlActionMacroSpec extends Spec { val q = quote { qr1 .insertValue(lift(TestEntity("s", 0, 1L, None, true))) - .returning(r => + .returning(_ => (query[Dummy] .filter(r => r.i == r.i /* always true since r overridden! */ ) @@ -745,7 +745,7 @@ class SqlActionMacroSpec extends Spec { mirror.returningBehavior mustEqual ReturnRecord } } - "output clause - should fail on query" in testContext.withDialect(MirrorSqlDialectWithOutputClause) { ctx => + "output clause - should fail on query" in testContext.withDialect(MirrorSqlDialectWithOutputClause) { _ => """import ctx._; quote { qr4.insert(lift(TestEntity4(1L))).returning(r => query[TestEntity4].filter(t => t.i == r.i)) }""" mustNot compile } } @@ -761,10 +761,10 @@ class SqlActionMacroSpec extends Spec { mirror.string mustEqual "UPDATE TestEntity SET s = ?, i = ?, l = ?, o = ?, b = ?" mirror.returningBehavior mustEqual ReturnColumns(List("l")) } - "multi - should fail on operation" in testContext.withDialect(MirrorSqlDialectWithReturnMulti) { ctx => + "multi - should fail on operation" in testContext.withDialect(MirrorSqlDialectWithReturnMulti) { _ => """import ctx._; quote { qr1.update(lift(TestEntity("s", 0, 1L, None))).returning(r => (r.i, r.l + 1)) }""" mustNot compile } - "no return - should fail on property" in testContext.withDialect(MirrorSqlDialectWithNoReturn) { ctx => + "no return - should fail on property" in testContext.withDialect(MirrorSqlDialectWithNoReturn) { _ => """import ctx._; quote { qr1.update(lift(TestEntity("s", 0, 1L, None))).returning(r => r.i) }""" mustNot compile } @@ -807,7 +807,7 @@ class SqlActionMacroSpec extends Spec { mirror.returningBehavior mustEqual ReturnRecord } "returning clause - embedded" - { - case class Dummy(i: Int) + final case class Dummy(i: Int) "embedded property" in testContext.withDialect(MirrorSqlDialectWithReturnClause) { ctx => import ctx._ @@ -842,14 +842,14 @@ class SqlActionMacroSpec extends Spec { } } "with returning clause - query" - { - case class Dummy(i: Int) + final case class Dummy(i: Int) "simple not using id - id not excluded" in testContext.withDialect(MirrorSqlDialectWithReturnClause) { ctx => import ctx._ val q = quote { qr1 .updateValue(lift(TestEntity("s", 0, 1L, None, true))) - .returning(r => query[Dummy].map(d => d.i).max) + .returning(_ => query[Dummy].map(d => d.i).max) } val mirror = ctx.run(q) mirror.string mustEqual "UPDATE TestEntity AS r SET s = ?, i = ?, l = ?, o = ?, b = ? RETURNING (SELECT MAX(d.i) FROM Dummy d)" @@ -888,7 +888,7 @@ class SqlActionMacroSpec extends Spec { val q = quote { qr1 .updateValue(lift(TestEntity("s", 0, 1L, None, true))) - .returning(r => query[Dummy].map(r => r.i).max) + .returning(_ => query[Dummy].map(r => r.i).max) } val mirror = ctx.run(q) mirror.string mustEqual "UPDATE TestEntity AS r SET s = ?, i = ?, l = ?, o = ?, b = ? RETURNING (SELECT MAX(r1.i) FROM Dummy r1)" @@ -901,7 +901,7 @@ class SqlActionMacroSpec extends Spec { val q = quote { qr1 .updateValue(lift(TestEntity("s", 0, 1L, None, true))) - .returning(r => + .returning(_ => (query[Dummy] .filter(r => r.i == r.i /* always true since r overridden! */ ) @@ -982,7 +982,7 @@ class SqlActionMacroSpec extends Spec { mirror.returningBehavior mustEqual ReturnRecord } } - "output clause - should fail on query" in testContext.withDialect(MirrorSqlDialectWithOutputClause) { ctx => + "output clause - should fail on query" in testContext.withDialect(MirrorSqlDialectWithOutputClause) { _ => """import ctx._; quote { qr4.update(lift(TestEntity4(1L))).returning(r => query[TestEntity4].filter(t => t.i == r.i)) }""" mustNot compile } } @@ -998,10 +998,10 @@ class SqlActionMacroSpec extends Spec { mirror.string mustEqual "DELETE FROM TestEntity" mirror.returningBehavior mustEqual ReturnColumns(List("l")) } - "multi - should fail on operation" in testContext.withDialect(MirrorSqlDialectWithReturnMulti) { ctx => + "multi - should fail on operation" in testContext.withDialect(MirrorSqlDialectWithReturnMulti) { _ => """import ctx._; quote { qr1.delete.returning(r => (r.i, r.l + 1)) }""" mustNot compile } - "no return - should fail on property" in testContext.withDialect(MirrorSqlDialectWithNoReturn) { ctx => + "no return - should fail on property" in testContext.withDialect(MirrorSqlDialectWithNoReturn) { _ => """import ctx._; quote { qr1.delete.returning(r => r.i) }""" mustNot compile } @@ -1044,7 +1044,7 @@ class SqlActionMacroSpec extends Spec { mirror.returningBehavior mustEqual ReturnRecord } "returning clause - embedded" - { - case class Dummy(i: Int) + final case class Dummy(i: Int) "embedded property" in testContext.withDialect(MirrorSqlDialectWithReturnClause) { ctx => import ctx._ @@ -1077,12 +1077,12 @@ class SqlActionMacroSpec extends Spec { } } "with returning clause - query" - { - case class Dummy(i: Int) + final case class Dummy(i: Int) "simple not using id - id not excluded" in testContext.withDialect(MirrorSqlDialectWithReturnClause) { ctx => import ctx._ val q = quote { - qr1.delete.returning(r => query[Dummy].map(d => d.i).max) + qr1.delete.returning(_ => query[Dummy].map(d => d.i).max) } val mirror = ctx.run(q) mirror.string mustEqual "DELETE FROM TestEntity AS r RETURNING (SELECT MAX(d.i) FROM Dummy d)" @@ -1115,7 +1115,7 @@ class SqlActionMacroSpec extends Spec { ) { ctx => import ctx._ val q = quote { - qr1.delete.returning(r => query[Dummy].map(r => r.i).max) + qr1.delete.returning(_ => query[Dummy].map(r => r.i).max) } val mirror = ctx.run(q) mirror.string mustEqual "DELETE FROM TestEntity AS r RETURNING (SELECT MAX(r1.i) FROM Dummy r1)" @@ -1127,7 +1127,7 @@ class SqlActionMacroSpec extends Spec { import ctx._ val q = quote { qr1.delete - .returning(r => + .returning(_ => (query[Dummy] .filter(r => r.i == r.i /* always true since r overridden! */ ) @@ -1207,14 +1207,14 @@ class SqlActionMacroSpec extends Spec { mirror.returningBehavior mustEqual ReturnRecord } } - "output clause - should fail on query" in testContext.withDialect(MirrorSqlDialectWithOutputClause) { ctx => + "output clause - should fail on query" in testContext.withDialect(MirrorSqlDialectWithOutputClause) { _ => """import ctx._; quote { qr4.delete.returning(r => query[TestEntity4].filter(t => t.i == r.i)) }""" mustNot compile } } } "apply naming strategy to returning action" in testContext.withNaming(SnakeCase) { ctx => import ctx._ - case class TestEntity4(intId: Int, textCol: String) + final case class TestEntity4(intId: Int, textCol: String) val q = quote { query[TestEntity4].insertValue(lift(TestEntity4(1, "s"))).returningGenerated(_.intId) } diff --git a/quill-sql/src/test/scala/io/getquill/context/sql/SqlContextSpec.scala b/quill-sql/src/test/scala/io/getquill/context/sql/SqlContextSpec.scala index 56e475c6d2..54e60cc151 100644 --- a/quill-sql/src/test/scala/io/getquill/context/sql/SqlContextSpec.scala +++ b/quill-sql/src/test/scala/io/getquill/context/sql/SqlContextSpec.scala @@ -26,7 +26,7 @@ class SqlContextSpec extends Spec { } "filter.map" in { val q = quote { - qr1.filter(t => t.i == lift(1)).map(t => lift(2L)) + qr1.filter(t => t.i == lift(1)).map(_ => lift(2L)) } val mirror = testContext.run(q) mirror.string mustEqual "SELECT ? FROM TestEntity t WHERE t.i = ?" @@ -64,9 +64,9 @@ class SqlContextSpec extends Spec { def probe(sql: String): Try[Any] = null - def encoder[T]: Encoder[T] = (index: Index, value: T, row: PrepareRow, session: Session) => row + def encoder[T]: Encoder[T] = (_: Index, _: T, row: PrepareRow, _: Session) => row - def decoder[T]: Decoder[T] = (index: Index, row: ResultRow, session: Session) => row(index).asInstanceOf[T] + def decoder[T]: Decoder[T] = (index: Index, row: ResultRow, _: Session) => row(index).asInstanceOf[T] implicit def optionEncoder[T](implicit d: Encoder[T]): Encoder[Option[T]] = encoder[Option[T]] diff --git a/quill-sql/src/test/scala/io/getquill/context/sql/SqlQueryMacroSpec.scala b/quill-sql/src/test/scala/io/getquill/context/sql/SqlQueryMacroSpec.scala index c42cb3df1b..161adaf140 100644 --- a/quill-sql/src/test/scala/io/getquill/context/sql/SqlQueryMacroSpec.scala +++ b/quill-sql/src/test/scala/io/getquill/context/sql/SqlQueryMacroSpec.scala @@ -29,7 +29,7 @@ class SqlQueryMacroSpec extends Spec { } "with flatMap" in { val q = quote { - qr1.flatMap(t => qr2) + qr1.flatMap(_ => qr2) } val mirror = testContext.run(q) mirror.prepareRow mustEqual Row() diff --git a/quill-sql/src/test/scala/io/getquill/context/sql/SqlQuerySpec.scala b/quill-sql/src/test/scala/io/getquill/context/sql/SqlQuerySpec.scala index 98b7f9f01d..bb7f90948c 100644 --- a/quill-sql/src/test/scala/io/getquill/context/sql/SqlQuerySpec.scala +++ b/quill-sql/src/test/scala/io/getquill/context/sql/SqlQuerySpec.scala @@ -10,7 +10,7 @@ import io.getquill.util.TraceConfig class SqlQuerySpec extends Spec { - implicit val naming = new Literal {} + implicit val naming: Literal = new Literal {} val SqlQuery = new SqlQueryApply(TraceConfig.Empty) @@ -371,7 +371,7 @@ class SqlQuerySpec extends Spec { val q = quote { qr1.flatMap(a => sql"SELECT * FROM TestEntity2 t where t.s = ${a.s}".as[Query[TestEntity2]]) } - val e = intercept[IllegalStateException] { + intercept[IllegalStateException] { SqlQuery(q.ast) } } @@ -400,7 +400,7 @@ class SqlQuerySpec extends Spec { } "with flatMap" in { val q = quote { - qr1.sortBy(t => t.s).flatMap(t => qr2.map(t => t.s)) + qr1.sortBy(t => t.s).flatMap(_ => qr2.map(t => t.s)) } testContext.run(q).string mustEqual "SELECT t1.s FROM (SELECT t.s, t.i, t.l, t.o, t.b FROM TestEntity t ORDER BY t.s ASC NULLS FIRST) AS t, TestEntity2 t1" @@ -458,12 +458,12 @@ class SqlQuerySpec extends Spec { "SELECT b._1, b._2 FROM (SELECT a.s AS _1, b.s AS _2 FROM TestEntity a, TestEntity2 b WHERE a.i = b.i) AS b ORDER BY b._2 DESC" } "fails if the sortBy criteria is malformed" in { - case class Test(a: (Int, Int)) + final case class Test(a: (Int, Int)) implicit val o: Ordering[TestEntity] = null val q = quote { query[Test].sortBy(_.a)(Ord(Ord.asc, Ord.desc)) } - val e = intercept[IllegalStateException] { + intercept[IllegalStateException] { SqlQuery(q.ast) } } @@ -478,7 +478,7 @@ class SqlQuerySpec extends Spec { } "nested" in { val q = quote { - qr1.groupBy(t => t.i).map(t => t._1).flatMap(t => qr2) + qr1.groupBy(t => t.i).map(t => t._1).flatMap(_ => qr2) } testContext.run(q).string mustEqual "SELECT x.s, x.i, x.l, x.o FROM (SELECT t.i FROM TestEntity t GROUP BY t.i) AS t, TestEntity2 x" @@ -487,7 +487,7 @@ class SqlQuerySpec extends Spec { val q = quote { qr1.groupBy(t => t.i) } - val e = intercept[IllegalStateException] { + intercept[IllegalStateException] { SqlQuery(q.ast) } } @@ -582,7 +582,7 @@ class SqlQuerySpec extends Spec { } "with map" in { val q = quote { - qr1.map(t => t.i).distinct.map(t => 1) + qr1.map(t => t.i).distinct.map(_ => 1) } testContext.run(q).string mustEqual "SELECT 1 FROM (SELECT DISTINCT t.i AS _1 FROM TestEntity t) AS t" // hel @@ -591,7 +591,7 @@ class SqlQuerySpec extends Spec { "with map uppercase" in { import testContextUpper._ val q = quote { - qr1.map(t => t.i).distinct.map(t => 1) + qr1.map(t => t.i).distinct.map(_ => 1) } testContextUpper.run(q).string mustEqual "SELECT 1 FROM (SELECT DISTINCT t.I AS _1 FROM TESTENTITY t) AS t" @@ -642,7 +642,7 @@ class SqlQuerySpec extends Spec { } "with map query inside join with case class" in { - case class IntermediateRecord(one: Int, two: Long) + final case class IntermediateRecord(one: Int, two: Long) val q = quote { qr1 .join( @@ -657,7 +657,7 @@ class SqlQuerySpec extends Spec { } "with map query inside join with case class and operation" in { - case class IntermediateRecord(one: Int, two: Long) + final case class IntermediateRecord(one: Int, two: Long) val q = quote { qr1 .join( @@ -704,7 +704,7 @@ class SqlQuerySpec extends Spec { } "mapped" in { - case class Person(id: Int, name: String, age: Int) + final case class Person(id: Int, name: String, age: Int) val q = quote { query[Person].map(e => (e.name, e.age % 2)).distinctOn(_._2).sortBy(_._2)(Ord.desc) } @@ -713,8 +713,8 @@ class SqlQuerySpec extends Spec { } "joined" in { - case class Person(id: Int, name: String, age: Int) - case class Address(fk: Int, street: String) + final case class Person(id: Int, name: String, age: Int) + final case class Address(fk: Int, street: String) val q = quote { (for { @@ -748,7 +748,7 @@ class SqlQuerySpec extends Spec { } "nested" in { val q = quote { - qr1.take(10).flatMap(a => qr2) + qr1.take(10).flatMap(_ => qr2) } testContext.run(q).string mustEqual "SELECT x.s, x.i, x.l, x.o FROM (SELECT x.s, x.i, x.l, x.o, x.b FROM TestEntity x LIMIT 10) AS a, TestEntity2 x" @@ -778,7 +778,7 @@ class SqlQuerySpec extends Spec { } "nested" in { val q = quote { - qr1.drop(10).flatMap(a => qr2) + qr1.drop(10).flatMap(_ => qr2) } testContext.run(q).string mustEqual "SELECT x.s, x.i, x.l, x.o FROM (SELECT x.s, x.i, x.l, x.o, x.b FROM TestEntity x OFFSET 10) AS a, TestEntity2 x" @@ -808,7 +808,7 @@ class SqlQuerySpec extends Spec { } "nested" in { val q = quote { - qr1.drop(10).take(11).flatMap(a => qr2) + qr1.drop(10).take(11).flatMap(_ => qr2) } testContext.run(q).string mustEqual "SELECT x.s, x.i, x.l, x.o FROM (SELECT x.s, x.i, x.l, x.o, x.b FROM TestEntity x LIMIT 11 OFFSET 10) AS a, TestEntity2 x" @@ -928,7 +928,7 @@ class SqlQuerySpec extends Spec { } "embedded sortBy" in { - case class Sim(sid: Int, name: String) + final case class Sim(sid: Int, name: String) val q = quote { query[Sim] .map(sim => (sim.sid, sim.name)) @@ -938,13 +938,13 @@ class SqlQuerySpec extends Spec { } "queries using options" - { - case class Entity(id: Int, s: String, o: Option[String], fk: Int, io: Option[Int]) - case class EntityA(id: Int, s: String, o: Option[String]) - case class EntityB(id: Int, s: String, o: Option[String]) + final case class Entity(id: Int, s: String, o: Option[String], fk: Int, io: Option[Int]) + final case class EntityA(id: Int, s: String, o: Option[String]) + final case class EntityB(id: Int, s: String, o: Option[String]) val e = quote(query[Entity]) val ea = quote(query[EntityA]) - val eb = quote(query[EntityB]) + quote(query[EntityB]) "flatten in left join" in { val q = quote { @@ -988,7 +988,7 @@ class SqlQuerySpec extends Spec { } "case class queries" - { - case class TrivialEntity(str: String) + final case class TrivialEntity(str: String) "in single join" in { val q = quote { @@ -1012,7 +1012,7 @@ class SqlQuerySpec extends Spec { } "in union same field name" in { - case class TrivialEntitySameField(s: String) + final case class TrivialEntitySameField(s: String) val q = quote { qr1.map(q => TrivialEntitySameField(q.s)) ++ qr1.map(q => TrivialEntitySameField(q.s)) diff --git a/quill-sql/src/test/scala/io/getquill/context/sql/TestDecoders.scala b/quill-sql/src/test/scala/io/getquill/context/sql/TestDecoders.scala index 3fc13333de..e3d42102a1 100644 --- a/quill-sql/src/test/scala/io/getquill/context/sql/TestDecoders.scala +++ b/quill-sql/src/test/scala/io/getquill/context/sql/TestDecoders.scala @@ -3,8 +3,8 @@ package io.getquill.context.sql import io.getquill.MappedEncoding trait TestDecoders { - implicit val encodingTestTypeDecoder = MappedEncoding[String, EncodingTestType](EncodingTestType) - implicit val nameDecoder = MappedEncoding[String, Number](s => + implicit val encodingTestTypeDecoder: MappedEncoding[String,EncodingTestType] = MappedEncoding[String, EncodingTestType](EncodingTestType) + implicit val nameDecoder: MappedEncoding[String,Number] = MappedEncoding[String, Number](s => Number .withValidation(s) .getOrElse(throw new Exception(s"Illegal number $s")) diff --git a/quill-sql/src/test/scala/io/getquill/context/sql/TestEncoders.scala b/quill-sql/src/test/scala/io/getquill/context/sql/TestEncoders.scala index dd403288d5..33726b5ed4 100644 --- a/quill-sql/src/test/scala/io/getquill/context/sql/TestEncoders.scala +++ b/quill-sql/src/test/scala/io/getquill/context/sql/TestEncoders.scala @@ -3,6 +3,6 @@ package io.getquill.context.sql import io.getquill.MappedEncoding trait TestEncoders { - implicit val encodingTestTypeEncoder = MappedEncoding[EncodingTestType, String](_.value) - implicit val nameEncoder = MappedEncoding[Number, String](_.value) + implicit val encodingTestTypeEncoder: MappedEncoding[EncodingTestType,String] = MappedEncoding[EncodingTestType, String](_.value) + implicit val nameEncoder: MappedEncoding[Number,String] = MappedEncoding[Number, String](_.value) } diff --git a/quill-sql/src/test/scala/io/getquill/context/sql/base/ArrayOpsSpec.scala b/quill-sql/src/test/scala/io/getquill/context/sql/base/ArrayOpsSpec.scala index db55da147f..2985a28744 100644 --- a/quill-sql/src/test/scala/io/getquill/context/sql/base/ArrayOpsSpec.scala +++ b/quill-sql/src/test/scala/io/getquill/context/sql/base/ArrayOpsSpec.scala @@ -3,6 +3,7 @@ package io.getquill.context.sql.base import io.getquill.base.Spec import io.getquill.context.sql.SqlContext import io.getquill.context.sql.encoding.ArrayEncoding +import io.getquill.{ EntityQuery, Quoted } trait ArrayOpsSpec extends Spec { @@ -12,13 +13,13 @@ trait ArrayOpsSpec extends Spec { case class ArrayOps(id: Int, numbers: Seq[Int]) - val entriesList = List( + val entriesList: List[ArrayOps] = List( ArrayOps(1, List(1, 2, 3)), ArrayOps(2, List(1, 4, 5)), ArrayOps(3, List(1, 4, 6)) ) - val entity = quote(query[ArrayOps]) + val entity: Quoted[EntityQuery[ArrayOps]] = quote(query[ArrayOps]) val insertEntries = quote { liftQuery(entriesList).foreach(e => entity.insertValue(e)) @@ -37,6 +38,6 @@ trait ArrayOpsSpec extends Spec { val `Ex 3 expected` = List(2, 3) val `Ex 4 return empty` = quote(idByContains(10)) - val `Ex 4 expected` = Nil + val `Ex 4 expected` = List.empty } } diff --git a/quill-sql/src/test/scala/io/getquill/context/sql/base/BatchUpdateValuesSpec.scala b/quill-sql/src/test/scala/io/getquill/context/sql/base/BatchUpdateValuesSpec.scala index 9a8e5a2f83..699b329782 100644 --- a/quill-sql/src/test/scala/io/getquill/context/sql/base/BatchUpdateValuesSpec.scala +++ b/quill-sql/src/test/scala/io/getquill/context/sql/base/BatchUpdateValuesSpec.scala @@ -22,12 +22,12 @@ trait BatchUpdateValuesSpec extends Spec with BeforeAndAfterEach { ContactBase("Caboose", "Castle", 66), ContactBase("E", "E", 111) ) - val updatePeople = List("Joe", "Jan", "James", "Dale", "Caboose") + val updatePeople: List[String] = List("Joe", "Jan", "James", "Dale", "Caboose") def includeInUpdate(name: String): Boolean = updatePeople.contains(name) def includeInUpdate(c: ContactBase): Boolean = includeInUpdate(c.firstName) - val updateBase = + val updateBase: List[ContactBase] = dataBase.filter(includeInUpdate(_)).map(r => r.copy(lastName = r.lastName + "U")) - val expectBase = dataBase.map { r => + val expectBase: List[ContactBase] = dataBase.map { r => if (includeInUpdate(r)) r.copy(lastName = r.lastName + "U") else r } diff --git a/quill-sql/src/test/scala/io/getquill/context/sql/base/BatchValuesSpec.scala b/quill-sql/src/test/scala/io/getquill/context/sql/base/BatchValuesSpec.scala index 25b3b598d8..220089666d 100644 --- a/quill-sql/src/test/scala/io/getquill/context/sql/base/BatchValuesSpec.scala +++ b/quill-sql/src/test/scala/io/getquill/context/sql/base/BatchValuesSpec.scala @@ -15,7 +15,7 @@ trait BatchValuesSpec extends Spec with BeforeAndAfterEach { def insertProduct = quote((p: Product) => query[Product].insertValue(p)) - def makeProducts(maxRows: Int = 22) = + def makeProducts(maxRows: Int = 22): IndexedSeq[Product] = (1 to maxRows).map(i => Product(i, s"Product-${i}", i * 100)) object `Ex 1 - Batch Insert Normal` { diff --git a/quill-sql/src/test/scala/io/getquill/context/sql/base/CaseClassQuerySpec.scala b/quill-sql/src/test/scala/io/getquill/context/sql/base/CaseClassQuerySpec.scala index 08f2a8e863..f17e2b78cc 100644 --- a/quill-sql/src/test/scala/io/getquill/context/sql/base/CaseClassQuerySpec.scala +++ b/quill-sql/src/test/scala/io/getquill/context/sql/base/CaseClassQuerySpec.scala @@ -20,7 +20,7 @@ trait CaseClassQuerySpec extends Spec { val peopleInsert = quote((p: Contact) => query[Contact].insertValue(p)) - val peopleEntries = List( + val peopleEntries: List[Contact] = List( Contact("Alex", "Jones", 60, 2, "foo"), Contact("Bert", "James", 55, 3, "bar"), Contact("Cora", "Jasper", 33, 3, "baz") @@ -29,7 +29,7 @@ trait CaseClassQuerySpec extends Spec { val addressInsert = quote((c: Address) => query[Address].insertValue(c)) - val addressEntries = List( + val addressEntries: List[Address] = List( Address(1, "123 Fake Street", 11234, "something"), Address(2, "456 Old Street", 45678, "something else"), Address(3, "789 New Street", 89010, "another thing") diff --git a/quill-sql/src/test/scala/io/getquill/context/sql/base/DepartmentsSpec.scala b/quill-sql/src/test/scala/io/getquill/context/sql/base/DepartmentsSpec.scala index 6d12531069..3ba2894ed8 100644 --- a/quill-sql/src/test/scala/io/getquill/context/sql/base/DepartmentsSpec.scala +++ b/quill-sql/src/test/scala/io/getquill/context/sql/base/DepartmentsSpec.scala @@ -3,6 +3,7 @@ package io.getquill.context.sql.base import io.getquill.context.sql.SqlContext import io.getquill.Query import io.getquill.base.Spec +import io.getquill.Quoted trait DepartmentsSpec extends Spec { @@ -21,7 +22,7 @@ trait DepartmentsSpec extends Spec { query[Department].insertValue(dpt) } - val departmentEntries = + val departmentEntries: List[Department] = List( Department("Product"), Department("Quality"), @@ -34,7 +35,7 @@ trait DepartmentsSpec extends Spec { query[Employee].insertValue(emp) } - val employeeEntries = + val employeeEntries: List[Employee] = List( Employee("Alex", "Product"), Employee("Bert", "Product"), @@ -49,7 +50,7 @@ trait DepartmentsSpec extends Spec { query[Task].insertValue(tsk) } - val taskEntries = + val taskEntries: List[Task] = List( Task("Alex", "build"), Task("Bert", "build"), @@ -85,7 +86,7 @@ trait DepartmentsSpec extends Spec { val `Example 8 expected result` = List("Quality", "Research") - def any[T] = + def any[T]: Quoted[Query[T] => ((T => Boolean) => Boolean)] = quote { (xs: Query[T]) => (p: T => Boolean) => (for { x <- xs if (p(x)) diff --git a/quill-sql/src/test/scala/io/getquill/context/sql/base/OnConflictSpec.scala b/quill-sql/src/test/scala/io/getquill/context/sql/base/OnConflictSpec.scala index 9e5520bdec..42db86dc76 100644 --- a/quill-sql/src/test/scala/io/getquill/context/sql/base/OnConflictSpec.scala +++ b/quill-sql/src/test/scala/io/getquill/context/sql/base/OnConflictSpec.scala @@ -3,6 +3,7 @@ package io.getquill.context.sql.base import io.getquill.context.sql.SqlContext import io.getquill.TestEntities import io.getquill.base.Spec +import io.getquill.{ EntityQuery, Quoted } trait OnConflictSpec extends Spec { val ctx: SqlContext[_, _] with TestEntities @@ -16,10 +17,10 @@ trait OnConflictSpec extends Spec { val res1 = 1 val res2 = 0 - val testQuery3 = quote { + val testQuery3: Quoted[EntityQuery[TestEntity]] = quote { qr1.filter(_.i == 1) } - val res3 = List(TestEntity("", 1, 0, None, true)) + val res3: List[TestEntity] = List(TestEntity("", 1, 0, None, true)) } object `onConflictIgnore(_.i)` { @@ -37,16 +38,16 @@ trait OnConflictSpec extends Spec { } abstract class onConflictUpdate(id: Int) { - val e1 = TestEntity("r1", id, 0, None, true) - val e2 = TestEntity("r2", id, 0, None, true) - val e3 = TestEntity("r3", id, 0, None, true) + val e1: TestEntity = TestEntity("r1", id, 0, None, true) + val e2: TestEntity = TestEntity("r2", id, 0, None, true) + val e3: TestEntity = TestEntity("r3", id, 0, None, true) val res1, res2, res3 = 1 val testQuery4 = quote { qr1.filter(_.i == lift(id)) } - val res4 = List(TestEntity("r1-r2-r3", id, 2, None, true)) + val res4: List[TestEntity] = List(TestEntity("r1-r2-r3", id, 2, None, true)) } object `onConflictUpdate((t, e) => ...)` extends onConflictUpdate(3) { diff --git a/quill-sql/src/test/scala/io/getquill/context/sql/base/PeopleAggregationSpec.scala b/quill-sql/src/test/scala/io/getquill/context/sql/base/PeopleAggregationSpec.scala index 20d4f4a22b..c25b703987 100644 --- a/quill-sql/src/test/scala/io/getquill/context/sql/base/PeopleAggregationSpec.scala +++ b/quill-sql/src/test/scala/io/getquill/context/sql/base/PeopleAggregationSpec.scala @@ -13,7 +13,7 @@ trait PeopleAggregationSpec extends Spec { case class Address(id: Int, street: String, zip: Int = 0, otherExtraInfo: Option[String] = None) - val people = List( + val people: List[Contact] = List( Contact("Joe", "A", 20, 1), Contact("Dan", "D", 30, 2), Contact("Joe", "B", 40, 3), @@ -21,7 +21,7 @@ trait PeopleAggregationSpec extends Spec { Contact("Dan", "E", 60, 1) ) - val addresses = List( + val addresses: List[Address] = List( Address(1, "111 St"), Address(2, "222 Ct"), Address(3, "333 Sq"), diff --git a/quill-sql/src/test/scala/io/getquill/context/sql/base/PeopleReturningSpec.scala b/quill-sql/src/test/scala/io/getquill/context/sql/base/PeopleReturningSpec.scala index 68ccc97149..3b53890160 100644 --- a/quill-sql/src/test/scala/io/getquill/context/sql/base/PeopleReturningSpec.scala +++ b/quill-sql/src/test/scala/io/getquill/context/sql/base/PeopleReturningSpec.scala @@ -23,14 +23,14 @@ trait PeopleReturningSpec extends Spec with BeforeAndAfterEach { val peopleInsert = quote((p: Contact) => query[Contact].insertValue(p)) - val people = List( + val people: List[Contact] = List( Contact("Joe", "A", 44), Contact("Dan", "D", 55), Contact("Joe", "B", 66), Contact("Jim", "J", 77) ) - val product = Product(0, "Something", 123) + val product: Product = Product(0, "Something", 123) object `Ex 0 insert.returning(_.generatedColumn) mod` { val op = quote { diff --git a/quill-sql/src/test/scala/io/getquill/context/sql/base/PeopleSpec.scala b/quill-sql/src/test/scala/io/getquill/context/sql/base/PeopleSpec.scala index 50eee20c44..953b72ca89 100644 --- a/quill-sql/src/test/scala/io/getquill/context/sql/base/PeopleSpec.scala +++ b/quill-sql/src/test/scala/io/getquill/context/sql/base/PeopleSpec.scala @@ -3,6 +3,7 @@ package io.getquill.context.sql.base import io.getquill.base.Spec import io.getquill.context.sql.SqlContext import io.getquill.{Ord, Query, Quoted} +import io.getquill.EntityQuery trait PeopleSpec extends Spec { @@ -17,7 +18,7 @@ trait PeopleSpec extends Spec { val peopleInsert = quote((p: Person) => query[Person].insertValue(p)) - val peopleEntries = List( + val peopleEntries: List[Person] = List( Person("Alex", 60), Person("Bert", 55), Person("Cora", 33), @@ -29,7 +30,7 @@ trait PeopleSpec extends Spec { val couplesInsert = quote((c: Couple) => query[Couple].insertValue(c)) - val couplesEntries = List( + val couplesEntries: List[Couple] = List( Couple("Alex", "Bert"), Couple("Cora", "Drew"), Couple("Edna", "Fred") @@ -58,7 +59,7 @@ trait PeopleSpec extends Spec { val `Ex 2 param 2` = 40 val `Ex 2 expected result` = List(Person("Cora", 33), Person("Drew", 31)) - val satisfies = + val satisfies: Quoted[(Int => Boolean) => EntityQuery[Person]] = quote { (p: Int => Boolean) => for { u <- query[Person] if (p(u.age)) diff --git a/quill-sql/src/test/scala/io/getquill/context/sql/base/QueryResultTypeSpec.scala b/quill-sql/src/test/scala/io/getquill/context/sql/base/QueryResultTypeSpec.scala index 996558f401..388d28e4d2 100644 --- a/quill-sql/src/test/scala/io/getquill/context/sql/base/QueryResultTypeSpec.scala +++ b/quill-sql/src/test/scala/io/getquill/context/sql/base/QueryResultTypeSpec.scala @@ -2,38 +2,39 @@ package io.getquill.context.sql.base import io.getquill.Ord import io.getquill.context.sql.ProductSpec +import io.getquill.{ Delete, EntityQuery, Query, Quoted } trait QueryResultTypeSpec extends ProductSpec { import context._ - val deleteAll = quote(query[Product].delete) - val selectAll = quote(query[Product]) - val map = quote(query[Product].map(_.id)) - val filter = quote(query[Product].filter(_ => true)) - val withFilter = quote(query[Product].withFilter(_ => true)) - val sortBy = quote(query[Product].sortBy(_.id)(Ord.asc)) - val take = quote(query[Product].take(10)) - val drop = quote(query[Product].drop(1)) + val deleteAll: Quoted[Delete[Product]] = quote(query[Product].delete) + val selectAll: Quoted[EntityQuery[Product]] = quote(query[Product]) + val map: Quoted[EntityQuery[Long]] = quote(query[Product].map(_.id)) + val filter: Quoted[EntityQuery[Product]] = quote(query[Product].filter(_ => true)) + val withFilter: Quoted[EntityQuery[Product]] = quote(query[Product].withFilter(_ => true)) + val sortBy: Quoted[Query[Product]] = quote(query[Product].sortBy(_.id)(Ord.asc)) + val take: Quoted[Query[Product]] = quote(query[Product].take(10)) + val drop: Quoted[Query[Product]] = quote(query[Product].drop(1)) val `++` = quote(query[Product] ++ query[Product]) - val unionAll = quote(query[Product].unionAll(query[Product])) - val union = quote(query[Product].union(query[Product])) - - val minExists = quote(query[Product].map(_.sku).min) - val minNonExists = quote(query[Product].filter(_.id > 1000).map(_.sku).min) - val maxExists = quote(query[Product].map(_.sku).max) - val maxNonExists = quote(query[Product].filter(_.id > 1000).map(_.sku).max) - val avgExists = quote(query[Product].map(_.sku).avg) - val avgNonExists = quote(query[Product].filter(_.id > 1000).map(_.sku).avg) - val productSize = quote(query[Product].size) - val parametrizedSize = quote { (id: Long) => + val unionAll: Quoted[Query[Product]] = quote(query[Product].unionAll(query[Product])) + val union: Quoted[Query[Product]] = quote(query[Product].union(query[Product])) + + val minExists: Quoted[Option[Long]] = quote(query[Product].map(_.sku).min) + val minNonExists: Quoted[Option[Long]] = quote(query[Product].filter(_.id > 1000).map(_.sku).min) + val maxExists: Quoted[Option[Long]] = quote(query[Product].map(_.sku).max) + val maxNonExists: Quoted[Option[Long]] = quote(query[Product].filter(_.id > 1000).map(_.sku).max) + val avgExists: Quoted[Option[BigDecimal]] = quote(query[Product].map(_.sku).avg) + val avgNonExists: Quoted[Option[BigDecimal]] = quote(query[Product].filter(_.id > 1000).map(_.sku).avg) + val productSize: Quoted[Long] = quote(query[Product].size) + val parametrizedSize: Quoted[Long => Long] = quote { (id: Long) => query[Product].filter(_.id == id).size } - val join = quote(query[Product].join(query[Product]).on(_.id == _.id)) + val join: Quoted[Query[(Product, Product)]] = quote(query[Product].join(query[Product]).on(_.id == _.id)) - val nonEmpty = quote(query[Product].nonEmpty) - val isEmpty = quote(query[Product].isEmpty) - val distinct = quote(query[Product].map(_.id).distinct) + val nonEmpty: Quoted[Boolean] = quote(query[Product].nonEmpty) + val isEmpty: Quoted[Boolean] = quote(query[Product].isEmpty) + val distinct: Quoted[Query[Long]] = quote(query[Product].map(_.id).distinct) } diff --git a/quill-sql/src/test/scala/io/getquill/context/sql/encoding/ArrayEncodingBaseSpec.scala b/quill-sql/src/test/scala/io/getquill/context/sql/encoding/ArrayEncodingBaseSpec.scala index 76f6060149..200c7f6deb 100644 --- a/quill-sql/src/test/scala/io/getquill/context/sql/encoding/ArrayEncodingBaseSpec.scala +++ b/quill-sql/src/test/scala/io/getquill/context/sql/encoding/ArrayEncodingBaseSpec.scala @@ -24,7 +24,7 @@ trait ArrayEncodingBaseSpec extends Spec with BeforeAndAfterEach { dates: Seq[LocalDate] ) - val e = ArraysTestEntity( + val e: ArraysTestEntity = ArraysTestEntity( List("test"), Seq(BigDecimal(2.33)), Vector(true, true), @@ -58,5 +58,5 @@ trait ArrayEncodingBaseSpec extends Spec with BeforeAndAfterEach { implicit val strWrapEncode: MappedEncoding[StrWrap, String] = MappedEncoding(_.str) implicit val strWrapDecode: MappedEncoding[String, StrWrap] = MappedEncoding(StrWrap.apply) case class WrapEntity(texts: Seq[StrWrap]) - val wrapE = WrapEntity(List("hey", "ho").map(StrWrap.apply)) + val wrapE: WrapEntity = WrapEntity(List("hey", "ho").map(StrWrap.apply)) } diff --git a/quill-sql/src/test/scala/io/getquill/context/sql/idiom/AbstractMySQLDialectSpec.scala b/quill-sql/src/test/scala/io/getquill/context/sql/idiom/AbstractMySQLDialectSpec.scala index 0be11995dd..53123f6e1d 100644 --- a/quill-sql/src/test/scala/io/getquill/context/sql/idiom/AbstractMySQLDialectSpec.scala +++ b/quill-sql/src/test/scala/io/getquill/context/sql/idiom/AbstractMySQLDialectSpec.scala @@ -2,7 +2,6 @@ package io.getquill.context.sql.idiom import io.getquill._ import io.getquill.idiom.StringToken -import io.getquill.idiom.{Idiom => BaseIdiom} trait AbstractMySQLDialectSpec extends OnConflictSpec { @@ -85,13 +84,13 @@ trait AbstractMySQLDialectSpec extends OnConflictSpec { "INSERT INTO TestEntity4 (i) VALUES (DEFAULT)" } "Insert with returning generated - multiple fields - should not compile" in { - val q = quote { + quote { qr1.insertValue(lift(TestEntity("s", 1, 2L, Some(3), true))) } "ctx.run(q.returningGenerated(r => (r.i, r.l))).string" mustNot compile } "Insert with returning should not compile" in { - val q = quote { + quote { qr4.insertValue(lift(TestEntity4(0))) } "ctx.run(q.returning(_.i)).string" mustNot compile diff --git a/quill-sql/src/test/scala/io/getquill/context/sql/idiom/BooleanLiteralSupportSpec.scala b/quill-sql/src/test/scala/io/getquill/context/sql/idiom/BooleanLiteralSupportSpec.scala index 68eb8b0a0f..52ecef19a9 100644 --- a/quill-sql/src/test/scala/io/getquill/context/sql/idiom/BooleanLiteralSupportSpec.scala +++ b/quill-sql/src/test/scala/io/getquill/context/sql/idiom/BooleanLiteralSupportSpec.scala @@ -3,16 +3,14 @@ package io.getquill.context.sql.idiom import io.getquill.MirrorSqlDialectWithBooleanLiterals import io.getquill.base.Spec import io.getquill.context.sql.testContext -import io.getquill.norm.EnableTrace -import io.getquill.util.Messages.TraceType class BooleanLiteralSupportSpec extends Spec { "value-fy boolean expression where needed" - testContext.withDialect(MirrorSqlDialectWithBooleanLiterals) { ctx => import ctx._ - case class Ent(name: String, b: Boolean, bb: Boolean, bc: Boolean, num: Int) - case class Status(name: String, value: Boolean) + final case class Ent(name: String, b: Boolean, bb: Boolean, bc: Boolean, num: Int) + final case class Status(name: String, value: Boolean) "condition" in { val q = quote { @@ -63,7 +61,7 @@ class BooleanLiteralSupportSpec extends Spec { import ctx._ "expressify asCondition" - { - case class Ent(name: String, i: Int, b: Boolean) + final case class Ent(name: String, i: Int, b: Boolean) "filter-clause" in { val q = quote { @@ -132,7 +130,7 @@ class BooleanLiteralSupportSpec extends Spec { } "valuefy normally" - { - case class Ent(name: String, i: Int, b: Boolean) + final case class Ent(name: String, i: Int, b: Boolean) "filter-clause" in { val q = quote { @@ -169,7 +167,7 @@ class BooleanLiteralSupportSpec extends Spec { } "do not expressify string transforming operations" - { - case class Product(id: Long, desc: String, sku: Int) + final case class Product(id: Long, desc: String, sku: Int) "first parameter" in testContext.withDialect(MirrorSqlDialectWithBooleanLiterals) { ctx => import ctx._ @@ -192,7 +190,7 @@ class BooleanLiteralSupportSpec extends Spec { "both parameters" in testContext.withDialect(MirrorSqlDialectWithBooleanLiterals) { ctx => import ctx._ val q = quote { - query[Product].filter(p => lift("2").toInt == lift("1").toInt) + query[Product].filter(_ => lift("2").toInt == lift("1").toInt) } ctx.run(q).string mustEqual "SELECT p.id, p.desc, p.sku FROM Product p WHERE (?) = (?)" @@ -225,7 +223,7 @@ class BooleanLiteralSupportSpec extends Spec { "join + map" in testContext.withDialect(MirrorSqlDialectWithBooleanLiterals) { ctx => import ctx._ val q = quote { - qr1.leftJoin(qr2).on((a, b) => true).map(t => (t._1.i, t._2.map(_.s), false)) + qr1.leftJoin(qr2).on((_, _) => true).map(t => (t._1.i, t._2.map(_.s), false)) } ctx.run(q).string mustEqual "SELECT a.i AS _1, b.s AS _2, 0 AS _3 FROM TestEntity a LEFT JOIN TestEntity2 b ON 1 = 1" @@ -234,7 +232,7 @@ class BooleanLiteralSupportSpec extends Spec { "join + map (with conditional)" in testContext.withDialect(MirrorSqlDialectWithBooleanLiterals) { ctx => import ctx._ val q = quote { - qr1.leftJoin(qr2).on((a, b) => true).map(t => (t._1.i, if (t._2.map(_.i > 20) === true) false else true)) + qr1.leftJoin(qr2).on((_, _) => true).map(t => (t._1.i, if (t._2.map(_.i > 20) === true) false else true)) } ctx.run(q).string mustEqual "SELECT a.i AS _1, CASE WHEN CASE WHEN b.i > 20 THEN 1 ELSE 0 END = 1 THEN 0 ELSE 1 END AS _2 FROM TestEntity a LEFT JOIN TestEntity2 b ON 1 = 1" @@ -243,7 +241,7 @@ class BooleanLiteralSupportSpec extends Spec { "join + map (with conditional comparison)" in testContext.withDialect(MirrorSqlDialectWithBooleanLiterals) { ctx => import ctx._ val q = quote { - qr1.leftJoin(qr2).on((a, b) => true).map(t => (t._1.i, if (t._2.exists(_.i > 20)) false else true)) + qr1.leftJoin(qr2).on((_, _) => true).map(t => (t._1.i, if (t._2.exists(_.i > 20)) false else true)) } ctx.run(q).string mustEqual "SELECT a.i AS _1, CASE WHEN b.i > 20 THEN 0 ELSE 1 END AS _2 FROM TestEntity a LEFT JOIN TestEntity2 b ON 1 = 1" @@ -255,7 +253,7 @@ class BooleanLiteralSupportSpec extends Spec { val q = quote { qr1 .leftJoin(qr2) - .on((a, b) => true) + .on((_, _) => true) .map(t => (t._1.i, if (t._2.exists(_.i > 20)) lift(false) else lift(true))) } ctx.run(q).string mustEqual @@ -267,9 +265,9 @@ class BooleanLiteralSupportSpec extends Spec { val q = quote { qr1 .leftJoin(qr2) - .on((a, b) => false) + .on((_, _) => false) .map(t => (t._1.i, t._2.map(_.s), false)) - .filter(_._2.forall(v => if (true) true else false)) + .filter(_._2.forall(_ => if (true) true else false)) } ctx.run(q).string mustEqual "SELECT a.i AS _1, b.s AS _2, 0 AS _3 FROM TestEntity a LEFT JOIN TestEntity2 b ON 1 = 0 WHERE b.s IS NULL OR b.s IS NOT NULL AND (1 = 1 AND 1 = 1 OR NOT (1 = 1) AND 1 = 0)" @@ -280,9 +278,9 @@ class BooleanLiteralSupportSpec extends Spec { val q = quote { qr1 .leftJoin(qr2) - .on((a, b) => false) + .on((_, _) => false) .map(t => (t._1.i, t._2.map(_.s), false)) - .filter(_._2.forall(v => if (lift(true)) lift(true) else lift(false))) + .filter(_._2.forall(_ => if (lift(true)) lift(true) else lift(false))) } ctx.run(q).string mustEqual "SELECT a.i AS _1, b.s AS _2, 0 AS _3 FROM TestEntity a LEFT JOIN TestEntity2 b ON 1 = 0 WHERE b.s IS NULL OR b.s IS NOT NULL AND (1 = ? AND 1 = ? OR NOT (1 = ?) AND 1 = ?)" @@ -293,7 +291,7 @@ class BooleanLiteralSupportSpec extends Spec { val q = quote { for { t1 <- query[TestEntity] - t2 <- query[TestEntity].join(t => true) + t2 <- query[TestEntity].join(_ => true) } yield (t1, t2) } ctx.run(q).string mustEqual @@ -317,7 +315,7 @@ class BooleanLiteralSupportSpec extends Spec { "constant" in testContext.withDialect(MirrorSqlDialectWithBooleanLiterals) { ctx => import ctx._ val q = quote { - query[TestEntity].filter(t => !true) + query[TestEntity].filter(_ => !true) } // See: diff --git a/quill-sql/src/test/scala/io/getquill/context/sql/idiom/H2DialectSpec.scala b/quill-sql/src/test/scala/io/getquill/context/sql/idiom/H2DialectSpec.scala index 80b3c6351f..2106d2a256 100644 --- a/quill-sql/src/test/scala/io/getquill/context/sql/idiom/H2DialectSpec.scala +++ b/quill-sql/src/test/scala/io/getquill/context/sql/idiom/H2DialectSpec.scala @@ -3,7 +3,7 @@ package io.getquill.context.sql.idiom import io.getquill.{H2Dialect, Literal, SqlMirrorContext, TestEntities} class H2DialectSpec extends OnConflictSpec { - val ctx = new SqlMirrorContext(H2Dialect, Literal) with TestEntities + val ctx: SqlMirrorContext[H2Dialect.type,Literal.type] with TestEntities = new SqlMirrorContext(H2Dialect, Literal) with TestEntities import ctx._ "OnConflict" - `onConflict with all` { i => "no target - ignore" in { diff --git a/quill-sql/src/test/scala/io/getquill/context/sql/idiom/MySQL5DialectSpec.scala b/quill-sql/src/test/scala/io/getquill/context/sql/idiom/MySQL5DialectSpec.scala index 813184c329..d7da855597 100644 --- a/quill-sql/src/test/scala/io/getquill/context/sql/idiom/MySQL5DialectSpec.scala +++ b/quill-sql/src/test/scala/io/getquill/context/sql/idiom/MySQL5DialectSpec.scala @@ -1,10 +1,9 @@ package io.getquill.context.sql.idiom import io.getquill._ -import io.getquill.idiom.StringToken class MySQL5DialectSpec extends AbstractMySQLDialectSpec { - lazy val ctx = new SqlMirrorContext(MySQL5Dialect, Literal) with TestEntities + lazy val ctx: SqlMirrorContext[MySQL5Dialect.type,Literal.type] with TestEntities = new SqlMirrorContext(MySQL5Dialect, Literal) with TestEntities import ctx._ diff --git a/quill-sql/src/test/scala/io/getquill/context/sql/idiom/MySQLDialectSpec.scala b/quill-sql/src/test/scala/io/getquill/context/sql/idiom/MySQLDialectSpec.scala index 54c894a378..1d5d0b62e0 100644 --- a/quill-sql/src/test/scala/io/getquill/context/sql/idiom/MySQLDialectSpec.scala +++ b/quill-sql/src/test/scala/io/getquill/context/sql/idiom/MySQLDialectSpec.scala @@ -1,10 +1,9 @@ package io.getquill.context.sql.idiom import io.getquill._ -import io.getquill.idiom.StringToken class MySQLDialectSpec extends AbstractMySQLDialectSpec { - lazy val ctx = new SqlMirrorContext(MySQLDialect, Literal) with TestEntities + lazy val ctx: SqlMirrorContext[MySQLDialect.type,Literal.type] with TestEntities = new SqlMirrorContext(MySQLDialect, Literal) with TestEntities import ctx._ diff --git a/quill-sql/src/test/scala/io/getquill/context/sql/idiom/NestedQueryNamingStrategySpec.scala b/quill-sql/src/test/scala/io/getquill/context/sql/idiom/NestedQueryNamingStrategySpec.scala index 10f8b04a2b..e66963d1ee 100644 --- a/quill-sql/src/test/scala/io/getquill/context/sql/idiom/NestedQueryNamingStrategySpec.scala +++ b/quill-sql/src/test/scala/io/getquill/context/sql/idiom/NestedQueryNamingStrategySpec.scala @@ -1,7 +1,6 @@ package io.getquill.context.sql.idiom import io.getquill.base.Spec -import io.getquill.{EntityQuery, Quoted} import io.getquill.context.sql.testContextEscapeElements class NestedQueryNamingStrategySpec extends Spec { diff --git a/quill-sql/src/test/scala/io/getquill/context/sql/idiom/OffsetWithoutLimitWorkaroundSpec.scala b/quill-sql/src/test/scala/io/getquill/context/sql/idiom/OffsetWithoutLimitWorkaroundSpec.scala index 5f985452d5..0c0f110bab 100644 --- a/quill-sql/src/test/scala/io/getquill/context/sql/idiom/OffsetWithoutLimitWorkaroundSpec.scala +++ b/quill-sql/src/test/scala/io/getquill/context/sql/idiom/OffsetWithoutLimitWorkaroundSpec.scala @@ -9,7 +9,7 @@ import scala.util.Try class OffsetWithoutLimitWorkaroundSpec extends Spec { - val ctx = new SqlMirrorContext(MySQLDialect, Literal) with TestEntities { + val ctx: SqlMirrorContext[MySQLDialect.type,Literal.type] with TestEntities = new SqlMirrorContext(MySQLDialect, Literal) with TestEntities { override def probe(statement: String) = Try { statement mustEqual diff --git a/quill-sql/src/test/scala/io/getquill/context/sql/idiom/OnConflictSpec.scala b/quill-sql/src/test/scala/io/getquill/context/sql/idiom/OnConflictSpec.scala index 0144867154..a60c3a2411 100644 --- a/quill-sql/src/test/scala/io/getquill/context/sql/idiom/OnConflictSpec.scala +++ b/quill-sql/src/test/scala/io/getquill/context/sql/idiom/OnConflictSpec.scala @@ -3,12 +3,13 @@ package io.getquill.context.sql.idiom import io.getquill.{Insert, Quoted, TestEntities} import io.getquill.base.Spec import io.getquill.context.sql.SqlContext +import io.getquill.Delete trait OnConflictSpec extends Spec { val ctx: SqlContext[_, _] with TestEntities import ctx._ - lazy val e = TestEntity("s1", 1, 1, None, true) + lazy val e: TestEntity = TestEntity("s1", 1, 1, None, true) def `onConflict with query`(fun: Quoted[Insert[TestEntity]] => Unit) = "with query" - fun(quote(query[TestEntity].insertValue(lift(e)))) @@ -26,7 +27,7 @@ trait OnConflictSpec extends Spec { `onConflict with querySchema`(fun) } - def del = quote(query[TestEntity].delete) + def del: Quoted[Delete[TestEntity]] = quote(query[TestEntity].delete) def `no target - ignore`(ins: Quoted[Insert[TestEntity]]) = quote { ins.onConflictIgnore diff --git a/quill-sql/src/test/scala/io/getquill/context/sql/idiom/OracleDialectSpec.scala b/quill-sql/src/test/scala/io/getquill/context/sql/idiom/OracleDialectSpec.scala index 9549f3a779..d9f5edaa6b 100644 --- a/quill-sql/src/test/scala/io/getquill/context/sql/idiom/OracleDialectSpec.scala +++ b/quill-sql/src/test/scala/io/getquill/context/sql/idiom/OracleDialectSpec.scala @@ -5,7 +5,7 @@ import io.getquill.base.Spec class OracleDialectSpec extends Spec { - val ctx = new SqlMirrorContext(OracleDialect, Literal) with TestEntities + val ctx: SqlMirrorContext[OracleDialect.type,Literal.type] with TestEntities = new SqlMirrorContext(OracleDialect, Literal) with TestEntities import ctx._ "uses 'mod' function" in { @@ -57,13 +57,13 @@ class OracleDialectSpec extends Spec { "INSERT INTO TestEntity (s,o,b) VALUES (?, ?, ?)" } "returning - multiple fields + operations - should not compile" in { - val q = quote { + quote { qr1.insertValue(lift(TestEntity("s", 1, 2L, Some(3), true))) } "ctx.run(q.returning(r => (r.i, r.l + 1))).string" mustNot compile } "returning generated - multiple fields + operations - should not compile" in { - val q = quote { + quote { qr1.insertValue(lift(TestEntity("s", 1, 2L, Some(3), true))) } "ctx.run(q.returningGenerated(r => (r.i, r.l + 1))).string" mustNot compile @@ -112,15 +112,15 @@ class OracleDialectSpec extends Spec { "literal booleans" - { "boolean expressions" - { "uses 1 = 1 instead of true" in { - ctx.run(qr4.filter(t => true)).string mustEqual + ctx.run(qr4.filter(_ => true)).string mustEqual "SELECT t.i FROM TestEntity4 t WHERE 1 = 1" } "uses 1 = 0 instead of false" in { - ctx.run(qr4.filter(t => false)).string mustEqual + ctx.run(qr4.filter(_ => false)).string mustEqual "SELECT t.i FROM TestEntity4 t WHERE 1 = 0" } "uses 1 = 0 and 1 = 1 altogether" in { - ctx.run(qr4.filter(t => false).filter(t => true)).string mustEqual + ctx.run(qr4.filter(_ => false).filter(_ => true)).string mustEqual "SELECT t.i FROM TestEntity4 t WHERE 1 = 0 AND 1 = 1" } } @@ -139,13 +139,13 @@ class OracleDialectSpec extends Spec { } } "boolean values and expressions together" in { - ctx.run(qr4.filter(t => true).filter(t => false).map(t => (t.i, false, true))).string mustEqual + ctx.run(qr4.filter(_ => true).filter(_ => false).map(t => (t.i, false, true))).string mustEqual """SELECT t.i AS "_1", 0 AS "_2", 1 AS "_3" FROM TestEntity4 t WHERE 1 = 1 AND 1 = 0""" } "if" - { "simple booleans" in { val q = quote { - qr1.map(t => if (true) true else false) + qr1.map(_ => if (true) true else false) } ctx.run(q).string mustEqual "SELECT CASE WHEN 1 = 1 THEN 1 ELSE 0 END FROM TestEntity t" @@ -153,7 +153,7 @@ class OracleDialectSpec extends Spec { "nested conditions" - { "inside then" in { val q = quote { - qr1.map(t => + qr1.map(_ => if (true) { if (false) true else false } else true @@ -164,14 +164,14 @@ class OracleDialectSpec extends Spec { } "inside else" in { val q = quote { - qr1.map(t => if (true) true else if (false) true else false) + qr1.map(_ => if (true) true else if (false) true else false) } ctx.run(q).string mustEqual "SELECT CASE WHEN 1 = 1 THEN 1 WHEN 1 = 0 THEN 1 ELSE 0 END FROM TestEntity t" } "inside both" in { val q = quote { - qr1.map(t => + qr1.map(_ => if (true) { if (false) true else false } else { diff --git a/quill-sql/src/test/scala/io/getquill/context/sql/idiom/PostgresDialectSpec.scala b/quill-sql/src/test/scala/io/getquill/context/sql/idiom/PostgresDialectSpec.scala index 4592150b24..f4443a50da 100644 --- a/quill-sql/src/test/scala/io/getquill/context/sql/idiom/PostgresDialectSpec.scala +++ b/quill-sql/src/test/scala/io/getquill/context/sql/idiom/PostgresDialectSpec.scala @@ -7,7 +7,7 @@ import io.getquill.TestEntities class PostgresDialectSpec extends OnConflictSpec { - val ctx = new SqlMirrorContext(PostgresDialect, Literal) with TestEntities + val ctx: SqlMirrorContext[PostgresDialect.type,Literal.type] with TestEntities = new SqlMirrorContext(PostgresDialect, Literal) with TestEntities import ctx._ "applies explicit casts" - { @@ -26,7 +26,7 @@ class PostgresDialectSpec extends OnConflictSpec { } "Array Operations" - { - case class ArrayOps(id: Int, numbers: Vector[Int]) + final case class ArrayOps(id: Int, numbers: Vector[Int]) "contains" in { ctx.run(query[ArrayOps].filter(_.numbers.contains(10))).string mustEqual "SELECT x1.id, x1.numbers FROM ArrayOps x1 WHERE 10 = ANY(x1.numbers)" diff --git a/quill-sql/src/test/scala/io/getquill/context/sql/idiom/SQLServerDialectSpec.scala b/quill-sql/src/test/scala/io/getquill/context/sql/idiom/SQLServerDialectSpec.scala index 82c7dbde79..550a07d8f4 100644 --- a/quill-sql/src/test/scala/io/getquill/context/sql/idiom/SQLServerDialectSpec.scala +++ b/quill-sql/src/test/scala/io/getquill/context/sql/idiom/SQLServerDialectSpec.scala @@ -10,7 +10,7 @@ class SQLServerDialectSpec extends Spec { SQLServerDialect.emptySetContainsToken(StringToken("w/e")) mustBe StringToken("1 <> 1") } - val ctx = new SqlMirrorContext(SQLServerDialect, Literal) with TestEntities + val ctx: SqlMirrorContext[SQLServerDialect.type,Literal.type] with TestEntities = new SqlMirrorContext(SQLServerDialect, Literal) with TestEntities import ctx._ "uses + instead of ||" in { @@ -32,15 +32,15 @@ class SQLServerDialectSpec extends Spec { "literal booleans" - { "boolean expressions" - { "uses 1 = 1 instead of true" in { - ctx.run(qr4.filter(t => true)).string mustEqual + ctx.run(qr4.filter(_ => true)).string mustEqual "SELECT t.i FROM TestEntity4 t WHERE 1 = 1" } "uses 1 = 0 instead of false" in { - ctx.run(qr4.filter(t => false)).string mustEqual + ctx.run(qr4.filter(_ => false)).string mustEqual "SELECT t.i FROM TestEntity4 t WHERE 1 = 0" } "uses 1 = 0 and 1 = 1 altogether" in { - ctx.run(qr4.filter(t => false).filter(t => true)).string mustEqual + ctx.run(qr4.filter(_ => false).filter(_ => true)).string mustEqual "SELECT t.i FROM TestEntity4 t WHERE 1 = 0 AND 1 = 1" } } @@ -59,13 +59,13 @@ class SQLServerDialectSpec extends Spec { } } "boolean values and expressions together" in { - ctx.run(qr4.filter(t => true).filter(t => false).map(t => (t.i, false, true))).string mustEqual + ctx.run(qr4.filter(_ => true).filter(_ => false).map(t => (t.i, false, true))).string mustEqual "SELECT t.i AS _1, 0 AS _2, 1 AS _3 FROM TestEntity4 t WHERE 1 = 1 AND 1 = 0" } "if" - { "simple booleans" in { val q = quote { - qr1.map(t => if (true) true else false) + qr1.map(_ => if (true) true else false) } ctx.run(q).string mustEqual "SELECT CASE WHEN 1 = 1 THEN 1 ELSE 0 END FROM TestEntity t" @@ -73,7 +73,7 @@ class SQLServerDialectSpec extends Spec { "nested conditions" - { "inside then" in { val q = quote { - qr1.map(t => + qr1.map(_ => if (true) { if (false) true else false } else true ) @@ -83,14 +83,14 @@ class SQLServerDialectSpec extends Spec { } "inside else" in { val q = quote { - qr1.map(t => if (true) true else if (false) true else false) + qr1.map(_ => if (true) true else if (false) true else false) } ctx.run(q).string mustEqual "SELECT CASE WHEN 1 = 1 THEN 1 WHEN 1 = 0 THEN 1 ELSE 0 END FROM TestEntity t" } "inside both" in { val q = quote { - qr1.map(t => + qr1.map(_ => if (true) { if (false) true else false } else { if (true) false else true } ) diff --git a/quill-sql/src/test/scala/io/getquill/context/sql/idiom/SqlActionSpec.scala b/quill-sql/src/test/scala/io/getquill/context/sql/idiom/SqlActionSpec.scala index 43108403e6..e65af6ad06 100644 --- a/quill-sql/src/test/scala/io/getquill/context/sql/idiom/SqlActionSpec.scala +++ b/quill-sql/src/test/scala/io/getquill/context/sql/idiom/SqlActionSpec.scala @@ -103,14 +103,14 @@ class SqlActionSpec extends Spec { val q = quote { query[TestEntity].insertValue(lift(TestEntity("s", 1, 2L, Some(1), true))).returning(_.l) } - val run = ctx.run(q).string mustEqual + ctx.run(q).string mustEqual "INSERT INTO TestEntity (s,i,l,o,b) VALUES (?, ?, ?, ?, ?)" } "returning generated" in { val q = quote { query[TestEntity].insertValue(lift(TestEntity("s", 1, 2L, Some(1), true))).returningGenerated(_.l) } - val run = testContext.run(q).string mustEqual + testContext.run(q).string mustEqual "INSERT INTO TestEntity (s,i,o,b) VALUES (?, ?, ?, ?)" } "returning with single column table" in testContext.withDialect(MirrorSqlDialectWithReturnMulti) { ctx => @@ -131,8 +131,8 @@ class SqlActionSpec extends Spec { } "update" - { "reuse field name - with no filter" in { - case class Timeslot(id: Int, booked: Int) - val timeslotId = 123 + final case class Timeslot(id: Int, booked: Int) + val q = quote { query[Timeslot] .update(ts => ts.booked -> (ts.booked + lift(1))) @@ -141,7 +141,7 @@ class SqlActionSpec extends Spec { "UPDATE Timeslot SET booked = (booked + ?)" } "reuse field name - with filter" in { - case class Timeslot(id: Int, booked: Int) + final case class Timeslot(id: Int, booked: Int) val timeslotId = 123 val q = quote { query[Timeslot] @@ -154,7 +154,7 @@ class SqlActionSpec extends Spec { "reuse field name - with filter (mysql)" in { val ctx = new SqlMirrorContext(MySQLDialect, Literal) import ctx._ - case class Timeslot(id: Int, booked: Int) + final case class Timeslot(id: Int, booked: Int) val timeslotId = 123 val q = quote { query[Timeslot] diff --git a/quill-sql/src/test/scala/io/getquill/context/sql/idiom/SqlIdiomNamingSpec.scala b/quill-sql/src/test/scala/io/getquill/context/sql/idiom/SqlIdiomNamingSpec.scala index 9da01af6e3..a0dff00572 100644 --- a/quill-sql/src/test/scala/io/getquill/context/sql/idiom/SqlIdiomNamingSpec.scala +++ b/quill-sql/src/test/scala/io/getquill/context/sql/idiom/SqlIdiomNamingSpec.scala @@ -27,7 +27,7 @@ class SqlIdiomNamingSpec extends Spec { "uses the naming strategy" - { - case class SomeEntity(someColumn: Int) + final case class SomeEntity(someColumn: Int) "one transformation" in { val db = new SqlMirrorContext(MirrorSqlDialect, SnakeCase) @@ -115,7 +115,7 @@ class SqlIdiomNamingSpec extends Spec { } "queries" - { "property empty check" in { - case class SomeEntity(optionValue: Option[Int]) + final case class SomeEntity(optionValue: Option[Int]) db.run(query[SomeEntity].filter(t => t.optionValue.isEmpty)).string mustEqual "SELECT t.option_value AS optionValue FROM some_entity t WHERE t.option_value IS NULL" } diff --git a/quill-sql/src/test/scala/io/getquill/context/sql/idiom/SqlIdiomOptionCompareSpec.scala b/quill-sql/src/test/scala/io/getquill/context/sql/idiom/SqlIdiomOptionCompareSpec.scala index 450f4f0174..6fd0bbf9d5 100644 --- a/quill-sql/src/test/scala/io/getquill/context/sql/idiom/SqlIdiomOptionCompareSpec.scala +++ b/quill-sql/src/test/scala/io/getquill/context/sql/idiom/SqlIdiomOptionCompareSpec.scala @@ -138,8 +138,8 @@ class SqlIdiomOptionCompareSpec extends Spec { "SELECT t.s, t.i, t.l, t.o, t.b FROM TestEntity t WHERE t.i <> 1 AND (t.o IS NULL OR t.o IS NOT NULL AND CASE WHEN t.o <> 1 THEN false ELSE true END)" } "embedded" - { - case class TestEntity(optionalEmbedded: Option[EmbeddedEntity]) - case class EmbeddedEntity(value: Int) + final case class TestEntity(optionalEmbedded: Option[EmbeddedEntity]) + final case class EmbeddedEntity(value: Int) "exists" in { val q = quote { @@ -157,8 +157,8 @@ class SqlIdiomOptionCompareSpec extends Spec { } } "nested" - { - case class TestEntity(optionalEmbedded: Option[EmbeddedEntity]) - case class EmbeddedEntity(optionalValue: Option[Int]) + final case class TestEntity(optionalEmbedded: Option[EmbeddedEntity]) + final case class EmbeddedEntity(optionalValue: Option[Int]) "contains" in { val q = quote { @@ -354,8 +354,8 @@ class SqlIdiomOptionCompareSpec extends Spec { "SELECT t.s, t.i, t.l, t.o, t.b FROM TestEntity t WHERE t.i <> 1 AND (t.o IS NULL OR t.o IS NOT NULL AND CASE WHEN t.o <> 1 THEN false ELSE true END)" } "embedded" - { - case class TestEntity(optionalEmbedded: Option[EmbeddedEntity]) - case class EmbeddedEntity(value: Int) + final case class TestEntity(optionalEmbedded: Option[EmbeddedEntity]) + final case class EmbeddedEntity(value: Int) "exists" in { val q = quote { @@ -373,8 +373,8 @@ class SqlIdiomOptionCompareSpec extends Spec { } } "nested" - { - case class TestEntity(optionalEmbedded: Option[EmbeddedEntity]) - case class EmbeddedEntity(optionalValue: Option[Int]) + final case class TestEntity(optionalEmbedded: Option[EmbeddedEntity]) + final case class EmbeddedEntity(optionalValue: Option[Int]) "contains" in { val q = quote { diff --git a/quill-sql/src/test/scala/io/getquill/context/sql/idiom/SqlIdiomSpec.scala b/quill-sql/src/test/scala/io/getquill/context/sql/idiom/SqlIdiomSpec.scala index 3e0c2a5935..283b0d8b1a 100644 --- a/quill-sql/src/test/scala/io/getquill/context/sql/idiom/SqlIdiomSpec.scala +++ b/quill-sql/src/test/scala/io/getquill/context/sql/idiom/SqlIdiomSpec.scala @@ -1,8 +1,5 @@ package io.getquill.context.sql.idiom -import io.getquill.ReturnAction.ReturnColumns -import io.getquill.MirrorSqlDialectWithReturnMulti -import io.getquill.context.mirror.Row import io.getquill.context.sql.testContext import io.getquill.context.sql.testContext._ import io.getquill.Ord @@ -130,7 +127,7 @@ class SqlIdiomSpec extends Spec { } "caseclass constructor" in { - case class IntLong(i: Int, l: Long) + final case class IntLong(i: Int, l: Long) val q = quote { qr1.map(i => new IntLong(i.i, i.l)).distinct } @@ -138,7 +135,7 @@ class SqlIdiomSpec extends Spec { "SELECT DISTINCT i.i, i.l FROM TestEntity i" } "caseclass companion constructor" in { - case class IntLong(i: Int, l: Long) + final case class IntLong(i: Int, l: Long) val q = quote { qr1.map(i => IntLong(i.i, i.l)).distinct } @@ -498,13 +495,13 @@ class SqlIdiomSpec extends Spec { "left" ignore { // TODO flatten left flatMaps val q = quote { - qr1.flatMap(a => qr2).leftJoin(qr3).on((b, c) => b.s == c.s).map(_._1) + qr1.flatMap(_ => qr2).leftJoin(qr3).on((b, c) => b.s == c.s).map(_._1) } testContext.run(q).string mustEqual "" } "right" in { val q = quote { - qr1.leftJoin(qr2).on((a, b) => a.s == b.s).flatMap(c => qr3) + qr1.leftJoin(qr2).on((a, b) => a.s == b.s).flatMap(_ => qr3) } testContext.run(q).string mustEqual "SELECT x.s, x.i, x.l, x.o FROM TestEntity a LEFT JOIN TestEntity2 b ON a.s = b.s, TestEntity3 x" @@ -766,21 +763,21 @@ class SqlIdiomSpec extends Spec { "constant" - { "string" in { val q = quote { - qr1.map(t => "s") + qr1.map(_ => "s") } testContext.run(q).string mustEqual "SELECT 's' FROM TestEntity t" } "unit" in { val q = quote { - qr1.filter(t => qr1.map { u => }.isEmpty) + qr1.filter(_ => qr1.map { _ => }.isEmpty) } testContext.run(q).string mustEqual "SELECT t.s, t.i, t.l, t.o, t.b FROM TestEntity t WHERE NOT EXISTS (SELECT 1 FROM TestEntity u)" } "value" in { val q = quote { - qr1.map(t => 12) + qr1.map(_ => 12) } testContext.run(q).string mustEqual "SELECT 12 FROM TestEntity t" @@ -795,30 +792,30 @@ class SqlIdiomSpec extends Spec { } "tuple" in { val q = quote { - qr1.map(t => (1, 2)) + qr1.map(_ => (1, 2)) } testContext.run(q).string mustEqual "SELECT 1 AS _1, 2 AS _2 FROM TestEntity t" } "caseclass" in { - case class TwoInts(one: Int, two: Int) + final case class TwoInts(one: Int, two: Int) val q = quote { - qr1.map(t => new TwoInts(1, 2)) + qr1.map(_ => new TwoInts(1, 2)) } testContext.run(q).string mustEqual "SELECT 1 AS one, 2 AS two FROM TestEntity t" } "caseclass companion" in { - case class TwoInts(one: Int, two: Int) + final case class TwoInts(one: Int, two: Int) val q = quote { - qr1.map(t => TwoInts(1, 2)) + qr1.map(_ => TwoInts(1, 2)) } testContext.run(q).string mustEqual "SELECT 1 AS one, 2 AS two FROM TestEntity t" } "caseclass companion class scope" in { val q = quote { - qr1.map(t => TwoIntsClassScope(1, 2)) + qr1.map(_ => TwoIntsClassScope(1, 2)) } testContext.run(q).string mustEqual "SELECT 1 AS one, 2 AS two FROM TestEntity t" @@ -833,8 +830,8 @@ class SqlIdiomSpec extends Spec { "SELECT t.s FROM TestEntity t" } "nested" in { - case class A(s: String) - case class B(a: A) + final case class A(s: String) + final case class B(a: A) testContext.run(query[B]).string mustEqual "SELECT x.s FROM B x" } @@ -940,7 +937,7 @@ class SqlIdiomSpec extends Spec { "SELECT CONCAT(t.s, t.s) FROM TestEntity t" } "source query" in { - case class Entity(i: Int) + final case class Entity(i: Int) val q = quote { sql"SELECT 1 i FROM DUAL".as[Query[Entity]].map(a => a.i) } @@ -956,7 +953,7 @@ class SqlIdiomSpec extends Spec { "DELETE FROM TestEntity" } "do not nest query if infix starts with input query" in { - case class Entity(i: Int) + final case class Entity(i: Int) val forUpdate = quote { q: Query[Entity] => sql"$q FOR UPDATE".as[Query[Entity]].map(a => a.i) } @@ -975,7 +972,7 @@ class SqlIdiomSpec extends Spec { } "simple booleans" in { val q = quote { - qr1.map(t => if (true) true else false) + qr1.map(_ => if (true) true else false) } testContext.run(q).string mustEqual "SELECT CASE WHEN true THEN true ELSE false END FROM TestEntity t" @@ -989,7 +986,7 @@ class SqlIdiomSpec extends Spec { } "nested booleans" in { val q = quote { - qr1.map(t => if (true) true else if (true) true else false) + qr1.map(_ => if (true) true else if (true) true else false) } testContext.run(q).string mustEqual "SELECT CASE WHEN true THEN true WHEN true THEN true ELSE false END FROM TestEntity t" diff --git a/quill-sql/src/test/scala/io/getquill/context/sql/idiom/SqliteDialectSpec.scala b/quill-sql/src/test/scala/io/getquill/context/sql/idiom/SqliteDialectSpec.scala index 575653e001..1fb79e316e 100644 --- a/quill-sql/src/test/scala/io/getquill/context/sql/idiom/SqliteDialectSpec.scala +++ b/quill-sql/src/test/scala/io/getquill/context/sql/idiom/SqliteDialectSpec.scala @@ -8,7 +8,7 @@ import io.getquill.Ord class SqliteDialectSpec extends OnConflictSpec { - val ctx = new SqlMirrorContext(SqliteDialect, Literal) with TestEntities + val ctx: SqlMirrorContext[SqliteDialect.type,Literal.type] with TestEntities = new SqlMirrorContext(SqliteDialect, Literal) with TestEntities import ctx._ "sortBy doesn't specify nulls ordering" - { @@ -31,7 +31,7 @@ class SqliteDialectSpec extends OnConflictSpec { } "transforms boolean literals into 0/1" in { - ctx.run(qr1.map(t => (true, false))).string mustEqual + ctx.run(qr1.map(_ => (true, false))).string mustEqual "SELECT 1 AS _1, 0 AS _2 FROM TestEntity t" } diff --git a/quill-sql/src/test/scala/io/getquill/context/sql/idiom/VerifySqlQuerySpec.scala b/quill-sql/src/test/scala/io/getquill/context/sql/idiom/VerifySqlQuerySpec.scala index 5abbaf8f3d..fce5ad9581 100644 --- a/quill-sql/src/test/scala/io/getquill/context/sql/idiom/VerifySqlQuerySpec.scala +++ b/quill-sql/src/test/scala/io/getquill/context/sql/idiom/VerifySqlQuerySpec.scala @@ -2,7 +2,7 @@ package io.getquill.context.sql.idiom import io.getquill.base.Spec import io.getquill.context.sql.testContext._ -import io.getquill.context.sql.{SqlQuery, SqlQueryApply} +import io.getquill.context.sql.SqlQueryApply import scala.util.Try import io.getquill.context.sql.norm.SqlNormalize diff --git a/quill-sql/src/test/scala/io/getquill/context/sql/mirror/ArrayMirrorEncodingSpec.scala b/quill-sql/src/test/scala/io/getquill/context/sql/mirror/ArrayMirrorEncodingSpec.scala index c0340a1490..c2ba31cd0a 100644 --- a/quill-sql/src/test/scala/io/getquill/context/sql/mirror/ArrayMirrorEncodingSpec.scala +++ b/quill-sql/src/test/scala/io/getquill/context/sql/mirror/ArrayMirrorEncodingSpec.scala @@ -5,13 +5,14 @@ import java.util.Date import io.getquill.context.sql.encoding.ArrayEncodingBaseSpec import io.getquill.context.sql.testContext +import io.getquill.{ EntityQuery, Quoted } class ArrayMirrorEncodingSpec extends ArrayEncodingBaseSpec { val ctx = testContext import ctx._ - val q = quote(query[ArraysTestEntity]) + val q: Quoted[EntityQuery[ArraysTestEntity]] = quote(query[ArraysTestEntity]) "Support all sql base types and `Seq` implementers" in { val insertStr = ctx.run(q.insertValue(lift(e))).string diff --git a/quill-sql/src/test/scala/io/getquill/context/sql/mirror/ObservationMirrorSpec.scala b/quill-sql/src/test/scala/io/getquill/context/sql/mirror/ObservationMirrorSpec.scala index 72279b0e2b..fcc3b317c4 100644 --- a/quill-sql/src/test/scala/io/getquill/context/sql/mirror/ObservationMirrorSpec.scala +++ b/quill-sql/src/test/scala/io/getquill/context/sql/mirror/ObservationMirrorSpec.scala @@ -2,6 +2,7 @@ package io.getquill.context.sql.mirror import io.getquill.base.Spec import io.getquill.context.mirror.Row +import io.getquill.{ EntityQuery, Quoted } class ObservationMirrorSpec extends Spec { @@ -12,7 +13,7 @@ class ObservationMirrorSpec extends Spec { case class ScalarData(value: Long, position: Option[LatLon]) case class Observation(data: Option[ScalarData], foo: Option[String], bar: Option[String]) - val obs = quote { + val obs: Quoted[EntityQuery[Observation]] = quote { querySchema[Observation]( "observation", _.data.map(_.value) -> "obs_value", @@ -22,7 +23,7 @@ class ObservationMirrorSpec extends Spec { ) } - val obsEntry = Observation(Some(ScalarData(123, Some(LatLon(2, 3)))), None, Some("abc")) + val obsEntry: Observation = Observation(Some(ScalarData(123, Some(LatLon(2, 3)))), None, Some("abc")) "select query" in { ctx.run(obs).string mustEqual diff --git a/quill-sql/src/test/scala/io/getquill/context/sql/norm/AddDropToNestedOrderBySpec.scala b/quill-sql/src/test/scala/io/getquill/context/sql/norm/AddDropToNestedOrderBySpec.scala index 56ac06f1a4..91195fe6be 100644 --- a/quill-sql/src/test/scala/io/getquill/context/sql/norm/AddDropToNestedOrderBySpec.scala +++ b/quill-sql/src/test/scala/io/getquill/context/sql/norm/AddDropToNestedOrderBySpec.scala @@ -6,10 +6,10 @@ import io.getquill.context.sql.{TestDecoders, TestEncoders} class AddDropToNestedOrderBySpec extends Spec { - val ctx = new SqlMirrorContext(SQLServerDialect, Literal) with TestEntities with TestEncoders with TestDecoders + val ctx: SqlMirrorContext[SQLServerDialect.type,Literal.type] with TestEntities with TestEncoders with TestDecoders = new SqlMirrorContext(SQLServerDialect, Literal) with TestEntities with TestEncoders with TestDecoders import ctx._ - val q2Sorted = quote(qr2.sortBy(r => r.i)) + val q2Sorted: Quoted[Query[TestEntity2]] = quote(qr2.sortBy(r => r.i)) "adds drop(0) to nested order-by" - { "simple" in { diff --git a/quill-sql/src/test/scala/io/getquill/context/sql/norm/ExpandDistinctSpec.scala b/quill-sql/src/test/scala/io/getquill/context/sql/norm/ExpandDistinctSpec.scala index c8aff9ed6f..bd741c9cd2 100644 --- a/quill-sql/src/test/scala/io/getquill/context/sql/norm/ExpandDistinctSpec.scala +++ b/quill-sql/src/test/scala/io/getquill/context/sql/norm/ExpandDistinctSpec.scala @@ -1,6 +1,5 @@ package io.getquill.context.sql.norm -import io.getquill.Ord import io.getquill.base.Spec import io.getquill.context.sql.testContext.qr1 import io.getquill.context.sql.testContext.quote @@ -26,7 +25,7 @@ class ExpandDistinctSpec extends Spec { """querySchema("TestEntity").map(e => (e.i, e.l)).groupBy(g => g._1).map(x1 => (x1._2.max)).distinct.map(x1 => x1._1).nested""" } "with case class" in { - case class Rec(one: Int, two: Long) + final case class Rec(one: Int, two: Long) val q = quote { qr1.map(e => Rec(e.i, e.l)).distinct.nested } diff --git a/quill-sql/src/test/scala/io/getquill/context/sql/norm/ExpandNestedQueriesSpec.scala b/quill-sql/src/test/scala/io/getquill/context/sql/norm/ExpandNestedQueriesSpec.scala index a5aa55e99b..301621786f 100644 --- a/quill-sql/src/test/scala/io/getquill/context/sql/norm/ExpandNestedQueriesSpec.scala +++ b/quill-sql/src/test/scala/io/getquill/context/sql/norm/ExpandNestedQueriesSpec.scala @@ -24,7 +24,7 @@ class ExpandNestedQueriesSpec extends Spec { "multi-nests correctly" in { import testContext._ - case class MyPerson(first: String, last: String, age: Int) + final case class MyPerson(first: String, last: String, age: Int) val q = quote { query[MyPerson].nested.nested } @@ -34,7 +34,7 @@ class ExpandNestedQueriesSpec extends Spec { "multi-nests correctly with exclusions" in { import testContext._ - case class MyPerson(first: String, last: String, age: Int) + final case class MyPerson(first: String, last: String, age: Int) val q = quote { query[MyPerson].nested.nested.map(p => (p.first, p.last)) } @@ -77,7 +77,7 @@ class ExpandNestedQueriesSpec extends Spec { object testContext extends SqlMirrorContext(MirrorSqlDialect, SnakeCase) import testContext._ - case class Entity(camelCase: String) + final case class Entity(camelCase: String) testContext .run( @@ -123,8 +123,8 @@ class ExpandNestedQueriesSpec extends Spec { "expands nested mapped entity correctly" in { import testContext._ - case class TestEntity(s: String, i: Int, l: Long, o: Option[Int]) - case class Dual(ta: TestEntity, tb: TestEntity) + final case class TestEntity(s: String, i: Int, l: Long, o: Option[Int]) + final case class Dual(ta: TestEntity, tb: TestEntity) val qr1 = quote { query[TestEntity] @@ -179,8 +179,8 @@ class ExpandNestedQueriesSpec extends Spec { import ctx._ "embedded, distinct entity in sub-tuple" in { - case class Parent(id: Int, emb: Emb) - case class Emb(name: String, id: Int) + final case class Parent(id: Int, emb: Emb) + final case class Emb(name: String, id: Int) val q = quote { query[Parent].map(p => (p.emb, 1)).distinct.map(e => (e._1.name, e._1.id)) @@ -190,9 +190,9 @@ class ExpandNestedQueriesSpec extends Spec { } "embedded, distinct entity in case class" in { - case class Parent(id: Int, emb: Emb) - case class Emb(name: String, id: Int) - case class SuperParent(emb: Emb, id: Int) + final case class Parent(id: Int, emb: Emb) + final case class Emb(name: String, id: Int) + final case class SuperParent(emb: Emb, id: Int) val q = quote { query[Parent].map(p => SuperParent(p.emb, 1)).distinct.map(e => (e.emb.name, e.emb.id)) @@ -202,8 +202,8 @@ class ExpandNestedQueriesSpec extends Spec { } "can be propagated across nested query with naming intact" in { - case class Parent(id: Int, emb: Emb) - case class Emb(name: String, id: Int) + final case class Parent(id: Int, emb: Emb) + final case class Emb(name: String, id: Int) val q = quote { query[Parent].map(p => p.emb).nested.map(e => (e.name, e.id)) @@ -212,8 +212,8 @@ class ExpandNestedQueriesSpec extends Spec { } "can be propagated across distinct query with naming intact" in { - case class Parent(id: Int, emb: Emb) - case class Emb(name: String, id: Int) + final case class Parent(id: Int, emb: Emb) + final case class Emb(name: String, id: Int) val q = quote { query[Parent].map(p => p.emb).distinct.map(e => (e.name, e.id)) @@ -222,8 +222,8 @@ class ExpandNestedQueriesSpec extends Spec { } "can be propagated across distinct query with naming intact - double distinct" in { - case class Parent(id: Int, emb: Emb) - case class Emb(name: String, id: Int) + final case class Parent(id: Int, emb: Emb) + final case class Emb(name: String, id: Int) val q = quote { query[Parent].map(p => p.emb).distinct.map(e => (e.name, e.id)).distinct @@ -232,8 +232,8 @@ class ExpandNestedQueriesSpec extends Spec { } "can be propagated across distinct query with naming intact then re-wrapped into the parent" in { - case class Parent(id: Int, emb: Emb) - case class Emb(name: String, id: Int) + final case class Parent(id: Int, emb: Emb) + final case class Emb(name: String, id: Int) val q = quote { query[Parent] @@ -255,9 +255,9 @@ class ExpandNestedQueriesSpec extends Spec { "multiple embedding levels" in { import testContext._ - case class Emb(id: Int, name: String) - case class Parent(id: Int, name: String, emb: Emb) - case class GrandParent(id: Int, par: Parent) + final case class Emb(id: Int, name: String) + final case class Parent(id: Int, name: String, emb: Emb) + final case class GrandParent(id: Int, par: Parent) val q = quote { query[GrandParent] @@ -317,9 +317,9 @@ class ExpandNestedQueriesSpec extends Spec { "multiple embedding levels - another example" in { import testContext._ - case class Sim(sid: Int) - case class Mam(mid: Int, sim: Sim) - case class Bim(bid: Int, mam: Mam) + final case class Sim(sid: Int) + final case class Mam(mid: Int, sim: Sim) + final case class Bim(bid: Int, mam: Mam) val q = quote { query[Bim] @@ -386,9 +386,9 @@ class ExpandNestedQueriesSpec extends Spec { "multiple embedding levels - another example - with rename" in { import testContext._ - case class Sim(sid: Int) - case class Mam(mid: Int, sim: Sim) - case class Bim(bid: Int, mam: Mam) + final case class Sim(sid: Int) + final case class Mam(mid: Int, sim: Sim) + final case class Bim(bid: Int, mam: Mam) implicit val bimSchemaMeta = schemaMeta[Bim]("theBim", _.bid -> "theBid", _.mam.sim.sid -> "theSid") @@ -459,9 +459,9 @@ class ExpandNestedQueriesSpec extends Spec { "multiple embedding levels - another example - with rename - with escape column" in { val ctx = testContextUpperEscapeColumn import ctx._ - case class Sim(sid: Int) - case class Mam(mid: Int, sim: Sim) - case class Bim(bid: Int, mam: Mam) + final case class Sim(sid: Int) + final case class Mam(mid: Int, sim: Sim) + final case class Bim(bid: Int, mam: Mam) implicit val bimSchemaMeta = schemaMeta[Bim]("theBim", _.bid -> "theBid", _.mam.sim.sid -> "theSid") @@ -531,9 +531,9 @@ class ExpandNestedQueriesSpec extends Spec { "multiple embedding levels - another example - with rename - with escape column - with groupby" in { val ctx = testContextUpperEscapeColumn import ctx._ - case class Sim(sid: Int) - case class Mam(mid: Int, sim: Sim) - case class Bim(bid: Int, mam: Mam) + final case class Sim(sid: Int) + final case class Mam(mid: Int, sim: Sim) + final case class Bim(bid: Int, mam: Mam) implicit val bimSchemaMeta = schemaMeta[Bim]("theBim", _.bid -> "theBid", _.mam.sim.sid -> "theSid") @@ -636,8 +636,8 @@ class ExpandNestedQueriesSpec extends Spec { val ctx = testContextUpperEscapeColumn import ctx._ - case class Sim(sid: Int) - case class Mam(mid: Int, sim: Sim) + final case class Sim(sid: Int) + final case class Mam(mid: Int, sim: Sim) val q = quote { query[Mam] @@ -696,7 +696,7 @@ class ExpandNestedQueriesSpec extends Spec { import testContext._ "should be handled correctly in a regular schema" in { - case class Person(firstName: String, lastName: String) + final case class Person(firstName: String, lastName: String) val q = quote { sql"fromSomewhere()".as[Query[Person]] } @@ -705,8 +705,8 @@ class ExpandNestedQueriesSpec extends Spec { } "should be handled correctly in a regular schema - nested" in { - case class Name(firstName: String, lastName: String) - case class Person(name: Name, theAge: Int) + final case class Name(firstName: String, lastName: String) + final case class Person(name: Name, theAge: Int) val q = quote { sql"fromSomewhere()".as[Query[Person]] } @@ -716,8 +716,8 @@ class ExpandNestedQueriesSpec extends Spec { } "expression subquery" - { - case class ThePerson(name: String, age: Int, bossId: Int) - case class TheBoss(bossId: Int, name: String, age: Int) + final case class ThePerson(name: String, age: Int, bossId: Int) + final case class TheBoss(bossId: Int, name: String, age: Int) object testContext extends SqlMirrorContext(MirrorSqlDialect, SnakeCase) import testContext._ diff --git a/quill-sql/src/test/scala/io/getquill/context/sql/norm/FlattenGroupByAggregationSpec.scala b/quill-sql/src/test/scala/io/getquill/context/sql/norm/FlattenGroupByAggregationSpec.scala index 259fc98a3a..8cbcce959d 100644 --- a/quill-sql/src/test/scala/io/getquill/context/sql/norm/FlattenGroupByAggregationSpec.scala +++ b/quill-sql/src/test/scala/io/getquill/context/sql/norm/FlattenGroupByAggregationSpec.scala @@ -35,7 +35,7 @@ class FlattenGroupByAggregationSpec extends Spec { } "doesn't fail for nested query" in { - val q = quote { (e: Query[TestEntity]) => + val q = quote { (_: Query[TestEntity]) => qr2.size } FlattenGroupByAggregation(Ident("e"))(q.ast.body) mustEqual @@ -47,7 +47,7 @@ class FlattenGroupByAggregationSpec extends Spec { val q = quote { (e: Query[TestEntity]) => e.filter(_.i == 1).map(_.i).max } - val e = intercept[IllegalStateException] { + intercept[IllegalStateException] { FlattenGroupByAggregation(Ident("e"))(q.ast.body) } } @@ -55,7 +55,7 @@ class FlattenGroupByAggregationSpec extends Spec { val q = quote { (e: Query[TestEntity]) => e.flatMap(_ => qr2).size } - val e = intercept[IllegalStateException] { + intercept[IllegalStateException] { FlattenGroupByAggregation(Ident("e"))(q.ast.body) } } @@ -63,7 +63,7 @@ class FlattenGroupByAggregationSpec extends Spec { val q = quote { (e: Query[TestEntity]) => e.filter(_.i == 1).size } - val e = intercept[IllegalStateException] { + intercept[IllegalStateException] { FlattenGroupByAggregation(Ident("e"))(q.ast.body) } } @@ -71,7 +71,7 @@ class FlattenGroupByAggregationSpec extends Spec { val q = quote { (e: Query[TestEntity]) => e.sortBy(_.i).size } - val e = intercept[IllegalStateException] { + intercept[IllegalStateException] { FlattenGroupByAggregation(Ident("e"))(q.ast.body) } } @@ -79,7 +79,7 @@ class FlattenGroupByAggregationSpec extends Spec { val q = quote { (e: Query[TestEntity]) => e.take(1).size } - val e = intercept[IllegalStateException] { + intercept[IllegalStateException] { FlattenGroupByAggregation(Ident("e"))(q.ast.body) } } @@ -87,7 +87,7 @@ class FlattenGroupByAggregationSpec extends Spec { val q = quote { (e: Query[TestEntity]) => e.drop(1).size } - val e = intercept[IllegalStateException] { + intercept[IllegalStateException] { FlattenGroupByAggregation(Ident("e"))(q.ast.body) } } @@ -96,7 +96,7 @@ class FlattenGroupByAggregationSpec extends Spec { val q = quote { (e: Query[TestEntity]) => (e ++ qr1).size } - val e = intercept[IllegalStateException] { + intercept[IllegalStateException] { FlattenGroupByAggregation(Ident("e"))(q.ast.body) } } @@ -104,7 +104,7 @@ class FlattenGroupByAggregationSpec extends Spec { val q = quote { (e: Query[TestEntity]) => (qr1 ++ e).size } - val e = intercept[IllegalStateException] { + intercept[IllegalStateException] { FlattenGroupByAggregation(Ident("e"))(q.ast.body) } } @@ -114,7 +114,7 @@ class FlattenGroupByAggregationSpec extends Spec { val q = quote { (e: Query[TestEntity]) => e.unionAll(qr1).size } - val e = intercept[IllegalStateException] { + intercept[IllegalStateException] { FlattenGroupByAggregation(Ident("e"))(q.ast.body) } } @@ -122,7 +122,7 @@ class FlattenGroupByAggregationSpec extends Spec { val q = quote { (e: Query[TestEntity]) => qr1.unionAll(e).size } - val e = intercept[IllegalStateException] { + intercept[IllegalStateException] { FlattenGroupByAggregation(Ident("e"))(q.ast.body) } } @@ -130,17 +130,17 @@ class FlattenGroupByAggregationSpec extends Spec { "outerJoin" - { "left" in { val q = quote { (e: Query[TestEntity]) => - e.leftJoin(qr1).on((a, b) => true).size + e.leftJoin(qr1).on((_, _) => true).size } - val e = intercept[IllegalStateException] { + intercept[IllegalStateException] { FlattenGroupByAggregation(Ident("e"))(q.ast.body) } } "right" in { val q = quote { (e: Query[TestEntity]) => - qr1.leftJoin(e).on((a, b) => true).size + qr1.leftJoin(e).on((_, _) => true).size } - val e = intercept[IllegalStateException] { + intercept[IllegalStateException] { FlattenGroupByAggregation(Ident("e"))(q.ast.body) } } diff --git a/quill-sql/src/test/scala/io/getquill/context/sql/norm/JoinComplexSpec.scala b/quill-sql/src/test/scala/io/getquill/context/sql/norm/JoinComplexSpec.scala index f5ee61caff..ca7af69dc0 100644 --- a/quill-sql/src/test/scala/io/getquill/context/sql/norm/JoinComplexSpec.scala +++ b/quill-sql/src/test/scala/io/getquill/context/sql/norm/JoinComplexSpec.scala @@ -44,7 +44,7 @@ class JoinComplexSpec extends Spec { } "FlatJoin should function properly when plugged in with a shadow" - { - case class FooEntity(fs: String, fi: Int, fl: Long, fo: Option[Int], fb: Boolean) + final case class FooEntity(fs: String, fi: Int, fl: Long, fo: Option[Int], fb: Boolean) val first = quote { (tbl: Query[TestEntity]) => for { diff --git a/quill-sql/src/test/scala/io/getquill/context/sql/norm/RenamePropertiesOverrideSpec.scala b/quill-sql/src/test/scala/io/getquill/context/sql/norm/RenamePropertiesOverrideSpec.scala index a8208310dd..7b5a983fc3 100644 --- a/quill-sql/src/test/scala/io/getquill/context/sql/norm/RenamePropertiesOverrideSpec.scala +++ b/quill-sql/src/test/scala/io/getquill/context/sql/norm/RenamePropertiesOverrideSpec.scala @@ -10,12 +10,12 @@ class RenamePropertiesOverrideSpec extends Spec { case class IntLongCaseClassScope(im: Int, lm: Long) - val e = quote { + val e: Quoted[EntityQuery[TestEntity]] = quote { // Field i should be capitalized according to the naming convention querySchema[TestEntity]("test_entity", _.i -> "field_i", _.s -> "field_s") } - val f = quote { + val f: Quoted[EntityQuery[TestEntity]] = quote { qr1.filter(t => t.i == 1) } @@ -33,7 +33,7 @@ class RenamePropertiesOverrideSpec extends Spec { "SELECT t.field_s AS _1, t._2 FROM test_tuple t" } "mapped to caseclass and filtered" in { - case class StringInt(strProp: String, intProp: Int) + final case class StringInt(strProp: String, intProp: Int) val q = quote { tup.map(t => new StringInt(t._1, t._2)).filter(_.strProp == "foo") } @@ -103,7 +103,7 @@ class RenamePropertiesOverrideSpec extends Spec { } "transitive" in { val q = quote { - e.flatMap(t => qr2.map(u => t)).map(t => t.s) + e.flatMap(t => qr2.map(_ => t)).map(t => t.s) } testContextUpper.run(q).string mustEqual "SELECT t.field_s FROM test_entity t, TESTENTITY2 u" @@ -137,7 +137,7 @@ class RenamePropertiesOverrideSpec extends Spec { "SELECT t.field_i AS _1, t.L AS _2 FROM test_entity t" } "body with caseclass" in { - case class IntLongCase(im: Int, lm: Long) + final case class IntLongCase(im: Int, lm: Long) val q = quote { e.map(t => new IntLongCase(t.i, t.l)) } @@ -145,7 +145,7 @@ class RenamePropertiesOverrideSpec extends Spec { "SELECT t.field_i AS im, t.L AS lm FROM test_entity t" } "body with caseclass companion constructed" in { - case class IntLongCase(im: Int, lm: Long) + final case class IntLongCase(im: Int, lm: Long) val q = quote { e.map(t => IntLongCase(t.i, t.l)) } @@ -324,7 +324,7 @@ class RenamePropertiesOverrideSpec extends Spec { "operation" - { "unary" in { val q: Quoted[EntityQuery[Index]] = quote { - e.filter(a => e.filter(b => b.i > 0).isEmpty).map(_.i) + e.filter(_ => e.filter(b => b.i > 0).isEmpty).map(_.i) } testContextUpper.run(q).string mustEqual "SELECT a.field_i FROM test_entity a WHERE NOT EXISTS (SELECT b.field_s, b.field_i, b.L AS l, b.O AS o, b.B AS b FROM test_entity b WHERE b.field_i > 0)" @@ -349,14 +349,14 @@ class RenamePropertiesOverrideSpec extends Spec { "respects the schema definition for embedded" - { "query" - { "without schema" in { - case class B(c: Int) - case class A(b: B) + final case class B(c: Int) + final case class A(b: B) testContextUpper.run(query[A]).string mustEqual "SELECT x.C AS c FROM A x" } "with schema" in { - case class B(c: Int) - case class A(b: B) + final case class B(c: Int) + final case class A(b: B) val q = quote { querySchema[A]("A", _.b.c -> "bC") } @@ -366,14 +366,14 @@ class RenamePropertiesOverrideSpec extends Spec { } "query for Option embedded" - { "without schema" in { - case class B(c1: Int, c2: Int) - case class A(b: Option[B]) + final case class B(c1: Int, c2: Int) + final case class A(b: Option[B]) testContextUpper.run(query[A]).string mustEqual "SELECT x.C1 AS c1, x.C2 AS c2 FROM A x" } "with schema" in { - case class B(c1: Int, c2: Int) - case class A(b: Option[B]) + final case class B(c1: Int, c2: Int) + final case class A(b: Option[B]) val q = quote { querySchema[A]("A", _.b.map(_.c1) -> "bC1", _.b.map(_.c2) -> "bC2") } @@ -383,8 +383,8 @@ class RenamePropertiesOverrideSpec extends Spec { } "update" - { "without schema" in { - case class B(c: Int) - case class A(b: B) + final case class B(c: Int) + final case class A(b: B) val q = quote { query[A].update(_.b.c -> 1) } @@ -392,8 +392,8 @@ class RenamePropertiesOverrideSpec extends Spec { "UPDATE A SET C = 1" } "with schema" in { - case class B(c: Int) - case class A(b: B) + final case class B(c: Int) + final case class A(b: B) val q = quote { querySchema[A]("A", _.b.c -> "bC").update(_.b.c -> 1) } @@ -403,8 +403,8 @@ class RenamePropertiesOverrideSpec extends Spec { } "insert" - { "without schema" in { - case class B(c: Int) - case class A(b: B) + final case class B(c: Int) + final case class A(b: B) val q = quote { query[A].insert(_.b.c -> 1) } @@ -412,8 +412,8 @@ class RenamePropertiesOverrideSpec extends Spec { "INSERT INTO A (C) VALUES (1)" } "with schema" in { - case class B(c: Int) - case class A(b: B) + final case class B(c: Int) + final case class A(b: B) val q = quote { querySchema[A]("A", _.b.c -> "bC").insert(_.b.c -> 1) } @@ -423,8 +423,8 @@ class RenamePropertiesOverrideSpec extends Spec { } "sql" - { - case class B(b: Int) - case class A(u: Long, v: Int, w: B) + final case class B(b: Int) + final case class A(u: Long, v: Int, w: B) "does not break schema" in { val q = quote { sql"${querySchema[A]("C", _.v -> "m", _.w.b -> "n")} LIMIT 10".as[Query[A]] diff --git a/quill-sql/src/test/scala/io/getquill/context/sql/norm/RenamePropertiesSpec.scala b/quill-sql/src/test/scala/io/getquill/context/sql/norm/RenamePropertiesSpec.scala index 3bc8f448aa..a69910e91f 100644 --- a/quill-sql/src/test/scala/io/getquill/context/sql/norm/RenamePropertiesSpec.scala +++ b/quill-sql/src/test/scala/io/getquill/context/sql/norm/RenamePropertiesSpec.scala @@ -6,24 +6,25 @@ import io.getquill.context.sql.testContext._ import io.getquill.context.sql.testContext import io.getquill.Query import io.getquill.base.Spec +import io.getquill.{ EntityQuery, Quoted } class RenamePropertiesSpec extends Spec { case class IntLongCaseClassScope(im: Int, lm: Long) - val e = quote { + val e: Quoted[EntityQuery[TestEntity]] = quote { querySchema[TestEntity]("test_entity", _.s -> "field_s", _.i -> "field_i") } - val e2 = quote { + val e2: Quoted[EntityQuery[TestEntity]] = quote { querySchema[TestEntity]("test_entity_2", _.s -> "field_s_2", _.i -> "field_i_2") } - val tup = quote { + val tup: Quoted[EntityQuery[(String, Int)]] = quote { querySchema[(String, Int)]("test_tuple", _._1 -> "field_s", _._2 -> "field_i") } - val f = quote { + val f: Quoted[EntityQuery[TestEntity]] = quote { qr1.filter(t => t.i == 1) } @@ -41,7 +42,7 @@ class RenamePropertiesSpec extends Spec { "SELECT t.field_s AS _1, t.field_i AS _2 FROM test_tuple t" } "mapped to caseclass and filtered" in { - case class StringInt(strProp: String, intProp: Int) + final case class StringInt(strProp: String, intProp: Int) val q = quote { tup.map(t => new StringInt(t._1, t._2)).filter(_.strProp == "foo") } @@ -111,7 +112,7 @@ class RenamePropertiesSpec extends Spec { } "transitive" in { val q = quote { - e.flatMap(t => qr2.map(u => t)).map(t => t.s) + e.flatMap(t => qr2.map(_ => t)).map(t => t.s) } testContext.run(q).string mustEqual "SELECT t.field_s FROM test_entity t, TestEntity2 u" @@ -145,7 +146,7 @@ class RenamePropertiesSpec extends Spec { "SELECT t.field_i AS _1, t.l AS _2 FROM test_entity t" } "body with caseclass" in { - case class IntLongCase(im: Int, lm: Long) + final case class IntLongCase(im: Int, lm: Long) val q = quote { e.map(t => new IntLongCase(t.i, t.l)) } @@ -153,7 +154,7 @@ class RenamePropertiesSpec extends Spec { "SELECT t.field_i AS im, t.l AS lm FROM test_entity t" } "body with caseclass companion constructed" in { - case class IntLongCase(im: Int, lm: Long) + final case class IntLongCase(im: Int, lm: Long) val q = quote { e.map(t => IntLongCase(t.i, t.l)) } @@ -370,7 +371,7 @@ class RenamePropertiesSpec extends Spec { "operation" - { "unary" in { val q = quote { - e.filter(a => e.filter(b => b.i > 0).isEmpty).map(_.i) + e.filter(_ => e.filter(b => b.i > 0).isEmpty).map(_.i) } testContext.run(q).string mustEqual "SELECT a.field_i FROM test_entity a WHERE NOT EXISTS (SELECT b.field_s, b.field_i, b.l, b.o, b.b FROM test_entity b WHERE b.field_i > 0)" @@ -395,14 +396,14 @@ class RenamePropertiesSpec extends Spec { "respects the schema definition for embedded" - { "query" - { "without schema" in { - case class B(c: Int) - case class A(b: B) + final case class B(c: Int) + final case class A(b: B) testContext.run(query[A]).string mustEqual "SELECT x.c FROM A x" } "with schema" in { - case class B(c: Int) - case class A(b: B) + final case class B(c: Int) + final case class A(b: B) val q = quote { querySchema[A]("A", _.b.c -> "bC") } @@ -412,14 +413,14 @@ class RenamePropertiesSpec extends Spec { } "query for Option embedded" - { "without schema" in { - case class B(c1: Int, c2: Int) - case class A(b: Option[B]) + final case class B(c1: Int, c2: Int) + final case class A(b: Option[B]) testContext.run(query[A]).string mustEqual "SELECT x.c1, x.c2 FROM A x" } "with schema" in { - case class B(c1: Int, c2: Int) - case class A(b: Option[B]) + final case class B(c1: Int, c2: Int) + final case class A(b: Option[B]) val q = quote { querySchema[A]("A", _.b.map(_.c1) -> "bC1", _.b.map(_.c2) -> "bC2") } @@ -429,8 +430,8 @@ class RenamePropertiesSpec extends Spec { } "update" - { "without schema" in { - case class B(c: Int) - case class A(b: B) + final case class B(c: Int) + final case class A(b: B) val q = quote { query[A].update(_.b.c -> 1) } @@ -438,8 +439,8 @@ class RenamePropertiesSpec extends Spec { "UPDATE A SET c = 1" } "with schema" in { - case class B(c: Int) - case class A(b: B) + final case class B(c: Int) + final case class A(b: B) val q = quote { querySchema[A]("A", _.b.c -> "bC").update(_.b.c -> 1) } @@ -449,8 +450,8 @@ class RenamePropertiesSpec extends Spec { } "insert" - { "without schema" in { - case class B(c: Int) - case class A(b: B) + final case class B(c: Int) + final case class A(b: B) val q = quote { query[A].insert(_.b.c -> 1) } @@ -458,8 +459,8 @@ class RenamePropertiesSpec extends Spec { "INSERT INTO A (c) VALUES (1)" } "with schema" in { - case class B(c: Int) - case class A(b: B) + final case class B(c: Int) + final case class A(b: B) val q = quote { querySchema[A]("A", _.b.c -> "bC").insert(_.b.c -> 1) } @@ -469,8 +470,8 @@ class RenamePropertiesSpec extends Spec { } "sql" - { - case class B(b: Int) - case class A(u: Long, v: Int, w: B) + final case class B(b: Int) + final case class A(u: Long, v: Int, w: B) "does not break schema" in { val q = quote { sql"${querySchema[A]("C", _.v -> "m", _.w.b -> "n")} LIMIT 10".as[Query[A]] diff --git a/quill-sql/src/test/scala/io/getquill/quat/QuatRunSpec.scala b/quill-sql/src/test/scala/io/getquill/quat/QuatRunSpec.scala index 8b1648ee6e..3fec591d8b 100644 --- a/quill-sql/src/test/scala/io/getquill/quat/QuatRunSpec.scala +++ b/quill-sql/src/test/scala/io/getquill/quat/QuatRunSpec.scala @@ -9,7 +9,7 @@ class QuatRunSpec extends Spec { import testContext._ "should refine quats from generic infixes and express during execution" - { - case class MyPerson(name: String, age: Int) + final case class MyPerson(name: String, age: Int) val MyPersonQuat = Quat.Product("MyPersonQuat", "name" -> Quat.Value, "age" -> Quat.Value) "from extension methods" in { From 8ce69420d2ad83cbf0fa5399118769188510a37c Mon Sep 17 00:00:00 2001 From: jules Ivanic Date: Thu, 28 Sep 2023 20:03:38 +0400 Subject: [PATCH 2/2] scalafmt --- .../cassandra/alpakka/ListsEncodingSpec.scala | 2 +- .../cassandra/alpakka/MapsEncodingSpec.scala | 2 +- .../cassandra/alpakka/SetsEncodingSpec.scala | 2 +- .../context/cassandra/monix/package.scala | 3 +- .../context/cassandra/streaming/package.scala | 3 +- .../cassandra/CassandraTestEntities.scala | 2 +- .../context/cassandra/CollectionsSpec.scala | 8 +- .../context/cassandra/ListsEncodingSpec.scala | 2 +- .../QueryResultTypeCassandraSpec.scala | 14 ++-- .../getquill/context/cassandra/package.scala | 13 +++- .../getquill/codegen/SimpleCodegenSpec.scala | 7 +- .../io/getquill/codegen/StructuralTests.scala | 2 +- .../integration/CodegenTestCases.scala | 3 +- .../scala/io/getquill/MirrorContextSpec.scala | 3 +- .../ast/StatefulTransformerSpec.scala | 78 ++++++++++++++----- .../ast/StatelessTransformerSpec.scala | 5 +- .../scala/io/getquill/base/EncodingSpec.scala | 56 ++++++++++++- .../test/scala/io/getquill/base/Spec.scala | 2 +- .../io/getquill/context/ActionMacroSpec.scala | 15 ++-- .../norm/FlattenOptionOperationSpec.scala | 2 +- .../getquill/norm/NormalizeCachingSpec.scala | 6 +- .../io/getquill/norm/QueryGenerator.scala | 2 +- .../norm/SimplifyNullChecksSpec.scala | 6 +- .../getquill/norm/SymbolicReductionSpec.scala | 3 +- .../quotation/FreeVariablesSpec.scala | 8 +- .../io/getquill/quotation/QuotationSpec.scala | 13 +++- .../scala/io/getquill/util/CacheSpec.scala | 2 +- .../io/getquill/util/InterpolatorSpec.scala | 5 +- .../io/getquill/doobie/issue/Issue1067.scala | 2 +- .../postgres/PostgresAsyncEncodingSpec.scala | 2 +- .../postgres/PostgresAsyncEncodingSpec.scala | 2 +- .../TransactionalExecutionContextSpec.scala | 3 +- .../io/getquill/ResultSetIteratorSpec.scala | 4 +- .../test/scala/io/getquill/RunnerSpec.scala | 6 +- .../StreamResultsOrBlowUpSpec.scala | 25 +++--- .../io/getquill/mock/Introspection.scala | 2 +- .../scala/io/getquill/mock/MockTests.scala | 5 +- .../examples/IdiomaticAppWithEncoders.scala | 24 +++--- .../getquill/postgres/PostgresJsonSpec.scala | 6 +- .../io/getquill/ResultSetIteratorSpec.scala | 2 +- .../io/getquill/examples/IdiomaticApp.scala | 20 ++--- .../getquill/examples/IdiomaticAppPlain.scala | 9 ++- .../io/getquill/examples/other/PlainApp.scala | 2 +- .../examples/other/PlainAppDataSource.scala | 2 +- .../examples/other/ServiceExample.scala | 6 +- .../io/getquill/examples/other/ZioApp.scala | 6 +- .../examples/other/ZioAppDataSource.scala | 4 +- .../examples/other/ZioAppExample.scala | 12 +-- .../examples/other/ZioAppImplicitEnv.scala | 10 +-- .../examples/other/ZioAppManual.scala | 4 +- .../io/getquill/h2/PrepareJdbcSpec.scala | 5 +- .../io/getquill/mock/Introspection.scala | 2 +- .../scala/io/getquill/mock/ZioMockSpec.scala | 5 +- .../postgres/ConnectionLeakTest.scala | 6 +- .../postgres/MultiLevelServiceSpec.scala | 30 ++++--- .../io/getquill/sqlite/PrepareJdbcSpec.scala | 5 +- .../jdbc/oracle/JdbcEncodingSpec.scala | 4 +- .../jdbc/postgres/ArrayJdbcEncodingSpec.scala | 5 +- .../jdbc/sqlserver/BatchValuesJdbcSpec.scala | 2 +- .../context/orientdb/ListsEncodingSpec.scala | 3 +- .../context/orientdb/OrientDBQuerySpec.scala | 6 +- .../context/spark/EncodingSparkSpec.scala | 2 +- .../context/spark/TypeMemberJoinSpec.scala | 4 +- .../context/spark/VariableShadowSpec.scala | 11 +-- .../spark/examples/GitHubExample.scala | 6 +- .../spark/examples/TopHashtagsExample.scala | 6 +- .../spark/norm/ExpandEntityIdsSpec.scala | 10 ++- .../context/sql/AggregationSpec.scala | 3 +- .../getquill/context/sql/EmbeddedSpec.scala | 3 +- .../getquill/context/sql/EncodingSpec.scala | 16 +--- .../io/getquill/context/sql/ProductSpec.scala | 4 +- .../context/sql/QuerySchemaSpec.scala | 3 +- .../getquill/context/sql/TestDecoders.scala | 5 +- .../getquill/context/sql/TestEncoders.scala | 5 +- .../context/sql/base/ArrayOpsSpec.scala | 2 +- .../sql/base/BatchUpdateValuesSpec.scala | 2 +- .../context/sql/base/OnConflictSpec.scala | 2 +- .../sql/base/QueryResultTypeSpec.scala | 34 ++++---- .../context/sql/idiom/H2DialectSpec.scala | 3 +- .../context/sql/idiom/MySQL5DialectSpec.scala | 3 +- .../context/sql/idiom/MySQLDialectSpec.scala | 3 +- .../OffsetWithoutLimitWorkaroundSpec.scala | 15 ++-- .../context/sql/idiom/OracleDialectSpec.scala | 3 +- .../sql/idiom/PostgresDialectSpec.scala | 3 +- .../sql/idiom/SQLServerDialectSpec.scala | 3 +- .../context/sql/idiom/SqlActionSpec.scala | 2 +- .../context/sql/idiom/SqliteDialectSpec.scala | 3 +- .../sql/mirror/ArrayMirrorEncodingSpec.scala | 2 +- .../sql/mirror/ObservationMirrorSpec.scala | 2 +- .../sql/norm/AddDropToNestedOrderBySpec.scala | 3 +- .../sql/norm/RenamePropertiesSpec.scala | 2 +- 91 files changed, 401 insertions(+), 264 deletions(-) diff --git a/quill-cassandra-alpakka/src/test/scala/io/getquill/context/cassandra/alpakka/ListsEncodingSpec.scala b/quill-cassandra-alpakka/src/test/scala/io/getquill/context/cassandra/alpakka/ListsEncodingSpec.scala index 8c3b7b8d0e..30e29a666a 100644 --- a/quill-cassandra-alpakka/src/test/scala/io/getquill/context/cassandra/alpakka/ListsEncodingSpec.scala +++ b/quill-cassandra-alpakka/src/test/scala/io/getquill/context/cassandra/alpakka/ListsEncodingSpec.scala @@ -4,7 +4,7 @@ import io.getquill.context.cassandra.CollectionsSpec import java.time.{Instant, LocalDate} import java.util.UUID -import io.getquill.{ EntityQuery, Quoted } +import io.getquill.{EntityQuery, Quoted} class ListsEncodingSpec extends CollectionsSpec with CassandraAlpakkaSpec { val ctx = testDB diff --git a/quill-cassandra-alpakka/src/test/scala/io/getquill/context/cassandra/alpakka/MapsEncodingSpec.scala b/quill-cassandra-alpakka/src/test/scala/io/getquill/context/cassandra/alpakka/MapsEncodingSpec.scala index d133afe7fd..956e66e820 100644 --- a/quill-cassandra-alpakka/src/test/scala/io/getquill/context/cassandra/alpakka/MapsEncodingSpec.scala +++ b/quill-cassandra-alpakka/src/test/scala/io/getquill/context/cassandra/alpakka/MapsEncodingSpec.scala @@ -4,7 +4,7 @@ import io.getquill.context.cassandra.CollectionsSpec import java.time.{Instant, LocalDate} import java.util.UUID -import io.getquill.{ EntityQuery, Quoted } +import io.getquill.{EntityQuery, Quoted} class MapsEncodingSpec extends CollectionsSpec with CassandraAlpakkaSpec { val ctx = testDB diff --git a/quill-cassandra-alpakka/src/test/scala/io/getquill/context/cassandra/alpakka/SetsEncodingSpec.scala b/quill-cassandra-alpakka/src/test/scala/io/getquill/context/cassandra/alpakka/SetsEncodingSpec.scala index a7a47ddf5e..b548f3fae8 100644 --- a/quill-cassandra-alpakka/src/test/scala/io/getquill/context/cassandra/alpakka/SetsEncodingSpec.scala +++ b/quill-cassandra-alpakka/src/test/scala/io/getquill/context/cassandra/alpakka/SetsEncodingSpec.scala @@ -4,7 +4,7 @@ import io.getquill.context.cassandra.CollectionsSpec import java.time.{Instant, LocalDate} import java.util.UUID -import io.getquill.{ EntityQuery, Quoted } +import io.getquill.{EntityQuery, Quoted} class SetsEncodingSpec extends CollectionsSpec with CassandraAlpakkaSpec { val ctx = testDB diff --git a/quill-cassandra-monix/src/test/scala/io/getquill/context/cassandra/monix/package.scala b/quill-cassandra-monix/src/test/scala/io/getquill/context/cassandra/monix/package.scala index 8cb7042104..e79cf2fdd9 100644 --- a/quill-cassandra-monix/src/test/scala/io/getquill/context/cassandra/monix/package.scala +++ b/quill-cassandra-monix/src/test/scala/io/getquill/context/cassandra/monix/package.scala @@ -2,5 +2,6 @@ package io.getquill.context.cassandra import io.getquill.{CassandraMonixContext, Literal} package object monix { - lazy val testMonixDB: CassandraMonixContext[Literal.type] with CassandraTestEntities = new CassandraMonixContext(Literal, "testStreamDB") with CassandraTestEntities + lazy val testMonixDB: CassandraMonixContext[Literal.type] with CassandraTestEntities = + new CassandraMonixContext(Literal, "testStreamDB") with CassandraTestEntities } diff --git a/quill-cassandra-monix/src/test/scala/io/getquill/context/cassandra/streaming/package.scala b/quill-cassandra-monix/src/test/scala/io/getquill/context/cassandra/streaming/package.scala index 48ba2cc8cc..2aec4bd0f0 100644 --- a/quill-cassandra-monix/src/test/scala/io/getquill/context/cassandra/streaming/package.scala +++ b/quill-cassandra-monix/src/test/scala/io/getquill/context/cassandra/streaming/package.scala @@ -2,5 +2,6 @@ package io.getquill.context.cassandra import io.getquill.{CassandraStreamContext, Literal} package object streaming { - lazy val testStreamDB: CassandraStreamContext[Literal.type] with CassandraTestEntities = new CassandraStreamContext(Literal, "testStreamDB") with CassandraTestEntities + lazy val testStreamDB: CassandraStreamContext[Literal.type] with CassandraTestEntities = + new CassandraStreamContext(Literal, "testStreamDB") with CassandraTestEntities } diff --git a/quill-cassandra/src/test/scala/io/getquill/context/cassandra/CassandraTestEntities.scala b/quill-cassandra/src/test/scala/io/getquill/context/cassandra/CassandraTestEntities.scala index 668b99fb77..6f4078e9ec 100644 --- a/quill-cassandra/src/test/scala/io/getquill/context/cassandra/CassandraTestEntities.scala +++ b/quill-cassandra/src/test/scala/io/getquill/context/cassandra/CassandraTestEntities.scala @@ -1,7 +1,7 @@ package io.getquill.context.cassandra import io.getquill.TestEntities -import io.getquill.{ EntityQuery, Quoted } +import io.getquill.{EntityQuery, Quoted} trait CassandraTestEntities extends TestEntities { this: CassandraContext[_] => diff --git a/quill-cassandra/src/test/scala/io/getquill/context/cassandra/CollectionsSpec.scala b/quill-cassandra/src/test/scala/io/getquill/context/cassandra/CollectionsSpec.scala index 47f19505c5..3c33589d5f 100644 --- a/quill-cassandra/src/test/scala/io/getquill/context/cassandra/CollectionsSpec.scala +++ b/quill-cassandra/src/test/scala/io/getquill/context/cassandra/CollectionsSpec.scala @@ -6,10 +6,10 @@ import org.scalatest.BeforeAndAfterEach trait CollectionsSpec extends Spec with BeforeAndAfterEach { case class StrWrap(x: String) - implicit val encodeStrWrap: MappedEncoding[StrWrap,String] = MappedEncoding[StrWrap, String](_.x) - implicit val decodeStrWrap: MappedEncoding[String,StrWrap] = MappedEncoding[String, StrWrap](StrWrap.apply) + implicit val encodeStrWrap: MappedEncoding[StrWrap, String] = MappedEncoding[StrWrap, String](_.x) + implicit val decodeStrWrap: MappedEncoding[String, StrWrap] = MappedEncoding[String, StrWrap](StrWrap.apply) case class IntWrap(x: Int) - implicit val encodeIntWrap: MappedEncoding[IntWrap,Int] = MappedEncoding[IntWrap, Int](_.x) - implicit val decodeIntWrap: MappedEncoding[Int,IntWrap] = MappedEncoding[Int, IntWrap](IntWrap.apply) + implicit val encodeIntWrap: MappedEncoding[IntWrap, Int] = MappedEncoding[IntWrap, Int](_.x) + implicit val decodeIntWrap: MappedEncoding[Int, IntWrap] = MappedEncoding[Int, IntWrap](IntWrap.apply) } diff --git a/quill-cassandra/src/test/scala/io/getquill/context/cassandra/ListsEncodingSpec.scala b/quill-cassandra/src/test/scala/io/getquill/context/cassandra/ListsEncodingSpec.scala index e5d5c05cfa..29171ee4e7 100644 --- a/quill-cassandra/src/test/scala/io/getquill/context/cassandra/ListsEncodingSpec.scala +++ b/quill-cassandra/src/test/scala/io/getquill/context/cassandra/ListsEncodingSpec.scala @@ -2,7 +2,7 @@ package io.getquill.context.cassandra import java.util.UUID import java.time.{Instant, LocalDate} -import io.getquill.{ EntityQuery, Quoted } +import io.getquill.{EntityQuery, Quoted} class ListsEncodingSpec extends CollectionsSpec { val ctx = testSyncDB diff --git a/quill-cassandra/src/test/scala/io/getquill/context/cassandra/QueryResultTypeCassandraSpec.scala b/quill-cassandra/src/test/scala/io/getquill/context/cassandra/QueryResultTypeCassandraSpec.scala index d30a1c1ae7..53ff10ae08 100644 --- a/quill-cassandra/src/test/scala/io/getquill/context/cassandra/QueryResultTypeCassandraSpec.scala +++ b/quill-cassandra/src/test/scala/io/getquill/context/cassandra/QueryResultTypeCassandraSpec.scala @@ -4,7 +4,7 @@ import io.getquill.context.cassandra.encoding.Encoders import io.getquill.context.cassandra.encoding.Decoders import io.getquill.Ord import io.getquill.base.Spec -import io.getquill.{ Delete, EntityQuery, Query, Quoted } +import io.getquill.{Delete, EntityQuery, Query, Quoted} trait QueryResultTypeCassandraSpec extends Spec { @@ -19,15 +19,15 @@ trait QueryResultTypeCassandraSpec extends Spec { OrderTestEntity(3, 3) ) - val insert = quote((e: OrderTestEntity) => query[OrderTestEntity].insertValue(e)) - val deleteAll: Quoted[Delete[OrderTestEntity]] = quote(query[OrderTestEntity].delete) + val insert = quote((e: OrderTestEntity) => query[OrderTestEntity].insertValue(e)) + val deleteAll: Quoted[Delete[OrderTestEntity]] = quote(query[OrderTestEntity].delete) val selectAll: Quoted[EntityQuery[OrderTestEntity]] = quote(query[OrderTestEntity]) - val map: Quoted[EntityQuery[Int]] = quote(query[OrderTestEntity].map(_.id)) + val map: Quoted[EntityQuery[Int]] = quote(query[OrderTestEntity].map(_.id)) val filter: Quoted[EntityQuery[OrderTestEntity]] = quote(query[OrderTestEntity].filter(_.id == 1)) val withFilter: Quoted[EntityQuery[OrderTestEntity]] = quote(query[OrderTestEntity].withFilter(_.id == 1)) - val sortBy: Quoted[Query[OrderTestEntity]] = quote(query[OrderTestEntity].filter(_.id == 1).sortBy(_.i)(Ord.asc)) - val take: Quoted[Query[OrderTestEntity]] = quote(query[OrderTestEntity].take(10)) - val entitySize: Quoted[Long] = quote(query[OrderTestEntity].size) + val sortBy: Quoted[Query[OrderTestEntity]] = quote(query[OrderTestEntity].filter(_.id == 1).sortBy(_.i)(Ord.asc)) + val take: Quoted[Query[OrderTestEntity]] = quote(query[OrderTestEntity].take(10)) + val entitySize: Quoted[Long] = quote(query[OrderTestEntity].size) val parametrizedSize: Quoted[Int => Long] = quote { (id: Int) => query[OrderTestEntity].filter(_.id == id).size } diff --git a/quill-cassandra/src/test/scala/io/getquill/context/cassandra/package.scala b/quill-cassandra/src/test/scala/io/getquill/context/cassandra/package.scala index d07ca8cfa5..85b0c0e53a 100644 --- a/quill-cassandra/src/test/scala/io/getquill/context/cassandra/package.scala +++ b/quill-cassandra/src/test/scala/io/getquill/context/cassandra/package.scala @@ -9,12 +9,17 @@ import io.getquill.Literal package object cassandra { - lazy val mirrorContext: CassandraMirrorContext[Literal.type] with CassandraTestEntities = new CassandraMirrorContext(Literal) with CassandraTestEntities - lazy val capsMirrorContext: CassandraMirrorContext[UpperCaseNonDefault.type] with CassandraTestEntities = new CassandraMirrorContext(UpperCaseNonDefault) with CassandraTestEntities + lazy val mirrorContext: CassandraMirrorContext[Literal.type] with CassandraTestEntities = new CassandraMirrorContext( + Literal + ) with CassandraTestEntities + lazy val capsMirrorContext: CassandraMirrorContext[UpperCaseNonDefault.type] with CassandraTestEntities = + new CassandraMirrorContext(UpperCaseNonDefault) with CassandraTestEntities - lazy val testSyncDB: CassandraSyncContext[Literal.type] with CassandraTestEntities = new CassandraSyncContext(Literal, "testSyncDB") with CassandraTestEntities + lazy val testSyncDB: CassandraSyncContext[Literal.type] with CassandraTestEntities = + new CassandraSyncContext(Literal, "testSyncDB") with CassandraTestEntities - lazy val testAsyncDB: CassandraAsyncContext[Literal.type] with CassandraTestEntities = new CassandraAsyncContext(Literal, "testAsyncDB") with CassandraTestEntities + lazy val testAsyncDB: CassandraAsyncContext[Literal.type] with CassandraTestEntities = + new CassandraAsyncContext(Literal, "testAsyncDB") with CassandraTestEntities def await[T](f: Future[T]): T = Await.result(f, Duration.Inf) } diff --git a/quill-codegen-jdbc/src/test/scala/io/getquill/codegen/SimpleCodegenSpec.scala b/quill-codegen-jdbc/src/test/scala/io/getquill/codegen/SimpleCodegenSpec.scala index b236c5f514..a806c5bc49 100644 --- a/quill-codegen-jdbc/src/test/scala/io/getquill/codegen/SimpleCodegenSpec.scala +++ b/quill-codegen-jdbc/src/test/scala/io/getquill/codegen/SimpleCodegenSpec.scala @@ -25,7 +25,12 @@ class SimpleCodegenSpec extends AnyFreeSpec with Matchers { case class QuerySchema(defName: String, tableName: String, fields: Seq[(String, String)]) - def assertStandardObject(objectCode: String, objectName: String, ccName: String, querySchemas: Seq[QuerySchema]): Unit = { + def assertStandardObject( + objectCode: String, + objectName: String, + ccName: String, + querySchemas: Seq[QuerySchema] + ): Unit = { val tb = runtimeMirror(this.getClass.getClassLoader).mkToolBox() val ob = tb.parse(objectCode) ob match { diff --git a/quill-codegen-jdbc/src/test/scala/io/getquill/codegen/StructuralTests.scala b/quill-codegen-jdbc/src/test/scala/io/getquill/codegen/StructuralTests.scala index 7883442e9c..c3524ca302 100644 --- a/quill-codegen-jdbc/src/test/scala/io/getquill/codegen/StructuralTests.scala +++ b/quill-codegen-jdbc/src/test/scala/io/getquill/codegen/StructuralTests.scala @@ -8,7 +8,7 @@ import io.getquill.codegen.util.SchemaConfig._ class StructuralTests extends SimpleCodegenSpec with WithStandardCodegen { - def LOG: Logger = Logger(getClass) + def LOG: Logger = Logger(getClass) override def defaultNamespace: String = "schema" "simple end to end tests" - { diff --git a/quill-codegen-jdbc/src/test/scala/io/getquill/codegen/integration/CodegenTestCases.scala b/quill-codegen-jdbc/src/test/scala/io/getquill/codegen/integration/CodegenTestCases.scala index c38f30e803..055376d6ae 100644 --- a/quill-codegen-jdbc/src/test/scala/io/getquill/codegen/integration/CodegenTestCases.scala +++ b/quill-codegen-jdbc/src/test/scala/io/getquill/codegen/integration/CodegenTestCases.scala @@ -29,7 +29,8 @@ sealed trait CodegenTestCases { sym.name.decodedName.toString + "-lib" } - def schemaMakerCoordinates(dbPrefix: ConfigPrefix): SchemaMakerCoordinates = SchemaMakerCoordinates(dbPrefix, naming, schemaConfig) + def schemaMakerCoordinates(dbPrefix: ConfigPrefix): SchemaMakerCoordinates = + SchemaMakerCoordinates(dbPrefix, naming, schemaConfig) def generateWithSchema(dbPrefix: ConfigPrefix, basePath: String): Future[Seq[Path]] = SchemaMaker.withContext(schemaMakerCoordinates(dbPrefix))({ diff --git a/quill-core/src/test/scala/io/getquill/MirrorContextSpec.scala b/quill-core/src/test/scala/io/getquill/MirrorContextSpec.scala index 8cc6004d6f..2cb2c6978b 100644 --- a/quill-core/src/test/scala/io/getquill/MirrorContextSpec.scala +++ b/quill-core/src/test/scala/io/getquill/MirrorContextSpec.scala @@ -3,7 +3,8 @@ package io.getquill import io.getquill.base.Spec class MirrorContextSpec extends Spec { - val ctx: MirrorContext[MirrorIdiom.type,Literal.type] with TestEntities = new MirrorContext(MirrorIdiom, Literal) with TestEntities + val ctx: MirrorContext[MirrorIdiom.type, Literal.type] with TestEntities = new MirrorContext(MirrorIdiom, Literal) + with TestEntities "probe" in { ctx.probe("Ok").toOption mustBe defined diff --git a/quill-core/src/test/scala/io/getquill/ast/StatefulTransformerSpec.scala b/quill-core/src/test/scala/io/getquill/ast/StatefulTransformerSpec.scala index c928d86e7b..cc1f1e159a 100644 --- a/quill-core/src/test/scala/io/getquill/ast/StatefulTransformerSpec.scala +++ b/quill-core/src/test/scala/io/getquill/ast/StatefulTransformerSpec.scala @@ -26,7 +26,9 @@ class StatefulTransformerSpec extends Spec { } "filter" in { val ast: Ast = Filter(Ident("a"), Ident("b"), Ident("c")) - Subject(List.empty, Ident("a") -> Ident("a'"), Ident("b") -> Ident("b'"), Ident("c") -> Ident("c'"))(ast) match { + Subject(List.empty, Ident("a") -> Ident("a'"), Ident("b") -> Ident("b'"), Ident("c") -> Ident("c'"))( + ast + ) match { case (at, att) => at mustEqual Filter(Ident("a'"), Ident("b"), Ident("c'")) att.state mustEqual List(Ident("a"), Ident("c")) @@ -34,7 +36,9 @@ class StatefulTransformerSpec extends Spec { } "map" in { val ast: Ast = Map(Ident("a"), Ident("b"), Ident("c")) - Subject(List.empty, Ident("a") -> Ident("a'"), Ident("b") -> Ident("b'"), Ident("c") -> Ident("c'"))(ast) match { + Subject(List.empty, Ident("a") -> Ident("a'"), Ident("b") -> Ident("b'"), Ident("c") -> Ident("c'"))( + ast + ) match { case (at, att) => at mustEqual Map(Ident("a'"), Ident("b"), Ident("c'")) att.state mustEqual List(Ident("a"), Ident("c")) @@ -42,7 +46,9 @@ class StatefulTransformerSpec extends Spec { } "flatMap" in { val ast: Ast = FlatMap(Ident("a"), Ident("b"), Ident("c")) - Subject(List.empty, Ident("a") -> Ident("a'"), Ident("b") -> Ident("b'"), Ident("c") -> Ident("c'"))(ast) match { + Subject(List.empty, Ident("a") -> Ident("a'"), Ident("b") -> Ident("b'"), Ident("c") -> Ident("c'"))( + ast + ) match { case (at, att) => at mustEqual FlatMap(Ident("a'"), Ident("b"), Ident("c'")) att.state mustEqual List(Ident("a"), Ident("c")) @@ -50,7 +56,9 @@ class StatefulTransformerSpec extends Spec { } "concatMap" in { val ast: Ast = ConcatMap(Ident("a"), Ident("b"), Ident("c")) - Subject(List.empty, Ident("a") -> Ident("a'"), Ident("b") -> Ident("b'"), Ident("c") -> Ident("c'"))(ast) match { + Subject(List.empty, Ident("a") -> Ident("a'"), Ident("b") -> Ident("b'"), Ident("c") -> Ident("c'"))( + ast + ) match { case (at, att) => at mustEqual ConcatMap(Ident("a'"), Ident("b"), Ident("c'")) att.state mustEqual List(Ident("a"), Ident("c")) @@ -58,7 +66,9 @@ class StatefulTransformerSpec extends Spec { } "sortBy" in { val ast: Ast = SortBy(Ident("a"), Ident("b"), Ident("c"), AscNullsFirst) - Subject(List.empty, Ident("a") -> Ident("a'"), Ident("b") -> Ident("b'"), Ident("c") -> Ident("c'"))(ast) match { + Subject(List.empty, Ident("a") -> Ident("a'"), Ident("b") -> Ident("b'"), Ident("c") -> Ident("c'"))( + ast + ) match { case (at, att) => at mustEqual SortBy(Ident("a'"), Ident("b"), Ident("c'"), AscNullsFirst) att.state mustEqual List(Ident("a"), Ident("c")) @@ -66,7 +76,9 @@ class StatefulTransformerSpec extends Spec { } "groupBy" in { val ast: Ast = GroupBy(Ident("a"), Ident("b"), Ident("c")) - Subject(List.empty, Ident("a") -> Ident("a'"), Ident("b") -> Ident("b'"), Ident("c") -> Ident("c'"))(ast) match { + Subject(List.empty, Ident("a") -> Ident("a'"), Ident("b") -> Ident("b'"), Ident("c") -> Ident("c'"))( + ast + ) match { case (at, att) => at mustEqual GroupBy(Ident("a'"), Ident("b"), Ident("c'")) att.state mustEqual List(Ident("a"), Ident("c")) @@ -114,7 +126,9 @@ class StatefulTransformerSpec extends Spec { } "outer join" in { val ast: Ast = Join(FullJoin, Ident("a"), Ident("b"), Ident("c"), Ident("d"), Ident("e")) - Subject(List.empty, Ident("a") -> Ident("a'"), Ident("b") -> Ident("b'"), Ident("e") -> Ident("e'"))(ast) match { + Subject(List.empty, Ident("a") -> Ident("a'"), Ident("b") -> Ident("b'"), Ident("e") -> Ident("e'"))( + ast + ) match { case (at, att) => at mustEqual Join(FullJoin, Ident("a'"), Ident("b'"), Ident("c"), Ident("d"), Ident("e'")) att.state mustEqual List(Ident("a"), Ident("b"), Ident("e")) @@ -149,7 +163,9 @@ class StatefulTransformerSpec extends Spec { } "function apply" in { val ast: Ast = FunctionApply(Ident("a"), List(Ident("b"), Ident("c"))) - Subject(List.empty, Ident("a") -> Ident("a'"), Ident("b") -> Ident("b'"), Ident("c") -> Ident("c'"))(ast) match { + Subject(List.empty, Ident("a") -> Ident("a'"), Ident("b") -> Ident("b'"), Ident("c") -> Ident("c'"))( + ast + ) match { case (at, att) => at mustEqual FunctionApply(Ident("a'"), List(Ident("b'"), Ident("c'"))) att.state mustEqual List(Ident("a"), Ident("b"), Ident("c")) @@ -176,7 +192,9 @@ class StatefulTransformerSpec extends Spec { } "tuple" in { val ast: Ast = Tuple(List(Ident("a"), Ident("b"), Ident("c"))) - Subject(List.empty, Ident("a") -> Ident("a'"), Ident("b") -> Ident("b'"), Ident("c") -> Ident("c'"))(ast) match { + Subject(List.empty, Ident("a") -> Ident("a'"), Ident("b") -> Ident("b'"), Ident("c") -> Ident("c'"))( + ast + ) match { case (at, att) => at mustEqual Tuple(List(Ident("a'"), Ident("b'"), Ident("c'"))) att.state mustEqual List(Ident("a"), Ident("b"), Ident("c")) @@ -184,7 +202,9 @@ class StatefulTransformerSpec extends Spec { } "caseclass" in { val ast: Ast = CaseClass("CC", List(("foo", Ident("a")), ("bar", Ident("b")), ("baz", Ident("c")))) - Subject(List.empty, Ident("a") -> Ident("a'"), Ident("b") -> Ident("b'"), Ident("c") -> Ident("c'"))(ast) match { + Subject(List.empty, Ident("a") -> Ident("a'"), Ident("b") -> Ident("b'"), Ident("c") -> Ident("c'"))( + ast + ) match { case (at, att) => at mustEqual CaseClass("CC", List(("foo", Ident("a'")), ("bar", Ident("b'")), ("baz", Ident("c'")))) att.state mustEqual List(Ident("a"), Ident("b"), Ident("c")) @@ -443,7 +463,9 @@ class StatefulTransformerSpec extends Spec { } "flatMap - Unchecked" in { val ast: Ast = OptionTableFlatMap(Ident("a"), Ident("b"), Ident("c")) - Subject(List.empty, Ident("a") -> Ident("a'"), Ident("b") -> Ident("b'"), Ident("c") -> Ident("c'"))(ast) match { + Subject(List.empty, Ident("a") -> Ident("a'"), Ident("b") -> Ident("b'"), Ident("c") -> Ident("c'"))( + ast + ) match { case (at, att) => at mustEqual OptionTableFlatMap(Ident("a'"), Ident("b"), Ident("c'")) att.state mustEqual List(Ident("a"), Ident("c")) @@ -451,7 +473,9 @@ class StatefulTransformerSpec extends Spec { } "map - Unchecked" in { val ast: Ast = OptionTableMap(Ident("a"), Ident("b"), Ident("c")) - Subject(List.empty, Ident("a") -> Ident("a'"), Ident("b") -> Ident("b'"), Ident("c") -> Ident("c'"))(ast) match { + Subject(List.empty, Ident("a") -> Ident("a'"), Ident("b") -> Ident("b'"), Ident("c") -> Ident("c'"))( + ast + ) match { case (at, att) => at mustEqual OptionTableMap(Ident("a'"), Ident("b"), Ident("c'")) att.state mustEqual List(Ident("a"), Ident("c")) @@ -459,7 +483,9 @@ class StatefulTransformerSpec extends Spec { } "flatMap" in { val ast: Ast = OptionFlatMap(Ident("a"), Ident("b"), Ident("c")) - Subject(List.empty, Ident("a") -> Ident("a'"), Ident("b") -> Ident("b'"), Ident("c") -> Ident("c'"))(ast) match { + Subject(List.empty, Ident("a") -> Ident("a'"), Ident("b") -> Ident("b'"), Ident("c") -> Ident("c'"))( + ast + ) match { case (at, att) => at mustEqual OptionFlatMap(Ident("a'"), Ident("b"), Ident("c'")) att.state mustEqual List(Ident("a"), Ident("c")) @@ -467,7 +493,9 @@ class StatefulTransformerSpec extends Spec { } "map" in { val ast: Ast = OptionMap(Ident("a"), Ident("b"), Ident("c")) - Subject(List.empty, Ident("a") -> Ident("a'"), Ident("b") -> Ident("b'"), Ident("c") -> Ident("c'"))(ast) match { + Subject(List.empty, Ident("a") -> Ident("a'"), Ident("b") -> Ident("b'"), Ident("c") -> Ident("c'"))( + ast + ) match { case (at, att) => at mustEqual OptionMap(Ident("a'"), Ident("b"), Ident("c'")) att.state mustEqual List(Ident("a"), Ident("c")) @@ -475,7 +503,9 @@ class StatefulTransformerSpec extends Spec { } "forall" in { val ast: Ast = OptionForall(Ident("a"), Ident("b"), Ident("c")) - Subject(List.empty, Ident("a") -> Ident("a'"), Ident("b") -> Ident("b'"), Ident("c") -> Ident("c'"))(ast) match { + Subject(List.empty, Ident("a") -> Ident("a'"), Ident("b") -> Ident("b'"), Ident("c") -> Ident("c'"))( + ast + ) match { case (at, att) => at mustEqual OptionForall(Ident("a'"), Ident("b"), Ident("c'")) att.state mustEqual List(Ident("a"), Ident("c")) @@ -483,7 +513,9 @@ class StatefulTransformerSpec extends Spec { } "forall - Unchecked" in { val ast: Ast = OptionTableForall(Ident("a"), Ident("b"), Ident("c")) - Subject(List.empty, Ident("a") -> Ident("a'"), Ident("b") -> Ident("b'"), Ident("c") -> Ident("c'"))(ast) match { + Subject(List.empty, Ident("a") -> Ident("a'"), Ident("b") -> Ident("b'"), Ident("c") -> Ident("c'"))( + ast + ) match { case (at, att) => at mustEqual OptionTableForall(Ident("a'"), Ident("b"), Ident("c'")) att.state mustEqual List(Ident("a"), Ident("c")) @@ -491,7 +523,9 @@ class StatefulTransformerSpec extends Spec { } "exists - Unchecked" in { val ast: Ast = OptionTableExists(Ident("a"), Ident("b"), Ident("c")) - Subject(List.empty, Ident("a") -> Ident("a'"), Ident("b") -> Ident("b'"), Ident("c") -> Ident("c'"))(ast) match { + Subject(List.empty, Ident("a") -> Ident("a'"), Ident("b") -> Ident("b'"), Ident("c") -> Ident("c'"))( + ast + ) match { case (at, att) => at mustEqual OptionTableExists(Ident("a'"), Ident("b"), Ident("c'")) att.state mustEqual List(Ident("a"), Ident("c")) @@ -499,7 +533,9 @@ class StatefulTransformerSpec extends Spec { } "exists" in { val ast: Ast = OptionExists(Ident("a"), Ident("b"), Ident("c")) - Subject(List.empty, Ident("a") -> Ident("a'"), Ident("b") -> Ident("b'"), Ident("c") -> Ident("c'"))(ast) match { + Subject(List.empty, Ident("a") -> Ident("a'"), Ident("b") -> Ident("b'"), Ident("c") -> Ident("c'"))( + ast + ) match { case (at, att) => at mustEqual OptionExists(Ident("a'"), Ident("b"), Ident("c'")) att.state mustEqual List(Ident("a"), Ident("c")) @@ -591,7 +627,11 @@ class StatefulTransformerSpec extends Spec { Val(Ident("b"), Entity("b", List.empty, QEP)) ) ) - Subject(List.empty, Entity("a", List.empty, QEP) -> Entity("b", List.empty, QEP), Entity("b", List.empty, QEP) -> Entity("c", List.empty, QEP))( + Subject( + List.empty, + Entity("a", List.empty, QEP) -> Entity("b", List.empty, QEP), + Entity("b", List.empty, QEP) -> Entity("c", List.empty, QEP) + )( ast ) match { case (at, att) => diff --git a/quill-core/src/test/scala/io/getquill/ast/StatelessTransformerSpec.scala b/quill-core/src/test/scala/io/getquill/ast/StatelessTransformerSpec.scala index 27d9155fdc..189c8b4a1c 100644 --- a/quill-core/src/test/scala/io/getquill/ast/StatelessTransformerSpec.scala +++ b/quill-core/src/test/scala/io/getquill/ast/StatelessTransformerSpec.scala @@ -387,7 +387,10 @@ class StatelessTransformerSpec extends Spec { Val(Ident("b"), Entity("b", List.empty, QEP)) ) ) - Subject(Entity("a", List.empty, QEP) -> Entity("b", List.empty, QEP), Entity("b", List.empty, QEP) -> Entity("c", List.empty, QEP))( + Subject( + Entity("a", List.empty, QEP) -> Entity("b", List.empty, QEP), + Entity("b", List.empty, QEP) -> Entity("c", List.empty, QEP) + )( ast ) mustEqual Block( diff --git a/quill-core/src/test/scala/io/getquill/base/EncodingSpec.scala b/quill-core/src/test/scala/io/getquill/base/EncodingSpec.scala index 0b93012739..c3c7804f76 100644 --- a/quill-core/src/test/scala/io/getquill/base/EncodingSpec.scala +++ b/quill-core/src/test/scala/io/getquill/base/EncodingSpec.scala @@ -3,7 +3,7 @@ package io.getquill.base import io.getquill.context.Context import java.util.Date -import io.getquill.{ Delete, Insert, Quoted } +import io.getquill.{Delete, Insert, Quoted} import org.scalatest.Assertion trait EncodingSpec extends Spec { @@ -41,7 +41,32 @@ trait EncodingSpec extends Spec { query[EncodingTestEntity].delete } - val insert: Quoted[(String, BigDecimal, Boolean, Byte, Short, Int, Long, Float, Double, Array[Byte], Date, Option[String], Option[BigDecimal], Option[Boolean], Option[Byte], Option[Short], Option[Int], Option[Long], Option[Float], Option[Double], Option[Array[Byte]], Option[Date]) => Insert[EncodingTestEntity]] = quote { + val insert: Quoted[ + ( + String, + BigDecimal, + Boolean, + Byte, + Short, + Int, + Long, + Float, + Double, + Array[Byte], + Date, + Option[String], + Option[BigDecimal], + Option[Boolean], + Option[Byte], + Option[Short], + Option[Int], + Option[Long], + Option[Float], + Option[Double], + Option[Array[Byte]], + Option[Date] + ) => Insert[EncodingTestEntity] + ] = quote { ( v1: String, v2: BigDecimal, @@ -92,7 +117,32 @@ trait EncodingSpec extends Spec { ) } - val insertValues: List[(String, BigDecimal, Boolean, Byte, Short, Int, Long, Float, Double, Array[Byte], Date, Option[String], Option[BigDecimal], Option[Boolean], Option[Byte], Option[Short], Option[Int], Option[Long], Option[Float], Option[Double], Option[Array[Byte]], Option[Date])] = + val insertValues: List[ + ( + String, + BigDecimal, + Boolean, + Byte, + Short, + Int, + Long, + Float, + Double, + Array[Byte], + Date, + Option[String], + Option[BigDecimal], + Option[Boolean], + Option[Byte], + Option[Short], + Option[Int], + Option[Long], + Option[Float], + Option[Double], + Option[Array[Byte]], + Option[Date] + ) + ] = List[ ( String, diff --git a/quill-core/src/test/scala/io/getquill/base/Spec.scala b/quill-core/src/test/scala/io/getquill/base/Spec.scala index c74025d404..51ee341e41 100644 --- a/quill-core/src/test/scala/io/getquill/base/Spec.scala +++ b/quill-core/src/test/scala/io/getquill/base/Spec.scala @@ -13,7 +13,7 @@ import scala.concurrent.{Await, Future} import io.getquill.context.ExecutionType abstract class Spec extends AnyFreeSpec with Matchers with BeforeAndAfterAll { - val QV = Quat.Value + val QV = Quat.Value val QEP: Quat.Product = Quat.Product.empty("Product") def QP(name: String, fields: String*): Quat.Product = Quat.LeafProduct(name, fields: _*) diff --git a/quill-core/src/test/scala/io/getquill/context/ActionMacroSpec.scala b/quill-core/src/test/scala/io/getquill/context/ActionMacroSpec.scala index 01c92233a4..f41a2cde76 100644 --- a/quill-core/src/test/scala/io/getquill/context/ActionMacroSpec.scala +++ b/quill-core/src/test/scala/io/getquill/context/ActionMacroSpec.scala @@ -53,9 +53,8 @@ class ActionMacroSpec extends Spec { r.prepareRow mustEqual Row() r.returningBehavior mustEqual ReturnRecord } - "returning value - with single - should not compile" in testContext.withDialect(MirrorIdiomReturningSingle) { - _ => - "import ctx._; ctx.run(qr1.insert(t => t.i -> 1).returning(t => t.l))" mustNot compile + "returning value - with single - should not compile" in testContext.withDialect(MirrorIdiomReturningSingle) { _ => + "import ctx._; ctx.run(qr1.insert(t => t.i -> 1).returning(t => t.l))" mustNot compile } "returning value - with multi" in testContext.withDialect(MirrorIdiomReturningMulti) { ctx => import ctx._ @@ -173,9 +172,8 @@ class ActionMacroSpec extends Spec { r.prepareRow mustEqual Row() r.returningBehavior mustEqual ReturnRecord } - "returning value - with single - should not compile" in testContext.withDialect(MirrorIdiomReturningSingle) { - _ => - "import ctx._; ctx.run(qr1.update(t => t.i -> 1).returning(t => t.l))" mustNot compile + "returning value - with single - should not compile" in testContext.withDialect(MirrorIdiomReturningSingle) { _ => + "import ctx._; ctx.run(qr1.update(t => t.i -> 1).returning(t => t.l))" mustNot compile } "returning value - with multi" in testContext.withDialect(MirrorIdiomReturningMulti) { ctx => import ctx._ @@ -226,9 +224,8 @@ class ActionMacroSpec extends Spec { r.prepareRow mustEqual Row() r.returningBehavior mustEqual ReturnRecord } - "returning value - with single - should not compile" in testContext.withDialect(MirrorIdiomReturningSingle) { - _ => - "import ctx._; ctx.delete.returning(t => t.l))" mustNot compile + "returning value - with single - should not compile" in testContext.withDialect(MirrorIdiomReturningSingle) { _ => + "import ctx._; ctx.delete.returning(t => t.l))" mustNot compile } "returning value - with multi" in testContext.withDialect(MirrorIdiomReturningMulti) { ctx => import ctx._ diff --git a/quill-core/src/test/scala/io/getquill/norm/FlattenOptionOperationSpec.scala b/quill-core/src/test/scala/io/getquill/norm/FlattenOptionOperationSpec.scala index 9740cc8f4f..0c935720d5 100644 --- a/quill-core/src/test/scala/io/getquill/norm/FlattenOptionOperationSpec.scala +++ b/quill-core/src/test/scala/io/getquill/norm/FlattenOptionOperationSpec.scala @@ -10,7 +10,7 @@ import io.getquill.util.TraceConfig class FlattenOptionOperationSpec extends Spec { // hello - def o: Ident = Ident("o") + def o: Ident = Ident("o") def c1: Constant = Constant.auto(1) def c2: Constant = Constant.auto(2) def cFoo: Constant = Constant.auto("foo") diff --git a/quill-core/src/test/scala/io/getquill/norm/NormalizeCachingSpec.scala b/quill-core/src/test/scala/io/getquill/norm/NormalizeCachingSpec.scala index 9c7fa665ce..05e5181c6a 100644 --- a/quill-core/src/test/scala/io/getquill/norm/NormalizeCachingSpec.scala +++ b/quill-core/src/test/scala/io/getquill/norm/NormalizeCachingSpec.scala @@ -5,9 +5,9 @@ import io.getquill.ast.Ast class NormalizeCachingSpec extends Spec { - val normalize = new Normalize(TranspileConfig.Empty) - val cached: Ast => Ast = NormalizeCaching(normalize.apply) - val gen = new QueryGenerator(1) + val normalize = new Normalize(TranspileConfig.Empty) + val cached: Ast => Ast = NormalizeCaching(normalize.apply) + val gen = new QueryGenerator(1) "Cached normalization" - { "consists with non-cached `Normalize`" in { diff --git a/quill-core/src/test/scala/io/getquill/norm/QueryGenerator.scala b/quill-core/src/test/scala/io/getquill/norm/QueryGenerator.scala index 0d599a0c30..4f585703b4 100644 --- a/quill-core/src/test/scala/io/getquill/norm/QueryGenerator.scala +++ b/quill-core/src/test/scala/io/getquill/norm/QueryGenerator.scala @@ -32,7 +32,7 @@ class QueryGenerator(seed: Int) { def apply(i: Int): Query = if (i <= 2) { Quat.Product("Test") - val s = string(3) + val s = string(3) Entity(s, List.empty, Quat.Product("Test", (1 to 20).map(_ => (string(3), Quat.Value)).toList.distinct: _*)) } else { random.nextInt(8) match { diff --git a/quill-core/src/test/scala/io/getquill/norm/SimplifyNullChecksSpec.scala b/quill-core/src/test/scala/io/getquill/norm/SimplifyNullChecksSpec.scala index f3a42316cf..b305090a52 100644 --- a/quill-core/src/test/scala/io/getquill/norm/SimplifyNullChecksSpec.scala +++ b/quill-core/src/test/scala/io/getquill/norm/SimplifyNullChecksSpec.scala @@ -12,9 +12,9 @@ class SimplifyNullChecksSpec extends Spec { // remove the === matcher from scalatest so that we can test === in Context.extra override def convertToEqualizer[T](left: T): Equalizer[T] = new Equalizer(left) - val ia: Ident = Ident("a") - val ib: Ident = Ident("b") - val it: Ident = Ident("t") + val ia: Ident = Ident("a") + val ib: Ident = Ident("b") + val it: Ident = Ident("t") val ca: Constant = Constant.auto("a") val SimplifyNullChecksAnsi = new SimplifyNullChecks(AnsiEquality) diff --git a/quill-core/src/test/scala/io/getquill/norm/SymbolicReductionSpec.scala b/quill-core/src/test/scala/io/getquill/norm/SymbolicReductionSpec.scala index 818901511f..15f86cee74 100644 --- a/quill-core/src/test/scala/io/getquill/norm/SymbolicReductionSpec.scala +++ b/quill-core/src/test/scala/io/getquill/norm/SymbolicReductionSpec.scala @@ -11,7 +11,8 @@ import io.getquill.ast.Query class SymbolicReductionSpec extends Spec { // hello - def symbolicReduction: Query => Option[Query] = (new SymbolicReduction(TraceConfig.Empty).unapply _).andThen(o => o.map(replaceTempIdent(_))) + def symbolicReduction: Query => Option[Query] = + (new SymbolicReduction(TraceConfig.Empty).unapply _).andThen(o => o.map(replaceTempIdent(_))) "a.filter(b => c).flatMap(d => e.$)" - { "e is an entity" in { diff --git a/quill-core/src/test/scala/io/getquill/quotation/FreeVariablesSpec.scala b/quill-core/src/test/scala/io/getquill/quotation/FreeVariablesSpec.scala index 7e11cc661a..5f044fc349 100644 --- a/quill-core/src/test/scala/io/getquill/quotation/FreeVariablesSpec.scala +++ b/quill-core/src/test/scala/io/getquill/quotation/FreeVariablesSpec.scala @@ -163,14 +163,14 @@ class FreeVariablesSpec extends Spec { } "option operators" - { "map" in { - + val q = quote { qr1.map(t => t.o.map(_ == t.i)) } FreeVariables(q.ast) mustBe empty } "forall" in { - + val q = quote { qr1.filter(t => t.o.forall(_ == t.i)) } @@ -178,14 +178,14 @@ class FreeVariablesSpec extends Spec { } "exists" in { - + val q = quote { qr1.filter(t => t.o.exists(_ == t.i)) } FreeVariables(q.ast) mustBe empty } "contains" in { - + val q = quote { qr1.filter(t => t.o.contains(t.i)) } diff --git a/quill-core/src/test/scala/io/getquill/quotation/QuotationSpec.scala b/quill-core/src/test/scala/io/getquill/quotation/QuotationSpec.scala index cea9c719f2..0ce6855827 100644 --- a/quill-core/src/test/scala/io/getquill/quotation/QuotationSpec.scala +++ b/quill-core/src/test/scala/io/getquill/quotation/QuotationSpec.scala @@ -1366,7 +1366,10 @@ class QuotationSpec extends Spec { val q = quote { qr1.isEmpty } - quote(unquote(q)).ast mustEqual UnaryOperation(SetOperator.`isEmpty`, Entity("TestEntity", List.empty, TestEntityQuat)) + quote(unquote(q)).ast mustEqual UnaryOperation( + SetOperator.`isEmpty`, + Entity("TestEntity", List.empty, TestEntityQuat) + ) } "toUpperCase" in { val q = quote { @@ -1778,7 +1781,11 @@ class QuotationSpec extends Spec { } "nested" in { def test[T: SchemaMeta] = quote(query[T].map(_ => 1)) - test[TestEntity].ast mustEqual Map(Entity("TestEntity", List.empty, TestEntityQuat), Ident("t"), Constant.auto(1)) + test[TestEntity].ast mustEqual Map( + Entity("TestEntity", List.empty, TestEntityQuat), + Ident("t"), + Constant.auto(1) + ) } } "forced" in { @@ -2107,7 +2114,7 @@ class QuotationSpec extends Spec { } "doesn't double quote" in { - val q = quote(1) + val q = quote(1) quote(q) } diff --git a/quill-core/src/test/scala/io/getquill/util/CacheSpec.scala b/quill-core/src/test/scala/io/getquill/util/CacheSpec.scala index 10cf1be209..a5b9c693c3 100644 --- a/quill-core/src/test/scala/io/getquill/util/CacheSpec.scala +++ b/quill-core/src/test/scala/io/getquill/util/CacheSpec.scala @@ -8,7 +8,7 @@ import scala.concurrent.duration.DurationInt class CacheSpec extends Spec { class Value extends Closeable { - var closes = 0 + var closes = 0 override def close: Unit = closes += 1 } diff --git a/quill-core/src/test/scala/io/getquill/util/InterpolatorSpec.scala b/quill-core/src/test/scala/io/getquill/util/InterpolatorSpec.scala index b729c2878e..9d80fb47ce 100644 --- a/quill-core/src/test/scala/io/getquill/util/InterpolatorSpec.scala +++ b/quill-core/src/test/scala/io/getquill/util/InterpolatorSpec.scala @@ -49,8 +49,9 @@ and bar $small""".generateString() mustEqual ( nine: String, ten: String ) - val vars: List[String] = (0 until 10).map(i => (0 until i).map(_ => "Test").mkString("")).toList - val large: Large = Large(123, vars(0), vars(1), vars(2), vars(3), vars(4), vars(5), vars(6), vars(7), vars(8), vars(9)) + val vars: List[String] = (0 until 10).map(i => (0 until i).map(_ => "Test").mkString("")).toList + val large: Large = + Large(123, vars(0), vars(1), vars(2), vars(3), vars(4), vars(5), vars(6), vars(7), vars(8), vars(9)) "traces large objects on multiple line - single" in { trace"large object: $large".generateString() mustEqual (( diff --git a/quill-doobie/src/test/scala/io/getquill/doobie/issue/Issue1067.scala b/quill-doobie/src/test/scala/io/getquill/doobie/issue/Issue1067.scala index c4a96057d1..af953c17cb 100644 --- a/quill-doobie/src/test/scala/io/getquill/doobie/issue/Issue1067.scala +++ b/quill-doobie/src/test/scala/io/getquill/doobie/issue/Issue1067.scala @@ -14,7 +14,7 @@ class Issue1067 extends AnyFreeSpec with Matchers { import cats.effect.unsafe.implicits.global - lazy val xa: transactor.Transactor.Aux[IO,Unit] = Transactor.fromDriverManager[IO]( + lazy val xa: transactor.Transactor.Aux[IO, Unit] = Transactor.fromDriverManager[IO]( "org.postgresql.Driver", s"jdbc:postgresql://${System.getenv("POSTGRES_HOST")}:${System.getenv("POSTGRES_PORT")}/doobie_test", "postgres", diff --git a/quill-jasync-postgres/src/test/scala/io/getquill/context/jasync/postgres/PostgresAsyncEncodingSpec.scala b/quill-jasync-postgres/src/test/scala/io/getquill/context/jasync/postgres/PostgresAsyncEncodingSpec.scala index 3995ee35cb..d3f9b56bcb 100644 --- a/quill-jasync-postgres/src/test/scala/io/getquill/context/jasync/postgres/PostgresAsyncEncodingSpec.scala +++ b/quill-jasync-postgres/src/test/scala/io/getquill/context/jasync/postgres/PostgresAsyncEncodingSpec.scala @@ -32,7 +32,7 @@ class PostgresAsyncEncodingSpec extends EncodingSpec { val testUUID = UUID.fromString("e5240c08-6ee7-474a-b5e4-91f79c48338f") // delete old values - val q0 = quote(query[EncodingUUIDTestEntity].delete) + val q0 = quote(query[EncodingUUIDTestEntity].delete) Await.result(testContext.run(q0), Duration.Inf) // insert new uuid diff --git a/quill-jasync-zio-postgres/src/test/scala/io/getquill/context/qzio/jasync/postgres/PostgresAsyncEncodingSpec.scala b/quill-jasync-zio-postgres/src/test/scala/io/getquill/context/qzio/jasync/postgres/PostgresAsyncEncodingSpec.scala index 8e9f0d6e06..cc15c80d58 100644 --- a/quill-jasync-zio-postgres/src/test/scala/io/getquill/context/qzio/jasync/postgres/PostgresAsyncEncodingSpec.scala +++ b/quill-jasync-zio-postgres/src/test/scala/io/getquill/context/qzio/jasync/postgres/PostgresAsyncEncodingSpec.scala @@ -27,7 +27,7 @@ class PostgresAsyncEncodingSpec extends EncodingSpec with ZioSpec { val testUUID = UUID.fromString("e5240c08-6ee7-474a-b5e4-91f79c48338f") // delete old values - val q0 = quote(query[EncodingUUIDTestEntity].delete) + val q0 = quote(query[EncodingUUIDTestEntity].delete) runSyncUnsafe(testContext.run(q0)) // insert new uuid diff --git a/quill-jasync/src/test/scala/io/getquill/context/jasync/TransactionalExecutionContextSpec.scala b/quill-jasync/src/test/scala/io/getquill/context/jasync/TransactionalExecutionContextSpec.scala index ac187164a1..fadd0471a9 100644 --- a/quill-jasync/src/test/scala/io/getquill/context/jasync/TransactionalExecutionContextSpec.scala +++ b/quill-jasync/src/test/scala/io/getquill/context/jasync/TransactionalExecutionContextSpec.scala @@ -26,9 +26,8 @@ class TransactionalExecutionContextSpec extends Spec { val reported = ListBuffer[Throwable]() val ec = new ExecutionContext { def execute(r: Runnable) = ??? - def reportFailure(t: Throwable) = { + def reportFailure(t: Throwable) = reported += t - } } val exception = new IllegalStateException TransactionalExecutionContext(ec, null).reportFailure(exception) diff --git a/quill-jdbc-monix/src/test/scala/io/getquill/ResultSetIteratorSpec.scala b/quill-jdbc-monix/src/test/scala/io/getquill/ResultSetIteratorSpec.scala index ad027402fb..095050c48b 100644 --- a/quill-jdbc-monix/src/test/scala/io/getquill/ResultSetIteratorSpec.scala +++ b/quill-jdbc-monix/src/test/scala/io/getquill/ResultSetIteratorSpec.scala @@ -14,8 +14,8 @@ import com.zaxxer.hikari.HikariDataSource class ResultSetIteratorSpec extends AnyFreeSpec with Matchers with BeforeAndAfterAll { - val ds: HikariDataSource = JdbcContextConfig(LoadConfig("testPostgresDB")).dataSource - implicit val scheduler = Scheduler.global + val ds: HikariDataSource = JdbcContextConfig(LoadConfig("testPostgresDB")).dataSource + implicit val scheduler = Scheduler.global val ctx = new PostgresMonixJdbcContext(Literal, ds, EffectWrapper.default) import ctx._ diff --git a/quill-jdbc-monix/src/test/scala/io/getquill/RunnerSpec.scala b/quill-jdbc-monix/src/test/scala/io/getquill/RunnerSpec.scala index 25d0720eb3..13f454e4a2 100644 --- a/quill-jdbc-monix/src/test/scala/io/getquill/RunnerSpec.scala +++ b/quill-jdbc-monix/src/test/scala/io/getquill/RunnerSpec.scala @@ -12,9 +12,9 @@ import scala.util.Failure class RunnerSpec extends Spec { class SideEffect { - private var state = 0 - def apply(): Unit = state = 1 - def applied: Boolean = state == 1 + private var state = 0 + def apply(): Unit = state = 1 + def applied: Boolean = state == 1 } implicit val scheduler = Scheduler.global diff --git a/quill-jdbc-monix/src/test/scala/io/getquill/integration/StreamResultsOrBlowUpSpec.scala b/quill-jdbc-monix/src/test/scala/io/getquill/integration/StreamResultsOrBlowUpSpec.scala index 45e70adbbc..a654ed5d57 100644 --- a/quill-jdbc-monix/src/test/scala/io/getquill/integration/StreamResultsOrBlowUpSpec.scala +++ b/quill-jdbc-monix/src/test/scala/io/getquill/integration/StreamResultsOrBlowUpSpec.scala @@ -31,19 +31,20 @@ class StreamResultsOrBlowUpSpec extends Spec { // that will force jdbc to load the entire ResultSet into memory and crash this test. val doBlowUp = false - val ctx: PostgresMonixJdbcContext[Literal.type] = new PostgresMonixJdbcContext(Literal, "testPostgresDB", EffectWrapper.default) { - override protected def prepareStatementForStreaming(sql: String, conn: Connection, fetchSize: Option[Int]) = { - val stmt = - conn.prepareStatement( - sql, - if (doBlowUp) ResultSet.TYPE_SCROLL_SENSITIVE - else ResultSet.TYPE_FORWARD_ONLY, - ResultSet.CONCUR_READ_ONLY - ) - fetchSize.foreach(stmt.setFetchSize(_)) - stmt + val ctx: PostgresMonixJdbcContext[Literal.type] = + new PostgresMonixJdbcContext(Literal, "testPostgresDB", EffectWrapper.default) { + override protected def prepareStatementForStreaming(sql: String, conn: Connection, fetchSize: Option[Int]) = { + val stmt = + conn.prepareStatement( + sql, + if (doBlowUp) ResultSet.TYPE_SCROLL_SENSITIVE + else ResultSet.TYPE_FORWARD_ONLY, + ResultSet.CONCUR_READ_ONLY + ) + fetchSize.foreach(stmt.setFetchSize(_)) + stmt + } } - } import ctx.{run => runQuill, _} val numRows = 1000000L diff --git a/quill-jdbc-monix/src/test/scala/io/getquill/mock/Introspection.scala b/quill-jdbc-monix/src/test/scala/io/getquill/mock/Introspection.scala index 52ef3950bb..a65a3fbde6 100644 --- a/quill-jdbc-monix/src/test/scala/io/getquill/mock/Introspection.scala +++ b/quill-jdbc-monix/src/test/scala/io/getquill/mock/Introspection.scala @@ -6,7 +6,7 @@ import scala.reflect.runtime.{universe => ru} class Introspection[T](t: T)(implicit tt: ru.TypeTag[T], ct: ClassTag[T]) { import ru._ - val rm: Mirror = runtimeMirror(getClass.getClassLoader) + val rm: Mirror = runtimeMirror(getClass.getClassLoader) val instanceMirror: InstanceMirror = rm.reflect(t) val fieldsAndValues: List[(String, Any)] = diff --git a/quill-jdbc-monix/src/test/scala/io/getquill/mock/MockTests.scala b/quill-jdbc-monix/src/test/scala/io/getquill/mock/MockTests.scala index 71cb8f731f..3cc9e50bfd 100644 --- a/quill-jdbc-monix/src/test/scala/io/getquill/mock/MockTests.scala +++ b/quill-jdbc-monix/src/test/scala/io/getquill/mock/MockTests.scala @@ -25,9 +25,8 @@ class MockTests extends Spec with AsyncMockitoSugar { val rs = mock[ResultSet] var rowIndex = -1 - def introspection = new Introspection(data(rowIndex)) - def getIndex(i: Int): Any = introspection.getIndex(i) - + def introspection = new Introspection(data(rowIndex)) + def getIndex(i: Int): Any = introspection.getIndex(i) when(rs.next()) thenAnswer { rowIndex += 1 diff --git a/quill-jdbc-zio/src/test/scala-2.13/io/getquill/examples/IdiomaticAppWithEncoders.scala b/quill-jdbc-zio/src/test/scala-2.13/io/getquill/examples/IdiomaticAppWithEncoders.scala index 26b2644b8c..8fb3dfd7f5 100644 --- a/quill-jdbc-zio/src/test/scala-2.13/io/getquill/examples/IdiomaticAppWithEncoders.scala +++ b/quill-jdbc-zio/src/test/scala-2.13/io/getquill/examples/IdiomaticAppWithEncoders.scala @@ -5,7 +5,7 @@ import io.getquill.jdbczio.Quill import zio.Console.printLine import zio.json.{DeriveJsonDecoder, DeriveJsonEncoder, JsonDecoder, JsonEncoder} import zio.{ZIO, ZIOAppDefault, ZLayer} -import io.getquill.{ EntityQuery, Quoted } +import io.getquill.{EntityQuery, Quoted} import java.sql.SQLException import javax.sql.DataSource @@ -20,23 +20,23 @@ object IdiomaticAppWithEncoders extends ZIOAppDefault { final case class App(quill: Quill.Postgres[Literal]) { import quill._ - val v: JsonbEntity = JsonbEntity("JoeEntity", JsonbValue(Person("Joe", 123))) - val setQuery = quote(query[JsonbEntity].insertValue(lift(v))) - val getQuery: Quoted[EntityQuery[JsonbEntity]] = quote(query[JsonbEntity]) - def get(): ZIO[Any,SQLException,List[JsonbEntity]] = quill.run(getQuery) - def set() = quill.run(setQuery) + val v: JsonbEntity = JsonbEntity("JoeEntity", JsonbValue(Person("Joe", 123))) + val setQuery = quote(query[JsonbEntity].insertValue(lift(v))) + val getQuery: Quoted[EntityQuery[JsonbEntity]] = quote(query[JsonbEntity]) + def get(): ZIO[Any, SQLException, List[JsonbEntity]] = quill.run(getQuery) + def set() = quill.run(setQuery) } object App { - def get(): ZIO[App with App,SQLException,List[JsonbEntity]] = ZIO.serviceWithZIO[App](_.get()) - def set(): ZIO[App with App,Nothing,Nothing] = ZIO.serviceWithZIO[App](_.set()) + def get(): ZIO[App with App, SQLException, List[JsonbEntity]] = ZIO.serviceWithZIO[App](_.get()) + def set(): ZIO[App with App, Nothing, Nothing] = ZIO.serviceWithZIO[App](_.set()) } - val dsLive: ZLayer[Any,Throwable,DataSource] = Quill.DataSource.fromPrefix("testPostgresDB") - val pgLive: ZLayer[DataSource,Nothing,Quill.Postgres[Literal.type]] = Quill.Postgres.fromNamingStrategy(Literal) - val appLive: ZLayer[Quill.Postgres[Literal],Nothing,App] = ZLayer.fromFunction(App.apply _) + val dsLive: ZLayer[Any, Throwable, DataSource] = Quill.DataSource.fromPrefix("testPostgresDB") + val pgLive: ZLayer[DataSource, Nothing, Quill.Postgres[Literal.type]] = Quill.Postgres.fromNamingStrategy(Literal) + val appLive: ZLayer[Quill.Postgres[Literal], Nothing, App] = ZLayer.fromFunction(App.apply _) - override def run: ZIO[Any,Throwable,Unit] = + override def run: ZIO[Any, Throwable, Unit] = (for { _ <- App.set() ent <- App.get() diff --git a/quill-jdbc-zio/src/test/scala-2.13/io/getquill/postgres/PostgresJsonSpec.scala b/quill-jdbc-zio/src/test/scala-2.13/io/getquill/postgres/PostgresJsonSpec.scala index 18ebb8a645..95e87b57e9 100644 --- a/quill-jdbc-zio/src/test/scala-2.13/io/getquill/postgres/PostgresJsonSpec.scala +++ b/quill-jdbc-zio/src/test/scala-2.13/io/getquill/postgres/PostgresJsonSpec.scala @@ -16,9 +16,9 @@ class PostgresJsonSpec extends ZioSpec { case class JsonbEntity(name: String, value: JsonbValue[PersonJsonb]) val jsonJoe: JsonValue[PersonJson] = JsonValue(PersonJson("Joe", 123)) - val jsonValue: JsonEntity = JsonEntity("JoeEntity", jsonJoe) - val jsonbJoe: JsonbValue[PersonJsonb] = JsonbValue(PersonJsonb("Joe", 123)) - val jsonbValue: JsonbEntity = JsonbEntity("JoeEntity", jsonbJoe) + val jsonValue: JsonEntity = JsonEntity("JoeEntity", jsonJoe) + val jsonbJoe: JsonbValue[PersonJsonb] = JsonbValue(PersonJsonb("Joe", 123)) + val jsonbValue: JsonbEntity = JsonbEntity("JoeEntity", jsonbJoe) case class JsonAstEntity(name: String, value: JsonValue[Json]) case class JsonbAstEntity(name: String, value: JsonbValue[Json]) diff --git a/quill-jdbc-zio/src/test/scala/io/getquill/ResultSetIteratorSpec.scala b/quill-jdbc-zio/src/test/scala/io/getquill/ResultSetIteratorSpec.scala index 4fc6a210ba..372382108a 100644 --- a/quill-jdbc-zio/src/test/scala/io/getquill/ResultSetIteratorSpec.scala +++ b/quill-jdbc-zio/src/test/scala/io/getquill/ResultSetIteratorSpec.scala @@ -10,7 +10,7 @@ import scala.collection.mutable.ArrayBuffer class ResultSetIteratorSpec extends ZioProxySpec { implicit val pool: Implicit[DataSource] = Implicit(io.getquill.postgres.pool) - val ctx = new PostgresZioJdbcContext(Literal) + val ctx = new PostgresZioJdbcContext(Literal) import ctx._ case class Person(name: String, age: Int) diff --git a/quill-jdbc-zio/src/test/scala/io/getquill/examples/IdiomaticApp.scala b/quill-jdbc-zio/src/test/scala/io/getquill/examples/IdiomaticApp.scala index 1ed705ec26..c1f19b3755 100644 --- a/quill-jdbc-zio/src/test/scala/io/getquill/examples/IdiomaticApp.scala +++ b/quill-jdbc-zio/src/test/scala/io/getquill/examples/IdiomaticApp.scala @@ -12,8 +12,9 @@ object IdiomaticApp extends ZIOAppDefault { final case class DataService(quill: Quill.Postgres[Literal]) { import quill._ - val people: Quoted[EntityQuery[Person]] = quote(query[Person]) - def peopleByName: Quoted[String => EntityQuery[Person]] = quote((name: String) => people.filter(p => p.name == name)) + val people: Quoted[EntityQuery[Person]] = quote(query[Person]) + def peopleByName: Quoted[String => EntityQuery[Person]] = + quote((name: String) => people.filter(p => p.name == name)) } final case class ApplicationLive(dataService: DataService) { import dataService.quill._ @@ -23,19 +24,20 @@ object IdiomaticApp extends ZIOAppDefault { def getAllPeople(): ZIO[Any, SQLException, List[Person]] = quill.run(dataService.people) } object Application { - def getPeopleByName(name: String): ZIO[ApplicationLive with ApplicationLive,SQLException,List[Person]] = + def getPeopleByName(name: String): ZIO[ApplicationLive with ApplicationLive, SQLException, List[Person]] = ZIO.serviceWithZIO[ApplicationLive](_.getPeopleByName(name)) - def getAllPeople(): ZIO[ApplicationLive with ApplicationLive,SQLException,List[Person]] = + def getAllPeople(): ZIO[ApplicationLive with ApplicationLive, SQLException, List[Person]] = ZIO.serviceWithZIO[ApplicationLive](_.getAllPeople()) } final case class Person(name: String, age: Int) - val dataServiceLive: ZLayer[Quill.Postgres[Literal],Nothing,DataService] = ZLayer.fromFunction(DataService.apply _) - val applicationLive: ZLayer[DataService,Nothing,ApplicationLive] = ZLayer.fromFunction(ApplicationLive.apply _) - val dataSourceLive: ZLayer[Any,Throwable,DataSource] = Quill.DataSource.fromPrefix("testPostgresDB") - val postgresLive: ZLayer[DataSource,Nothing,Quill.Postgres[Literal.type]] = Quill.Postgres.fromNamingStrategy(Literal) + val dataServiceLive: ZLayer[Quill.Postgres[Literal], Nothing, DataService] = ZLayer.fromFunction(DataService.apply _) + val applicationLive: ZLayer[DataService, Nothing, ApplicationLive] = ZLayer.fromFunction(ApplicationLive.apply _) + val dataSourceLive: ZLayer[Any, Throwable, DataSource] = Quill.DataSource.fromPrefix("testPostgresDB") + val postgresLive: ZLayer[DataSource, Nothing, Quill.Postgres[Literal.type]] = + Quill.Postgres.fromNamingStrategy(Literal) - override def run: ZIO[Any,Throwable,Unit] = + override def run: ZIO[Any, Throwable, Unit] = (for { joes <- Application.getPeopleByName("Joe") _ <- printLine(joes) diff --git a/quill-jdbc-zio/src/test/scala/io/getquill/examples/IdiomaticAppPlain.scala b/quill-jdbc-zio/src/test/scala/io/getquill/examples/IdiomaticAppPlain.scala index 96c9256932..b0157f4e86 100644 --- a/quill-jdbc-zio/src/test/scala/io/getquill/examples/IdiomaticAppPlain.scala +++ b/quill-jdbc-zio/src/test/scala/io/getquill/examples/IdiomaticAppPlain.scala @@ -11,8 +11,9 @@ object IdiomaticAppPlain { final case class DataService(quill: Quill.Postgres[Literal]) { import quill._ - val people: Quoted[EntityQuery[Person]] = quote(query[Person]) - def peopleByName: Quoted[String => EntityQuery[Person]] = quote((name: String) => people.filter(p => p.name == name)) + val people: Quoted[EntityQuery[Person]] = quote(query[Person]) + def peopleByName: Quoted[String => EntityQuery[Person]] = + quote((name: String) => people.filter(p => p.name == name)) } final case class ApplicationLive(dataService: DataService) { import dataService.quill._ @@ -20,9 +21,9 @@ object IdiomaticAppPlain { def getAllPeople(): ZIO[Any, SQLException, List[Person]] = run(dataService.people) } object Application { - def getPeopleByName(name: String): ZIO[ApplicationLive with ApplicationLive,SQLException,List[Person]] = + def getPeopleByName(name: String): ZIO[ApplicationLive with ApplicationLive, SQLException, List[Person]] = ZIO.serviceWithZIO[ApplicationLive](_.getPeopleByName(name)) - def getAllPeople(): ZIO[ApplicationLive with ApplicationLive,SQLException,List[Person]] = + def getAllPeople(): ZIO[ApplicationLive with ApplicationLive, SQLException, List[Person]] = ZIO.serviceWithZIO[ApplicationLive](_.getAllPeople()) } final case class Person(name: String, age: Int) diff --git a/quill-jdbc-zio/src/test/scala/io/getquill/examples/other/PlainApp.scala b/quill-jdbc-zio/src/test/scala/io/getquill/examples/other/PlainApp.scala index 271e9bb51b..1f76392012 100644 --- a/quill-jdbc-zio/src/test/scala/io/getquill/examples/other/PlainApp.scala +++ b/quill-jdbc-zio/src/test/scala/io/getquill/examples/other/PlainApp.scala @@ -13,7 +13,7 @@ object PlainApp { final case class Person(name: String, age: Int) - val zioDS: ZLayer[Any,Throwable,DataSource] = Quill.DataSource.fromPrefix("testPostgresDB") + val zioDS: ZLayer[Any, Throwable, DataSource] = Quill.DataSource.fromPrefix("testPostgresDB") def main(args: Array[String]): Unit = { val people = quote { diff --git a/quill-jdbc-zio/src/test/scala/io/getquill/examples/other/PlainAppDataSource.scala b/quill-jdbc-zio/src/test/scala/io/getquill/examples/other/PlainAppDataSource.scala index 24c5034346..d011cb704a 100644 --- a/quill-jdbc-zio/src/test/scala/io/getquill/examples/other/PlainAppDataSource.scala +++ b/quill-jdbc-zio/src/test/scala/io/getquill/examples/other/PlainAppDataSource.scala @@ -18,7 +18,7 @@ object PlainAppDataSource { def config: HikariDataSource = JdbcContextConfig(LoadConfig("testPostgresDB")).dataSource - val zioDS: ZLayer[Any,Throwable,DataSource] = Quill.DataSource.fromDataSource(new HikariDataSource(config)) + val zioDS: ZLayer[Any, Throwable, DataSource] = Quill.DataSource.fromDataSource(new HikariDataSource(config)) def main(args: Array[String]): Unit = { val people = quote { diff --git a/quill-jdbc-zio/src/test/scala/io/getquill/examples/other/ServiceExample.scala b/quill-jdbc-zio/src/test/scala/io/getquill/examples/other/ServiceExample.scala index e695043093..b463e96886 100644 --- a/quill-jdbc-zio/src/test/scala/io/getquill/examples/other/ServiceExample.scala +++ b/quill-jdbc-zio/src/test/scala/io/getquill/examples/other/ServiceExample.scala @@ -7,15 +7,15 @@ import zio.{ZIO, ZIOAppDefault, ZLayer} import java.sql.SQLException import javax.sql.DataSource -import zio.{ ExitCode, URIO } +import zio.{ExitCode, URIO} object ServiceExample extends ZIOAppDefault { import DBModel._ - override def run: URIO[Any,ExitCode] = + override def run: URIO[Any, ExitCode] = runApp.provide(DBManager.live).exitCode - def runApp: ZIO[DBManager.Service,Throwable,Unit] = + def runApp: ZIO[DBManager.Service, Throwable, Unit] = for { _ <- DBManager.deleteJoes _ <- DBManager.persist(Person("Joe", 123)) diff --git a/quill-jdbc-zio/src/test/scala/io/getquill/examples/other/ZioApp.scala b/quill-jdbc-zio/src/test/scala/io/getquill/examples/other/ZioApp.scala index aa1fd4c324..463c7b0e3d 100644 --- a/quill-jdbc-zio/src/test/scala/io/getquill/examples/other/ZioApp.scala +++ b/quill-jdbc-zio/src/test/scala/io/getquill/examples/other/ZioApp.scala @@ -5,7 +5,7 @@ import io.getquill.jdbczio.Quill import zio.Console.printLine import zio.ZIOAppDefault import javax.sql.DataSource -import zio.{ ExitCode, URIO, ZLayer } +import zio.{ExitCode, URIO, ZLayer} object ZioApp extends ZIOAppDefault { @@ -14,9 +14,9 @@ object ZioApp extends ZIOAppDefault { final case class Person(name: String, age: Int) - val zioDS: ZLayer[Any,Throwable,DataSource] = Quill.DataSource.fromPrefix("testPostgresDB") + val zioDS: ZLayer[Any, Throwable, DataSource] = Quill.DataSource.fromPrefix("testPostgresDB") - override def run: URIO[Any,ExitCode] = { + override def run: URIO[Any, ExitCode] = { val people = quote { query[Person].filter(p => p.name == "Alex") } diff --git a/quill-jdbc-zio/src/test/scala/io/getquill/examples/other/ZioAppDataSource.scala b/quill-jdbc-zio/src/test/scala/io/getquill/examples/other/ZioAppDataSource.scala index bdac12b7ad..12d3d9a3ff 100644 --- a/quill-jdbc-zio/src/test/scala/io/getquill/examples/other/ZioAppDataSource.scala +++ b/quill-jdbc-zio/src/test/scala/io/getquill/examples/other/ZioAppDataSource.scala @@ -5,7 +5,7 @@ import io.getquill.util.LoadConfig import zio.Console.printLine import zio.{ZEnvironment, ZIOAppDefault} import com.zaxxer.hikari.HikariDataSource -import zio.{ ExitCode, URIO } +import zio.{ExitCode, URIO} object ZioAppDataSource extends ZIOAppDefault { @@ -16,7 +16,7 @@ object ZioAppDataSource extends ZIOAppDefault { def dataSource: HikariDataSource = JdbcContextConfig(LoadConfig("testPostgresDB")).dataSource - override def run: URIO[Any,ExitCode] = { + override def run: URIO[Any, ExitCode] = { val people = quote { query[Person].filter(p => p.name == "Alex") } diff --git a/quill-jdbc-zio/src/test/scala/io/getquill/examples/other/ZioAppExample.scala b/quill-jdbc-zio/src/test/scala/io/getquill/examples/other/ZioAppExample.scala index d8f260a8e2..5ebedda02a 100644 --- a/quill-jdbc-zio/src/test/scala/io/getquill/examples/other/ZioAppExample.scala +++ b/quill-jdbc-zio/src/test/scala/io/getquill/examples/other/ZioAppExample.scala @@ -10,29 +10,29 @@ import java.sql.SQLException final case class Person(name: String, age: Int) object QuillContext extends PostgresZioJdbcContext(SnakeCase) { - val dataSourceLayer: ZLayer[Any,Nothing,DataSource] = Quill.DataSource.fromPrefix("testPostgresDB").orDie + val dataSourceLayer: ZLayer[Any, Nothing, DataSource] = Quill.DataSource.fromPrefix("testPostgresDB").orDie } object DataService { - def getPeople: ZIO[DataServiceLive,Nothing,IO[SQLException,List[Person]]] = + def getPeople: ZIO[DataServiceLive, Nothing, IO[SQLException, List[Person]]] = ZIO.serviceWith[DataServiceLive](_.getPeople) - def getPeopleOlderThan(age: Int): ZIO[DataServiceLive,Nothing,Nothing] = + def getPeopleOlderThan(age: Int): ZIO[DataServiceLive, Nothing, Nothing] = ZIO.serviceWith[DataServiceLive](_.getPeopleOlderThan(age)) } object DataServiceLive { - val layer: ZLayer[DataSource,Nothing,DataServiceLive] = ZLayer.fromFunction(DataServiceLive.apply _) + val layer: ZLayer[DataSource, Nothing, DataServiceLive] = ZLayer.fromFunction(DataServiceLive.apply _) } final case class DataServiceLive(dataSource: DataSource) { import QuillContext._ - def getPeople: IO[SQLException,List[Person]] = run(query[Person]).provideEnvironment(ZEnvironment(dataSource)) + def getPeople: IO[SQLException, List[Person]] = run(query[Person]).provideEnvironment(ZEnvironment(dataSource)) def getPeopleOlderThan(age: Int) = run(query[Person].filter(p => p.age > lift(age))).provideEnvironment(ZEnvironment(dataSource)) } object ZioAppExample extends ZIOAppDefault { - override def run: URIO[Any,ExitCode] = + override def run: URIO[Any, ExitCode] = DataService.getPeople .provide(QuillContext.dataSourceLayer, DataServiceLive.layer) .debug("Results") diff --git a/quill-jdbc-zio/src/test/scala/io/getquill/examples/other/ZioAppImplicitEnv.scala b/quill-jdbc-zio/src/test/scala/io/getquill/examples/other/ZioAppImplicitEnv.scala index 7922fa24fc..5fecea2646 100644 --- a/quill-jdbc-zio/src/test/scala/io/getquill/examples/other/ZioAppImplicitEnv.scala +++ b/quill-jdbc-zio/src/test/scala/io/getquill/examples/other/ZioAppImplicitEnv.scala @@ -9,7 +9,7 @@ import zio.ZIOAppDefault import javax.sql.DataSource import com.zaxxer.hikari.HikariDataSource import java.sql.SQLException -import zio.{ ExitCode, IO, URIO } +import zio.{ExitCode, IO, URIO} object ZioAppImplicitEnv extends ZIOAppDefault { @@ -23,12 +23,12 @@ object ZioAppImplicitEnv extends ZIOAppDefault { import Ctx._ implicit val env: Implicit[DataSource] = Implicit(ds) - val joes: IO[SQLException,List[Person]] = Ctx.run(query[Person].filter(p => p.name == "Joe")).implicitly - val jills: IO[SQLException,List[Person]] = Ctx.run(query[Person].filter(p => p.name == "Jill")).implicitly - val alexes: IO[SQLException,List[Person]] = Ctx.run(query[Person].filter(p => p.name == "Alex")).implicitly + val joes: IO[SQLException, List[Person]] = Ctx.run(query[Person].filter(p => p.name == "Joe")).implicitly + val jills: IO[SQLException, List[Person]] = Ctx.run(query[Person].filter(p => p.name == "Jill")).implicitly + val alexes: IO[SQLException, List[Person]] = Ctx.run(query[Person].filter(p => p.name == "Alex")).implicitly } - override def run: URIO[Any,ExitCode] = + override def run: URIO[Any, ExitCode] = MyQueryService(dataSource).joes .tap(result => printLine(result.toString)) .exitCode diff --git a/quill-jdbc-zio/src/test/scala/io/getquill/examples/other/ZioAppManual.scala b/quill-jdbc-zio/src/test/scala/io/getquill/examples/other/ZioAppManual.scala index d4558e38df..d500b73d2b 100644 --- a/quill-jdbc-zio/src/test/scala/io/getquill/examples/other/ZioAppManual.scala +++ b/quill-jdbc-zio/src/test/scala/io/getquill/examples/other/ZioAppManual.scala @@ -6,7 +6,7 @@ import zio.{ZIOAppDefault, ZLayer} import zio.Console.printLine import javax.sql.DataSource -import zio.{ ExitCode, URIO } +import zio.{ExitCode, URIO} object ZioAppManual extends ZIOAppDefault { @@ -16,7 +16,7 @@ object ZioAppManual extends ZIOAppDefault { final case class Person(name: String, age: Int) lazy val ds: DataSource = JdbcContextConfig(LoadConfig("testPostgresDB")).dataSource - override def run: URIO[Any,ExitCode] = { + override def run: URIO[Any, ExitCode] = { val people = quote { query[Person].filter(p => p.name == "Alex") } diff --git a/quill-jdbc-zio/src/test/scala/io/getquill/h2/PrepareJdbcSpec.scala b/quill-jdbc-zio/src/test/scala/io/getquill/h2/PrepareJdbcSpec.scala index 8724e83497..d6c7e55fab 100644 --- a/quill-jdbc-zio/src/test/scala/io/getquill/h2/PrepareJdbcSpec.scala +++ b/quill-jdbc-zio/src/test/scala/io/getquill/h2/PrepareJdbcSpec.scala @@ -18,8 +18,9 @@ class PrepareJdbcSpec extends PrepareZioJdbcSpecBase with BeforeAndAfter { testContext.run(query[Product].delete).runSyncUnsafe() } - def productExtractor: (ResultSet, Connection) => Product = (rs: ResultSet, conn: Connection) => materializeQueryMeta[Product].extract(rs, conn) - val prepareQuery: ZioJdbc.QCIO[PreparedStatement] = prepare(query[Product]) + def productExtractor: (ResultSet, Connection) => Product = (rs: ResultSet, conn: Connection) => + materializeQueryMeta[Product].extract(rs, conn) + val prepareQuery: ZioJdbc.QCIO[PreparedStatement] = prepare(query[Product]) "single" in { val prepareInsert = prepare(query[Product].insertValue(lift(productEntries.head))) diff --git a/quill-jdbc-zio/src/test/scala/io/getquill/mock/Introspection.scala b/quill-jdbc-zio/src/test/scala/io/getquill/mock/Introspection.scala index 52ef3950bb..a65a3fbde6 100644 --- a/quill-jdbc-zio/src/test/scala/io/getquill/mock/Introspection.scala +++ b/quill-jdbc-zio/src/test/scala/io/getquill/mock/Introspection.scala @@ -6,7 +6,7 @@ import scala.reflect.runtime.{universe => ru} class Introspection[T](t: T)(implicit tt: ru.TypeTag[T], ct: ClassTag[T]) { import ru._ - val rm: Mirror = runtimeMirror(getClass.getClassLoader) + val rm: Mirror = runtimeMirror(getClass.getClassLoader) val instanceMirror: InstanceMirror = rm.reflect(t) val fieldsAndValues: List[(String, Any)] = diff --git a/quill-jdbc-zio/src/test/scala/io/getquill/mock/ZioMockSpec.scala b/quill-jdbc-zio/src/test/scala/io/getquill/mock/ZioMockSpec.scala index 8ec6c02150..b72df305ad 100644 --- a/quill-jdbc-zio/src/test/scala/io/getquill/mock/ZioMockSpec.scala +++ b/quill-jdbc-zio/src/test/scala/io/getquill/mock/ZioMockSpec.scala @@ -19,9 +19,8 @@ class ZioMockSpec extends AnyFreeSpec with MockitoSugar { // with AsyncMockitoSu val rs = mock[ResultSet] var rowIndex = -1 - def introspection = new Introspection(data(rowIndex)) - def getIndex(i: Int): Any = introspection.getIndex(i) - + def introspection = new Introspection(data(rowIndex)) + def getIndex(i: Int): Any = introspection.getIndex(i) when(rs.next()) thenAnswer { rowIndex += 1 diff --git a/quill-jdbc-zio/src/test/scala/io/getquill/postgres/ConnectionLeakTest.scala b/quill-jdbc-zio/src/test/scala/io/getquill/postgres/ConnectionLeakTest.scala index 06bca83ca7..ca5a7381b7 100644 --- a/quill-jdbc-zio/src/test/scala/io/getquill/postgres/ConnectionLeakTest.scala +++ b/quill-jdbc-zio/src/test/scala/io/getquill/postgres/ConnectionLeakTest.scala @@ -16,10 +16,12 @@ import zio.ZLayer class ConnectionLeakTest extends ProductSpec with ZioProxySpec { - implicit val pool: Implicit[ZLayer[Any,Throwable,DataSource]] = Implicit(Quill.DataSource.fromPrefix("testPostgresDB")) + implicit val pool: Implicit[ZLayer[Any, Throwable, DataSource]] = Implicit( + Quill.DataSource.fromPrefix("testPostgresDB") + ) val dataSource: HikariDataSource = JdbcContextConfig(LoadConfig("testPostgresLeakDB")).dataSource - val context = new PostgresZioJdbcContext(Literal) + val context = new PostgresZioJdbcContext(Literal) import context._ override def beforeAll: Unit = { diff --git a/quill-jdbc-zio/src/test/scala/io/getquill/postgres/MultiLevelServiceSpec.scala b/quill-jdbc-zio/src/test/scala/io/getquill/postgres/MultiLevelServiceSpec.scala index 11a52d745a..e8e0f57f14 100644 --- a/quill-jdbc-zio/src/test/scala/io/getquill/postgres/MultiLevelServiceSpec.scala +++ b/quill-jdbc-zio/src/test/scala/io/getquill/postgres/MultiLevelServiceSpec.scala @@ -25,9 +25,11 @@ class MultiLevelServiceSpec extends PeopleZioSpec with ZioSpec { case class DataService(quill: Quill[PostgresDialect, Literal]) { import quill.{run => qrun, _} - val people: Quoted[EntityQuery[Person]] = quote(query[Person]) - def somePeopleByName: Quoted[(Query[Person], String) => Query[Person]] = quote((ps: Query[Person], name: String) => ps.filter(p => p.name == name)) - def peopleByName: Quoted[String => EntityQuery[Person]] = quote((name: String) => people.filter(p => p.name == name)) + val people: Quoted[EntityQuery[Person]] = quote(query[Person]) + def somePeopleByName: Quoted[(Query[Person], String) => Query[Person]] = + quote((ps: Query[Person], name: String) => ps.filter(p => p.name == name)) + def peopleByName: Quoted[String => EntityQuery[Person]] = + quote((name: String) => people.filter(p => p.name == name)) def getAllPeople(): ZIO[Any, SQLException, List[Person]] = qrun(people) def getPeopleByName(name: String): ZIO[Any, SQLException, List[Person]] = qrun(peopleByName(lift(name))) } @@ -35,7 +37,7 @@ class MultiLevelServiceSpec extends PeopleZioSpec with ZioSpec { import dataService._ import dataService.quill.{run => qrun, _} - val joes: Quoted[EntityQuery[Person]] = quote(peopleByName("Joe")) + val joes: Quoted[EntityQuery[Person]] = quote(peopleByName("Joe")) def getJoes: ZIO[Any, SQLException, List[Person]] = qrun(joes) def getPeopleByName3(name: String): ZIO[Any, SQLException, List[Person]] = qrun( somePeopleByName(query[Person], lift(name)) @@ -44,15 +46,21 @@ class MultiLevelServiceSpec extends PeopleZioSpec with ZioSpec { def getPeopleByName(name: String): ZIO[Any, SQLException, List[Person]] = dataService.getPeopleByName(name) def getAllPeople(): ZIO[Any, SQLException, List[Person]] = dataService.getAllPeople() } - val dataServiceLive: ZLayer[Quill[PostgresDialect,Literal],Nothing,DataService] = ZLayer.fromFunction(DataService.apply _) - val applicationLive: ZLayer[DataService,Nothing,ApplicationLive] = ZLayer.fromFunction(ApplicationLive.apply _) + val dataServiceLive: ZLayer[Quill[PostgresDialect, Literal], Nothing, DataService] = + ZLayer.fromFunction(DataService.apply _) + val applicationLive: ZLayer[DataService, Nothing, ApplicationLive] = ZLayer.fromFunction(ApplicationLive.apply _) object Application { - def getJoes(): ZIO[ApplicationLive with ApplicationLive,SQLException,List[Person]] = ZIO.serviceWithZIO[ApplicationLive](_.getJoes) - def getPeopleByName3(name: String): ZIO[ApplicationLive with ApplicationLive,SQLException,List[Person]] = ZIO.serviceWithZIO[ApplicationLive](_.getPeopleByName3(name)) - def getPeopleByName2(name: String): ZIO[ApplicationLive with ApplicationLive,SQLException,List[Person]] = ZIO.serviceWithZIO[ApplicationLive](_.getPeopleByName2(name)) - def getPeopleByName(name: String): ZIO[ApplicationLive with ApplicationLive,SQLException,List[Person]] = ZIO.serviceWithZIO[ApplicationLive](_.getPeopleByName(name)) - def getAllPeople(): ZIO[ApplicationLive with ApplicationLive,SQLException,List[Person]] = ZIO.serviceWithZIO[ApplicationLive](_.getAllPeople()) + def getJoes(): ZIO[ApplicationLive with ApplicationLive, SQLException, List[Person]] = + ZIO.serviceWithZIO[ApplicationLive](_.getJoes) + def getPeopleByName3(name: String): ZIO[ApplicationLive with ApplicationLive, SQLException, List[Person]] = + ZIO.serviceWithZIO[ApplicationLive](_.getPeopleByName3(name)) + def getPeopleByName2(name: String): ZIO[ApplicationLive with ApplicationLive, SQLException, List[Person]] = + ZIO.serviceWithZIO[ApplicationLive](_.getPeopleByName2(name)) + def getPeopleByName(name: String): ZIO[ApplicationLive with ApplicationLive, SQLException, List[Person]] = + ZIO.serviceWithZIO[ApplicationLive](_.getPeopleByName(name)) + def getAllPeople(): ZIO[ApplicationLive with ApplicationLive, SQLException, List[Person]] = + ZIO.serviceWithZIO[ApplicationLive](_.getAllPeople()) } "All Composition variations must work" in { diff --git a/quill-jdbc-zio/src/test/scala/io/getquill/sqlite/PrepareJdbcSpec.scala b/quill-jdbc-zio/src/test/scala/io/getquill/sqlite/PrepareJdbcSpec.scala index 6466d5a1c2..1bbfea630f 100644 --- a/quill-jdbc-zio/src/test/scala/io/getquill/sqlite/PrepareJdbcSpec.scala +++ b/quill-jdbc-zio/src/test/scala/io/getquill/sqlite/PrepareJdbcSpec.scala @@ -18,8 +18,9 @@ class PrepareJdbcSpec extends PrepareZioJdbcSpecBase with BeforeAndAfter { testContext.run(query[Product].delete).runSyncUnsafe() } - def productExtractor: (ResultSet, Connection) => Product = (rs: ResultSet, conn: Connection) => materializeQueryMeta[Product].extract(rs, conn) - val prepareQuery: ZioJdbc.QCIO[PreparedStatement] = prepare(query[Product]) + def productExtractor: (ResultSet, Connection) => Product = (rs: ResultSet, conn: Connection) => + materializeQueryMeta[Product].extract(rs, conn) + val prepareQuery: ZioJdbc.QCIO[PreparedStatement] = prepare(query[Product]) "single" in { val prepareInsert = prepare(query[Product].insertValue(lift(productEntries.head))) diff --git a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/oracle/JdbcEncodingSpec.scala b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/oracle/JdbcEncodingSpec.scala index dfb15279e2..728341f4cc 100644 --- a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/oracle/JdbcEncodingSpec.scala +++ b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/oracle/JdbcEncodingSpec.scala @@ -35,8 +35,8 @@ class JdbcEncodingSpec extends EncodingSpec { } def emptyAsNull(e: EncodingTestType): EncodingTestType = e.copy(value = if (e.value == "") null else e.value) - def emptyAsNull(str: String): String = if (str == "") null else str - def emptyAsNull(bytes: Array[Byte]): Array[Byte] = if (bytes == null || bytes.isEmpty) null else bytes + def emptyAsNull(str: String): String = if (str == "") null else str + def emptyAsNull(bytes: Array[Byte]): Array[Byte] = if (bytes == null || bytes.isEmpty) null else bytes /** * Since oracle encodes "" as null, need to modify verification in order to diff --git a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/postgres/ArrayJdbcEncodingSpec.scala b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/postgres/ArrayJdbcEncodingSpec.scala index e1687ae209..8434759928 100644 --- a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/postgres/ArrayJdbcEncodingSpec.scala +++ b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/postgres/ArrayJdbcEncodingSpec.scala @@ -11,7 +11,7 @@ class ArrayJdbcEncodingSpec extends ArrayEncodingBaseSpec { val ctx = testContext import ctx._ - val q = quote(query[ArraysTestEntity]) + val q = quote(query[ArraysTestEntity]) val corrected: ArraysTestEntity = e.copy(timestamps = e.timestamps.map(d => new Timestamp(d.getTime))) "Support all sql base types and `Seq` implementers" in { @@ -56,9 +56,6 @@ class ArrayJdbcEncodingSpec extends ArrayEncodingBaseSpec { val e = Entity(List(UUID.randomUUID(), UUID.randomUUID())) val q = quote(querySchema[Entity]("ArraysTestEntity")) - - - ctx.run(q.insertValue(lift(e))) ctx.run(q).head.uuids mustBe e.uuids } diff --git a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/sqlserver/BatchValuesJdbcSpec.scala b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/sqlserver/BatchValuesJdbcSpec.scala index b3f269aba1..2088b25aab 100644 --- a/quill-jdbc/src/test/scala/io/getquill/context/jdbc/sqlserver/BatchValuesJdbcSpec.scala +++ b/quill-jdbc/src/test/scala/io/getquill/context/jdbc/sqlserver/BatchValuesJdbcSpec.scala @@ -28,7 +28,7 @@ class BatchValuesJdbcSpec extends BatchValuesSpec { "Ex 2B - Batch Insert Returning - whole row" in { import `Ex 2 - Batch Insert Returning`._ - + def op = quote { liftQuery(products).foreach(p => query[Product].insertValue(p).returning(p => p)) } diff --git a/quill-orientdb/src/test/scala/io/getquill/context/orientdb/ListsEncodingSpec.scala b/quill-orientdb/src/test/scala/io/getquill/context/orientdb/ListsEncodingSpec.scala index e54b4baf0c..ea6b72aeeb 100644 --- a/quill-orientdb/src/test/scala/io/getquill/context/orientdb/ListsEncodingSpec.scala +++ b/quill-orientdb/src/test/scala/io/getquill/context/orientdb/ListsEncodingSpec.scala @@ -16,7 +16,8 @@ class ListsEncodingSpec extends Spec { doubles: List[Double], timestamps: List[Date] ) - val e: ListsEntity = ListsEntity(1, List("c"), List(true), List(1, 2), List(2, 3), List(1.2f, 3.2f), List(5.1d), List(new Date())) + val e: ListsEntity = + ListsEntity(1, List("c"), List(true), List(1, 2), List(2, 3), List(1.2f, 3.2f), List(5.1d), List(new Date())) private def verify(expected: ListsEntity, actual: ListsEntity): Boolean = { expected.id mustEqual actual.id diff --git a/quill-orientdb/src/test/scala/io/getquill/context/orientdb/OrientDBQuerySpec.scala b/quill-orientdb/src/test/scala/io/getquill/context/orientdb/OrientDBQuerySpec.scala index 921bc30b99..fa7de16ab3 100644 --- a/quill-orientdb/src/test/scala/io/getquill/context/orientdb/OrientDBQuerySpec.scala +++ b/quill-orientdb/src/test/scala/io/getquill/context/orientdb/OrientDBQuerySpec.scala @@ -185,7 +185,7 @@ class OrientDBQuerySpec extends Spec { import OrientDBIdiom._ implicit val n = Literal - val i: Ident = Ident("i") + val i: Ident = Ident("i") "tokenizers" - { "if" in { @@ -198,7 +198,9 @@ class OrientDBQuerySpec extends Spec { } "query" in { val t = implicitly[Tokenizer[AstQuery]] - t.token(Entity("name", List.empty, QEP)) mustBe new SqlQueryApply(TraceConfig.Empty)(Entity("name", List.empty, QEP)).token + t.token(Entity("name", List.empty, QEP)) mustBe new SqlQueryApply(TraceConfig.Empty)( + Entity("name", List.empty, QEP) + ).token } "sql query" in { val t = implicitly[Tokenizer[SqlQuery]] diff --git a/quill-spark/src/test/scala/io/getquill/context/spark/EncodingSparkSpec.scala b/quill-spark/src/test/scala/io/getquill/context/spark/EncodingSparkSpec.scala index 805773b66e..d35f2643ea 100644 --- a/quill-spark/src/test/scala/io/getquill/context/spark/EncodingSparkSpec.scala +++ b/quill-spark/src/test/scala/io/getquill/context/spark/EncodingSparkSpec.scala @@ -1,7 +1,7 @@ package io.getquill.context.spark import io.getquill.base.Spec -import io.getquill.{ Query, Quoted } +import io.getquill.{Query, Quoted} import org.scalatest.Assertion final case class EncodingTestEntity( diff --git a/quill-spark/src/test/scala/io/getquill/context/spark/TypeMemberJoinSpec.scala b/quill-spark/src/test/scala/io/getquill/context/spark/TypeMemberJoinSpec.scala index 2b19cb2fe2..0f98a44e7e 100644 --- a/quill-spark/src/test/scala/io/getquill/context/spark/TypeMemberJoinSpec.scala +++ b/quill-spark/src/test/scala/io/getquill/context/spark/TypeMemberJoinSpec.scala @@ -39,8 +39,8 @@ class TypeMemberJoinSpec extends Spec { } object Data { - val parent: Parent = Parent("Joe", 1) - val child: Child = Child("Jack", 1) + val parent: Parent = Parent("Joe", 1) + val child: Child = Child("Jack", 1) val grandChild: GrandChild = GrandChild("James", 1) } val parents = List(Data.parent).toDS diff --git a/quill-spark/src/test/scala/io/getquill/context/spark/VariableShadowSpec.scala b/quill-spark/src/test/scala/io/getquill/context/spark/VariableShadowSpec.scala index 7a345b1d15..b8ea2c2d6e 100644 --- a/quill-spark/src/test/scala/io/getquill/context/spark/VariableShadowSpec.scala +++ b/quill-spark/src/test/scala/io/getquill/context/spark/VariableShadowSpec.scala @@ -26,11 +26,12 @@ class VariableShadowSpec extends Spec { val americans: Quoted[Query[American]] = quote(liftQuery(americansList.toDS())) val addresses: Quoted[Query[Address1]] = quote(liftQuery(addressesList.toDS())) - val addressToSomeone: Quoted[Query[HumanoidLivingSomewhere] => Query[HumanoidLivingSomewhere]] = quote { (hum: Query[HumanoidLivingSomewhere]) => - for { - t <- hum - a <- addresses if (a.id == t.whereHeLives_id) - } yield t + val addressToSomeone: Quoted[Query[HumanoidLivingSomewhere] => Query[HumanoidLivingSomewhere]] = quote { + (hum: Query[HumanoidLivingSomewhere]) => + for { + t <- hum + a <- addresses if (a.id == t.whereHeLives_id) + } yield t } val americanClients: Quoted[Query[HumanoidLivingSomewhere]] = quote { diff --git a/quill-spark/src/test/scala/io/getquill/context/spark/examples/GitHubExample.scala b/quill-spark/src/test/scala/io/getquill/context/spark/examples/GitHubExample.scala index 3113f0e21c..a5d00fc913 100644 --- a/quill-spark/src/test/scala/io/getquill/context/spark/examples/GitHubExample.scala +++ b/quill-spark/src/test/scala/io/getquill/context/spark/examples/GitHubExample.scala @@ -11,7 +11,7 @@ import io.getquill.QuillSparkContext._ import scala.concurrent.ExecutionContext.Implicits._ import scala.concurrent.duration._ import scala.concurrent.{Await, Future} -import io.getquill.{ Query, Quoted } +import io.getquill.{Query, Quoted} import org.apache.spark.sql.SQLContext final case class User( @@ -69,7 +69,9 @@ object GitHubExample extends App { import sqlContext.implicits._ - val activities: Quoted[Query[Activity]] = liftQuery(sqlContext.read.json(files.map(n => s"$n.json.gz"): _*).as[Activity]) + val activities: Quoted[Query[Activity]] = liftQuery( + sqlContext.read.json(files.map(n => s"$n.json.gz"): _*).as[Activity] + ) val topStargazers: Quoted[Query[(String, Long)]] = quote { activities diff --git a/quill-spark/src/test/scala/io/getquill/context/spark/examples/TopHashtagsExample.scala b/quill-spark/src/test/scala/io/getquill/context/spark/examples/TopHashtagsExample.scala index f6f11026f4..57a70f2372 100644 --- a/quill-spark/src/test/scala/io/getquill/context/spark/examples/TopHashtagsExample.scala +++ b/quill-spark/src/test/scala/io/getquill/context/spark/examples/TopHashtagsExample.scala @@ -8,7 +8,7 @@ import org.apache.spark.sql.functions.{count => fcount, _} import io.getquill.QuillSparkContext._ import org.apache.spark.rdd.RDD import org.apache.spark.sql.Dataset -import org.apache.spark.sql.{ Row, SQLContext } +import org.apache.spark.sql.{Row, SQLContext} object TopHashtagsExample extends App { @@ -84,9 +84,9 @@ object TopHashtagsExample extends App { val tweets: Dataset[Tweet] = List(Tweet("some #hashTAG #h2"), Tweet("dds #h2 #hashtag #h2 #h3")).toDS() val rddR: List[(String, BigInt)] = rdd.topHashtags(tweets.rdd, 10).toList - val dfR: List[Row] = dataframe.topHashtags(tweets.toDF(), 10).rdd.toLocalIterator.toList + val dfR: List[Row] = dataframe.topHashtags(tweets.toDF(), 10).rdd.toLocalIterator.toList val dsR: List[(String, BigInt)] = dataset.topHashtags(tweets, 10).rdd.toLocalIterator.toList - val qR: List[(String, Long)] = quill.topHashtags(tweets, 10).rdd.toLocalIterator.toList + val qR: List[(String, Long)] = quill.topHashtags(tweets, 10).rdd.toLocalIterator.toList println("rddR: " + rddR) println("dfR: " + dfR) diff --git a/quill-spark/src/test/scala/io/getquill/context/spark/norm/ExpandEntityIdsSpec.scala b/quill-spark/src/test/scala/io/getquill/context/spark/norm/ExpandEntityIdsSpec.scala index 583037e6e9..b07009bf28 100644 --- a/quill-spark/src/test/scala/io/getquill/context/spark/norm/ExpandEntityIdsSpec.scala +++ b/quill-spark/src/test/scala/io/getquill/context/spark/norm/ExpandEntityIdsSpec.scala @@ -2,7 +2,7 @@ package io.getquill.context.spark.norm import io.getquill.base.Spec import io.getquill.context.spark.{sqlContext, testContext} -import io.getquill.{ Query, Quoted } +import io.getquill.{Query, Quoted} final case class Test(i: Int, j: Int, s: String) final case class TestHolder(ta: Test, tb: Test) @@ -22,7 +22,7 @@ class ExpandEntityIdsSpec extends Spec { import testContext._ import sqlContext.implicits._ - val ent: Test = Test(1, 2, "3") + val ent: Test = Test(1, 2, "3") val entities: Seq[Test] = Seq(ent) val qr1: Quoted[Query[Test]] = liftQuery(entities.toDS) @@ -30,9 +30,11 @@ class ExpandEntityIdsSpec extends Spec { val qr3: Quoted[Query[Test]] = liftQuery(entities.toDS) val qr4: Quoted[Query[Test]] = liftQuery(entities.toDS) - val s0: Quoted[Query[Tuple1[Int]]] = liftQuery(Seq(Tuple1(1), Tuple1(2)).toDS) + val s0: Quoted[Query[Tuple1[Int]]] = liftQuery(Seq(Tuple1(1), Tuple1(2)).toDS) val s1: Quoted[Query[SingleElement]] = liftQuery(Seq(SingleElement(1), SingleElement(2)).toDS) - val s2: Quoted[Query[SingleElementSingleHolder]] = liftQuery(Seq(SingleElementSingleHolder(SingleElement(1)), SingleElementSingleHolder(SingleElement(2))).toDS) + val s2: Quoted[Query[SingleElementSingleHolder]] = liftQuery( + Seq(SingleElementSingleHolder(SingleElement(1)), SingleElementSingleHolder(SingleElement(2))).toDS + ) val s3: Quoted[Query[SingleElementMultiHolder]] = liftQuery( Seq( SingleElementMultiHolder(Test(1, 2, "3"), SingleElement(1)), diff --git a/quill-sql/src/test/scala/io/getquill/context/sql/AggregationSpec.scala b/quill-sql/src/test/scala/io/getquill/context/sql/AggregationSpec.scala index a6d44292db..f13e2e04be 100644 --- a/quill-sql/src/test/scala/io/getquill/context/sql/AggregationSpec.scala +++ b/quill-sql/src/test/scala/io/getquill/context/sql/AggregationSpec.scala @@ -12,7 +12,8 @@ class AggregationSpec extends Spec { // remove the === matcher from scalatest so that we can test === in Context.extra override def convertToEqualizer[T](left: T): Equalizer[T] = new Equalizer(left) - val ctx: SqlMirrorContext[MirrorSqlDialect.type,Literal.type] with TestEntities = new SqlMirrorContext(MirrorSqlDialect, Literal) with TestEntities + val ctx: SqlMirrorContext[MirrorSqlDialect.type, Literal.type] with TestEntities = + new SqlMirrorContext(MirrorSqlDialect, Literal) with TestEntities import ctx._ // an issue heavily related to the ability to use an aggregator and then a .nested after which diff --git a/quill-sql/src/test/scala/io/getquill/context/sql/EmbeddedSpec.scala b/quill-sql/src/test/scala/io/getquill/context/sql/EmbeddedSpec.scala index b81d428b9b..79fcef015e 100644 --- a/quill-sql/src/test/scala/io/getquill/context/sql/EmbeddedSpec.scala +++ b/quill-sql/src/test/scala/io/getquill/context/sql/EmbeddedSpec.scala @@ -5,7 +5,8 @@ import io.getquill.base.Spec class EmbeddedSpec extends Spec { - val ctx: SqlMirrorContext[MirrorSqlDialect.type,Literal.type] with TestEntities = new SqlMirrorContext(MirrorSqlDialect, Literal) with TestEntities + val ctx: SqlMirrorContext[MirrorSqlDialect.type, Literal.type] with TestEntities = + new SqlMirrorContext(MirrorSqlDialect, Literal) with TestEntities import ctx._ "queries with embedded entities should" - { diff --git a/quill-sql/src/test/scala/io/getquill/context/sql/EncodingSpec.scala b/quill-sql/src/test/scala/io/getquill/context/sql/EncodingSpec.scala index 108a1115d2..b35288a8d2 100644 --- a/quill-sql/src/test/scala/io/getquill/context/sql/EncodingSpec.scala +++ b/quill-sql/src/test/scala/io/getquill/context/sql/EncodingSpec.scala @@ -2,17 +2,9 @@ package io.getquill.context.sql import io.getquill.base.Spec -import java.time.{ - LocalDate, - LocalDateTime, - OffsetDateTime, - OffsetTime, - ZoneId, - ZoneOffset, - ZonedDateTime -} +import java.time.{LocalDate, LocalDateTime, OffsetDateTime, OffsetTime, ZoneId, ZoneOffset, ZonedDateTime} import java.util.{Date, UUID} -import io.getquill.{ Delete, Quoted } +import io.getquill.{Delete, Quoted} import org.scalatest.Assertion final case class EncodingTestType(value: String) @@ -236,8 +228,8 @@ trait EncodingSpec extends Spec { case class BarCode(description: String, uuid: Option[UUID] = None) - val insertBarCode = quote((b: BarCode) => query[BarCode].insertValue(b).returningGenerated(_.uuid)) - val barCodeEntry: BarCode = BarCode("returning UUID") + val insertBarCode = quote((b: BarCode) => query[BarCode].insertValue(b).returningGenerated(_.uuid)) + val barCodeEntry: BarCode = BarCode("returning UUID") def findBarCodeByUuid(uuid: UUID) = quote(query[BarCode].filter(_.uuid.forall(_ == lift(uuid)))) diff --git a/quill-sql/src/test/scala/io/getquill/context/sql/ProductSpec.scala b/quill-sql/src/test/scala/io/getquill/context/sql/ProductSpec.scala index 867dde11d3..e2b2314e33 100644 --- a/quill-sql/src/test/scala/io/getquill/context/sql/ProductSpec.scala +++ b/quill-sql/src/test/scala/io/getquill/context/sql/ProductSpec.scala @@ -2,7 +2,7 @@ package io.getquill.context.sql import io.getquill.Query import io.getquill.base.Spec -import io.getquill.{ ActionReturning, EntityQuery, Quoted } +import io.getquill.{ActionReturning, EntityQuery, Quoted} final case class Id(value: Long) extends AnyVal @@ -36,7 +36,7 @@ trait ProductSpec extends Spec { Product(0L, "Pencil", 1003L) ) - val productSingleInsert: Quoted[ActionReturning[Product,Long]] = quote { + val productSingleInsert: Quoted[ActionReturning[Product, Long]] = quote { product.insert(_.id -> 0, _.description -> "Window", _.sku -> 1004L).returningGenerated(_.id) } } diff --git a/quill-sql/src/test/scala/io/getquill/context/sql/QuerySchemaSpec.scala b/quill-sql/src/test/scala/io/getquill/context/sql/QuerySchemaSpec.scala index aab5e7a9fe..2a5e9c4910 100644 --- a/quill-sql/src/test/scala/io/getquill/context/sql/QuerySchemaSpec.scala +++ b/quill-sql/src/test/scala/io/getquill/context/sql/QuerySchemaSpec.scala @@ -5,7 +5,8 @@ import io.getquill.{Literal, PostgresDialect, SqlMirrorContext, TestEntities} class QuerySchemaSpec extends Spec { - val ctx: SqlMirrorContext[PostgresDialect.type,Literal.type] with TestEntities = new SqlMirrorContext(PostgresDialect, Literal) with TestEntities + val ctx: SqlMirrorContext[PostgresDialect.type, Literal.type] with TestEntities = + new SqlMirrorContext(PostgresDialect, Literal) with TestEntities import ctx._ "OnConflict Should work correct with" - { diff --git a/quill-sql/src/test/scala/io/getquill/context/sql/TestDecoders.scala b/quill-sql/src/test/scala/io/getquill/context/sql/TestDecoders.scala index e3d42102a1..8e487df1a3 100644 --- a/quill-sql/src/test/scala/io/getquill/context/sql/TestDecoders.scala +++ b/quill-sql/src/test/scala/io/getquill/context/sql/TestDecoders.scala @@ -3,8 +3,9 @@ package io.getquill.context.sql import io.getquill.MappedEncoding trait TestDecoders { - implicit val encodingTestTypeDecoder: MappedEncoding[String,EncodingTestType] = MappedEncoding[String, EncodingTestType](EncodingTestType) - implicit val nameDecoder: MappedEncoding[String,Number] = MappedEncoding[String, Number](s => + implicit val encodingTestTypeDecoder: MappedEncoding[String, EncodingTestType] = + MappedEncoding[String, EncodingTestType](EncodingTestType) + implicit val nameDecoder: MappedEncoding[String, Number] = MappedEncoding[String, Number](s => Number .withValidation(s) .getOrElse(throw new Exception(s"Illegal number $s")) diff --git a/quill-sql/src/test/scala/io/getquill/context/sql/TestEncoders.scala b/quill-sql/src/test/scala/io/getquill/context/sql/TestEncoders.scala index 33726b5ed4..942f11172f 100644 --- a/quill-sql/src/test/scala/io/getquill/context/sql/TestEncoders.scala +++ b/quill-sql/src/test/scala/io/getquill/context/sql/TestEncoders.scala @@ -3,6 +3,7 @@ package io.getquill.context.sql import io.getquill.MappedEncoding trait TestEncoders { - implicit val encodingTestTypeEncoder: MappedEncoding[EncodingTestType,String] = MappedEncoding[EncodingTestType, String](_.value) - implicit val nameEncoder: MappedEncoding[Number,String] = MappedEncoding[Number, String](_.value) + implicit val encodingTestTypeEncoder: MappedEncoding[EncodingTestType, String] = + MappedEncoding[EncodingTestType, String](_.value) + implicit val nameEncoder: MappedEncoding[Number, String] = MappedEncoding[Number, String](_.value) } diff --git a/quill-sql/src/test/scala/io/getquill/context/sql/base/ArrayOpsSpec.scala b/quill-sql/src/test/scala/io/getquill/context/sql/base/ArrayOpsSpec.scala index 2985a28744..f31ff77a54 100644 --- a/quill-sql/src/test/scala/io/getquill/context/sql/base/ArrayOpsSpec.scala +++ b/quill-sql/src/test/scala/io/getquill/context/sql/base/ArrayOpsSpec.scala @@ -3,7 +3,7 @@ package io.getquill.context.sql.base import io.getquill.base.Spec import io.getquill.context.sql.SqlContext import io.getquill.context.sql.encoding.ArrayEncoding -import io.getquill.{ EntityQuery, Quoted } +import io.getquill.{EntityQuery, Quoted} trait ArrayOpsSpec extends Spec { diff --git a/quill-sql/src/test/scala/io/getquill/context/sql/base/BatchUpdateValuesSpec.scala b/quill-sql/src/test/scala/io/getquill/context/sql/base/BatchUpdateValuesSpec.scala index 699b329782..71cf8ec5fc 100644 --- a/quill-sql/src/test/scala/io/getquill/context/sql/base/BatchUpdateValuesSpec.scala +++ b/quill-sql/src/test/scala/io/getquill/context/sql/base/BatchUpdateValuesSpec.scala @@ -22,7 +22,7 @@ trait BatchUpdateValuesSpec extends Spec with BeforeAndAfterEach { ContactBase("Caboose", "Castle", 66), ContactBase("E", "E", 111) ) - val updatePeople: List[String] = List("Joe", "Jan", "James", "Dale", "Caboose") + val updatePeople: List[String] = List("Joe", "Jan", "James", "Dale", "Caboose") def includeInUpdate(name: String): Boolean = updatePeople.contains(name) def includeInUpdate(c: ContactBase): Boolean = includeInUpdate(c.firstName) val updateBase: List[ContactBase] = diff --git a/quill-sql/src/test/scala/io/getquill/context/sql/base/OnConflictSpec.scala b/quill-sql/src/test/scala/io/getquill/context/sql/base/OnConflictSpec.scala index 42db86dc76..878d94efcc 100644 --- a/quill-sql/src/test/scala/io/getquill/context/sql/base/OnConflictSpec.scala +++ b/quill-sql/src/test/scala/io/getquill/context/sql/base/OnConflictSpec.scala @@ -3,7 +3,7 @@ package io.getquill.context.sql.base import io.getquill.context.sql.SqlContext import io.getquill.TestEntities import io.getquill.base.Spec -import io.getquill.{ EntityQuery, Quoted } +import io.getquill.{EntityQuery, Quoted} trait OnConflictSpec extends Spec { val ctx: SqlContext[_, _] with TestEntities diff --git a/quill-sql/src/test/scala/io/getquill/context/sql/base/QueryResultTypeSpec.scala b/quill-sql/src/test/scala/io/getquill/context/sql/base/QueryResultTypeSpec.scala index 388d28e4d2..5c482a91a3 100644 --- a/quill-sql/src/test/scala/io/getquill/context/sql/base/QueryResultTypeSpec.scala +++ b/quill-sql/src/test/scala/io/getquill/context/sql/base/QueryResultTypeSpec.scala @@ -2,39 +2,39 @@ package io.getquill.context.sql.base import io.getquill.Ord import io.getquill.context.sql.ProductSpec -import io.getquill.{ Delete, EntityQuery, Query, Quoted } +import io.getquill.{Delete, EntityQuery, Query, Quoted} trait QueryResultTypeSpec extends ProductSpec { import context._ - val deleteAll: Quoted[Delete[Product]] = quote(query[Product].delete) + val deleteAll: Quoted[Delete[Product]] = quote(query[Product].delete) val selectAll: Quoted[EntityQuery[Product]] = quote(query[Product]) - val map: Quoted[EntityQuery[Long]] = quote(query[Product].map(_.id)) + val map: Quoted[EntityQuery[Long]] = quote(query[Product].map(_.id)) val filter: Quoted[EntityQuery[Product]] = quote(query[Product].filter(_ => true)) val withFilter: Quoted[EntityQuery[Product]] = quote(query[Product].withFilter(_ => true)) - val sortBy: Quoted[Query[Product]] = quote(query[Product].sortBy(_.id)(Ord.asc)) - val take: Quoted[Query[Product]] = quote(query[Product].take(10)) - val drop: Quoted[Query[Product]] = quote(query[Product].drop(1)) - val `++` = quote(query[Product] ++ query[Product]) - val unionAll: Quoted[Query[Product]] = quote(query[Product].unionAll(query[Product])) - val union: Quoted[Query[Product]] = quote(query[Product].union(query[Product])) - - val minExists: Quoted[Option[Long]] = quote(query[Product].map(_.sku).min) - val minNonExists: Quoted[Option[Long]] = quote(query[Product].filter(_.id > 1000).map(_.sku).min) - val maxExists: Quoted[Option[Long]] = quote(query[Product].map(_.sku).max) - val maxNonExists: Quoted[Option[Long]] = quote(query[Product].filter(_.id > 1000).map(_.sku).max) + val sortBy: Quoted[Query[Product]] = quote(query[Product].sortBy(_.id)(Ord.asc)) + val take: Quoted[Query[Product]] = quote(query[Product].take(10)) + val drop: Quoted[Query[Product]] = quote(query[Product].drop(1)) + val `++` = quote(query[Product] ++ query[Product]) + val unionAll: Quoted[Query[Product]] = quote(query[Product].unionAll(query[Product])) + val union: Quoted[Query[Product]] = quote(query[Product].union(query[Product])) + + val minExists: Quoted[Option[Long]] = quote(query[Product].map(_.sku).min) + val minNonExists: Quoted[Option[Long]] = quote(query[Product].filter(_.id > 1000).map(_.sku).min) + val maxExists: Quoted[Option[Long]] = quote(query[Product].map(_.sku).max) + val maxNonExists: Quoted[Option[Long]] = quote(query[Product].filter(_.id > 1000).map(_.sku).max) val avgExists: Quoted[Option[BigDecimal]] = quote(query[Product].map(_.sku).avg) val avgNonExists: Quoted[Option[BigDecimal]] = quote(query[Product].filter(_.id > 1000).map(_.sku).avg) - val productSize: Quoted[Long] = quote(query[Product].size) + val productSize: Quoted[Long] = quote(query[Product].size) val parametrizedSize: Quoted[Long => Long] = quote { (id: Long) => query[Product].filter(_.id == id).size } val join: Quoted[Query[(Product, Product)]] = quote(query[Product].join(query[Product]).on(_.id == _.id)) - val nonEmpty: Quoted[Boolean] = quote(query[Product].nonEmpty) - val isEmpty: Quoted[Boolean] = quote(query[Product].isEmpty) + val nonEmpty: Quoted[Boolean] = quote(query[Product].nonEmpty) + val isEmpty: Quoted[Boolean] = quote(query[Product].isEmpty) val distinct: Quoted[Query[Long]] = quote(query[Product].map(_.id).distinct) } diff --git a/quill-sql/src/test/scala/io/getquill/context/sql/idiom/H2DialectSpec.scala b/quill-sql/src/test/scala/io/getquill/context/sql/idiom/H2DialectSpec.scala index 2106d2a256..ae84795bab 100644 --- a/quill-sql/src/test/scala/io/getquill/context/sql/idiom/H2DialectSpec.scala +++ b/quill-sql/src/test/scala/io/getquill/context/sql/idiom/H2DialectSpec.scala @@ -3,7 +3,8 @@ package io.getquill.context.sql.idiom import io.getquill.{H2Dialect, Literal, SqlMirrorContext, TestEntities} class H2DialectSpec extends OnConflictSpec { - val ctx: SqlMirrorContext[H2Dialect.type,Literal.type] with TestEntities = new SqlMirrorContext(H2Dialect, Literal) with TestEntities + val ctx: SqlMirrorContext[H2Dialect.type, Literal.type] with TestEntities = new SqlMirrorContext(H2Dialect, Literal) + with TestEntities import ctx._ "OnConflict" - `onConflict with all` { i => "no target - ignore" in { diff --git a/quill-sql/src/test/scala/io/getquill/context/sql/idiom/MySQL5DialectSpec.scala b/quill-sql/src/test/scala/io/getquill/context/sql/idiom/MySQL5DialectSpec.scala index d7da855597..0c72044ec2 100644 --- a/quill-sql/src/test/scala/io/getquill/context/sql/idiom/MySQL5DialectSpec.scala +++ b/quill-sql/src/test/scala/io/getquill/context/sql/idiom/MySQL5DialectSpec.scala @@ -3,7 +3,8 @@ package io.getquill.context.sql.idiom import io.getquill._ class MySQL5DialectSpec extends AbstractMySQLDialectSpec { - lazy val ctx: SqlMirrorContext[MySQL5Dialect.type,Literal.type] with TestEntities = new SqlMirrorContext(MySQL5Dialect, Literal) with TestEntities + lazy val ctx: SqlMirrorContext[MySQL5Dialect.type, Literal.type] with TestEntities = + new SqlMirrorContext(MySQL5Dialect, Literal) with TestEntities import ctx._ diff --git a/quill-sql/src/test/scala/io/getquill/context/sql/idiom/MySQLDialectSpec.scala b/quill-sql/src/test/scala/io/getquill/context/sql/idiom/MySQLDialectSpec.scala index 1d5d0b62e0..a7688509e8 100644 --- a/quill-sql/src/test/scala/io/getquill/context/sql/idiom/MySQLDialectSpec.scala +++ b/quill-sql/src/test/scala/io/getquill/context/sql/idiom/MySQLDialectSpec.scala @@ -3,7 +3,8 @@ package io.getquill.context.sql.idiom import io.getquill._ class MySQLDialectSpec extends AbstractMySQLDialectSpec { - lazy val ctx: SqlMirrorContext[MySQLDialect.type,Literal.type] with TestEntities = new SqlMirrorContext(MySQLDialect, Literal) with TestEntities + lazy val ctx: SqlMirrorContext[MySQLDialect.type, Literal.type] with TestEntities = + new SqlMirrorContext(MySQLDialect, Literal) with TestEntities import ctx._ diff --git a/quill-sql/src/test/scala/io/getquill/context/sql/idiom/OffsetWithoutLimitWorkaroundSpec.scala b/quill-sql/src/test/scala/io/getquill/context/sql/idiom/OffsetWithoutLimitWorkaroundSpec.scala index 0c0f110bab..ea33a399a5 100644 --- a/quill-sql/src/test/scala/io/getquill/context/sql/idiom/OffsetWithoutLimitWorkaroundSpec.scala +++ b/quill-sql/src/test/scala/io/getquill/context/sql/idiom/OffsetWithoutLimitWorkaroundSpec.scala @@ -9,13 +9,14 @@ import scala.util.Try class OffsetWithoutLimitWorkaroundSpec extends Spec { - val ctx: SqlMirrorContext[MySQLDialect.type,Literal.type] with TestEntities = new SqlMirrorContext(MySQLDialect, Literal) with TestEntities { - override def probe(statement: String) = - Try { - statement mustEqual - "PREPARE p603247403 FROM 'SELECT x.s, x.i, x.l, x.o FROM TestEntity x LIMIT 18446744073709551610 OFFSET 1'" - } - } + val ctx: SqlMirrorContext[MySQLDialect.type, Literal.type] with TestEntities = + new SqlMirrorContext(MySQLDialect, Literal) with TestEntities { + override def probe(statement: String) = + Try { + statement mustEqual + "PREPARE p603247403 FROM 'SELECT x.s, x.i, x.l, x.o FROM TestEntity x LIMIT 18446744073709551610 OFFSET 1'" + } + } import ctx._ "creates a synthetic limit" in { diff --git a/quill-sql/src/test/scala/io/getquill/context/sql/idiom/OracleDialectSpec.scala b/quill-sql/src/test/scala/io/getquill/context/sql/idiom/OracleDialectSpec.scala index d9f5edaa6b..6c6110ab4e 100644 --- a/quill-sql/src/test/scala/io/getquill/context/sql/idiom/OracleDialectSpec.scala +++ b/quill-sql/src/test/scala/io/getquill/context/sql/idiom/OracleDialectSpec.scala @@ -5,7 +5,8 @@ import io.getquill.base.Spec class OracleDialectSpec extends Spec { - val ctx: SqlMirrorContext[OracleDialect.type,Literal.type] with TestEntities = new SqlMirrorContext(OracleDialect, Literal) with TestEntities + val ctx: SqlMirrorContext[OracleDialect.type, Literal.type] with TestEntities = + new SqlMirrorContext(OracleDialect, Literal) with TestEntities import ctx._ "uses 'mod' function" in { diff --git a/quill-sql/src/test/scala/io/getquill/context/sql/idiom/PostgresDialectSpec.scala b/quill-sql/src/test/scala/io/getquill/context/sql/idiom/PostgresDialectSpec.scala index f4443a50da..dae4a923fd 100644 --- a/quill-sql/src/test/scala/io/getquill/context/sql/idiom/PostgresDialectSpec.scala +++ b/quill-sql/src/test/scala/io/getquill/context/sql/idiom/PostgresDialectSpec.scala @@ -7,7 +7,8 @@ import io.getquill.TestEntities class PostgresDialectSpec extends OnConflictSpec { - val ctx: SqlMirrorContext[PostgresDialect.type,Literal.type] with TestEntities = new SqlMirrorContext(PostgresDialect, Literal) with TestEntities + val ctx: SqlMirrorContext[PostgresDialect.type, Literal.type] with TestEntities = + new SqlMirrorContext(PostgresDialect, Literal) with TestEntities import ctx._ "applies explicit casts" - { diff --git a/quill-sql/src/test/scala/io/getquill/context/sql/idiom/SQLServerDialectSpec.scala b/quill-sql/src/test/scala/io/getquill/context/sql/idiom/SQLServerDialectSpec.scala index 550a07d8f4..9003a0c10b 100644 --- a/quill-sql/src/test/scala/io/getquill/context/sql/idiom/SQLServerDialectSpec.scala +++ b/quill-sql/src/test/scala/io/getquill/context/sql/idiom/SQLServerDialectSpec.scala @@ -10,7 +10,8 @@ class SQLServerDialectSpec extends Spec { SQLServerDialect.emptySetContainsToken(StringToken("w/e")) mustBe StringToken("1 <> 1") } - val ctx: SqlMirrorContext[SQLServerDialect.type,Literal.type] with TestEntities = new SqlMirrorContext(SQLServerDialect, Literal) with TestEntities + val ctx: SqlMirrorContext[SQLServerDialect.type, Literal.type] with TestEntities = + new SqlMirrorContext(SQLServerDialect, Literal) with TestEntities import ctx._ "uses + instead of ||" in { diff --git a/quill-sql/src/test/scala/io/getquill/context/sql/idiom/SqlActionSpec.scala b/quill-sql/src/test/scala/io/getquill/context/sql/idiom/SqlActionSpec.scala index e65af6ad06..0beff15033 100644 --- a/quill-sql/src/test/scala/io/getquill/context/sql/idiom/SqlActionSpec.scala +++ b/quill-sql/src/test/scala/io/getquill/context/sql/idiom/SqlActionSpec.scala @@ -132,7 +132,7 @@ class SqlActionSpec extends Spec { "update" - { "reuse field name - with no filter" in { final case class Timeslot(id: Int, booked: Int) - + val q = quote { query[Timeslot] .update(ts => ts.booked -> (ts.booked + lift(1))) diff --git a/quill-sql/src/test/scala/io/getquill/context/sql/idiom/SqliteDialectSpec.scala b/quill-sql/src/test/scala/io/getquill/context/sql/idiom/SqliteDialectSpec.scala index 1fb79e316e..94de7c58c0 100644 --- a/quill-sql/src/test/scala/io/getquill/context/sql/idiom/SqliteDialectSpec.scala +++ b/quill-sql/src/test/scala/io/getquill/context/sql/idiom/SqliteDialectSpec.scala @@ -8,7 +8,8 @@ import io.getquill.Ord class SqliteDialectSpec extends OnConflictSpec { - val ctx: SqlMirrorContext[SqliteDialect.type,Literal.type] with TestEntities = new SqlMirrorContext(SqliteDialect, Literal) with TestEntities + val ctx: SqlMirrorContext[SqliteDialect.type, Literal.type] with TestEntities = + new SqlMirrorContext(SqliteDialect, Literal) with TestEntities import ctx._ "sortBy doesn't specify nulls ordering" - { diff --git a/quill-sql/src/test/scala/io/getquill/context/sql/mirror/ArrayMirrorEncodingSpec.scala b/quill-sql/src/test/scala/io/getquill/context/sql/mirror/ArrayMirrorEncodingSpec.scala index c2ba31cd0a..4d31729ee3 100644 --- a/quill-sql/src/test/scala/io/getquill/context/sql/mirror/ArrayMirrorEncodingSpec.scala +++ b/quill-sql/src/test/scala/io/getquill/context/sql/mirror/ArrayMirrorEncodingSpec.scala @@ -5,7 +5,7 @@ import java.util.Date import io.getquill.context.sql.encoding.ArrayEncodingBaseSpec import io.getquill.context.sql.testContext -import io.getquill.{ EntityQuery, Quoted } +import io.getquill.{EntityQuery, Quoted} class ArrayMirrorEncodingSpec extends ArrayEncodingBaseSpec { val ctx = testContext diff --git a/quill-sql/src/test/scala/io/getquill/context/sql/mirror/ObservationMirrorSpec.scala b/quill-sql/src/test/scala/io/getquill/context/sql/mirror/ObservationMirrorSpec.scala index fcc3b317c4..5b0cd0bc9e 100644 --- a/quill-sql/src/test/scala/io/getquill/context/sql/mirror/ObservationMirrorSpec.scala +++ b/quill-sql/src/test/scala/io/getquill/context/sql/mirror/ObservationMirrorSpec.scala @@ -2,7 +2,7 @@ package io.getquill.context.sql.mirror import io.getquill.base.Spec import io.getquill.context.mirror.Row -import io.getquill.{ EntityQuery, Quoted } +import io.getquill.{EntityQuery, Quoted} class ObservationMirrorSpec extends Spec { diff --git a/quill-sql/src/test/scala/io/getquill/context/sql/norm/AddDropToNestedOrderBySpec.scala b/quill-sql/src/test/scala/io/getquill/context/sql/norm/AddDropToNestedOrderBySpec.scala index 91195fe6be..8ae0bdca63 100644 --- a/quill-sql/src/test/scala/io/getquill/context/sql/norm/AddDropToNestedOrderBySpec.scala +++ b/quill-sql/src/test/scala/io/getquill/context/sql/norm/AddDropToNestedOrderBySpec.scala @@ -6,7 +6,8 @@ import io.getquill.context.sql.{TestDecoders, TestEncoders} class AddDropToNestedOrderBySpec extends Spec { - val ctx: SqlMirrorContext[SQLServerDialect.type,Literal.type] with TestEntities with TestEncoders with TestDecoders = new SqlMirrorContext(SQLServerDialect, Literal) with TestEntities with TestEncoders with TestDecoders + val ctx: SqlMirrorContext[SQLServerDialect.type, Literal.type] with TestEntities with TestEncoders with TestDecoders = + new SqlMirrorContext(SQLServerDialect, Literal) with TestEntities with TestEncoders with TestDecoders import ctx._ val q2Sorted: Quoted[Query[TestEntity2]] = quote(qr2.sortBy(r => r.i)) diff --git a/quill-sql/src/test/scala/io/getquill/context/sql/norm/RenamePropertiesSpec.scala b/quill-sql/src/test/scala/io/getquill/context/sql/norm/RenamePropertiesSpec.scala index a69910e91f..a2336b2800 100644 --- a/quill-sql/src/test/scala/io/getquill/context/sql/norm/RenamePropertiesSpec.scala +++ b/quill-sql/src/test/scala/io/getquill/context/sql/norm/RenamePropertiesSpec.scala @@ -6,7 +6,7 @@ import io.getquill.context.sql.testContext._ import io.getquill.context.sql.testContext import io.getquill.Query import io.getquill.base.Spec -import io.getquill.{ EntityQuery, Quoted } +import io.getquill.{EntityQuery, Quoted} class RenamePropertiesSpec extends Spec {