diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/document/DocumentRepo.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/document/DocumentRepo.scala index a813d2ba9e..6c32ca02c0 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/document/DocumentRepo.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/document/DocumentRepo.scala @@ -25,7 +25,7 @@ trait DocumentRepo { def selectAll(implicit c: Connection): List[DocumentRow] def selectById(documentnode: DocumentId)(implicit c: Connection): Option[DocumentRow] def selectByIds(documentnodes: Array[DocumentId])(implicit c: Connection): List[DocumentRow] - def selectByUnique(rowguid: TypoUUID)(implicit c: Connection): Option[DocumentRow] + def selectByUniqueRowguid(rowguid: TypoUUID)(implicit c: Connection): Option[DocumentRow] def update(row: DocumentRow)(implicit c: Connection): Boolean def update: UpdateBuilder[DocumentFields, DocumentRow] def upsert(unsaved: DocumentRow)(implicit c: Connection): DocumentRow diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/document/DocumentRepoImpl.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/document/DocumentRepoImpl.scala index 3e83bbc71a..a9d54618d4 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/document/DocumentRepoImpl.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/document/DocumentRepoImpl.scala @@ -119,7 +119,7 @@ class DocumentRepoImpl extends DocumentRepo { """.as(DocumentRow.rowParser(1).*) } - override def selectByUnique(rowguid: TypoUUID)(implicit c: Connection): Option[DocumentRow] = { + override def selectByUniqueRowguid(rowguid: TypoUUID)(implicit c: Connection): Option[DocumentRow] = { SQL"""select "title", "owner", "folderflag", "filename", "fileextension", "revision", "changenumber", "status", "documentsummary", "document", "rowguid", "modifieddate"::text, "documentnode" from production.document where "rowguid" = ${ParameterValue(rowguid, null, TypoUUID.toStatement)} diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/document/DocumentRepoMock.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/document/DocumentRepoMock.scala index b8ecd35c07..8182f37388 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/document/DocumentRepoMock.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/document/DocumentRepoMock.scala @@ -65,7 +65,7 @@ class DocumentRepoMock(toRow: Function1[DocumentRowUnsaved, DocumentRow], override def selectByIds(documentnodes: Array[DocumentId])(implicit c: Connection): List[DocumentRow] = { documentnodes.flatMap(map.get).toList } - override def selectByUnique(rowguid: TypoUUID)(implicit c: Connection): Option[DocumentRow] = { + override def selectByUniqueRowguid(rowguid: TypoUUID)(implicit c: Connection): Option[DocumentRow] = { map.values.find(v => rowguid == v.rowguid) } override def update(row: DocumentRow)(implicit c: Connection): Boolean = { diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/public/users/UsersRepo.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/public/users/UsersRepo.scala index 29352f4c7d..4db71ba9fa 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/public/users/UsersRepo.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/public/users/UsersRepo.scala @@ -25,7 +25,7 @@ trait UsersRepo { def selectAll(implicit c: Connection): List[UsersRow] def selectById(userId: UsersId)(implicit c: Connection): Option[UsersRow] def selectByIds(userIds: Array[UsersId])(implicit c: Connection): List[UsersRow] - def selectByUnique(email: TypoUnknownCitext)(implicit c: Connection): Option[UsersRow] + def selectByUniqueEmail(email: TypoUnknownCitext)(implicit c: Connection): Option[UsersRow] def update(row: UsersRow)(implicit c: Connection): Boolean def update: UpdateBuilder[UsersFields, UsersRow] def upsert(unsaved: UsersRow)(implicit c: Connection): UsersRow diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/public/users/UsersRepoImpl.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/public/users/UsersRepoImpl.scala index 8a70e1012d..d2199cfb5b 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/public/users/UsersRepoImpl.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/public/users/UsersRepoImpl.scala @@ -97,7 +97,7 @@ class UsersRepoImpl extends UsersRepo { """.as(UsersRow.rowParser(1).*) } - override def selectByUnique(email: TypoUnknownCitext)(implicit c: Connection): Option[UsersRow] = { + override def selectByUniqueEmail(email: TypoUnknownCitext)(implicit c: Connection): Option[UsersRow] = { SQL"""select "user_id", "name", "last_name", "email"::text, "password", "created_at"::text, "verified_on"::text from public.users where "email" = ${ParameterValue(email, null, TypoUnknownCitext.toStatement)} diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/public/users/UsersRepoMock.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/public/users/UsersRepoMock.scala index d6ede6d8e6..1a215a5ce7 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/public/users/UsersRepoMock.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/public/users/UsersRepoMock.scala @@ -65,7 +65,7 @@ class UsersRepoMock(toRow: Function1[UsersRowUnsaved, UsersRow], override def selectByIds(userIds: Array[UsersId])(implicit c: Connection): List[UsersRow] = { userIds.flatMap(map.get).toList } - override def selectByUnique(email: TypoUnknownCitext)(implicit c: Connection): Option[UsersRow] = { + override def selectByUniqueEmail(email: TypoUnknownCitext)(implicit c: Connection): Option[UsersRow] = { map.values.find(v => email == v.email) } override def update(row: UsersRow)(implicit c: Connection): Boolean = { diff --git a/typo-tester-doobie/generated-and-checked-in/adventureworks/production/document/DocumentRepo.scala b/typo-tester-doobie/generated-and-checked-in/adventureworks/production/document/DocumentRepo.scala index 197564a28c..473e975188 100644 --- a/typo-tester-doobie/generated-and-checked-in/adventureworks/production/document/DocumentRepo.scala +++ b/typo-tester-doobie/generated-and-checked-in/adventureworks/production/document/DocumentRepo.scala @@ -26,7 +26,7 @@ trait DocumentRepo { def selectAll: Stream[ConnectionIO, DocumentRow] def selectById(documentnode: DocumentId): ConnectionIO[Option[DocumentRow]] def selectByIds(documentnodes: Array[DocumentId]): Stream[ConnectionIO, DocumentRow] - def selectByUnique(rowguid: TypoUUID): ConnectionIO[Option[DocumentRow]] + def selectByUniqueRowguid(rowguid: TypoUUID): ConnectionIO[Option[DocumentRow]] def update(row: DocumentRow): ConnectionIO[Boolean] def update: UpdateBuilder[DocumentFields, DocumentRow] def upsert(unsaved: DocumentRow): ConnectionIO[DocumentRow] diff --git a/typo-tester-doobie/generated-and-checked-in/adventureworks/production/document/DocumentRepoImpl.scala b/typo-tester-doobie/generated-and-checked-in/adventureworks/production/document/DocumentRepoImpl.scala index 809a013365..6672b7e178 100644 --- a/typo-tester-doobie/generated-and-checked-in/adventureworks/production/document/DocumentRepoImpl.scala +++ b/typo-tester-doobie/generated-and-checked-in/adventureworks/production/document/DocumentRepoImpl.scala @@ -105,7 +105,7 @@ class DocumentRepoImpl extends DocumentRepo { override def selectByIds(documentnodes: Array[DocumentId]): Stream[ConnectionIO, DocumentRow] = { sql"""select "title", "owner", "folderflag", "filename", "fileextension", "revision", "changenumber", "status", "documentsummary", "document", "rowguid", "modifieddate"::text, "documentnode" from production.document where "documentnode" = ANY(${documentnodes})""".query(using DocumentRow.read).stream } - override def selectByUnique(rowguid: TypoUUID): ConnectionIO[Option[DocumentRow]] = { + override def selectByUniqueRowguid(rowguid: TypoUUID): ConnectionIO[Option[DocumentRow]] = { sql"""select "title", "owner", "folderflag", "filename", "fileextension", "revision", "changenumber", "status", "documentsummary", "document", "rowguid", "modifieddate"::text, "documentnode" from production.document where "rowguid" = ${fromWrite(rowguid)(Write.fromPut(TypoUUID.put))} diff --git a/typo-tester-doobie/generated-and-checked-in/adventureworks/production/document/DocumentRepoMock.scala b/typo-tester-doobie/generated-and-checked-in/adventureworks/production/document/DocumentRepoMock.scala index 3dd1271cb1..b6bd6a8c46 100644 --- a/typo-tester-doobie/generated-and-checked-in/adventureworks/production/document/DocumentRepoMock.scala +++ b/typo-tester-doobie/generated-and-checked-in/adventureworks/production/document/DocumentRepoMock.scala @@ -77,7 +77,7 @@ class DocumentRepoMock(toRow: Function1[DocumentRowUnsaved, DocumentRow], override def selectByIds(documentnodes: Array[DocumentId]): Stream[ConnectionIO, DocumentRow] = { Stream.emits(documentnodes.flatMap(map.get).toList) } - override def selectByUnique(rowguid: TypoUUID): ConnectionIO[Option[DocumentRow]] = { + override def selectByUniqueRowguid(rowguid: TypoUUID): ConnectionIO[Option[DocumentRow]] = { delay(map.values.find(v => rowguid == v.rowguid)) } override def update(row: DocumentRow): ConnectionIO[Boolean] = { diff --git a/typo-tester-doobie/generated-and-checked-in/adventureworks/public/users/UsersRepo.scala b/typo-tester-doobie/generated-and-checked-in/adventureworks/public/users/UsersRepo.scala index fc13a5f5b8..f2c445f485 100644 --- a/typo-tester-doobie/generated-and-checked-in/adventureworks/public/users/UsersRepo.scala +++ b/typo-tester-doobie/generated-and-checked-in/adventureworks/public/users/UsersRepo.scala @@ -26,7 +26,7 @@ trait UsersRepo { def selectAll: Stream[ConnectionIO, UsersRow] def selectById(userId: UsersId): ConnectionIO[Option[UsersRow]] def selectByIds(userIds: Array[UsersId]): Stream[ConnectionIO, UsersRow] - def selectByUnique(email: TypoUnknownCitext): ConnectionIO[Option[UsersRow]] + def selectByUniqueEmail(email: TypoUnknownCitext): ConnectionIO[Option[UsersRow]] def update(row: UsersRow): ConnectionIO[Boolean] def update: UpdateBuilder[UsersFields, UsersRow] def upsert(unsaved: UsersRow): ConnectionIO[UsersRow] diff --git a/typo-tester-doobie/generated-and-checked-in/adventureworks/public/users/UsersRepoImpl.scala b/typo-tester-doobie/generated-and-checked-in/adventureworks/public/users/UsersRepoImpl.scala index 351a6fbec9..510e7b752c 100644 --- a/typo-tester-doobie/generated-and-checked-in/adventureworks/public/users/UsersRepoImpl.scala +++ b/typo-tester-doobie/generated-and-checked-in/adventureworks/public/users/UsersRepoImpl.scala @@ -83,7 +83,7 @@ class UsersRepoImpl extends UsersRepo { override def selectByIds(userIds: Array[UsersId]): Stream[ConnectionIO, UsersRow] = { sql"""select "user_id", "name", "last_name", "email"::text, "password", "created_at"::text, "verified_on"::text from public.users where "user_id" = ANY(${userIds})""".query(using UsersRow.read).stream } - override def selectByUnique(email: TypoUnknownCitext): ConnectionIO[Option[UsersRow]] = { + override def selectByUniqueEmail(email: TypoUnknownCitext): ConnectionIO[Option[UsersRow]] = { sql"""select "user_id", "name", "last_name", "email"::text, "password", "created_at"::text, "verified_on"::text from public.users where "email" = ${fromWrite(email)(Write.fromPut(TypoUnknownCitext.put))} diff --git a/typo-tester-doobie/generated-and-checked-in/adventureworks/public/users/UsersRepoMock.scala b/typo-tester-doobie/generated-and-checked-in/adventureworks/public/users/UsersRepoMock.scala index a14c2c9741..b251049b70 100644 --- a/typo-tester-doobie/generated-and-checked-in/adventureworks/public/users/UsersRepoMock.scala +++ b/typo-tester-doobie/generated-and-checked-in/adventureworks/public/users/UsersRepoMock.scala @@ -77,7 +77,7 @@ class UsersRepoMock(toRow: Function1[UsersRowUnsaved, UsersRow], override def selectByIds(userIds: Array[UsersId]): Stream[ConnectionIO, UsersRow] = { Stream.emits(userIds.flatMap(map.get).toList) } - override def selectByUnique(email: TypoUnknownCitext): ConnectionIO[Option[UsersRow]] = { + override def selectByUniqueEmail(email: TypoUnknownCitext): ConnectionIO[Option[UsersRow]] = { delay(map.values.find(v => email == v.email)) } override def update(row: UsersRow): ConnectionIO[Boolean] = { diff --git a/typo-tester-zio-jdbc/generated-and-checked-in/adventureworks/production/document/DocumentRepo.scala b/typo-tester-zio-jdbc/generated-and-checked-in/adventureworks/production/document/DocumentRepo.scala index 8843a66712..0479ddd5e7 100644 --- a/typo-tester-zio-jdbc/generated-and-checked-in/adventureworks/production/document/DocumentRepo.scala +++ b/typo-tester-zio-jdbc/generated-and-checked-in/adventureworks/production/document/DocumentRepo.scala @@ -28,7 +28,7 @@ trait DocumentRepo { def selectAll: ZStream[ZConnection, Throwable, DocumentRow] def selectById(documentnode: DocumentId): ZIO[ZConnection, Throwable, Option[DocumentRow]] def selectByIds(documentnodes: Array[DocumentId]): ZStream[ZConnection, Throwable, DocumentRow] - def selectByUnique(rowguid: TypoUUID): ZIO[ZConnection, Throwable, Option[DocumentRow]] + def selectByUniqueRowguid(rowguid: TypoUUID): ZIO[ZConnection, Throwable, Option[DocumentRow]] def update(row: DocumentRow): ZIO[ZConnection, Throwable, Boolean] def update: UpdateBuilder[DocumentFields, DocumentRow] def upsert(unsaved: DocumentRow): ZIO[ZConnection, Throwable, UpdateResult[DocumentRow]] diff --git a/typo-tester-zio-jdbc/generated-and-checked-in/adventureworks/production/document/DocumentRepoImpl.scala b/typo-tester-zio-jdbc/generated-and-checked-in/adventureworks/production/document/DocumentRepoImpl.scala index e9635b6cc3..108a4ea03b 100644 --- a/typo-tester-zio-jdbc/generated-and-checked-in/adventureworks/production/document/DocumentRepoImpl.scala +++ b/typo-tester-zio-jdbc/generated-and-checked-in/adventureworks/production/document/DocumentRepoImpl.scala @@ -104,7 +104,7 @@ class DocumentRepoImpl extends DocumentRepo { override def selectByIds(documentnodes: Array[DocumentId]): ZStream[ZConnection, Throwable, DocumentRow] = { sql"""select "title", "owner", "folderflag", "filename", "fileextension", "revision", "changenumber", "status", "documentsummary", "document", "rowguid", "modifieddate"::text, "documentnode" from production.document where "documentnode" = ANY(${Segment.paramSegment(documentnodes)(DocumentId.arraySetter)})""".query(using DocumentRow.jdbcDecoder).selectStream() } - override def selectByUnique(rowguid: TypoUUID): ZIO[ZConnection, Throwable, Option[DocumentRow]] = { + override def selectByUniqueRowguid(rowguid: TypoUUID): ZIO[ZConnection, Throwable, Option[DocumentRow]] = { sql"""select "title", "owner", "folderflag", "filename", "fileextension", "revision", "changenumber", "status", "documentsummary", "document", "rowguid", "modifieddate"::text, "documentnode" from production.document where "rowguid" = ${Segment.paramSegment(rowguid)(TypoUUID.setter)} diff --git a/typo-tester-zio-jdbc/generated-and-checked-in/adventureworks/production/document/DocumentRepoMock.scala b/typo-tester-zio-jdbc/generated-and-checked-in/adventureworks/production/document/DocumentRepoMock.scala index 8dfe847fe2..1ebc422c4a 100644 --- a/typo-tester-zio-jdbc/generated-and-checked-in/adventureworks/production/document/DocumentRepoMock.scala +++ b/typo-tester-zio-jdbc/generated-and-checked-in/adventureworks/production/document/DocumentRepoMock.scala @@ -76,7 +76,7 @@ class DocumentRepoMock(toRow: Function1[DocumentRowUnsaved, DocumentRow], override def selectByIds(documentnodes: Array[DocumentId]): ZStream[ZConnection, Throwable, DocumentRow] = { ZStream.fromIterable(documentnodes.flatMap(map.get)) } - override def selectByUnique(rowguid: TypoUUID): ZIO[ZConnection, Throwable, Option[DocumentRow]] = { + override def selectByUniqueRowguid(rowguid: TypoUUID): ZIO[ZConnection, Throwable, Option[DocumentRow]] = { ZIO.succeed(map.values.find(v => rowguid == v.rowguid)) } override def update(row: DocumentRow): ZIO[ZConnection, Throwable, Boolean] = { diff --git a/typo-tester-zio-jdbc/generated-and-checked-in/adventureworks/public/users/UsersRepo.scala b/typo-tester-zio-jdbc/generated-and-checked-in/adventureworks/public/users/UsersRepo.scala index e74b198395..e518125fa5 100644 --- a/typo-tester-zio-jdbc/generated-and-checked-in/adventureworks/public/users/UsersRepo.scala +++ b/typo-tester-zio-jdbc/generated-and-checked-in/adventureworks/public/users/UsersRepo.scala @@ -28,7 +28,7 @@ trait UsersRepo { def selectAll: ZStream[ZConnection, Throwable, UsersRow] def selectById(userId: UsersId): ZIO[ZConnection, Throwable, Option[UsersRow]] def selectByIds(userIds: Array[UsersId]): ZStream[ZConnection, Throwable, UsersRow] - def selectByUnique(email: TypoUnknownCitext): ZIO[ZConnection, Throwable, Option[UsersRow]] + def selectByUniqueEmail(email: TypoUnknownCitext): ZIO[ZConnection, Throwable, Option[UsersRow]] def update(row: UsersRow): ZIO[ZConnection, Throwable, Boolean] def update: UpdateBuilder[UsersFields, UsersRow] def upsert(unsaved: UsersRow): ZIO[ZConnection, Throwable, UpdateResult[UsersRow]] diff --git a/typo-tester-zio-jdbc/generated-and-checked-in/adventureworks/public/users/UsersRepoImpl.scala b/typo-tester-zio-jdbc/generated-and-checked-in/adventureworks/public/users/UsersRepoImpl.scala index 5fe606780d..b90038ca0b 100644 --- a/typo-tester-zio-jdbc/generated-and-checked-in/adventureworks/public/users/UsersRepoImpl.scala +++ b/typo-tester-zio-jdbc/generated-and-checked-in/adventureworks/public/users/UsersRepoImpl.scala @@ -82,7 +82,7 @@ class UsersRepoImpl extends UsersRepo { override def selectByIds(userIds: Array[UsersId]): ZStream[ZConnection, Throwable, UsersRow] = { sql"""select "user_id", "name", "last_name", "email"::text, "password", "created_at"::text, "verified_on"::text from public.users where "user_id" = ANY(${Segment.paramSegment(userIds)(UsersId.arraySetter)})""".query(using UsersRow.jdbcDecoder).selectStream() } - override def selectByUnique(email: TypoUnknownCitext): ZIO[ZConnection, Throwable, Option[UsersRow]] = { + override def selectByUniqueEmail(email: TypoUnknownCitext): ZIO[ZConnection, Throwable, Option[UsersRow]] = { sql"""select "user_id", "name", "last_name", "email"::text, "password", "created_at"::text, "verified_on"::text from public.users where "email" = ${Segment.paramSegment(email)(TypoUnknownCitext.setter)} diff --git a/typo-tester-zio-jdbc/generated-and-checked-in/adventureworks/public/users/UsersRepoMock.scala b/typo-tester-zio-jdbc/generated-and-checked-in/adventureworks/public/users/UsersRepoMock.scala index 222fb29020..e4d28b6762 100644 --- a/typo-tester-zio-jdbc/generated-and-checked-in/adventureworks/public/users/UsersRepoMock.scala +++ b/typo-tester-zio-jdbc/generated-and-checked-in/adventureworks/public/users/UsersRepoMock.scala @@ -76,7 +76,7 @@ class UsersRepoMock(toRow: Function1[UsersRowUnsaved, UsersRow], override def selectByIds(userIds: Array[UsersId]): ZStream[ZConnection, Throwable, UsersRow] = { ZStream.fromIterable(userIds.flatMap(map.get)) } - override def selectByUnique(email: TypoUnknownCitext): ZIO[ZConnection, Throwable, Option[UsersRow]] = { + override def selectByUniqueEmail(email: TypoUnknownCitext): ZIO[ZConnection, Throwable, Option[UsersRow]] = { ZIO.succeed(map.values.find(v => email == v.email)) } override def update(row: UsersRow): ZIO[ZConnection, Throwable, Boolean] = { diff --git a/typo/src/scala/typo/internal/ComputedTable.scala b/typo/src/scala/typo/internal/ComputedTable.scala index 3df39365cf..839ae586db 100644 --- a/typo/src/scala/typo/internal/ComputedTable.scala +++ b/typo/src/scala/typo/internal/ComputedTable.scala @@ -1,7 +1,6 @@ package typo package internal -import typo.internal.compat.ListOps import typo.internal.rewriteDependentData.Eval case class ComputedTable( @@ -201,7 +200,6 @@ case class ComputedTable( rowType = names.RowName ) } - .distinctByCompat(x => x.keyColumns.map(_.tpe)) // avoid erasure clashes ) val valid = maybeMethods.flatten.filter { case _: RepoMethod.Mutator => !options.readonlyRepo.include(dbTable.name) diff --git a/typo/src/scala/typo/internal/codegen/DbLibAnorm.scala b/typo/src/scala/typo/internal/codegen/DbLibAnorm.scala index 2fc89128d4..21f9e0116d 100644 --- a/typo/src/scala/typo/internal/codegen/DbLibAnorm.scala +++ b/typo/src/scala/typo/internal/codegen/DbLibAnorm.scala @@ -173,7 +173,8 @@ class DbLibAnorm(pkg: sc.QIdent, inlineImplicits: Boolean, default: ComputedDefa code"def selectByIds($idsParam)(implicit c: ${TypesJava.Connection}): ${TypesScala.List.of(rowType)}" } case RepoMethod.SelectByUnique(_, keyColumns, _, rowType) => - code"def selectByUnique(${keyColumns.map(_.param.code).mkCode(", ")})(implicit c: ${TypesJava.Connection}): ${TypesScala.Option.of(rowType)}" + val name = s"selectByUnique${keyColumns.map(x => Naming.titleCase(x.name.value)).mkString("And")}" + code"def $name(${keyColumns.map(_.param.code).mkCode(", ")})(implicit c: ${TypesJava.Connection}): ${TypesScala.Option.of(rowType)}" case RepoMethod.SelectByFieldValues(_, _, _, fieldValueOrIdsParam, rowType) => code"def selectByFieldValues($fieldValueOrIdsParam)(implicit c: ${TypesJava.Connection}): ${TypesScala.List.of(rowType)}" case RepoMethod.UpdateBuilder(_, fieldsType, rowType) => diff --git a/typo/src/scala/typo/internal/codegen/DbLibDoobie.scala b/typo/src/scala/typo/internal/codegen/DbLibDoobie.scala index 3febe759fe..d602ab4ce2 100644 --- a/typo/src/scala/typo/internal/codegen/DbLibDoobie.scala +++ b/typo/src/scala/typo/internal/codegen/DbLibDoobie.scala @@ -75,7 +75,8 @@ class DbLibDoobie(pkg: sc.QIdent, inlineImplicits: Boolean, default: ComputedDef code"def selectByIds($idsParam): ${fs2Stream.of(ConnectionIO, rowType)}" } case RepoMethod.SelectByUnique(_, keyColumns, _, rowType) => - code"def selectByUnique(${keyColumns.map(_.param.code).mkCode(", ")}): ${ConnectionIO.of(TypesScala.Option.of(rowType))}" + val name = s"selectByUnique${keyColumns.map(x => Naming.titleCase(x.name.value)).mkString("And")}" + code"def $name(${keyColumns.map(_.param.code).mkCode(", ")}): ${ConnectionIO.of(TypesScala.Option.of(rowType))}" case RepoMethod.SelectByFieldValues(_, _, _, fieldValueOrIdsParam, rowType) => code"def selectByFieldValues($fieldValueOrIdsParam): ${fs2Stream.of(ConnectionIO, rowType)}" case RepoMethod.UpdateBuilder(_, fieldsType, rowType) => diff --git a/typo/src/scala/typo/internal/codegen/DbLibZioJdbc.scala b/typo/src/scala/typo/internal/codegen/DbLibZioJdbc.scala index 67fcfeb878..e8b2f6c886 100644 --- a/typo/src/scala/typo/internal/codegen/DbLibZioJdbc.scala +++ b/typo/src/scala/typo/internal/codegen/DbLibZioJdbc.scala @@ -194,7 +194,8 @@ class DbLibZioJdbc(pkg: sc.QIdent, inlineImplicits: Boolean, dslEnabled: Boolean code"def selectByIds($idsParam): ${ZStream.of(ZConnection, Throwable, rowType)}" } case RepoMethod.SelectByUnique(_, keyColumns, _, rowType) => - code"def selectByUnique(${keyColumns.map(_.param.code).mkCode(", ")}): ${ZIO.of(ZConnection, Throwable, TypesScala.Option.of(rowType))}" + val name = s"selectByUnique${keyColumns.map(x => Naming.titleCase(x.name.value)).mkString("And")}" + code"def $name(${keyColumns.map(_.param.code).mkCode(", ")}): ${ZIO.of(ZConnection, Throwable, TypesScala.Option.of(rowType))}" case RepoMethod.SelectByFieldValues(_, _, _, fieldValueOrIdsParam, rowType) => code"def selectByFieldValues($fieldValueOrIdsParam): ${ZStream.of(ZConnection, Throwable, rowType)}" case RepoMethod.UpdateBuilder(_, fieldsType, rowType) =>