From fddba55fbb3f15df5d12aa17af41290198fa693d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=98yvind=20Raddum=20Berg?= Date: Fri, 30 Aug 2024 14:53:12 +0200 Subject: [PATCH] anorm: update returns maybe row --- .../compositepk/person/PersonRepo.scala | 2 +- .../compositepk/person/PersonRepoImpl.scala | 5 ++-- .../compositepk/person/PersonRepoMock.scala | 11 +++----- .../football_club/FootballClubRepo.scala | 2 +- .../football_club/FootballClubRepoImpl.scala | 5 ++-- .../football_club/FootballClubRepoMock.scala | 11 +++----- .../myschema/person/PersonRepo.scala | 2 +- .../myschema/person/PersonRepoImpl.scala | 5 ++-- .../myschema/person/PersonRepoMock.scala | 11 +++----- .../compositepk/person/PersonRepo.scala | 2 +- .../compositepk/person/PersonRepoImpl.scala | 5 ++-- .../compositepk/person/PersonRepoMock.scala | 11 +++----- .../football_club/FootballClubRepo.scala | 2 +- .../football_club/FootballClubRepoImpl.scala | 5 ++-- .../football_club/FootballClubRepoMock.scala | 11 +++----- .../myschema/person/PersonRepo.scala | 2 +- .../myschema/person/PersonRepoImpl.scala | 5 ++-- .../myschema/person/PersonRepoMock.scala | 11 +++----- .../department/DepartmentRepo.scala | 2 +- .../department/DepartmentRepoImpl.scala | 5 ++-- .../department/DepartmentRepoMock.scala | 11 +++----- .../employee/EmployeeRepo.scala | 2 +- .../employee/EmployeeRepoImpl.scala | 5 ++-- .../employee/EmployeeRepoMock.scala | 11 +++----- .../EmployeedepartmenthistoryRepo.scala | 2 +- .../EmployeedepartmenthistoryRepoImpl.scala | 7 ++--- .../EmployeedepartmenthistoryRepoMock.scala | 11 +++----- .../EmployeepayhistoryRepo.scala | 2 +- .../EmployeepayhistoryRepoImpl.scala | 7 ++--- .../EmployeepayhistoryRepoMock.scala | 11 +++----- .../jobcandidate/JobcandidateRepo.scala | 2 +- .../jobcandidate/JobcandidateRepoImpl.scala | 5 ++-- .../jobcandidate/JobcandidateRepoMock.scala | 11 +++----- .../humanresources/shift/ShiftRepo.scala | 2 +- .../humanresources/shift/ShiftRepoImpl.scala | 5 ++-- .../humanresources/shift/ShiftRepoMock.scala | 11 +++----- .../person/address/AddressRepo.scala | 2 +- .../person/address/AddressRepoImpl.scala | 5 ++-- .../person/address/AddressRepoMock.scala | 11 +++----- .../person/addresstype/AddresstypeRepo.scala | 2 +- .../addresstype/AddresstypeRepoImpl.scala | 5 ++-- .../addresstype/AddresstypeRepoMock.scala | 11 +++----- .../businessentity/BusinessentityRepo.scala | 2 +- .../BusinessentityRepoImpl.scala | 5 ++-- .../BusinessentityRepoMock.scala | 11 +++----- .../BusinessentityaddressRepo.scala | 2 +- .../BusinessentityaddressRepoImpl.scala | 7 ++--- .../BusinessentityaddressRepoMock.scala | 11 +++----- .../BusinessentitycontactRepo.scala | 2 +- .../BusinessentitycontactRepoImpl.scala | 7 ++--- .../BusinessentitycontactRepoMock.scala | 11 +++----- .../person/contacttype/ContacttypeRepo.scala | 2 +- .../contacttype/ContacttypeRepoImpl.scala | 5 ++-- .../contacttype/ContacttypeRepoMock.scala | 11 +++----- .../countryregion/CountryregionRepo.scala | 2 +- .../countryregion/CountryregionRepoImpl.scala | 5 ++-- .../countryregion/CountryregionRepoMock.scala | 11 +++----- .../emailaddress/EmailaddressRepo.scala | 2 +- .../emailaddress/EmailaddressRepoImpl.scala | 7 ++--- .../emailaddress/EmailaddressRepoMock.scala | 11 +++----- .../person/password/PasswordRepo.scala | 2 +- .../person/password/PasswordRepoImpl.scala | 5 ++-- .../person/password/PasswordRepoMock.scala | 11 +++----- .../person/person/PersonRepo.scala | 2 +- .../person/person/PersonRepoImpl.scala | 5 ++-- .../person/person/PersonRepoMock.scala | 11 +++----- .../person/personphone/PersonphoneRepo.scala | 2 +- .../personphone/PersonphoneRepoImpl.scala | 7 ++--- .../personphone/PersonphoneRepoMock.scala | 11 +++----- .../phonenumbertype/PhonenumbertypeRepo.scala | 2 +- .../PhonenumbertypeRepoImpl.scala | 5 ++-- .../PhonenumbertypeRepoMock.scala | 11 +++----- .../stateprovince/StateprovinceRepo.scala | 2 +- .../stateprovince/StateprovinceRepoImpl.scala | 5 ++-- .../stateprovince/StateprovinceRepoMock.scala | 11 +++----- .../billofmaterials/BillofmaterialsRepo.scala | 2 +- .../BillofmaterialsRepoImpl.scala | 5 ++-- .../BillofmaterialsRepoMock.scala | 11 +++----- .../production/culture/CultureRepo.scala | 2 +- .../production/culture/CultureRepoImpl.scala | 5 ++-- .../production/culture/CultureRepoMock.scala | 11 +++----- .../production/document/DocumentRepo.scala | 2 +- .../document/DocumentRepoImpl.scala | 5 ++-- .../document/DocumentRepoMock.scala | 11 +++----- .../illustration/IllustrationRepo.scala | 2 +- .../illustration/IllustrationRepoImpl.scala | 5 ++-- .../illustration/IllustrationRepoMock.scala | 11 +++----- .../production/location/LocationRepo.scala | 2 +- .../location/LocationRepoImpl.scala | 5 ++-- .../location/LocationRepoMock.scala | 11 +++----- .../production/product/ProductRepo.scala | 2 +- .../production/product/ProductRepoImpl.scala | 5 ++-- .../production/product/ProductRepoMock.scala | 11 +++----- .../productcategory/ProductcategoryRepo.scala | 2 +- .../ProductcategoryRepoImpl.scala | 5 ++-- .../ProductcategoryRepoMock.scala | 11 +++----- .../ProductcosthistoryRepo.scala | 2 +- .../ProductcosthistoryRepoImpl.scala | 7 ++--- .../ProductcosthistoryRepoMock.scala | 11 +++----- .../ProductdescriptionRepo.scala | 2 +- .../ProductdescriptionRepoImpl.scala | 5 ++-- .../ProductdescriptionRepoMock.scala | 11 +++----- .../productdocument/ProductdocumentRepo.scala | 2 +- .../ProductdocumentRepoImpl.scala | 7 ++--- .../ProductdocumentRepoMock.scala | 11 +++----- .../ProductinventoryRepo.scala | 2 +- .../ProductinventoryRepoImpl.scala | 7 ++--- .../ProductinventoryRepoMock.scala | 11 +++----- .../ProductlistpricehistoryRepo.scala | 2 +- .../ProductlistpricehistoryRepoImpl.scala | 7 ++--- .../ProductlistpricehistoryRepoMock.scala | 11 +++----- .../productmodel/ProductmodelRepo.scala | 2 +- .../productmodel/ProductmodelRepoImpl.scala | 5 ++-- .../productmodel/ProductmodelRepoMock.scala | 11 +++----- .../ProductmodelillustrationRepo.scala | 2 +- .../ProductmodelillustrationRepoImpl.scala | 7 ++--- .../ProductmodelillustrationRepoMock.scala | 11 +++----- ...ctmodelproductdescriptioncultureRepo.scala | 2 +- ...delproductdescriptioncultureRepoImpl.scala | 7 ++--- ...delproductdescriptioncultureRepoMock.scala | 11 +++----- .../productphoto/ProductphotoRepo.scala | 2 +- .../productphoto/ProductphotoRepoImpl.scala | 5 ++-- .../productphoto/ProductphotoRepoMock.scala | 11 +++----- .../ProductproductphotoRepo.scala | 2 +- .../ProductproductphotoRepoImpl.scala | 7 ++--- .../ProductproductphotoRepoMock.scala | 11 +++----- .../productreview/ProductreviewRepo.scala | 2 +- .../productreview/ProductreviewRepoImpl.scala | 5 ++-- .../productreview/ProductreviewRepoMock.scala | 11 +++----- .../ProductsubcategoryRepo.scala | 2 +- .../ProductsubcategoryRepoImpl.scala | 5 ++-- .../ProductsubcategoryRepoMock.scala | 11 +++----- .../scrapreason/ScrapreasonRepo.scala | 2 +- .../scrapreason/ScrapreasonRepoImpl.scala | 5 ++-- .../scrapreason/ScrapreasonRepoMock.scala | 11 +++----- .../TransactionhistoryRepo.scala | 2 +- .../TransactionhistoryRepoImpl.scala | 5 ++-- .../TransactionhistoryRepoMock.scala | 11 +++----- .../TransactionhistoryarchiveRepo.scala | 2 +- .../TransactionhistoryarchiveRepoImpl.scala | 5 ++-- .../TransactionhistoryarchiveRepoMock.scala | 11 +++----- .../unitmeasure/UnitmeasureRepo.scala | 2 +- .../unitmeasure/UnitmeasureRepoImpl.scala | 5 ++-- .../unitmeasure/UnitmeasureRepoMock.scala | 11 +++----- .../production/workorder/WorkorderRepo.scala | 2 +- .../workorder/WorkorderRepoImpl.scala | 5 ++-- .../workorder/WorkorderRepoMock.scala | 11 +++----- .../WorkorderroutingRepo.scala | 2 +- .../WorkorderroutingRepoImpl.scala | 7 ++--- .../WorkorderroutingRepoMock.scala | 11 +++----- .../public/flaff/FlaffRepo.scala | 2 +- .../public/flaff/FlaffRepoImpl.scala | 7 ++--- .../public/flaff/FlaffRepoMock.scala | 11 +++----- .../identity_test/IdentityTestRepo.scala | 2 +- .../identity_test/IdentityTestRepoImpl.scala | 5 ++-- .../identity_test/IdentityTestRepoMock.scala | 11 +++----- .../public/users/UsersRepo.scala | 2 +- .../public/users/UsersRepoImpl.scala | 5 ++-- .../public/users/UsersRepoMock.scala | 11 +++----- .../productvendor/ProductvendorRepo.scala | 2 +- .../productvendor/ProductvendorRepoImpl.scala | 7 ++--- .../productvendor/ProductvendorRepoMock.scala | 11 +++----- .../PurchaseorderdetailRepoImpl.scala | 2 +- .../PurchaseorderheaderRepo.scala | 2 +- .../PurchaseorderheaderRepoImpl.scala | 5 ++-- .../PurchaseorderheaderRepoMock.scala | 11 +++----- .../shipmethod/ShipmethodRepo.scala | 2 +- .../shipmethod/ShipmethodRepoImpl.scala | 5 ++-- .../shipmethod/ShipmethodRepoMock.scala | 11 +++----- .../purchasing/vendor/VendorRepo.scala | 2 +- .../purchasing/vendor/VendorRepoImpl.scala | 5 ++-- .../purchasing/vendor/VendorRepoMock.scala | 11 +++----- .../CountryregioncurrencyRepo.scala | 2 +- .../CountryregioncurrencyRepoImpl.scala | 7 ++--- .../CountryregioncurrencyRepoMock.scala | 11 +++----- .../sales/creditcard/CreditcardRepo.scala | 2 +- .../sales/creditcard/CreditcardRepoImpl.scala | 5 ++-- .../sales/creditcard/CreditcardRepoMock.scala | 11 +++----- .../sales/currency/CurrencyRepo.scala | 2 +- .../sales/currency/CurrencyRepoImpl.scala | 5 ++-- .../sales/currency/CurrencyRepoMock.scala | 11 +++----- .../sales/currencyrate/CurrencyrateRepo.scala | 2 +- .../currencyrate/CurrencyrateRepoImpl.scala | 5 ++-- .../currencyrate/CurrencyrateRepoMock.scala | 11 +++----- .../sales/customer/CustomerRepo.scala | 2 +- .../sales/customer/CustomerRepoImpl.scala | 5 ++-- .../sales/customer/CustomerRepoMock.scala | 11 +++----- .../PersoncreditcardRepo.scala | 2 +- .../PersoncreditcardRepoImpl.scala | 7 ++--- .../PersoncreditcardRepoMock.scala | 11 +++----- .../SalesorderdetailRepo.scala | 2 +- .../SalesorderdetailRepoImpl.scala | 7 ++--- .../SalesorderdetailRepoMock.scala | 11 +++----- .../SalesorderheaderRepo.scala | 2 +- .../SalesorderheaderRepoImpl.scala | 5 ++-- .../SalesorderheaderRepoMock.scala | 11 +++----- .../SalesorderheadersalesreasonRepo.scala | 2 +- .../SalesorderheadersalesreasonRepoImpl.scala | 7 ++--- .../SalesorderheadersalesreasonRepoMock.scala | 11 +++----- .../sales/salesperson/SalespersonRepo.scala | 2 +- .../salesperson/SalespersonRepoImpl.scala | 5 ++-- .../salesperson/SalespersonRepoMock.scala | 11 +++----- .../SalespersonquotahistoryRepo.scala | 2 +- .../SalespersonquotahistoryRepoImpl.scala | 7 ++--- .../SalespersonquotahistoryRepoMock.scala | 11 +++----- .../sales/salesreason/SalesreasonRepo.scala | 2 +- .../salesreason/SalesreasonRepoImpl.scala | 5 ++-- .../salesreason/SalesreasonRepoMock.scala | 11 +++----- .../sales/salestaxrate/SalestaxrateRepo.scala | 2 +- .../salestaxrate/SalestaxrateRepoImpl.scala | 5 ++-- .../salestaxrate/SalestaxrateRepoMock.scala | 11 +++----- .../salesterritory/SalesterritoryRepo.scala | 2 +- .../SalesterritoryRepoImpl.scala | 5 ++-- .../SalesterritoryRepoMock.scala | 11 +++----- .../SalesterritoryhistoryRepo.scala | 2 +- .../SalesterritoryhistoryRepoImpl.scala | 7 ++--- .../SalesterritoryhistoryRepoMock.scala | 11 +++----- .../ShoppingcartitemRepo.scala | 2 +- .../ShoppingcartitemRepoImpl.scala | 5 ++-- .../ShoppingcartitemRepoMock.scala | 11 +++----- .../sales/specialoffer/SpecialofferRepo.scala | 2 +- .../specialoffer/SpecialofferRepoImpl.scala | 5 ++-- .../specialoffer/SpecialofferRepoMock.scala | 11 +++----- .../SpecialofferproductRepo.scala | 2 +- .../SpecialofferproductRepoImpl.scala | 7 ++--- .../SpecialofferproductRepoMock.scala | 11 +++----- .../sales/store/StoreRepo.scala | 2 +- .../sales/store/StoreRepoImpl.scala | 5 ++-- .../sales/store/StoreRepoMock.scala | 11 +++----- .../production/product/ProductTest.scala | 2 +- .../typo/internal/codegen/DbLibAnorm.scala | 26 +++++++++---------- 231 files changed, 645 insertions(+), 799 deletions(-) diff --git a/.bleep/generated-sources/typo-tester-anorm@jvm213/scripts.GenHardcodedFiles/testdb/hardcoded/compositepk/person/PersonRepo.scala b/.bleep/generated-sources/typo-tester-anorm@jvm213/scripts.GenHardcodedFiles/testdb/hardcoded/compositepk/person/PersonRepo.scala index 87d9280d4..9cd76c122 100644 --- a/.bleep/generated-sources/typo-tester-anorm@jvm213/scripts.GenHardcodedFiles/testdb/hardcoded/compositepk/person/PersonRepo.scala +++ b/.bleep/generated-sources/typo-tester-anorm@jvm213/scripts.GenHardcodedFiles/testdb/hardcoded/compositepk/person/PersonRepo.scala @@ -26,7 +26,7 @@ trait PersonRepo { def selectByFieldValues(fieldValues: List[PersonFieldOrIdValue[?]])(implicit c: Connection): List[PersonRow] def selectById(compositeId: PersonId)(implicit c: Connection): Option[PersonRow] def update: UpdateBuilder[PersonFields, PersonRow] - def update(row: PersonRow)(implicit c: Connection): Boolean + def update(row: PersonRow)(implicit c: Connection): Option[PersonRow] def updateFieldValues(compositeId: PersonId, fieldValues: List[PersonFieldValue[?]])(implicit c: Connection): Boolean def upsert(unsaved: PersonRow)(implicit c: Connection): PersonRow def upsertBatch(unsaved: Iterable[PersonRow])(implicit c: Connection): List[PersonRow] diff --git a/.bleep/generated-sources/typo-tester-anorm@jvm213/scripts.GenHardcodedFiles/testdb/hardcoded/compositepk/person/PersonRepoImpl.scala b/.bleep/generated-sources/typo-tester-anorm@jvm213/scripts.GenHardcodedFiles/testdb/hardcoded/compositepk/person/PersonRepoImpl.scala index 20cfa992b..33e22be08 100644 --- a/.bleep/generated-sources/typo-tester-anorm@jvm213/scripts.GenHardcodedFiles/testdb/hardcoded/compositepk/person/PersonRepoImpl.scala +++ b/.bleep/generated-sources/typo-tester-anorm@jvm213/scripts.GenHardcodedFiles/testdb/hardcoded/compositepk/person/PersonRepoImpl.scala @@ -111,12 +111,13 @@ class PersonRepoImpl extends PersonRepo { override def update: UpdateBuilder[PersonFields, PersonRow] = { UpdateBuilder(""""compositepk"."person"""", PersonFields.structure, PersonRow.rowParser) } - override def update(row: PersonRow)(implicit c: Connection): Boolean = { + override def update(row: PersonRow)(implicit c: Connection): Option[PersonRow] = { val compositeId = row.compositeId SQL"""update "compositepk"."person" set "name" = ${ParameterValue(row.name, null, ToStatement.optionToStatement(ToStatement.stringToStatement, ParameterMetaData.StringParameterMetaData))} where "one" = ${ParameterValue(compositeId.one, null, ToStatement.longToStatement)} AND "two" = ${ParameterValue(compositeId.two, null, ToStatement.optionToStatement(ToStatement.stringToStatement, ParameterMetaData.StringParameterMetaData))} - """.executeUpdate() > 0 + returning "one", "two", "name" + """.executeInsert(PersonRow.rowParser(1).singleOpt) } override def updateFieldValues(compositeId: PersonId, fieldValues: List[PersonFieldValue[?]])(implicit c: Connection): Boolean = { fieldValues match { diff --git a/.bleep/generated-sources/typo-tester-anorm@jvm213/scripts.GenHardcodedFiles/testdb/hardcoded/compositepk/person/PersonRepoMock.scala b/.bleep/generated-sources/typo-tester-anorm@jvm213/scripts.GenHardcodedFiles/testdb/hardcoded/compositepk/person/PersonRepoMock.scala index 12d1979be..5d538f821 100644 --- a/.bleep/generated-sources/typo-tester-anorm@jvm213/scripts.GenHardcodedFiles/testdb/hardcoded/compositepk/person/PersonRepoMock.scala +++ b/.bleep/generated-sources/typo-tester-anorm@jvm213/scripts.GenHardcodedFiles/testdb/hardcoded/compositepk/person/PersonRepoMock.scala @@ -72,13 +72,10 @@ class PersonRepoMock(toRow: Function1[PersonRowUnsaved, PersonRow], override def update: UpdateBuilder[PersonFields, PersonRow] = { UpdateBuilderMock(UpdateParams.empty, PersonFields.structure, map) } - override def update(row: PersonRow)(implicit c: Connection): Boolean = { - map.get(row.compositeId) match { - case Some(`row`) => false - case Some(_) => - map.put(row.compositeId, row): @nowarn - true - case None => false + override def update(row: PersonRow)(implicit c: Connection): Option[PersonRow] = { + map.get(row.compositeId).map { _ => + map.put(row.compositeId, row): @nowarn + row } } override def updateFieldValues(compositeId: PersonId, fieldValues: List[PersonFieldValue[?]])(implicit c: Connection): Boolean = { diff --git a/.bleep/generated-sources/typo-tester-anorm@jvm213/scripts.GenHardcodedFiles/testdb/hardcoded/myschema/football_club/FootballClubRepo.scala b/.bleep/generated-sources/typo-tester-anorm@jvm213/scripts.GenHardcodedFiles/testdb/hardcoded/myschema/football_club/FootballClubRepo.scala index 7fba23c57..1b233df1d 100644 --- a/.bleep/generated-sources/typo-tester-anorm@jvm213/scripts.GenHardcodedFiles/testdb/hardcoded/myschema/football_club/FootballClubRepo.scala +++ b/.bleep/generated-sources/typo-tester-anorm@jvm213/scripts.GenHardcodedFiles/testdb/hardcoded/myschema/football_club/FootballClubRepo.scala @@ -26,7 +26,7 @@ trait FootballClubRepo { def selectByIds(ids: Array[FootballClubId])(implicit c: Connection): List[FootballClubRow] def selectByIdsTracked(ids: Array[FootballClubId])(implicit c: Connection): Map[FootballClubId, FootballClubRow] def update: UpdateBuilder[FootballClubFields, FootballClubRow] - def update(row: FootballClubRow)(implicit c: Connection): Boolean + def update(row: FootballClubRow)(implicit c: Connection): Option[FootballClubRow] def updateFieldValues(id: FootballClubId, fieldValues: List[FootballClubFieldValue[?]])(implicit c: Connection): Boolean def upsert(unsaved: FootballClubRow)(implicit c: Connection): FootballClubRow def upsertBatch(unsaved: Iterable[FootballClubRow])(implicit c: Connection): List[FootballClubRow] diff --git a/.bleep/generated-sources/typo-tester-anorm@jvm213/scripts.GenHardcodedFiles/testdb/hardcoded/myschema/football_club/FootballClubRepoImpl.scala b/.bleep/generated-sources/typo-tester-anorm@jvm213/scripts.GenHardcodedFiles/testdb/hardcoded/myschema/football_club/FootballClubRepoImpl.scala index c13fcba7a..f38b589a8 100644 --- a/.bleep/generated-sources/typo-tester-anorm@jvm213/scripts.GenHardcodedFiles/testdb/hardcoded/myschema/football_club/FootballClubRepoImpl.scala +++ b/.bleep/generated-sources/typo-tester-anorm@jvm213/scripts.GenHardcodedFiles/testdb/hardcoded/myschema/football_club/FootballClubRepoImpl.scala @@ -94,12 +94,13 @@ class FootballClubRepoImpl extends FootballClubRepo { override def update: UpdateBuilder[FootballClubFields, FootballClubRow] = { UpdateBuilder(""""myschema"."football_club"""", FootballClubFields.structure, FootballClubRow.rowParser) } - override def update(row: FootballClubRow)(implicit c: Connection): Boolean = { + override def update(row: FootballClubRow)(implicit c: Connection): Option[FootballClubRow] = { val id = row.id SQL"""update "myschema"."football_club" set "name" = ${ParameterValue(row.name, null, ToStatement.stringToStatement)} where "id" = ${ParameterValue(id, null, FootballClubId.toStatement)} - """.executeUpdate() > 0 + returning "id", "name" + """.executeInsert(FootballClubRow.rowParser(1).singleOpt) } override def updateFieldValues(id: FootballClubId, fieldValues: List[FootballClubFieldValue[?]])(implicit c: Connection): Boolean = { fieldValues match { diff --git a/.bleep/generated-sources/typo-tester-anorm@jvm213/scripts.GenHardcodedFiles/testdb/hardcoded/myschema/football_club/FootballClubRepoMock.scala b/.bleep/generated-sources/typo-tester-anorm@jvm213/scripts.GenHardcodedFiles/testdb/hardcoded/myschema/football_club/FootballClubRepoMock.scala index 37d177d06..7c274b6c2 100644 --- a/.bleep/generated-sources/typo-tester-anorm@jvm213/scripts.GenHardcodedFiles/testdb/hardcoded/myschema/football_club/FootballClubRepoMock.scala +++ b/.bleep/generated-sources/typo-tester-anorm@jvm213/scripts.GenHardcodedFiles/testdb/hardcoded/myschema/football_club/FootballClubRepoMock.scala @@ -69,13 +69,10 @@ class FootballClubRepoMock(map: scala.collection.mutable.Map[FootballClubId, Foo override def update: UpdateBuilder[FootballClubFields, FootballClubRow] = { UpdateBuilderMock(UpdateParams.empty, FootballClubFields.structure, map) } - override def update(row: FootballClubRow)(implicit c: Connection): Boolean = { - map.get(row.id) match { - case Some(`row`) => false - case Some(_) => - map.put(row.id, row): @nowarn - true - case None => false + override def update(row: FootballClubRow)(implicit c: Connection): Option[FootballClubRow] = { + map.get(row.id).map { _ => + map.put(row.id, row): @nowarn + row } } override def updateFieldValues(id: FootballClubId, fieldValues: List[FootballClubFieldValue[?]])(implicit c: Connection): Boolean = { diff --git a/.bleep/generated-sources/typo-tester-anorm@jvm213/scripts.GenHardcodedFiles/testdb/hardcoded/myschema/person/PersonRepo.scala b/.bleep/generated-sources/typo-tester-anorm@jvm213/scripts.GenHardcodedFiles/testdb/hardcoded/myschema/person/PersonRepo.scala index b8c43ba30..b21d3428f 100644 --- a/.bleep/generated-sources/typo-tester-anorm@jvm213/scripts.GenHardcodedFiles/testdb/hardcoded/myschema/person/PersonRepo.scala +++ b/.bleep/generated-sources/typo-tester-anorm@jvm213/scripts.GenHardcodedFiles/testdb/hardcoded/myschema/person/PersonRepo.scala @@ -29,7 +29,7 @@ trait PersonRepo { def selectByIds(ids: Array[PersonId])(implicit c: Connection): List[PersonRow] def selectByIdsTracked(ids: Array[PersonId])(implicit c: Connection): Map[PersonId, PersonRow] def update: UpdateBuilder[PersonFields, PersonRow] - def update(row: PersonRow)(implicit c: Connection): Boolean + def update(row: PersonRow)(implicit c: Connection): Option[PersonRow] def updateFieldValues(id: PersonId, fieldValues: List[PersonFieldValue[?]])(implicit c: Connection): Boolean def upsert(unsaved: PersonRow)(implicit c: Connection): PersonRow def upsertBatch(unsaved: Iterable[PersonRow])(implicit c: Connection): List[PersonRow] diff --git a/.bleep/generated-sources/typo-tester-anorm@jvm213/scripts.GenHardcodedFiles/testdb/hardcoded/myschema/person/PersonRepoImpl.scala b/.bleep/generated-sources/typo-tester-anorm@jvm213/scripts.GenHardcodedFiles/testdb/hardcoded/myschema/person/PersonRepoImpl.scala index c9aceff13..bfdb48abd 100644 --- a/.bleep/generated-sources/typo-tester-anorm@jvm213/scripts.GenHardcodedFiles/testdb/hardcoded/myschema/person/PersonRepoImpl.scala +++ b/.bleep/generated-sources/typo-tester-anorm@jvm213/scripts.GenHardcodedFiles/testdb/hardcoded/myschema/person/PersonRepoImpl.scala @@ -151,7 +151,7 @@ class PersonRepoImpl extends PersonRepo { override def update: UpdateBuilder[PersonFields, PersonRow] = { UpdateBuilder(""""myschema"."person"""", PersonFields.structure, PersonRow.rowParser) } - override def update(row: PersonRow)(implicit c: Connection): Boolean = { + override def update(row: PersonRow)(implicit c: Connection): Option[PersonRow] = { val id = row.id SQL"""update "myschema"."person" set "favourite_football_club_id" = ${ParameterValue(row.favouriteFootballClubId, null, FootballClubId.toStatement)}, @@ -165,7 +165,8 @@ class PersonRepoImpl extends PersonRepo { "work_email" = ${ParameterValue(row.workEmail, null, ToStatement.optionToStatement(ToStatement.stringToStatement, ParameterMetaData.StringParameterMetaData))}, "favorite_number" = ${ParameterValue(row.favoriteNumber, null, Number.toStatement)}::myschema.number where "id" = ${ParameterValue(id, null, PersonId.toStatement)} - """.executeUpdate() > 0 + returning "id", "favourite_football_club_id", "name", "nick_name", "blog_url", "email", "phone", "likes_pizza", "marital_status_id", "work_email", "sector", "favorite_number" + """.executeInsert(PersonRow.rowParser(1).singleOpt) } override def updateFieldValues(id: PersonId, fieldValues: List[PersonFieldValue[?]])(implicit c: Connection): Boolean = { fieldValues match { diff --git a/.bleep/generated-sources/typo-tester-anorm@jvm213/scripts.GenHardcodedFiles/testdb/hardcoded/myschema/person/PersonRepoMock.scala b/.bleep/generated-sources/typo-tester-anorm@jvm213/scripts.GenHardcodedFiles/testdb/hardcoded/myschema/person/PersonRepoMock.scala index bb9994c80..e3757b60e 100644 --- a/.bleep/generated-sources/typo-tester-anorm@jvm213/scripts.GenHardcodedFiles/testdb/hardcoded/myschema/person/PersonRepoMock.scala +++ b/.bleep/generated-sources/typo-tester-anorm@jvm213/scripts.GenHardcodedFiles/testdb/hardcoded/myschema/person/PersonRepoMock.scala @@ -91,13 +91,10 @@ class PersonRepoMock(toRow: Function1[PersonRowUnsaved, PersonRow], override def update: UpdateBuilder[PersonFields, PersonRow] = { UpdateBuilderMock(UpdateParams.empty, PersonFields.structure, map) } - override def update(row: PersonRow)(implicit c: Connection): Boolean = { - map.get(row.id) match { - case Some(`row`) => false - case Some(_) => - map.put(row.id, row): @nowarn - true - case None => false + override def update(row: PersonRow)(implicit c: Connection): Option[PersonRow] = { + map.get(row.id).map { _ => + map.put(row.id, row): @nowarn + row } } override def updateFieldValues(id: PersonId, fieldValues: List[PersonFieldValue[?]])(implicit c: Connection): Boolean = { diff --git a/.bleep/generated-sources/typo-tester-anorm@jvm3/scripts.GenHardcodedFiles/testdb/hardcoded/compositepk/person/PersonRepo.scala b/.bleep/generated-sources/typo-tester-anorm@jvm3/scripts.GenHardcodedFiles/testdb/hardcoded/compositepk/person/PersonRepo.scala index 87d9280d4..9cd76c122 100644 --- a/.bleep/generated-sources/typo-tester-anorm@jvm3/scripts.GenHardcodedFiles/testdb/hardcoded/compositepk/person/PersonRepo.scala +++ b/.bleep/generated-sources/typo-tester-anorm@jvm3/scripts.GenHardcodedFiles/testdb/hardcoded/compositepk/person/PersonRepo.scala @@ -26,7 +26,7 @@ trait PersonRepo { def selectByFieldValues(fieldValues: List[PersonFieldOrIdValue[?]])(implicit c: Connection): List[PersonRow] def selectById(compositeId: PersonId)(implicit c: Connection): Option[PersonRow] def update: UpdateBuilder[PersonFields, PersonRow] - def update(row: PersonRow)(implicit c: Connection): Boolean + def update(row: PersonRow)(implicit c: Connection): Option[PersonRow] def updateFieldValues(compositeId: PersonId, fieldValues: List[PersonFieldValue[?]])(implicit c: Connection): Boolean def upsert(unsaved: PersonRow)(implicit c: Connection): PersonRow def upsertBatch(unsaved: Iterable[PersonRow])(implicit c: Connection): List[PersonRow] diff --git a/.bleep/generated-sources/typo-tester-anorm@jvm3/scripts.GenHardcodedFiles/testdb/hardcoded/compositepk/person/PersonRepoImpl.scala b/.bleep/generated-sources/typo-tester-anorm@jvm3/scripts.GenHardcodedFiles/testdb/hardcoded/compositepk/person/PersonRepoImpl.scala index 20cfa992b..33e22be08 100644 --- a/.bleep/generated-sources/typo-tester-anorm@jvm3/scripts.GenHardcodedFiles/testdb/hardcoded/compositepk/person/PersonRepoImpl.scala +++ b/.bleep/generated-sources/typo-tester-anorm@jvm3/scripts.GenHardcodedFiles/testdb/hardcoded/compositepk/person/PersonRepoImpl.scala @@ -111,12 +111,13 @@ class PersonRepoImpl extends PersonRepo { override def update: UpdateBuilder[PersonFields, PersonRow] = { UpdateBuilder(""""compositepk"."person"""", PersonFields.structure, PersonRow.rowParser) } - override def update(row: PersonRow)(implicit c: Connection): Boolean = { + override def update(row: PersonRow)(implicit c: Connection): Option[PersonRow] = { val compositeId = row.compositeId SQL"""update "compositepk"."person" set "name" = ${ParameterValue(row.name, null, ToStatement.optionToStatement(ToStatement.stringToStatement, ParameterMetaData.StringParameterMetaData))} where "one" = ${ParameterValue(compositeId.one, null, ToStatement.longToStatement)} AND "two" = ${ParameterValue(compositeId.two, null, ToStatement.optionToStatement(ToStatement.stringToStatement, ParameterMetaData.StringParameterMetaData))} - """.executeUpdate() > 0 + returning "one", "two", "name" + """.executeInsert(PersonRow.rowParser(1).singleOpt) } override def updateFieldValues(compositeId: PersonId, fieldValues: List[PersonFieldValue[?]])(implicit c: Connection): Boolean = { fieldValues match { diff --git a/.bleep/generated-sources/typo-tester-anorm@jvm3/scripts.GenHardcodedFiles/testdb/hardcoded/compositepk/person/PersonRepoMock.scala b/.bleep/generated-sources/typo-tester-anorm@jvm3/scripts.GenHardcodedFiles/testdb/hardcoded/compositepk/person/PersonRepoMock.scala index 12d1979be..5d538f821 100644 --- a/.bleep/generated-sources/typo-tester-anorm@jvm3/scripts.GenHardcodedFiles/testdb/hardcoded/compositepk/person/PersonRepoMock.scala +++ b/.bleep/generated-sources/typo-tester-anorm@jvm3/scripts.GenHardcodedFiles/testdb/hardcoded/compositepk/person/PersonRepoMock.scala @@ -72,13 +72,10 @@ class PersonRepoMock(toRow: Function1[PersonRowUnsaved, PersonRow], override def update: UpdateBuilder[PersonFields, PersonRow] = { UpdateBuilderMock(UpdateParams.empty, PersonFields.structure, map) } - override def update(row: PersonRow)(implicit c: Connection): Boolean = { - map.get(row.compositeId) match { - case Some(`row`) => false - case Some(_) => - map.put(row.compositeId, row): @nowarn - true - case None => false + override def update(row: PersonRow)(implicit c: Connection): Option[PersonRow] = { + map.get(row.compositeId).map { _ => + map.put(row.compositeId, row): @nowarn + row } } override def updateFieldValues(compositeId: PersonId, fieldValues: List[PersonFieldValue[?]])(implicit c: Connection): Boolean = { diff --git a/.bleep/generated-sources/typo-tester-anorm@jvm3/scripts.GenHardcodedFiles/testdb/hardcoded/myschema/football_club/FootballClubRepo.scala b/.bleep/generated-sources/typo-tester-anorm@jvm3/scripts.GenHardcodedFiles/testdb/hardcoded/myschema/football_club/FootballClubRepo.scala index 7fba23c57..1b233df1d 100644 --- a/.bleep/generated-sources/typo-tester-anorm@jvm3/scripts.GenHardcodedFiles/testdb/hardcoded/myschema/football_club/FootballClubRepo.scala +++ b/.bleep/generated-sources/typo-tester-anorm@jvm3/scripts.GenHardcodedFiles/testdb/hardcoded/myschema/football_club/FootballClubRepo.scala @@ -26,7 +26,7 @@ trait FootballClubRepo { def selectByIds(ids: Array[FootballClubId])(implicit c: Connection): List[FootballClubRow] def selectByIdsTracked(ids: Array[FootballClubId])(implicit c: Connection): Map[FootballClubId, FootballClubRow] def update: UpdateBuilder[FootballClubFields, FootballClubRow] - def update(row: FootballClubRow)(implicit c: Connection): Boolean + def update(row: FootballClubRow)(implicit c: Connection): Option[FootballClubRow] def updateFieldValues(id: FootballClubId, fieldValues: List[FootballClubFieldValue[?]])(implicit c: Connection): Boolean def upsert(unsaved: FootballClubRow)(implicit c: Connection): FootballClubRow def upsertBatch(unsaved: Iterable[FootballClubRow])(implicit c: Connection): List[FootballClubRow] diff --git a/.bleep/generated-sources/typo-tester-anorm@jvm3/scripts.GenHardcodedFiles/testdb/hardcoded/myschema/football_club/FootballClubRepoImpl.scala b/.bleep/generated-sources/typo-tester-anorm@jvm3/scripts.GenHardcodedFiles/testdb/hardcoded/myschema/football_club/FootballClubRepoImpl.scala index c13fcba7a..f38b589a8 100644 --- a/.bleep/generated-sources/typo-tester-anorm@jvm3/scripts.GenHardcodedFiles/testdb/hardcoded/myschema/football_club/FootballClubRepoImpl.scala +++ b/.bleep/generated-sources/typo-tester-anorm@jvm3/scripts.GenHardcodedFiles/testdb/hardcoded/myschema/football_club/FootballClubRepoImpl.scala @@ -94,12 +94,13 @@ class FootballClubRepoImpl extends FootballClubRepo { override def update: UpdateBuilder[FootballClubFields, FootballClubRow] = { UpdateBuilder(""""myschema"."football_club"""", FootballClubFields.structure, FootballClubRow.rowParser) } - override def update(row: FootballClubRow)(implicit c: Connection): Boolean = { + override def update(row: FootballClubRow)(implicit c: Connection): Option[FootballClubRow] = { val id = row.id SQL"""update "myschema"."football_club" set "name" = ${ParameterValue(row.name, null, ToStatement.stringToStatement)} where "id" = ${ParameterValue(id, null, FootballClubId.toStatement)} - """.executeUpdate() > 0 + returning "id", "name" + """.executeInsert(FootballClubRow.rowParser(1).singleOpt) } override def updateFieldValues(id: FootballClubId, fieldValues: List[FootballClubFieldValue[?]])(implicit c: Connection): Boolean = { fieldValues match { diff --git a/.bleep/generated-sources/typo-tester-anorm@jvm3/scripts.GenHardcodedFiles/testdb/hardcoded/myschema/football_club/FootballClubRepoMock.scala b/.bleep/generated-sources/typo-tester-anorm@jvm3/scripts.GenHardcodedFiles/testdb/hardcoded/myschema/football_club/FootballClubRepoMock.scala index 37d177d06..7c274b6c2 100644 --- a/.bleep/generated-sources/typo-tester-anorm@jvm3/scripts.GenHardcodedFiles/testdb/hardcoded/myschema/football_club/FootballClubRepoMock.scala +++ b/.bleep/generated-sources/typo-tester-anorm@jvm3/scripts.GenHardcodedFiles/testdb/hardcoded/myschema/football_club/FootballClubRepoMock.scala @@ -69,13 +69,10 @@ class FootballClubRepoMock(map: scala.collection.mutable.Map[FootballClubId, Foo override def update: UpdateBuilder[FootballClubFields, FootballClubRow] = { UpdateBuilderMock(UpdateParams.empty, FootballClubFields.structure, map) } - override def update(row: FootballClubRow)(implicit c: Connection): Boolean = { - map.get(row.id) match { - case Some(`row`) => false - case Some(_) => - map.put(row.id, row): @nowarn - true - case None => false + override def update(row: FootballClubRow)(implicit c: Connection): Option[FootballClubRow] = { + map.get(row.id).map { _ => + map.put(row.id, row): @nowarn + row } } override def updateFieldValues(id: FootballClubId, fieldValues: List[FootballClubFieldValue[?]])(implicit c: Connection): Boolean = { diff --git a/.bleep/generated-sources/typo-tester-anorm@jvm3/scripts.GenHardcodedFiles/testdb/hardcoded/myschema/person/PersonRepo.scala b/.bleep/generated-sources/typo-tester-anorm@jvm3/scripts.GenHardcodedFiles/testdb/hardcoded/myschema/person/PersonRepo.scala index b8c43ba30..b21d3428f 100644 --- a/.bleep/generated-sources/typo-tester-anorm@jvm3/scripts.GenHardcodedFiles/testdb/hardcoded/myschema/person/PersonRepo.scala +++ b/.bleep/generated-sources/typo-tester-anorm@jvm3/scripts.GenHardcodedFiles/testdb/hardcoded/myschema/person/PersonRepo.scala @@ -29,7 +29,7 @@ trait PersonRepo { def selectByIds(ids: Array[PersonId])(implicit c: Connection): List[PersonRow] def selectByIdsTracked(ids: Array[PersonId])(implicit c: Connection): Map[PersonId, PersonRow] def update: UpdateBuilder[PersonFields, PersonRow] - def update(row: PersonRow)(implicit c: Connection): Boolean + def update(row: PersonRow)(implicit c: Connection): Option[PersonRow] def updateFieldValues(id: PersonId, fieldValues: List[PersonFieldValue[?]])(implicit c: Connection): Boolean def upsert(unsaved: PersonRow)(implicit c: Connection): PersonRow def upsertBatch(unsaved: Iterable[PersonRow])(implicit c: Connection): List[PersonRow] diff --git a/.bleep/generated-sources/typo-tester-anorm@jvm3/scripts.GenHardcodedFiles/testdb/hardcoded/myschema/person/PersonRepoImpl.scala b/.bleep/generated-sources/typo-tester-anorm@jvm3/scripts.GenHardcodedFiles/testdb/hardcoded/myschema/person/PersonRepoImpl.scala index c9aceff13..bfdb48abd 100644 --- a/.bleep/generated-sources/typo-tester-anorm@jvm3/scripts.GenHardcodedFiles/testdb/hardcoded/myschema/person/PersonRepoImpl.scala +++ b/.bleep/generated-sources/typo-tester-anorm@jvm3/scripts.GenHardcodedFiles/testdb/hardcoded/myschema/person/PersonRepoImpl.scala @@ -151,7 +151,7 @@ class PersonRepoImpl extends PersonRepo { override def update: UpdateBuilder[PersonFields, PersonRow] = { UpdateBuilder(""""myschema"."person"""", PersonFields.structure, PersonRow.rowParser) } - override def update(row: PersonRow)(implicit c: Connection): Boolean = { + override def update(row: PersonRow)(implicit c: Connection): Option[PersonRow] = { val id = row.id SQL"""update "myschema"."person" set "favourite_football_club_id" = ${ParameterValue(row.favouriteFootballClubId, null, FootballClubId.toStatement)}, @@ -165,7 +165,8 @@ class PersonRepoImpl extends PersonRepo { "work_email" = ${ParameterValue(row.workEmail, null, ToStatement.optionToStatement(ToStatement.stringToStatement, ParameterMetaData.StringParameterMetaData))}, "favorite_number" = ${ParameterValue(row.favoriteNumber, null, Number.toStatement)}::myschema.number where "id" = ${ParameterValue(id, null, PersonId.toStatement)} - """.executeUpdate() > 0 + returning "id", "favourite_football_club_id", "name", "nick_name", "blog_url", "email", "phone", "likes_pizza", "marital_status_id", "work_email", "sector", "favorite_number" + """.executeInsert(PersonRow.rowParser(1).singleOpt) } override def updateFieldValues(id: PersonId, fieldValues: List[PersonFieldValue[?]])(implicit c: Connection): Boolean = { fieldValues match { diff --git a/.bleep/generated-sources/typo-tester-anorm@jvm3/scripts.GenHardcodedFiles/testdb/hardcoded/myschema/person/PersonRepoMock.scala b/.bleep/generated-sources/typo-tester-anorm@jvm3/scripts.GenHardcodedFiles/testdb/hardcoded/myschema/person/PersonRepoMock.scala index bb9994c80..e3757b60e 100644 --- a/.bleep/generated-sources/typo-tester-anorm@jvm3/scripts.GenHardcodedFiles/testdb/hardcoded/myschema/person/PersonRepoMock.scala +++ b/.bleep/generated-sources/typo-tester-anorm@jvm3/scripts.GenHardcodedFiles/testdb/hardcoded/myschema/person/PersonRepoMock.scala @@ -91,13 +91,10 @@ class PersonRepoMock(toRow: Function1[PersonRowUnsaved, PersonRow], override def update: UpdateBuilder[PersonFields, PersonRow] = { UpdateBuilderMock(UpdateParams.empty, PersonFields.structure, map) } - override def update(row: PersonRow)(implicit c: Connection): Boolean = { - map.get(row.id) match { - case Some(`row`) => false - case Some(_) => - map.put(row.id, row): @nowarn - true - case None => false + override def update(row: PersonRow)(implicit c: Connection): Option[PersonRow] = { + map.get(row.id).map { _ => + map.put(row.id, row): @nowarn + row } } override def updateFieldValues(id: PersonId, fieldValues: List[PersonFieldValue[?]])(implicit c: Connection): Boolean = { diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/humanresources/department/DepartmentRepo.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/humanresources/department/DepartmentRepo.scala index e55859678..1d5c4379b 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/humanresources/department/DepartmentRepo.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/humanresources/department/DepartmentRepo.scala @@ -27,7 +27,7 @@ trait DepartmentRepo { def selectByIds(departmentids: Array[DepartmentId])(implicit c: Connection): List[DepartmentRow] def selectByIdsTracked(departmentids: Array[DepartmentId])(implicit c: Connection): Map[DepartmentId, DepartmentRow] def update: UpdateBuilder[DepartmentFields, DepartmentRow] - def update(row: DepartmentRow)(implicit c: Connection): Boolean + def update(row: DepartmentRow)(implicit c: Connection): Option[DepartmentRow] def upsert(unsaved: DepartmentRow)(implicit c: Connection): DepartmentRow def upsertBatch(unsaved: Iterable[DepartmentRow])(implicit c: Connection): List[DepartmentRow] /* NOTE: this functionality is not safe if you use auto-commit mode! it runs 3 SQL statements */ diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/humanresources/department/DepartmentRepoImpl.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/humanresources/department/DepartmentRepoImpl.scala index db361d29b..dc0a71e31 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/humanresources/department/DepartmentRepoImpl.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/humanresources/department/DepartmentRepoImpl.scala @@ -110,14 +110,15 @@ class DepartmentRepoImpl extends DepartmentRepo { override def update: UpdateBuilder[DepartmentFields, DepartmentRow] = { UpdateBuilder(""""humanresources"."department"""", DepartmentFields.structure, DepartmentRow.rowParser) } - override def update(row: DepartmentRow)(implicit c: Connection): Boolean = { + override def update(row: DepartmentRow)(implicit c: Connection): Option[DepartmentRow] = { val departmentid = row.departmentid SQL"""update "humanresources"."department" set "name" = ${ParameterValue(row.name, null, Name.toStatement)}::varchar, "groupname" = ${ParameterValue(row.groupname, null, Name.toStatement)}::varchar, "modifieddate" = ${ParameterValue(row.modifieddate, null, TypoLocalDateTime.toStatement)}::timestamp where "departmentid" = ${ParameterValue(departmentid, null, DepartmentId.toStatement)} - """.executeUpdate() > 0 + returning "departmentid", "name", "groupname", "modifieddate"::text + """.executeInsert(DepartmentRow.rowParser(1).singleOpt) } override def upsert(unsaved: DepartmentRow)(implicit c: Connection): DepartmentRow = { SQL"""insert into "humanresources"."department"("departmentid", "name", "groupname", "modifieddate") diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/humanresources/department/DepartmentRepoMock.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/humanresources/department/DepartmentRepoMock.scala index d663ba0a1..e998c9255 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/humanresources/department/DepartmentRepoMock.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/humanresources/department/DepartmentRepoMock.scala @@ -74,13 +74,10 @@ class DepartmentRepoMock(toRow: Function1[DepartmentRowUnsaved, DepartmentRow], override def update: UpdateBuilder[DepartmentFields, DepartmentRow] = { UpdateBuilderMock(UpdateParams.empty, DepartmentFields.structure, map) } - override def update(row: DepartmentRow)(implicit c: Connection): Boolean = { - map.get(row.departmentid) match { - case Some(`row`) => false - case Some(_) => - map.put(row.departmentid, row): @nowarn - true - case None => false + override def update(row: DepartmentRow)(implicit c: Connection): Option[DepartmentRow] = { + map.get(row.departmentid).map { _ => + map.put(row.departmentid, row): @nowarn + row } } override def upsert(unsaved: DepartmentRow)(implicit c: Connection): DepartmentRow = { diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/humanresources/employee/EmployeeRepo.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/humanresources/employee/EmployeeRepo.scala index e9ff53ff6..67c7ab49d 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/humanresources/employee/EmployeeRepo.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/humanresources/employee/EmployeeRepo.scala @@ -28,7 +28,7 @@ trait EmployeeRepo { def selectByIds(businessentityids: Array[BusinessentityId])(implicit c: Connection): List[EmployeeRow] def selectByIdsTracked(businessentityids: Array[BusinessentityId])(implicit c: Connection): Map[BusinessentityId, EmployeeRow] def update: UpdateBuilder[EmployeeFields, EmployeeRow] - def update(row: EmployeeRow)(implicit c: Connection): Boolean + def update(row: EmployeeRow)(implicit c: Connection): Option[EmployeeRow] def upsert(unsaved: EmployeeRow)(implicit c: Connection): EmployeeRow def upsertBatch(unsaved: Iterable[EmployeeRow])(implicit c: Connection): List[EmployeeRow] /* NOTE: this functionality is not safe if you use auto-commit mode! it runs 3 SQL statements */ diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/humanresources/employee/EmployeeRepoImpl.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/humanresources/employee/EmployeeRepoImpl.scala index a0d6c0173..db1d686df 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/humanresources/employee/EmployeeRepoImpl.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/humanresources/employee/EmployeeRepoImpl.scala @@ -142,7 +142,7 @@ class EmployeeRepoImpl extends EmployeeRepo { override def update: UpdateBuilder[EmployeeFields, EmployeeRow] = { UpdateBuilder(""""humanresources"."employee"""", EmployeeFields.structure, EmployeeRow.rowParser) } - override def update(row: EmployeeRow)(implicit c: Connection): Boolean = { + override def update(row: EmployeeRow)(implicit c: Connection): Option[EmployeeRow] = { val businessentityid = row.businessentityid SQL"""update "humanresources"."employee" set "nationalidnumber" = ${ParameterValue(row.nationalidnumber, null, ToStatement.stringToStatement)}, @@ -160,7 +160,8 @@ class EmployeeRepoImpl extends EmployeeRepo { "modifieddate" = ${ParameterValue(row.modifieddate, null, TypoLocalDateTime.toStatement)}::timestamp, "organizationnode" = ${ParameterValue(row.organizationnode, null, ToStatement.optionToStatement(ToStatement.stringToStatement, ParameterMetaData.StringParameterMetaData))} where "businessentityid" = ${ParameterValue(businessentityid, null, BusinessentityId.toStatement)} - """.executeUpdate() > 0 + returning "businessentityid", "nationalidnumber", "loginid", "jobtitle", "birthdate"::text, "maritalstatus", "gender", "hiredate"::text, "salariedflag", "vacationhours", "sickleavehours", "currentflag", "rowguid", "modifieddate"::text, "organizationnode" + """.executeInsert(EmployeeRow.rowParser(1).singleOpt) } override def upsert(unsaved: EmployeeRow)(implicit c: Connection): EmployeeRow = { SQL"""insert into "humanresources"."employee"("businessentityid", "nationalidnumber", "loginid", "jobtitle", "birthdate", "maritalstatus", "gender", "hiredate", "salariedflag", "vacationhours", "sickleavehours", "currentflag", "rowguid", "modifieddate", "organizationnode") diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/humanresources/employee/EmployeeRepoMock.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/humanresources/employee/EmployeeRepoMock.scala index 85e6fda6f..1750625b2 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/humanresources/employee/EmployeeRepoMock.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/humanresources/employee/EmployeeRepoMock.scala @@ -75,13 +75,10 @@ class EmployeeRepoMock(toRow: Function1[EmployeeRowUnsaved, EmployeeRow], override def update: UpdateBuilder[EmployeeFields, EmployeeRow] = { UpdateBuilderMock(UpdateParams.empty, EmployeeFields.structure, map) } - override def update(row: EmployeeRow)(implicit c: Connection): Boolean = { - map.get(row.businessentityid) match { - case Some(`row`) => false - case Some(_) => - map.put(row.businessentityid, row): @nowarn - true - case None => false + override def update(row: EmployeeRow)(implicit c: Connection): Option[EmployeeRow] = { + map.get(row.businessentityid).map { _ => + map.put(row.businessentityid, row): @nowarn + row } } override def upsert(unsaved: EmployeeRow)(implicit c: Connection): EmployeeRow = { diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/humanresources/employeedepartmenthistory/EmployeedepartmenthistoryRepo.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/humanresources/employeedepartmenthistory/EmployeedepartmenthistoryRepo.scala index 28efa9188..8dfa9df76 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/humanresources/employeedepartmenthistory/EmployeedepartmenthistoryRepo.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/humanresources/employeedepartmenthistory/EmployeedepartmenthistoryRepo.scala @@ -27,7 +27,7 @@ trait EmployeedepartmenthistoryRepo { def selectByIds(compositeIds: Array[EmployeedepartmenthistoryId])(implicit c: Connection): List[EmployeedepartmenthistoryRow] def selectByIdsTracked(compositeIds: Array[EmployeedepartmenthistoryId])(implicit c: Connection): Map[EmployeedepartmenthistoryId, EmployeedepartmenthistoryRow] def update: UpdateBuilder[EmployeedepartmenthistoryFields, EmployeedepartmenthistoryRow] - def update(row: EmployeedepartmenthistoryRow)(implicit c: Connection): Boolean + def update(row: EmployeedepartmenthistoryRow)(implicit c: Connection): Option[EmployeedepartmenthistoryRow] def upsert(unsaved: EmployeedepartmenthistoryRow)(implicit c: Connection): EmployeedepartmenthistoryRow def upsertBatch(unsaved: Iterable[EmployeedepartmenthistoryRow])(implicit c: Connection): List[EmployeedepartmenthistoryRow] /* NOTE: this functionality is not safe if you use auto-commit mode! it runs 3 SQL statements */ diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/humanresources/employeedepartmenthistory/EmployeedepartmenthistoryRepoImpl.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/humanresources/employeedepartmenthistory/EmployeedepartmenthistoryRepoImpl.scala index 097fbba65..885b358f0 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/humanresources/employeedepartmenthistory/EmployeedepartmenthistoryRepoImpl.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/humanresources/employeedepartmenthistory/EmployeedepartmenthistoryRepoImpl.scala @@ -111,7 +111,7 @@ class EmployeedepartmenthistoryRepoImpl extends EmployeedepartmenthistoryRepo { val shiftid = compositeIds.map(_.shiftid) SQL"""select "businessentityid", "departmentid", "shiftid", "startdate"::text, "enddate"::text, "modifieddate"::text from "humanresources"."employeedepartmenthistory" - where ("businessentityid", "startdate", "departmentid", "shiftid") + where ("businessentityid", "startdate", "departmentid", "shiftid") in (select unnest(${businessentityid}), unnest(${startdate}), unnest(${departmentid}), unnest(${shiftid})) """.as(EmployeedepartmenthistoryRow.rowParser(1).*) @@ -123,13 +123,14 @@ class EmployeedepartmenthistoryRepoImpl extends EmployeedepartmenthistoryRepo { override def update: UpdateBuilder[EmployeedepartmenthistoryFields, EmployeedepartmenthistoryRow] = { UpdateBuilder(""""humanresources"."employeedepartmenthistory"""", EmployeedepartmenthistoryFields.structure, EmployeedepartmenthistoryRow.rowParser) } - override def update(row: EmployeedepartmenthistoryRow)(implicit c: Connection): Boolean = { + override def update(row: EmployeedepartmenthistoryRow)(implicit c: Connection): Option[EmployeedepartmenthistoryRow] = { val compositeId = row.compositeId SQL"""update "humanresources"."employeedepartmenthistory" set "enddate" = ${ParameterValue(row.enddate, null, ToStatement.optionToStatement(TypoLocalDate.toStatement, TypoLocalDate.parameterMetadata))}::date, "modifieddate" = ${ParameterValue(row.modifieddate, null, TypoLocalDateTime.toStatement)}::timestamp where "businessentityid" = ${ParameterValue(compositeId.businessentityid, null, BusinessentityId.toStatement)} AND "startdate" = ${ParameterValue(compositeId.startdate, null, TypoLocalDate.toStatement)} AND "departmentid" = ${ParameterValue(compositeId.departmentid, null, DepartmentId.toStatement)} AND "shiftid" = ${ParameterValue(compositeId.shiftid, null, ShiftId.toStatement)} - """.executeUpdate() > 0 + returning "businessentityid", "departmentid", "shiftid", "startdate"::text, "enddate"::text, "modifieddate"::text + """.executeInsert(EmployeedepartmenthistoryRow.rowParser(1).singleOpt) } override def upsert(unsaved: EmployeedepartmenthistoryRow)(implicit c: Connection): EmployeedepartmenthistoryRow = { SQL"""insert into "humanresources"."employeedepartmenthistory"("businessentityid", "departmentid", "shiftid", "startdate", "enddate", "modifieddate") diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/humanresources/employeedepartmenthistory/EmployeedepartmenthistoryRepoMock.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/humanresources/employeedepartmenthistory/EmployeedepartmenthistoryRepoMock.scala index 18aecce70..f917b1d9d 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/humanresources/employeedepartmenthistory/EmployeedepartmenthistoryRepoMock.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/humanresources/employeedepartmenthistory/EmployeedepartmenthistoryRepoMock.scala @@ -74,13 +74,10 @@ class EmployeedepartmenthistoryRepoMock(toRow: Function1[Employeedepartmenthisto override def update: UpdateBuilder[EmployeedepartmenthistoryFields, EmployeedepartmenthistoryRow] = { UpdateBuilderMock(UpdateParams.empty, EmployeedepartmenthistoryFields.structure, map) } - override def update(row: EmployeedepartmenthistoryRow)(implicit c: Connection): Boolean = { - map.get(row.compositeId) match { - case Some(`row`) => false - case Some(_) => - map.put(row.compositeId, row): @nowarn - true - case None => false + override def update(row: EmployeedepartmenthistoryRow)(implicit c: Connection): Option[EmployeedepartmenthistoryRow] = { + map.get(row.compositeId).map { _ => + map.put(row.compositeId, row): @nowarn + row } } override def upsert(unsaved: EmployeedepartmenthistoryRow)(implicit c: Connection): EmployeedepartmenthistoryRow = { diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/humanresources/employeepayhistory/EmployeepayhistoryRepo.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/humanresources/employeepayhistory/EmployeepayhistoryRepo.scala index 3c4d2d46a..f9310615f 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/humanresources/employeepayhistory/EmployeepayhistoryRepo.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/humanresources/employeepayhistory/EmployeepayhistoryRepo.scala @@ -27,7 +27,7 @@ trait EmployeepayhistoryRepo { def selectByIds(compositeIds: Array[EmployeepayhistoryId])(implicit c: Connection): List[EmployeepayhistoryRow] def selectByIdsTracked(compositeIds: Array[EmployeepayhistoryId])(implicit c: Connection): Map[EmployeepayhistoryId, EmployeepayhistoryRow] def update: UpdateBuilder[EmployeepayhistoryFields, EmployeepayhistoryRow] - def update(row: EmployeepayhistoryRow)(implicit c: Connection): Boolean + def update(row: EmployeepayhistoryRow)(implicit c: Connection): Option[EmployeepayhistoryRow] def upsert(unsaved: EmployeepayhistoryRow)(implicit c: Connection): EmployeepayhistoryRow def upsertBatch(unsaved: Iterable[EmployeepayhistoryRow])(implicit c: Connection): List[EmployeepayhistoryRow] /* NOTE: this functionality is not safe if you use auto-commit mode! it runs 3 SQL statements */ diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/humanresources/employeepayhistory/EmployeepayhistoryRepoImpl.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/humanresources/employeepayhistory/EmployeepayhistoryRepoImpl.scala index e7df369fd..b31883997 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/humanresources/employeepayhistory/EmployeepayhistoryRepoImpl.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/humanresources/employeepayhistory/EmployeepayhistoryRepoImpl.scala @@ -104,7 +104,7 @@ class EmployeepayhistoryRepoImpl extends EmployeepayhistoryRepo { val ratechangedate = compositeIds.map(_.ratechangedate) SQL"""select "businessentityid", "ratechangedate"::text, "rate", "payfrequency", "modifieddate"::text from "humanresources"."employeepayhistory" - where ("businessentityid", "ratechangedate") + where ("businessentityid", "ratechangedate") in (select unnest(${businessentityid}), unnest(${ratechangedate})) """.as(EmployeepayhistoryRow.rowParser(1).*) @@ -116,14 +116,15 @@ class EmployeepayhistoryRepoImpl extends EmployeepayhistoryRepo { override def update: UpdateBuilder[EmployeepayhistoryFields, EmployeepayhistoryRow] = { UpdateBuilder(""""humanresources"."employeepayhistory"""", EmployeepayhistoryFields.structure, EmployeepayhistoryRow.rowParser) } - override def update(row: EmployeepayhistoryRow)(implicit c: Connection): Boolean = { + override def update(row: EmployeepayhistoryRow)(implicit c: Connection): Option[EmployeepayhistoryRow] = { val compositeId = row.compositeId SQL"""update "humanresources"."employeepayhistory" set "rate" = ${ParameterValue(row.rate, null, ToStatement.scalaBigDecimalToStatement)}::numeric, "payfrequency" = ${ParameterValue(row.payfrequency, null, TypoShort.toStatement)}::int2, "modifieddate" = ${ParameterValue(row.modifieddate, null, TypoLocalDateTime.toStatement)}::timestamp where "businessentityid" = ${ParameterValue(compositeId.businessentityid, null, BusinessentityId.toStatement)} AND "ratechangedate" = ${ParameterValue(compositeId.ratechangedate, null, TypoLocalDateTime.toStatement)} - """.executeUpdate() > 0 + returning "businessentityid", "ratechangedate"::text, "rate", "payfrequency", "modifieddate"::text + """.executeInsert(EmployeepayhistoryRow.rowParser(1).singleOpt) } override def upsert(unsaved: EmployeepayhistoryRow)(implicit c: Connection): EmployeepayhistoryRow = { SQL"""insert into "humanresources"."employeepayhistory"("businessentityid", "ratechangedate", "rate", "payfrequency", "modifieddate") diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/humanresources/employeepayhistory/EmployeepayhistoryRepoMock.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/humanresources/employeepayhistory/EmployeepayhistoryRepoMock.scala index 82a22249d..37ea35112 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/humanresources/employeepayhistory/EmployeepayhistoryRepoMock.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/humanresources/employeepayhistory/EmployeepayhistoryRepoMock.scala @@ -74,13 +74,10 @@ class EmployeepayhistoryRepoMock(toRow: Function1[EmployeepayhistoryRowUnsaved, override def update: UpdateBuilder[EmployeepayhistoryFields, EmployeepayhistoryRow] = { UpdateBuilderMock(UpdateParams.empty, EmployeepayhistoryFields.structure, map) } - override def update(row: EmployeepayhistoryRow)(implicit c: Connection): Boolean = { - map.get(row.compositeId) match { - case Some(`row`) => false - case Some(_) => - map.put(row.compositeId, row): @nowarn - true - case None => false + override def update(row: EmployeepayhistoryRow)(implicit c: Connection): Option[EmployeepayhistoryRow] = { + map.get(row.compositeId).map { _ => + map.put(row.compositeId, row): @nowarn + row } } override def upsert(unsaved: EmployeepayhistoryRow)(implicit c: Connection): EmployeepayhistoryRow = { diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/humanresources/jobcandidate/JobcandidateRepo.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/humanresources/jobcandidate/JobcandidateRepo.scala index 5df163c7a..69e334ffa 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/humanresources/jobcandidate/JobcandidateRepo.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/humanresources/jobcandidate/JobcandidateRepo.scala @@ -27,7 +27,7 @@ trait JobcandidateRepo { def selectByIds(jobcandidateids: Array[JobcandidateId])(implicit c: Connection): List[JobcandidateRow] def selectByIdsTracked(jobcandidateids: Array[JobcandidateId])(implicit c: Connection): Map[JobcandidateId, JobcandidateRow] def update: UpdateBuilder[JobcandidateFields, JobcandidateRow] - def update(row: JobcandidateRow)(implicit c: Connection): Boolean + def update(row: JobcandidateRow)(implicit c: Connection): Option[JobcandidateRow] def upsert(unsaved: JobcandidateRow)(implicit c: Connection): JobcandidateRow def upsertBatch(unsaved: Iterable[JobcandidateRow])(implicit c: Connection): List[JobcandidateRow] /* NOTE: this functionality is not safe if you use auto-commit mode! it runs 3 SQL statements */ diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/humanresources/jobcandidate/JobcandidateRepoImpl.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/humanresources/jobcandidate/JobcandidateRepoImpl.scala index b5f40fc99..de99d1ce5 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/humanresources/jobcandidate/JobcandidateRepoImpl.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/humanresources/jobcandidate/JobcandidateRepoImpl.scala @@ -112,14 +112,15 @@ class JobcandidateRepoImpl extends JobcandidateRepo { override def update: UpdateBuilder[JobcandidateFields, JobcandidateRow] = { UpdateBuilder(""""humanresources"."jobcandidate"""", JobcandidateFields.structure, JobcandidateRow.rowParser) } - override def update(row: JobcandidateRow)(implicit c: Connection): Boolean = { + override def update(row: JobcandidateRow)(implicit c: Connection): Option[JobcandidateRow] = { val jobcandidateid = row.jobcandidateid SQL"""update "humanresources"."jobcandidate" set "businessentityid" = ${ParameterValue(row.businessentityid, null, ToStatement.optionToStatement(BusinessentityId.toStatement, BusinessentityId.parameterMetadata))}::int4, "resume" = ${ParameterValue(row.resume, null, ToStatement.optionToStatement(TypoXml.toStatement, TypoXml.parameterMetadata))}::xml, "modifieddate" = ${ParameterValue(row.modifieddate, null, TypoLocalDateTime.toStatement)}::timestamp where "jobcandidateid" = ${ParameterValue(jobcandidateid, null, JobcandidateId.toStatement)} - """.executeUpdate() > 0 + returning "jobcandidateid", "businessentityid", "resume", "modifieddate"::text + """.executeInsert(JobcandidateRow.rowParser(1).singleOpt) } override def upsert(unsaved: JobcandidateRow)(implicit c: Connection): JobcandidateRow = { SQL"""insert into "humanresources"."jobcandidate"("jobcandidateid", "businessentityid", "resume", "modifieddate") diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/humanresources/jobcandidate/JobcandidateRepoMock.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/humanresources/jobcandidate/JobcandidateRepoMock.scala index e5f65c7b8..f3bf7d5d3 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/humanresources/jobcandidate/JobcandidateRepoMock.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/humanresources/jobcandidate/JobcandidateRepoMock.scala @@ -74,13 +74,10 @@ class JobcandidateRepoMock(toRow: Function1[JobcandidateRowUnsaved, Jobcandidate override def update: UpdateBuilder[JobcandidateFields, JobcandidateRow] = { UpdateBuilderMock(UpdateParams.empty, JobcandidateFields.structure, map) } - override def update(row: JobcandidateRow)(implicit c: Connection): Boolean = { - map.get(row.jobcandidateid) match { - case Some(`row`) => false - case Some(_) => - map.put(row.jobcandidateid, row): @nowarn - true - case None => false + override def update(row: JobcandidateRow)(implicit c: Connection): Option[JobcandidateRow] = { + map.get(row.jobcandidateid).map { _ => + map.put(row.jobcandidateid, row): @nowarn + row } } override def upsert(unsaved: JobcandidateRow)(implicit c: Connection): JobcandidateRow = { diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/humanresources/shift/ShiftRepo.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/humanresources/shift/ShiftRepo.scala index fa27a24eb..2bf2c5860 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/humanresources/shift/ShiftRepo.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/humanresources/shift/ShiftRepo.scala @@ -27,7 +27,7 @@ trait ShiftRepo { def selectByIds(shiftids: Array[ShiftId])(implicit c: Connection): List[ShiftRow] def selectByIdsTracked(shiftids: Array[ShiftId])(implicit c: Connection): Map[ShiftId, ShiftRow] def update: UpdateBuilder[ShiftFields, ShiftRow] - def update(row: ShiftRow)(implicit c: Connection): Boolean + def update(row: ShiftRow)(implicit c: Connection): Option[ShiftRow] def upsert(unsaved: ShiftRow)(implicit c: Connection): ShiftRow def upsertBatch(unsaved: Iterable[ShiftRow])(implicit c: Connection): List[ShiftRow] /* NOTE: this functionality is not safe if you use auto-commit mode! it runs 3 SQL statements */ diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/humanresources/shift/ShiftRepoImpl.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/humanresources/shift/ShiftRepoImpl.scala index 798e28746..cd34bc444 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/humanresources/shift/ShiftRepoImpl.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/humanresources/shift/ShiftRepoImpl.scala @@ -112,7 +112,7 @@ class ShiftRepoImpl extends ShiftRepo { override def update: UpdateBuilder[ShiftFields, ShiftRow] = { UpdateBuilder(""""humanresources"."shift"""", ShiftFields.structure, ShiftRow.rowParser) } - override def update(row: ShiftRow)(implicit c: Connection): Boolean = { + override def update(row: ShiftRow)(implicit c: Connection): Option[ShiftRow] = { val shiftid = row.shiftid SQL"""update "humanresources"."shift" set "name" = ${ParameterValue(row.name, null, Name.toStatement)}::varchar, @@ -120,7 +120,8 @@ class ShiftRepoImpl extends ShiftRepo { "endtime" = ${ParameterValue(row.endtime, null, TypoLocalTime.toStatement)}::time, "modifieddate" = ${ParameterValue(row.modifieddate, null, TypoLocalDateTime.toStatement)}::timestamp where "shiftid" = ${ParameterValue(shiftid, null, ShiftId.toStatement)} - """.executeUpdate() > 0 + returning "shiftid", "name", "starttime"::text, "endtime"::text, "modifieddate"::text + """.executeInsert(ShiftRow.rowParser(1).singleOpt) } override def upsert(unsaved: ShiftRow)(implicit c: Connection): ShiftRow = { SQL"""insert into "humanresources"."shift"("shiftid", "name", "starttime", "endtime", "modifieddate") diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/humanresources/shift/ShiftRepoMock.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/humanresources/shift/ShiftRepoMock.scala index 9b2ed3bcf..7bd90cfd6 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/humanresources/shift/ShiftRepoMock.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/humanresources/shift/ShiftRepoMock.scala @@ -74,13 +74,10 @@ class ShiftRepoMock(toRow: Function1[ShiftRowUnsaved, ShiftRow], override def update: UpdateBuilder[ShiftFields, ShiftRow] = { UpdateBuilderMock(UpdateParams.empty, ShiftFields.structure, map) } - override def update(row: ShiftRow)(implicit c: Connection): Boolean = { - map.get(row.shiftid) match { - case Some(`row`) => false - case Some(_) => - map.put(row.shiftid, row): @nowarn - true - case None => false + override def update(row: ShiftRow)(implicit c: Connection): Option[ShiftRow] = { + map.get(row.shiftid).map { _ => + map.put(row.shiftid, row): @nowarn + row } } override def upsert(unsaved: ShiftRow)(implicit c: Connection): ShiftRow = { diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/person/address/AddressRepo.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/person/address/AddressRepo.scala index f31e96c50..8eab27f18 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/person/address/AddressRepo.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/person/address/AddressRepo.scala @@ -27,7 +27,7 @@ trait AddressRepo { def selectByIds(addressids: Array[AddressId])(implicit c: Connection): List[AddressRow] def selectByIdsTracked(addressids: Array[AddressId])(implicit c: Connection): Map[AddressId, AddressRow] def update: UpdateBuilder[AddressFields, AddressRow] - def update(row: AddressRow)(implicit c: Connection): Boolean + def update(row: AddressRow)(implicit c: Connection): Option[AddressRow] def upsert(unsaved: AddressRow)(implicit c: Connection): AddressRow def upsertBatch(unsaved: Iterable[AddressRow])(implicit c: Connection): List[AddressRow] /* NOTE: this functionality is not safe if you use auto-commit mode! it runs 3 SQL statements */ diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/person/address/AddressRepoImpl.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/person/address/AddressRepoImpl.scala index 14b48fb05..1da08b4d9 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/person/address/AddressRepoImpl.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/person/address/AddressRepoImpl.scala @@ -122,7 +122,7 @@ class AddressRepoImpl extends AddressRepo { override def update: UpdateBuilder[AddressFields, AddressRow] = { UpdateBuilder(""""person"."address"""", AddressFields.structure, AddressRow.rowParser) } - override def update(row: AddressRow)(implicit c: Connection): Boolean = { + override def update(row: AddressRow)(implicit c: Connection): Option[AddressRow] = { val addressid = row.addressid SQL"""update "person"."address" set "addressline1" = ${ParameterValue(row.addressline1, null, ToStatement.stringToStatement)}, @@ -134,7 +134,8 @@ class AddressRepoImpl extends AddressRepo { "rowguid" = ${ParameterValue(row.rowguid, null, TypoUUID.toStatement)}::uuid, "modifieddate" = ${ParameterValue(row.modifieddate, null, TypoLocalDateTime.toStatement)}::timestamp where "addressid" = ${ParameterValue(addressid, null, AddressId.toStatement)} - """.executeUpdate() > 0 + returning "addressid", "addressline1", "addressline2", "city", "stateprovinceid", "postalcode", "spatiallocation", "rowguid", "modifieddate"::text + """.executeInsert(AddressRow.rowParser(1).singleOpt) } override def upsert(unsaved: AddressRow)(implicit c: Connection): AddressRow = { SQL"""insert into "person"."address"("addressid", "addressline1", "addressline2", "city", "stateprovinceid", "postalcode", "spatiallocation", "rowguid", "modifieddate") diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/person/address/AddressRepoMock.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/person/address/AddressRepoMock.scala index b6d6823ae..2f4fb4811 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/person/address/AddressRepoMock.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/person/address/AddressRepoMock.scala @@ -74,13 +74,10 @@ class AddressRepoMock(toRow: Function1[AddressRowUnsaved, AddressRow], override def update: UpdateBuilder[AddressFields, AddressRow] = { UpdateBuilderMock(UpdateParams.empty, AddressFields.structure, map) } - override def update(row: AddressRow)(implicit c: Connection): Boolean = { - map.get(row.addressid) match { - case Some(`row`) => false - case Some(_) => - map.put(row.addressid, row): @nowarn - true - case None => false + override def update(row: AddressRow)(implicit c: Connection): Option[AddressRow] = { + map.get(row.addressid).map { _ => + map.put(row.addressid, row): @nowarn + row } } override def upsert(unsaved: AddressRow)(implicit c: Connection): AddressRow = { diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/person/addresstype/AddresstypeRepo.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/person/addresstype/AddresstypeRepo.scala index 226bcb2ae..fc46c37a8 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/person/addresstype/AddresstypeRepo.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/person/addresstype/AddresstypeRepo.scala @@ -27,7 +27,7 @@ trait AddresstypeRepo { def selectByIds(addresstypeids: Array[AddresstypeId])(implicit c: Connection): List[AddresstypeRow] def selectByIdsTracked(addresstypeids: Array[AddresstypeId])(implicit c: Connection): Map[AddresstypeId, AddresstypeRow] def update: UpdateBuilder[AddresstypeFields, AddresstypeRow] - def update(row: AddresstypeRow)(implicit c: Connection): Boolean + def update(row: AddresstypeRow)(implicit c: Connection): Option[AddresstypeRow] def upsert(unsaved: AddresstypeRow)(implicit c: Connection): AddresstypeRow def upsertBatch(unsaved: Iterable[AddresstypeRow])(implicit c: Connection): List[AddresstypeRow] /* NOTE: this functionality is not safe if you use auto-commit mode! it runs 3 SQL statements */ diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/person/addresstype/AddresstypeRepoImpl.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/person/addresstype/AddresstypeRepoImpl.scala index 03dcf4f1d..0a73deae1 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/person/addresstype/AddresstypeRepoImpl.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/person/addresstype/AddresstypeRepoImpl.scala @@ -114,14 +114,15 @@ class AddresstypeRepoImpl extends AddresstypeRepo { override def update: UpdateBuilder[AddresstypeFields, AddresstypeRow] = { UpdateBuilder(""""person"."addresstype"""", AddresstypeFields.structure, AddresstypeRow.rowParser) } - override def update(row: AddresstypeRow)(implicit c: Connection): Boolean = { + override def update(row: AddresstypeRow)(implicit c: Connection): Option[AddresstypeRow] = { val addresstypeid = row.addresstypeid SQL"""update "person"."addresstype" set "name" = ${ParameterValue(row.name, null, Name.toStatement)}::varchar, "rowguid" = ${ParameterValue(row.rowguid, null, TypoUUID.toStatement)}::uuid, "modifieddate" = ${ParameterValue(row.modifieddate, null, TypoLocalDateTime.toStatement)}::timestamp where "addresstypeid" = ${ParameterValue(addresstypeid, null, AddresstypeId.toStatement)} - """.executeUpdate() > 0 + returning "addresstypeid", "name", "rowguid", "modifieddate"::text + """.executeInsert(AddresstypeRow.rowParser(1).singleOpt) } override def upsert(unsaved: AddresstypeRow)(implicit c: Connection): AddresstypeRow = { SQL"""insert into "person"."addresstype"("addresstypeid", "name", "rowguid", "modifieddate") diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/person/addresstype/AddresstypeRepoMock.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/person/addresstype/AddresstypeRepoMock.scala index 1b15838bc..15a02f957 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/person/addresstype/AddresstypeRepoMock.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/person/addresstype/AddresstypeRepoMock.scala @@ -74,13 +74,10 @@ class AddresstypeRepoMock(toRow: Function1[AddresstypeRowUnsaved, AddresstypeRow override def update: UpdateBuilder[AddresstypeFields, AddresstypeRow] = { UpdateBuilderMock(UpdateParams.empty, AddresstypeFields.structure, map) } - override def update(row: AddresstypeRow)(implicit c: Connection): Boolean = { - map.get(row.addresstypeid) match { - case Some(`row`) => false - case Some(_) => - map.put(row.addresstypeid, row): @nowarn - true - case None => false + override def update(row: AddresstypeRow)(implicit c: Connection): Option[AddresstypeRow] = { + map.get(row.addresstypeid).map { _ => + map.put(row.addresstypeid, row): @nowarn + row } } override def upsert(unsaved: AddresstypeRow)(implicit c: Connection): AddresstypeRow = { diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/person/businessentity/BusinessentityRepo.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/person/businessentity/BusinessentityRepo.scala index b77437aac..62f226227 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/person/businessentity/BusinessentityRepo.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/person/businessentity/BusinessentityRepo.scala @@ -27,7 +27,7 @@ trait BusinessentityRepo { def selectByIds(businessentityids: Array[BusinessentityId])(implicit c: Connection): List[BusinessentityRow] def selectByIdsTracked(businessentityids: Array[BusinessentityId])(implicit c: Connection): Map[BusinessentityId, BusinessentityRow] def update: UpdateBuilder[BusinessentityFields, BusinessentityRow] - def update(row: BusinessentityRow)(implicit c: Connection): Boolean + def update(row: BusinessentityRow)(implicit c: Connection): Option[BusinessentityRow] def upsert(unsaved: BusinessentityRow)(implicit c: Connection): BusinessentityRow def upsertBatch(unsaved: Iterable[BusinessentityRow])(implicit c: Connection): List[BusinessentityRow] /* NOTE: this functionality is not safe if you use auto-commit mode! it runs 3 SQL statements */ diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/person/businessentity/BusinessentityRepoImpl.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/person/businessentity/BusinessentityRepoImpl.scala index 366b6a12e..cfa942d65 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/person/businessentity/BusinessentityRepoImpl.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/person/businessentity/BusinessentityRepoImpl.scala @@ -112,13 +112,14 @@ class BusinessentityRepoImpl extends BusinessentityRepo { override def update: UpdateBuilder[BusinessentityFields, BusinessentityRow] = { UpdateBuilder(""""person"."businessentity"""", BusinessentityFields.structure, BusinessentityRow.rowParser) } - override def update(row: BusinessentityRow)(implicit c: Connection): Boolean = { + override def update(row: BusinessentityRow)(implicit c: Connection): Option[BusinessentityRow] = { val businessentityid = row.businessentityid SQL"""update "person"."businessentity" set "rowguid" = ${ParameterValue(row.rowguid, null, TypoUUID.toStatement)}::uuid, "modifieddate" = ${ParameterValue(row.modifieddate, null, TypoLocalDateTime.toStatement)}::timestamp where "businessentityid" = ${ParameterValue(businessentityid, null, BusinessentityId.toStatement)} - """.executeUpdate() > 0 + returning "businessentityid", "rowguid", "modifieddate"::text + """.executeInsert(BusinessentityRow.rowParser(1).singleOpt) } override def upsert(unsaved: BusinessentityRow)(implicit c: Connection): BusinessentityRow = { SQL"""insert into "person"."businessentity"("businessentityid", "rowguid", "modifieddate") diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/person/businessentity/BusinessentityRepoMock.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/person/businessentity/BusinessentityRepoMock.scala index 8286a0f73..fb71f3caf 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/person/businessentity/BusinessentityRepoMock.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/person/businessentity/BusinessentityRepoMock.scala @@ -74,13 +74,10 @@ class BusinessentityRepoMock(toRow: Function1[BusinessentityRowUnsaved, Business override def update: UpdateBuilder[BusinessentityFields, BusinessentityRow] = { UpdateBuilderMock(UpdateParams.empty, BusinessentityFields.structure, map) } - override def update(row: BusinessentityRow)(implicit c: Connection): Boolean = { - map.get(row.businessentityid) match { - case Some(`row`) => false - case Some(_) => - map.put(row.businessentityid, row): @nowarn - true - case None => false + override def update(row: BusinessentityRow)(implicit c: Connection): Option[BusinessentityRow] = { + map.get(row.businessentityid).map { _ => + map.put(row.businessentityid, row): @nowarn + row } } override def upsert(unsaved: BusinessentityRow)(implicit c: Connection): BusinessentityRow = { diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/person/businessentityaddress/BusinessentityaddressRepo.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/person/businessentityaddress/BusinessentityaddressRepo.scala index 6a659700b..75312cbf9 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/person/businessentityaddress/BusinessentityaddressRepo.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/person/businessentityaddress/BusinessentityaddressRepo.scala @@ -27,7 +27,7 @@ trait BusinessentityaddressRepo { def selectByIds(compositeIds: Array[BusinessentityaddressId])(implicit c: Connection): List[BusinessentityaddressRow] def selectByIdsTracked(compositeIds: Array[BusinessentityaddressId])(implicit c: Connection): Map[BusinessentityaddressId, BusinessentityaddressRow] def update: UpdateBuilder[BusinessentityaddressFields, BusinessentityaddressRow] - def update(row: BusinessentityaddressRow)(implicit c: Connection): Boolean + def update(row: BusinessentityaddressRow)(implicit c: Connection): Option[BusinessentityaddressRow] def upsert(unsaved: BusinessentityaddressRow)(implicit c: Connection): BusinessentityaddressRow def upsertBatch(unsaved: Iterable[BusinessentityaddressRow])(implicit c: Connection): List[BusinessentityaddressRow] /* NOTE: this functionality is not safe if you use auto-commit mode! it runs 3 SQL statements */ diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/person/businessentityaddress/BusinessentityaddressRepoImpl.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/person/businessentityaddress/BusinessentityaddressRepoImpl.scala index 43ae2488c..51b1ae37d 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/person/businessentityaddress/BusinessentityaddressRepoImpl.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/person/businessentityaddress/BusinessentityaddressRepoImpl.scala @@ -110,7 +110,7 @@ class BusinessentityaddressRepoImpl extends BusinessentityaddressRepo { val addresstypeid = compositeIds.map(_.addresstypeid) SQL"""select "businessentityid", "addressid", "addresstypeid", "rowguid", "modifieddate"::text from "person"."businessentityaddress" - where ("businessentityid", "addressid", "addresstypeid") + where ("businessentityid", "addressid", "addresstypeid") in (select unnest(${businessentityid}), unnest(${addressid}), unnest(${addresstypeid})) """.as(BusinessentityaddressRow.rowParser(1).*) @@ -122,13 +122,14 @@ class BusinessentityaddressRepoImpl extends BusinessentityaddressRepo { override def update: UpdateBuilder[BusinessentityaddressFields, BusinessentityaddressRow] = { UpdateBuilder(""""person"."businessentityaddress"""", BusinessentityaddressFields.structure, BusinessentityaddressRow.rowParser) } - override def update(row: BusinessentityaddressRow)(implicit c: Connection): Boolean = { + override def update(row: BusinessentityaddressRow)(implicit c: Connection): Option[BusinessentityaddressRow] = { val compositeId = row.compositeId SQL"""update "person"."businessentityaddress" set "rowguid" = ${ParameterValue(row.rowguid, null, TypoUUID.toStatement)}::uuid, "modifieddate" = ${ParameterValue(row.modifieddate, null, TypoLocalDateTime.toStatement)}::timestamp where "businessentityid" = ${ParameterValue(compositeId.businessentityid, null, BusinessentityId.toStatement)} AND "addressid" = ${ParameterValue(compositeId.addressid, null, AddressId.toStatement)} AND "addresstypeid" = ${ParameterValue(compositeId.addresstypeid, null, AddresstypeId.toStatement)} - """.executeUpdate() > 0 + returning "businessentityid", "addressid", "addresstypeid", "rowguid", "modifieddate"::text + """.executeInsert(BusinessentityaddressRow.rowParser(1).singleOpt) } override def upsert(unsaved: BusinessentityaddressRow)(implicit c: Connection): BusinessentityaddressRow = { SQL"""insert into "person"."businessentityaddress"("businessentityid", "addressid", "addresstypeid", "rowguid", "modifieddate") diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/person/businessentityaddress/BusinessentityaddressRepoMock.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/person/businessentityaddress/BusinessentityaddressRepoMock.scala index b80a3e4fe..da3eb4654 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/person/businessentityaddress/BusinessentityaddressRepoMock.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/person/businessentityaddress/BusinessentityaddressRepoMock.scala @@ -74,13 +74,10 @@ class BusinessentityaddressRepoMock(toRow: Function1[BusinessentityaddressRowUns override def update: UpdateBuilder[BusinessentityaddressFields, BusinessentityaddressRow] = { UpdateBuilderMock(UpdateParams.empty, BusinessentityaddressFields.structure, map) } - override def update(row: BusinessentityaddressRow)(implicit c: Connection): Boolean = { - map.get(row.compositeId) match { - case Some(`row`) => false - case Some(_) => - map.put(row.compositeId, row): @nowarn - true - case None => false + override def update(row: BusinessentityaddressRow)(implicit c: Connection): Option[BusinessentityaddressRow] = { + map.get(row.compositeId).map { _ => + map.put(row.compositeId, row): @nowarn + row } } override def upsert(unsaved: BusinessentityaddressRow)(implicit c: Connection): BusinessentityaddressRow = { diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/person/businessentitycontact/BusinessentitycontactRepo.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/person/businessentitycontact/BusinessentitycontactRepo.scala index 38734e4d7..ab927ce72 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/person/businessentitycontact/BusinessentitycontactRepo.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/person/businessentitycontact/BusinessentitycontactRepo.scala @@ -27,7 +27,7 @@ trait BusinessentitycontactRepo { def selectByIds(compositeIds: Array[BusinessentitycontactId])(implicit c: Connection): List[BusinessentitycontactRow] def selectByIdsTracked(compositeIds: Array[BusinessentitycontactId])(implicit c: Connection): Map[BusinessentitycontactId, BusinessentitycontactRow] def update: UpdateBuilder[BusinessentitycontactFields, BusinessentitycontactRow] - def update(row: BusinessentitycontactRow)(implicit c: Connection): Boolean + def update(row: BusinessentitycontactRow)(implicit c: Connection): Option[BusinessentitycontactRow] def upsert(unsaved: BusinessentitycontactRow)(implicit c: Connection): BusinessentitycontactRow def upsertBatch(unsaved: Iterable[BusinessentitycontactRow])(implicit c: Connection): List[BusinessentitycontactRow] /* NOTE: this functionality is not safe if you use auto-commit mode! it runs 3 SQL statements */ diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/person/businessentitycontact/BusinessentitycontactRepoImpl.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/person/businessentitycontact/BusinessentitycontactRepoImpl.scala index 307c96bf2..bf88ffa27 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/person/businessentitycontact/BusinessentitycontactRepoImpl.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/person/businessentitycontact/BusinessentitycontactRepoImpl.scala @@ -109,7 +109,7 @@ class BusinessentitycontactRepoImpl extends BusinessentitycontactRepo { val contacttypeid = compositeIds.map(_.contacttypeid) SQL"""select "businessentityid", "personid", "contacttypeid", "rowguid", "modifieddate"::text from "person"."businessentitycontact" - where ("businessentityid", "personid", "contacttypeid") + where ("businessentityid", "personid", "contacttypeid") in (select unnest(${businessentityid}), unnest(${personid}), unnest(${contacttypeid})) """.as(BusinessentitycontactRow.rowParser(1).*) @@ -121,13 +121,14 @@ class BusinessentitycontactRepoImpl extends BusinessentitycontactRepo { override def update: UpdateBuilder[BusinessentitycontactFields, BusinessentitycontactRow] = { UpdateBuilder(""""person"."businessentitycontact"""", BusinessentitycontactFields.structure, BusinessentitycontactRow.rowParser) } - override def update(row: BusinessentitycontactRow)(implicit c: Connection): Boolean = { + override def update(row: BusinessentitycontactRow)(implicit c: Connection): Option[BusinessentitycontactRow] = { val compositeId = row.compositeId SQL"""update "person"."businessentitycontact" set "rowguid" = ${ParameterValue(row.rowguid, null, TypoUUID.toStatement)}::uuid, "modifieddate" = ${ParameterValue(row.modifieddate, null, TypoLocalDateTime.toStatement)}::timestamp where "businessentityid" = ${ParameterValue(compositeId.businessentityid, null, BusinessentityId.toStatement)} AND "personid" = ${ParameterValue(compositeId.personid, null, BusinessentityId.toStatement)} AND "contacttypeid" = ${ParameterValue(compositeId.contacttypeid, null, ContacttypeId.toStatement)} - """.executeUpdate() > 0 + returning "businessentityid", "personid", "contacttypeid", "rowguid", "modifieddate"::text + """.executeInsert(BusinessentitycontactRow.rowParser(1).singleOpt) } override def upsert(unsaved: BusinessentitycontactRow)(implicit c: Connection): BusinessentitycontactRow = { SQL"""insert into "person"."businessentitycontact"("businessentityid", "personid", "contacttypeid", "rowguid", "modifieddate") diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/person/businessentitycontact/BusinessentitycontactRepoMock.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/person/businessentitycontact/BusinessentitycontactRepoMock.scala index c8611d5d4..803d93aa5 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/person/businessentitycontact/BusinessentitycontactRepoMock.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/person/businessentitycontact/BusinessentitycontactRepoMock.scala @@ -74,13 +74,10 @@ class BusinessentitycontactRepoMock(toRow: Function1[BusinessentitycontactRowUns override def update: UpdateBuilder[BusinessentitycontactFields, BusinessentitycontactRow] = { UpdateBuilderMock(UpdateParams.empty, BusinessentitycontactFields.structure, map) } - override def update(row: BusinessentitycontactRow)(implicit c: Connection): Boolean = { - map.get(row.compositeId) match { - case Some(`row`) => false - case Some(_) => - map.put(row.compositeId, row): @nowarn - true - case None => false + override def update(row: BusinessentitycontactRow)(implicit c: Connection): Option[BusinessentitycontactRow] = { + map.get(row.compositeId).map { _ => + map.put(row.compositeId, row): @nowarn + row } } override def upsert(unsaved: BusinessentitycontactRow)(implicit c: Connection): BusinessentitycontactRow = { diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/person/contacttype/ContacttypeRepo.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/person/contacttype/ContacttypeRepo.scala index 8feeadef9..13fad8e98 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/person/contacttype/ContacttypeRepo.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/person/contacttype/ContacttypeRepo.scala @@ -27,7 +27,7 @@ trait ContacttypeRepo { def selectByIds(contacttypeids: Array[ContacttypeId])(implicit c: Connection): List[ContacttypeRow] def selectByIdsTracked(contacttypeids: Array[ContacttypeId])(implicit c: Connection): Map[ContacttypeId, ContacttypeRow] def update: UpdateBuilder[ContacttypeFields, ContacttypeRow] - def update(row: ContacttypeRow)(implicit c: Connection): Boolean + def update(row: ContacttypeRow)(implicit c: Connection): Option[ContacttypeRow] def upsert(unsaved: ContacttypeRow)(implicit c: Connection): ContacttypeRow def upsertBatch(unsaved: Iterable[ContacttypeRow])(implicit c: Connection): List[ContacttypeRow] /* NOTE: this functionality is not safe if you use auto-commit mode! it runs 3 SQL statements */ diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/person/contacttype/ContacttypeRepoImpl.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/person/contacttype/ContacttypeRepoImpl.scala index 290af31fb..1c958348f 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/person/contacttype/ContacttypeRepoImpl.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/person/contacttype/ContacttypeRepoImpl.scala @@ -109,13 +109,14 @@ class ContacttypeRepoImpl extends ContacttypeRepo { override def update: UpdateBuilder[ContacttypeFields, ContacttypeRow] = { UpdateBuilder(""""person"."contacttype"""", ContacttypeFields.structure, ContacttypeRow.rowParser) } - override def update(row: ContacttypeRow)(implicit c: Connection): Boolean = { + override def update(row: ContacttypeRow)(implicit c: Connection): Option[ContacttypeRow] = { val contacttypeid = row.contacttypeid SQL"""update "person"."contacttype" set "name" = ${ParameterValue(row.name, null, Name.toStatement)}::varchar, "modifieddate" = ${ParameterValue(row.modifieddate, null, TypoLocalDateTime.toStatement)}::timestamp where "contacttypeid" = ${ParameterValue(contacttypeid, null, ContacttypeId.toStatement)} - """.executeUpdate() > 0 + returning "contacttypeid", "name", "modifieddate"::text + """.executeInsert(ContacttypeRow.rowParser(1).singleOpt) } override def upsert(unsaved: ContacttypeRow)(implicit c: Connection): ContacttypeRow = { SQL"""insert into "person"."contacttype"("contacttypeid", "name", "modifieddate") diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/person/contacttype/ContacttypeRepoMock.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/person/contacttype/ContacttypeRepoMock.scala index bc9949089..c7bac906d 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/person/contacttype/ContacttypeRepoMock.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/person/contacttype/ContacttypeRepoMock.scala @@ -74,13 +74,10 @@ class ContacttypeRepoMock(toRow: Function1[ContacttypeRowUnsaved, ContacttypeRow override def update: UpdateBuilder[ContacttypeFields, ContacttypeRow] = { UpdateBuilderMock(UpdateParams.empty, ContacttypeFields.structure, map) } - override def update(row: ContacttypeRow)(implicit c: Connection): Boolean = { - map.get(row.contacttypeid) match { - case Some(`row`) => false - case Some(_) => - map.put(row.contacttypeid, row): @nowarn - true - case None => false + override def update(row: ContacttypeRow)(implicit c: Connection): Option[ContacttypeRow] = { + map.get(row.contacttypeid).map { _ => + map.put(row.contacttypeid, row): @nowarn + row } } override def upsert(unsaved: ContacttypeRow)(implicit c: Connection): ContacttypeRow = { diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/person/countryregion/CountryregionRepo.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/person/countryregion/CountryregionRepo.scala index 42d88560f..23998e17c 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/person/countryregion/CountryregionRepo.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/person/countryregion/CountryregionRepo.scala @@ -27,7 +27,7 @@ trait CountryregionRepo { def selectByIds(countryregioncodes: Array[CountryregionId])(implicit c: Connection): List[CountryregionRow] def selectByIdsTracked(countryregioncodes: Array[CountryregionId])(implicit c: Connection): Map[CountryregionId, CountryregionRow] def update: UpdateBuilder[CountryregionFields, CountryregionRow] - def update(row: CountryregionRow)(implicit c: Connection): Boolean + def update(row: CountryregionRow)(implicit c: Connection): Option[CountryregionRow] def upsert(unsaved: CountryregionRow)(implicit c: Connection): CountryregionRow def upsertBatch(unsaved: Iterable[CountryregionRow])(implicit c: Connection): List[CountryregionRow] /* NOTE: this functionality is not safe if you use auto-commit mode! it runs 3 SQL statements */ diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/person/countryregion/CountryregionRepoImpl.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/person/countryregion/CountryregionRepoImpl.scala index d0ed0659a..4f3e7b358 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/person/countryregion/CountryregionRepoImpl.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/person/countryregion/CountryregionRepoImpl.scala @@ -106,13 +106,14 @@ class CountryregionRepoImpl extends CountryregionRepo { override def update: UpdateBuilder[CountryregionFields, CountryregionRow] = { UpdateBuilder(""""person"."countryregion"""", CountryregionFields.structure, CountryregionRow.rowParser) } - override def update(row: CountryregionRow)(implicit c: Connection): Boolean = { + override def update(row: CountryregionRow)(implicit c: Connection): Option[CountryregionRow] = { val countryregioncode = row.countryregioncode SQL"""update "person"."countryregion" set "name" = ${ParameterValue(row.name, null, Name.toStatement)}::varchar, "modifieddate" = ${ParameterValue(row.modifieddate, null, TypoLocalDateTime.toStatement)}::timestamp where "countryregioncode" = ${ParameterValue(countryregioncode, null, CountryregionId.toStatement)} - """.executeUpdate() > 0 + returning "countryregioncode", "name", "modifieddate"::text + """.executeInsert(CountryregionRow.rowParser(1).singleOpt) } override def upsert(unsaved: CountryregionRow)(implicit c: Connection): CountryregionRow = { SQL"""insert into "person"."countryregion"("countryregioncode", "name", "modifieddate") diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/person/countryregion/CountryregionRepoMock.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/person/countryregion/CountryregionRepoMock.scala index 0be599f48..ec86368ad 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/person/countryregion/CountryregionRepoMock.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/person/countryregion/CountryregionRepoMock.scala @@ -74,13 +74,10 @@ class CountryregionRepoMock(toRow: Function1[CountryregionRowUnsaved, Countryreg override def update: UpdateBuilder[CountryregionFields, CountryregionRow] = { UpdateBuilderMock(UpdateParams.empty, CountryregionFields.structure, map) } - override def update(row: CountryregionRow)(implicit c: Connection): Boolean = { - map.get(row.countryregioncode) match { - case Some(`row`) => false - case Some(_) => - map.put(row.countryregioncode, row): @nowarn - true - case None => false + override def update(row: CountryregionRow)(implicit c: Connection): Option[CountryregionRow] = { + map.get(row.countryregioncode).map { _ => + map.put(row.countryregioncode, row): @nowarn + row } } override def upsert(unsaved: CountryregionRow)(implicit c: Connection): CountryregionRow = { diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/person/emailaddress/EmailaddressRepo.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/person/emailaddress/EmailaddressRepo.scala index 1cdd9bf29..5fb1cf850 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/person/emailaddress/EmailaddressRepo.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/person/emailaddress/EmailaddressRepo.scala @@ -27,7 +27,7 @@ trait EmailaddressRepo { def selectByIds(compositeIds: Array[EmailaddressId])(implicit c: Connection): List[EmailaddressRow] def selectByIdsTracked(compositeIds: Array[EmailaddressId])(implicit c: Connection): Map[EmailaddressId, EmailaddressRow] def update: UpdateBuilder[EmailaddressFields, EmailaddressRow] - def update(row: EmailaddressRow)(implicit c: Connection): Boolean + def update(row: EmailaddressRow)(implicit c: Connection): Option[EmailaddressRow] def upsert(unsaved: EmailaddressRow)(implicit c: Connection): EmailaddressRow def upsertBatch(unsaved: Iterable[EmailaddressRow])(implicit c: Connection): List[EmailaddressRow] /* NOTE: this functionality is not safe if you use auto-commit mode! it runs 3 SQL statements */ diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/person/emailaddress/EmailaddressRepoImpl.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/person/emailaddress/EmailaddressRepoImpl.scala index 81f398ba5..e4494ab52 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/person/emailaddress/EmailaddressRepoImpl.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/person/emailaddress/EmailaddressRepoImpl.scala @@ -111,7 +111,7 @@ class EmailaddressRepoImpl extends EmailaddressRepo { val emailaddressid = compositeIds.map(_.emailaddressid) SQL"""select "businessentityid", "emailaddressid", "emailaddress", "rowguid", "modifieddate"::text from "person"."emailaddress" - where ("businessentityid", "emailaddressid") + where ("businessentityid", "emailaddressid") in (select unnest(${businessentityid}), unnest(${emailaddressid})) """.as(EmailaddressRow.rowParser(1).*) @@ -123,14 +123,15 @@ class EmailaddressRepoImpl extends EmailaddressRepo { override def update: UpdateBuilder[EmailaddressFields, EmailaddressRow] = { UpdateBuilder(""""person"."emailaddress"""", EmailaddressFields.structure, EmailaddressRow.rowParser) } - override def update(row: EmailaddressRow)(implicit c: Connection): Boolean = { + override def update(row: EmailaddressRow)(implicit c: Connection): Option[EmailaddressRow] = { val compositeId = row.compositeId SQL"""update "person"."emailaddress" set "emailaddress" = ${ParameterValue(row.emailaddress, null, ToStatement.optionToStatement(ToStatement.stringToStatement, ParameterMetaData.StringParameterMetaData))}, "rowguid" = ${ParameterValue(row.rowguid, null, TypoUUID.toStatement)}::uuid, "modifieddate" = ${ParameterValue(row.modifieddate, null, TypoLocalDateTime.toStatement)}::timestamp where "businessentityid" = ${ParameterValue(compositeId.businessentityid, null, BusinessentityId.toStatement)} AND "emailaddressid" = ${ParameterValue(compositeId.emailaddressid, null, ToStatement.intToStatement)} - """.executeUpdate() > 0 + returning "businessentityid", "emailaddressid", "emailaddress", "rowguid", "modifieddate"::text + """.executeInsert(EmailaddressRow.rowParser(1).singleOpt) } override def upsert(unsaved: EmailaddressRow)(implicit c: Connection): EmailaddressRow = { SQL"""insert into "person"."emailaddress"("businessentityid", "emailaddressid", "emailaddress", "rowguid", "modifieddate") diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/person/emailaddress/EmailaddressRepoMock.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/person/emailaddress/EmailaddressRepoMock.scala index 75b2f9a0b..d09296fba 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/person/emailaddress/EmailaddressRepoMock.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/person/emailaddress/EmailaddressRepoMock.scala @@ -74,13 +74,10 @@ class EmailaddressRepoMock(toRow: Function1[EmailaddressRowUnsaved, Emailaddress override def update: UpdateBuilder[EmailaddressFields, EmailaddressRow] = { UpdateBuilderMock(UpdateParams.empty, EmailaddressFields.structure, map) } - override def update(row: EmailaddressRow)(implicit c: Connection): Boolean = { - map.get(row.compositeId) match { - case Some(`row`) => false - case Some(_) => - map.put(row.compositeId, row): @nowarn - true - case None => false + override def update(row: EmailaddressRow)(implicit c: Connection): Option[EmailaddressRow] = { + map.get(row.compositeId).map { _ => + map.put(row.compositeId, row): @nowarn + row } } override def upsert(unsaved: EmailaddressRow)(implicit c: Connection): EmailaddressRow = { diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/person/password/PasswordRepo.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/person/password/PasswordRepo.scala index 23708ec43..b958470c2 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/person/password/PasswordRepo.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/person/password/PasswordRepo.scala @@ -28,7 +28,7 @@ trait PasswordRepo { def selectByIds(businessentityids: Array[BusinessentityId])(implicit c: Connection): List[PasswordRow] def selectByIdsTracked(businessentityids: Array[BusinessentityId])(implicit c: Connection): Map[BusinessentityId, PasswordRow] def update: UpdateBuilder[PasswordFields, PasswordRow] - def update(row: PasswordRow)(implicit c: Connection): Boolean + def update(row: PasswordRow)(implicit c: Connection): Option[PasswordRow] def upsert(unsaved: PasswordRow)(implicit c: Connection): PasswordRow def upsertBatch(unsaved: Iterable[PasswordRow])(implicit c: Connection): List[PasswordRow] /* NOTE: this functionality is not safe if you use auto-commit mode! it runs 3 SQL statements */ diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/person/password/PasswordRepoImpl.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/person/password/PasswordRepoImpl.scala index 2a2b5ed30..d4a9b26b1 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/person/password/PasswordRepoImpl.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/person/password/PasswordRepoImpl.scala @@ -113,7 +113,7 @@ class PasswordRepoImpl extends PasswordRepo { override def update: UpdateBuilder[PasswordFields, PasswordRow] = { UpdateBuilder(""""person"."password"""", PasswordFields.structure, PasswordRow.rowParser) } - override def update(row: PasswordRow)(implicit c: Connection): Boolean = { + override def update(row: PasswordRow)(implicit c: Connection): Option[PasswordRow] = { val businessentityid = row.businessentityid SQL"""update "person"."password" set "passwordhash" = ${ParameterValue(row.passwordhash, null, ToStatement.stringToStatement)}, @@ -121,7 +121,8 @@ class PasswordRepoImpl extends PasswordRepo { "rowguid" = ${ParameterValue(row.rowguid, null, TypoUUID.toStatement)}::uuid, "modifieddate" = ${ParameterValue(row.modifieddate, null, TypoLocalDateTime.toStatement)}::timestamp where "businessentityid" = ${ParameterValue(businessentityid, null, BusinessentityId.toStatement)} - """.executeUpdate() > 0 + returning "businessentityid", "passwordhash", "passwordsalt", "rowguid", "modifieddate"::text + """.executeInsert(PasswordRow.rowParser(1).singleOpt) } override def upsert(unsaved: PasswordRow)(implicit c: Connection): PasswordRow = { SQL"""insert into "person"."password"("businessentityid", "passwordhash", "passwordsalt", "rowguid", "modifieddate") diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/person/password/PasswordRepoMock.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/person/password/PasswordRepoMock.scala index c4a75b3b1..7a10decbb 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/person/password/PasswordRepoMock.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/person/password/PasswordRepoMock.scala @@ -75,13 +75,10 @@ class PasswordRepoMock(toRow: Function1[PasswordRowUnsaved, PasswordRow], override def update: UpdateBuilder[PasswordFields, PasswordRow] = { UpdateBuilderMock(UpdateParams.empty, PasswordFields.structure, map) } - override def update(row: PasswordRow)(implicit c: Connection): Boolean = { - map.get(row.businessentityid) match { - case Some(`row`) => false - case Some(_) => - map.put(row.businessentityid, row): @nowarn - true - case None => false + override def update(row: PasswordRow)(implicit c: Connection): Option[PasswordRow] = { + map.get(row.businessentityid).map { _ => + map.put(row.businessentityid, row): @nowarn + row } } override def upsert(unsaved: PasswordRow)(implicit c: Connection): PasswordRow = { diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/person/person/PersonRepo.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/person/person/PersonRepo.scala index cb6c61d72..c70e277c6 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/person/person/PersonRepo.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/person/person/PersonRepo.scala @@ -28,7 +28,7 @@ trait PersonRepo { def selectByIds(businessentityids: Array[BusinessentityId])(implicit c: Connection): List[PersonRow] def selectByIdsTracked(businessentityids: Array[BusinessentityId])(implicit c: Connection): Map[BusinessentityId, PersonRow] def update: UpdateBuilder[PersonFields, PersonRow] - def update(row: PersonRow)(implicit c: Connection): Boolean + def update(row: PersonRow)(implicit c: Connection): Option[PersonRow] def upsert(unsaved: PersonRow)(implicit c: Connection): PersonRow def upsertBatch(unsaved: Iterable[PersonRow])(implicit c: Connection): List[PersonRow] /* NOTE: this functionality is not safe if you use auto-commit mode! it runs 3 SQL statements */ diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/person/person/PersonRepoImpl.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/person/person/PersonRepoImpl.scala index a7c4d1136..969646b8b 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/person/person/PersonRepoImpl.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/person/person/PersonRepoImpl.scala @@ -132,7 +132,7 @@ class PersonRepoImpl extends PersonRepo { override def update: UpdateBuilder[PersonFields, PersonRow] = { UpdateBuilder(""""person"."person"""", PersonFields.structure, PersonRow.rowParser) } - override def update(row: PersonRow)(implicit c: Connection): Boolean = { + override def update(row: PersonRow)(implicit c: Connection): Option[PersonRow] = { val businessentityid = row.businessentityid SQL"""update "person"."person" set "persontype" = ${ParameterValue(row.persontype, null, ToStatement.stringToStatement)}::bpchar, @@ -148,7 +148,8 @@ class PersonRepoImpl extends PersonRepo { "rowguid" = ${ParameterValue(row.rowguid, null, TypoUUID.toStatement)}::uuid, "modifieddate" = ${ParameterValue(row.modifieddate, null, TypoLocalDateTime.toStatement)}::timestamp where "businessentityid" = ${ParameterValue(businessentityid, null, BusinessentityId.toStatement)} - """.executeUpdate() > 0 + returning "businessentityid", "persontype", "namestyle", "title", "firstname", "middlename", "lastname", "suffix", "emailpromotion", "additionalcontactinfo", "demographics", "rowguid", "modifieddate"::text + """.executeInsert(PersonRow.rowParser(1).singleOpt) } override def upsert(unsaved: PersonRow)(implicit c: Connection): PersonRow = { SQL"""insert into "person"."person"("businessentityid", "persontype", "namestyle", "title", "firstname", "middlename", "lastname", "suffix", "emailpromotion", "additionalcontactinfo", "demographics", "rowguid", "modifieddate") diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/person/person/PersonRepoMock.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/person/person/PersonRepoMock.scala index da4f66c04..708bfdad0 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/person/person/PersonRepoMock.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/person/person/PersonRepoMock.scala @@ -75,13 +75,10 @@ class PersonRepoMock(toRow: Function1[PersonRowUnsaved, PersonRow], override def update: UpdateBuilder[PersonFields, PersonRow] = { UpdateBuilderMock(UpdateParams.empty, PersonFields.structure, map) } - override def update(row: PersonRow)(implicit c: Connection): Boolean = { - map.get(row.businessentityid) match { - case Some(`row`) => false - case Some(_) => - map.put(row.businessentityid, row): @nowarn - true - case None => false + override def update(row: PersonRow)(implicit c: Connection): Option[PersonRow] = { + map.get(row.businessentityid).map { _ => + map.put(row.businessentityid, row): @nowarn + row } } override def upsert(unsaved: PersonRow)(implicit c: Connection): PersonRow = { diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/person/personphone/PersonphoneRepo.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/person/personphone/PersonphoneRepo.scala index 742f73178..95eb7e3d2 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/person/personphone/PersonphoneRepo.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/person/personphone/PersonphoneRepo.scala @@ -27,7 +27,7 @@ trait PersonphoneRepo { def selectByIds(compositeIds: Array[PersonphoneId])(implicit c: Connection): List[PersonphoneRow] def selectByIdsTracked(compositeIds: Array[PersonphoneId])(implicit c: Connection): Map[PersonphoneId, PersonphoneRow] def update: UpdateBuilder[PersonphoneFields, PersonphoneRow] - def update(row: PersonphoneRow)(implicit c: Connection): Boolean + def update(row: PersonphoneRow)(implicit c: Connection): Option[PersonphoneRow] def upsert(unsaved: PersonphoneRow)(implicit c: Connection): PersonphoneRow def upsertBatch(unsaved: Iterable[PersonphoneRow])(implicit c: Connection): List[PersonphoneRow] /* NOTE: this functionality is not safe if you use auto-commit mode! it runs 3 SQL statements */ diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/person/personphone/PersonphoneRepoImpl.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/person/personphone/PersonphoneRepoImpl.scala index d3c32d9e4..fa82514ff 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/person/personphone/PersonphoneRepoImpl.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/person/personphone/PersonphoneRepoImpl.scala @@ -105,7 +105,7 @@ class PersonphoneRepoImpl extends PersonphoneRepo { val phonenumbertypeid = compositeIds.map(_.phonenumbertypeid) SQL"""select "businessentityid", "phonenumber", "phonenumbertypeid", "modifieddate"::text from "person"."personphone" - where ("businessentityid", "phonenumber", "phonenumbertypeid") + where ("businessentityid", "phonenumber", "phonenumbertypeid") in (select unnest(${businessentityid}), unnest(${phonenumber}), unnest(${phonenumbertypeid})) """.as(PersonphoneRow.rowParser(1).*) @@ -117,12 +117,13 @@ class PersonphoneRepoImpl extends PersonphoneRepo { override def update: UpdateBuilder[PersonphoneFields, PersonphoneRow] = { UpdateBuilder(""""person"."personphone"""", PersonphoneFields.structure, PersonphoneRow.rowParser) } - override def update(row: PersonphoneRow)(implicit c: Connection): Boolean = { + override def update(row: PersonphoneRow)(implicit c: Connection): Option[PersonphoneRow] = { val compositeId = row.compositeId SQL"""update "person"."personphone" set "modifieddate" = ${ParameterValue(row.modifieddate, null, TypoLocalDateTime.toStatement)}::timestamp where "businessentityid" = ${ParameterValue(compositeId.businessentityid, null, BusinessentityId.toStatement)} AND "phonenumber" = ${ParameterValue(compositeId.phonenumber, null, Phone.toStatement)} AND "phonenumbertypeid" = ${ParameterValue(compositeId.phonenumbertypeid, null, PhonenumbertypeId.toStatement)} - """.executeUpdate() > 0 + returning "businessentityid", "phonenumber", "phonenumbertypeid", "modifieddate"::text + """.executeInsert(PersonphoneRow.rowParser(1).singleOpt) } override def upsert(unsaved: PersonphoneRow)(implicit c: Connection): PersonphoneRow = { SQL"""insert into "person"."personphone"("businessentityid", "phonenumber", "phonenumbertypeid", "modifieddate") diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/person/personphone/PersonphoneRepoMock.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/person/personphone/PersonphoneRepoMock.scala index ed12d4df3..a7385ac26 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/person/personphone/PersonphoneRepoMock.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/person/personphone/PersonphoneRepoMock.scala @@ -74,13 +74,10 @@ class PersonphoneRepoMock(toRow: Function1[PersonphoneRowUnsaved, PersonphoneRow override def update: UpdateBuilder[PersonphoneFields, PersonphoneRow] = { UpdateBuilderMock(UpdateParams.empty, PersonphoneFields.structure, map) } - override def update(row: PersonphoneRow)(implicit c: Connection): Boolean = { - map.get(row.compositeId) match { - case Some(`row`) => false - case Some(_) => - map.put(row.compositeId, row): @nowarn - true - case None => false + override def update(row: PersonphoneRow)(implicit c: Connection): Option[PersonphoneRow] = { + map.get(row.compositeId).map { _ => + map.put(row.compositeId, row): @nowarn + row } } override def upsert(unsaved: PersonphoneRow)(implicit c: Connection): PersonphoneRow = { diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/person/phonenumbertype/PhonenumbertypeRepo.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/person/phonenumbertype/PhonenumbertypeRepo.scala index 1d49582a9..725ec5b96 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/person/phonenumbertype/PhonenumbertypeRepo.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/person/phonenumbertype/PhonenumbertypeRepo.scala @@ -27,7 +27,7 @@ trait PhonenumbertypeRepo { def selectByIds(phonenumbertypeids: Array[PhonenumbertypeId])(implicit c: Connection): List[PhonenumbertypeRow] def selectByIdsTracked(phonenumbertypeids: Array[PhonenumbertypeId])(implicit c: Connection): Map[PhonenumbertypeId, PhonenumbertypeRow] def update: UpdateBuilder[PhonenumbertypeFields, PhonenumbertypeRow] - def update(row: PhonenumbertypeRow)(implicit c: Connection): Boolean + def update(row: PhonenumbertypeRow)(implicit c: Connection): Option[PhonenumbertypeRow] def upsert(unsaved: PhonenumbertypeRow)(implicit c: Connection): PhonenumbertypeRow def upsertBatch(unsaved: Iterable[PhonenumbertypeRow])(implicit c: Connection): List[PhonenumbertypeRow] /* NOTE: this functionality is not safe if you use auto-commit mode! it runs 3 SQL statements */ diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/person/phonenumbertype/PhonenumbertypeRepoImpl.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/person/phonenumbertype/PhonenumbertypeRepoImpl.scala index 8bdf1c132..27a5259b3 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/person/phonenumbertype/PhonenumbertypeRepoImpl.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/person/phonenumbertype/PhonenumbertypeRepoImpl.scala @@ -109,13 +109,14 @@ class PhonenumbertypeRepoImpl extends PhonenumbertypeRepo { override def update: UpdateBuilder[PhonenumbertypeFields, PhonenumbertypeRow] = { UpdateBuilder(""""person"."phonenumbertype"""", PhonenumbertypeFields.structure, PhonenumbertypeRow.rowParser) } - override def update(row: PhonenumbertypeRow)(implicit c: Connection): Boolean = { + override def update(row: PhonenumbertypeRow)(implicit c: Connection): Option[PhonenumbertypeRow] = { val phonenumbertypeid = row.phonenumbertypeid SQL"""update "person"."phonenumbertype" set "name" = ${ParameterValue(row.name, null, Name.toStatement)}::varchar, "modifieddate" = ${ParameterValue(row.modifieddate, null, TypoLocalDateTime.toStatement)}::timestamp where "phonenumbertypeid" = ${ParameterValue(phonenumbertypeid, null, PhonenumbertypeId.toStatement)} - """.executeUpdate() > 0 + returning "phonenumbertypeid", "name", "modifieddate"::text + """.executeInsert(PhonenumbertypeRow.rowParser(1).singleOpt) } override def upsert(unsaved: PhonenumbertypeRow)(implicit c: Connection): PhonenumbertypeRow = { SQL"""insert into "person"."phonenumbertype"("phonenumbertypeid", "name", "modifieddate") diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/person/phonenumbertype/PhonenumbertypeRepoMock.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/person/phonenumbertype/PhonenumbertypeRepoMock.scala index 3b0853dd1..752fedcac 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/person/phonenumbertype/PhonenumbertypeRepoMock.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/person/phonenumbertype/PhonenumbertypeRepoMock.scala @@ -74,13 +74,10 @@ class PhonenumbertypeRepoMock(toRow: Function1[PhonenumbertypeRowUnsaved, Phonen override def update: UpdateBuilder[PhonenumbertypeFields, PhonenumbertypeRow] = { UpdateBuilderMock(UpdateParams.empty, PhonenumbertypeFields.structure, map) } - override def update(row: PhonenumbertypeRow)(implicit c: Connection): Boolean = { - map.get(row.phonenumbertypeid) match { - case Some(`row`) => false - case Some(_) => - map.put(row.phonenumbertypeid, row): @nowarn - true - case None => false + override def update(row: PhonenumbertypeRow)(implicit c: Connection): Option[PhonenumbertypeRow] = { + map.get(row.phonenumbertypeid).map { _ => + map.put(row.phonenumbertypeid, row): @nowarn + row } } override def upsert(unsaved: PhonenumbertypeRow)(implicit c: Connection): PhonenumbertypeRow = { diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/person/stateprovince/StateprovinceRepo.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/person/stateprovince/StateprovinceRepo.scala index b9d836a6e..5d8e14e05 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/person/stateprovince/StateprovinceRepo.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/person/stateprovince/StateprovinceRepo.scala @@ -27,7 +27,7 @@ trait StateprovinceRepo { def selectByIds(stateprovinceids: Array[StateprovinceId])(implicit c: Connection): List[StateprovinceRow] def selectByIdsTracked(stateprovinceids: Array[StateprovinceId])(implicit c: Connection): Map[StateprovinceId, StateprovinceRow] def update: UpdateBuilder[StateprovinceFields, StateprovinceRow] - def update(row: StateprovinceRow)(implicit c: Connection): Boolean + def update(row: StateprovinceRow)(implicit c: Connection): Option[StateprovinceRow] def upsert(unsaved: StateprovinceRow)(implicit c: Connection): StateprovinceRow def upsertBatch(unsaved: Iterable[StateprovinceRow])(implicit c: Connection): List[StateprovinceRow] /* NOTE: this functionality is not safe if you use auto-commit mode! it runs 3 SQL statements */ diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/person/stateprovince/StateprovinceRepoImpl.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/person/stateprovince/StateprovinceRepoImpl.scala index 13a35b97d..dd4379164 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/person/stateprovince/StateprovinceRepoImpl.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/person/stateprovince/StateprovinceRepoImpl.scala @@ -125,7 +125,7 @@ class StateprovinceRepoImpl extends StateprovinceRepo { override def update: UpdateBuilder[StateprovinceFields, StateprovinceRow] = { UpdateBuilder(""""person"."stateprovince"""", StateprovinceFields.structure, StateprovinceRow.rowParser) } - override def update(row: StateprovinceRow)(implicit c: Connection): Boolean = { + override def update(row: StateprovinceRow)(implicit c: Connection): Option[StateprovinceRow] = { val stateprovinceid = row.stateprovinceid SQL"""update "person"."stateprovince" set "stateprovincecode" = ${ParameterValue(row.stateprovincecode, null, ToStatement.stringToStatement)}::bpchar, @@ -136,7 +136,8 @@ class StateprovinceRepoImpl extends StateprovinceRepo { "rowguid" = ${ParameterValue(row.rowguid, null, TypoUUID.toStatement)}::uuid, "modifieddate" = ${ParameterValue(row.modifieddate, null, TypoLocalDateTime.toStatement)}::timestamp where "stateprovinceid" = ${ParameterValue(stateprovinceid, null, StateprovinceId.toStatement)} - """.executeUpdate() > 0 + returning "stateprovinceid", "stateprovincecode", "countryregioncode", "isonlystateprovinceflag", "name", "territoryid", "rowguid", "modifieddate"::text + """.executeInsert(StateprovinceRow.rowParser(1).singleOpt) } override def upsert(unsaved: StateprovinceRow)(implicit c: Connection): StateprovinceRow = { SQL"""insert into "person"."stateprovince"("stateprovinceid", "stateprovincecode", "countryregioncode", "isonlystateprovinceflag", "name", "territoryid", "rowguid", "modifieddate") diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/person/stateprovince/StateprovinceRepoMock.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/person/stateprovince/StateprovinceRepoMock.scala index ad2e4cb12..b6f300b28 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/person/stateprovince/StateprovinceRepoMock.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/person/stateprovince/StateprovinceRepoMock.scala @@ -74,13 +74,10 @@ class StateprovinceRepoMock(toRow: Function1[StateprovinceRowUnsaved, Stateprovi override def update: UpdateBuilder[StateprovinceFields, StateprovinceRow] = { UpdateBuilderMock(UpdateParams.empty, StateprovinceFields.structure, map) } - override def update(row: StateprovinceRow)(implicit c: Connection): Boolean = { - map.get(row.stateprovinceid) match { - case Some(`row`) => false - case Some(_) => - map.put(row.stateprovinceid, row): @nowarn - true - case None => false + override def update(row: StateprovinceRow)(implicit c: Connection): Option[StateprovinceRow] = { + map.get(row.stateprovinceid).map { _ => + map.put(row.stateprovinceid, row): @nowarn + row } } override def upsert(unsaved: StateprovinceRow)(implicit c: Connection): StateprovinceRow = { diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/billofmaterials/BillofmaterialsRepo.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/billofmaterials/BillofmaterialsRepo.scala index e7d39a783..b103dc8ff 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/billofmaterials/BillofmaterialsRepo.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/billofmaterials/BillofmaterialsRepo.scala @@ -27,7 +27,7 @@ trait BillofmaterialsRepo { def selectByIds(billofmaterialsids: Array[Int])(implicit c: Connection): List[BillofmaterialsRow] def selectByIdsTracked(billofmaterialsids: Array[Int])(implicit c: Connection): Map[Int, BillofmaterialsRow] def update: UpdateBuilder[BillofmaterialsFields, BillofmaterialsRow] - def update(row: BillofmaterialsRow)(implicit c: Connection): Boolean + def update(row: BillofmaterialsRow)(implicit c: Connection): Option[BillofmaterialsRow] def upsert(unsaved: BillofmaterialsRow)(implicit c: Connection): BillofmaterialsRow def upsertBatch(unsaved: Iterable[BillofmaterialsRow])(implicit c: Connection): List[BillofmaterialsRow] /* NOTE: this functionality is not safe if you use auto-commit mode! it runs 3 SQL statements */ diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/billofmaterials/BillofmaterialsRepoImpl.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/billofmaterials/BillofmaterialsRepoImpl.scala index 4941a0c97..ebe32c657 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/billofmaterials/BillofmaterialsRepoImpl.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/billofmaterials/BillofmaterialsRepoImpl.scala @@ -124,7 +124,7 @@ class BillofmaterialsRepoImpl extends BillofmaterialsRepo { override def update: UpdateBuilder[BillofmaterialsFields, BillofmaterialsRow] = { UpdateBuilder(""""production"."billofmaterials"""", BillofmaterialsFields.structure, BillofmaterialsRow.rowParser) } - override def update(row: BillofmaterialsRow)(implicit c: Connection): Boolean = { + override def update(row: BillofmaterialsRow)(implicit c: Connection): Option[BillofmaterialsRow] = { val billofmaterialsid = row.billofmaterialsid SQL"""update "production"."billofmaterials" set "productassemblyid" = ${ParameterValue(row.productassemblyid, null, ToStatement.optionToStatement(ProductId.toStatement, ProductId.parameterMetadata))}::int4, @@ -136,7 +136,8 @@ class BillofmaterialsRepoImpl extends BillofmaterialsRepo { "perassemblyqty" = ${ParameterValue(row.perassemblyqty, null, ToStatement.scalaBigDecimalToStatement)}::numeric, "modifieddate" = ${ParameterValue(row.modifieddate, null, TypoLocalDateTime.toStatement)}::timestamp where "billofmaterialsid" = ${ParameterValue(billofmaterialsid, null, ToStatement.intToStatement)} - """.executeUpdate() > 0 + returning "billofmaterialsid", "productassemblyid", "componentid", "startdate"::text, "enddate"::text, "unitmeasurecode", "bomlevel", "perassemblyqty", "modifieddate"::text + """.executeInsert(BillofmaterialsRow.rowParser(1).singleOpt) } override def upsert(unsaved: BillofmaterialsRow)(implicit c: Connection): BillofmaterialsRow = { SQL"""insert into "production"."billofmaterials"("billofmaterialsid", "productassemblyid", "componentid", "startdate", "enddate", "unitmeasurecode", "bomlevel", "perassemblyqty", "modifieddate") diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/billofmaterials/BillofmaterialsRepoMock.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/billofmaterials/BillofmaterialsRepoMock.scala index a50cef175..4d8c33b93 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/billofmaterials/BillofmaterialsRepoMock.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/billofmaterials/BillofmaterialsRepoMock.scala @@ -74,13 +74,10 @@ class BillofmaterialsRepoMock(toRow: Function1[BillofmaterialsRowUnsaved, Billof override def update: UpdateBuilder[BillofmaterialsFields, BillofmaterialsRow] = { UpdateBuilderMock(UpdateParams.empty, BillofmaterialsFields.structure, map) } - override def update(row: BillofmaterialsRow)(implicit c: Connection): Boolean = { - map.get(row.billofmaterialsid) match { - case Some(`row`) => false - case Some(_) => - map.put(row.billofmaterialsid, row): @nowarn - true - case None => false + override def update(row: BillofmaterialsRow)(implicit c: Connection): Option[BillofmaterialsRow] = { + map.get(row.billofmaterialsid).map { _ => + map.put(row.billofmaterialsid, row): @nowarn + row } } override def upsert(unsaved: BillofmaterialsRow)(implicit c: Connection): BillofmaterialsRow = { diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/culture/CultureRepo.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/culture/CultureRepo.scala index cd42c61ca..52d69b805 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/culture/CultureRepo.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/culture/CultureRepo.scala @@ -27,7 +27,7 @@ trait CultureRepo { def selectByIds(cultureids: Array[CultureId])(implicit c: Connection): List[CultureRow] def selectByIdsTracked(cultureids: Array[CultureId])(implicit c: Connection): Map[CultureId, CultureRow] def update: UpdateBuilder[CultureFields, CultureRow] - def update(row: CultureRow)(implicit c: Connection): Boolean + def update(row: CultureRow)(implicit c: Connection): Option[CultureRow] def upsert(unsaved: CultureRow)(implicit c: Connection): CultureRow def upsertBatch(unsaved: Iterable[CultureRow])(implicit c: Connection): List[CultureRow] /* NOTE: this functionality is not safe if you use auto-commit mode! it runs 3 SQL statements */ diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/culture/CultureRepoImpl.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/culture/CultureRepoImpl.scala index 1f295126b..b52fe7326 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/culture/CultureRepoImpl.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/culture/CultureRepoImpl.scala @@ -106,13 +106,14 @@ class CultureRepoImpl extends CultureRepo { override def update: UpdateBuilder[CultureFields, CultureRow] = { UpdateBuilder(""""production"."culture"""", CultureFields.structure, CultureRow.rowParser) } - override def update(row: CultureRow)(implicit c: Connection): Boolean = { + override def update(row: CultureRow)(implicit c: Connection): Option[CultureRow] = { val cultureid = row.cultureid SQL"""update "production"."culture" set "name" = ${ParameterValue(row.name, null, Name.toStatement)}::varchar, "modifieddate" = ${ParameterValue(row.modifieddate, null, TypoLocalDateTime.toStatement)}::timestamp where "cultureid" = ${ParameterValue(cultureid, null, CultureId.toStatement)} - """.executeUpdate() > 0 + returning "cultureid", "name", "modifieddate"::text + """.executeInsert(CultureRow.rowParser(1).singleOpt) } override def upsert(unsaved: CultureRow)(implicit c: Connection): CultureRow = { SQL"""insert into "production"."culture"("cultureid", "name", "modifieddate") diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/culture/CultureRepoMock.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/culture/CultureRepoMock.scala index 8e36e29cb..26be772aa 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/culture/CultureRepoMock.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/culture/CultureRepoMock.scala @@ -74,13 +74,10 @@ class CultureRepoMock(toRow: Function1[CultureRowUnsaved, CultureRow], override def update: UpdateBuilder[CultureFields, CultureRow] = { UpdateBuilderMock(UpdateParams.empty, CultureFields.structure, map) } - override def update(row: CultureRow)(implicit c: Connection): Boolean = { - map.get(row.cultureid) match { - case Some(`row`) => false - case Some(_) => - map.put(row.cultureid, row): @nowarn - true - case None => false + override def update(row: CultureRow)(implicit c: Connection): Option[CultureRow] = { + map.get(row.cultureid).map { _ => + map.put(row.cultureid, row): @nowarn + row } } override def upsert(unsaved: CultureRow)(implicit c: Connection): CultureRow = { 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 95154b1b2..d3c90c3db 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 @@ -29,7 +29,7 @@ trait DocumentRepo { def selectByIdsTracked(documentnodes: Array[DocumentId])(implicit c: Connection): Map[DocumentId, DocumentRow] def selectByUniqueRowguid(rowguid: TypoUUID)(implicit c: Connection): Option[DocumentRow] def update: UpdateBuilder[DocumentFields, DocumentRow] - def update(row: DocumentRow)(implicit c: Connection): Boolean + def update(row: DocumentRow)(implicit c: Connection): Option[DocumentRow] def upsert(unsaved: DocumentRow)(implicit c: Connection): DocumentRow def upsertBatch(unsaved: Iterable[DocumentRow])(implicit c: Connection): List[DocumentRow] /* NOTE: this functionality is not safe if you use auto-commit mode! it runs 3 SQL statements */ 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 ae390e5c7..6696ec5de 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 @@ -141,7 +141,7 @@ class DocumentRepoImpl extends DocumentRepo { override def update: UpdateBuilder[DocumentFields, DocumentRow] = { UpdateBuilder(""""production"."document"""", DocumentFields.structure, DocumentRow.rowParser) } - override def update(row: DocumentRow)(implicit c: Connection): Boolean = { + override def update(row: DocumentRow)(implicit c: Connection): Option[DocumentRow] = { val documentnode = row.documentnode SQL"""update "production"."document" set "title" = ${ParameterValue(row.title, null, ToStatement.stringToStatement)}, @@ -157,7 +157,8 @@ class DocumentRepoImpl extends DocumentRepo { "rowguid" = ${ParameterValue(row.rowguid, null, TypoUUID.toStatement)}::uuid, "modifieddate" = ${ParameterValue(row.modifieddate, null, TypoLocalDateTime.toStatement)}::timestamp where "documentnode" = ${ParameterValue(documentnode, null, DocumentId.toStatement)} - """.executeUpdate() > 0 + returning "title", "owner", "folderflag", "filename", "fileextension", "revision", "changenumber", "status", "documentsummary", "document", "rowguid", "modifieddate"::text, "documentnode" + """.executeInsert(DocumentRow.rowParser(1).singleOpt) } override def upsert(unsaved: DocumentRow)(implicit c: Connection): DocumentRow = { SQL"""insert into "production"."document"("title", "owner", "folderflag", "filename", "fileextension", "revision", "changenumber", "status", "documentsummary", "document", "rowguid", "modifieddate", "documentnode") 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 ee6057ff8..83ee6e82d 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 @@ -78,13 +78,10 @@ class DocumentRepoMock(toRow: Function1[DocumentRowUnsaved, DocumentRow], override def update: UpdateBuilder[DocumentFields, DocumentRow] = { UpdateBuilderMock(UpdateParams.empty, DocumentFields.structure, map) } - override def update(row: DocumentRow)(implicit c: Connection): Boolean = { - map.get(row.documentnode) match { - case Some(`row`) => false - case Some(_) => - map.put(row.documentnode, row): @nowarn - true - case None => false + override def update(row: DocumentRow)(implicit c: Connection): Option[DocumentRow] = { + map.get(row.documentnode).map { _ => + map.put(row.documentnode, row): @nowarn + row } } override def upsert(unsaved: DocumentRow)(implicit c: Connection): DocumentRow = { diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/illustration/IllustrationRepo.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/illustration/IllustrationRepo.scala index 9f4506d3c..bf1037d31 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/illustration/IllustrationRepo.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/illustration/IllustrationRepo.scala @@ -27,7 +27,7 @@ trait IllustrationRepo { def selectByIds(illustrationids: Array[IllustrationId])(implicit c: Connection): List[IllustrationRow] def selectByIdsTracked(illustrationids: Array[IllustrationId])(implicit c: Connection): Map[IllustrationId, IllustrationRow] def update: UpdateBuilder[IllustrationFields, IllustrationRow] - def update(row: IllustrationRow)(implicit c: Connection): Boolean + def update(row: IllustrationRow)(implicit c: Connection): Option[IllustrationRow] def upsert(unsaved: IllustrationRow)(implicit c: Connection): IllustrationRow def upsertBatch(unsaved: Iterable[IllustrationRow])(implicit c: Connection): List[IllustrationRow] /* NOTE: this functionality is not safe if you use auto-commit mode! it runs 3 SQL statements */ diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/illustration/IllustrationRepoImpl.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/illustration/IllustrationRepoImpl.scala index e14c4ae9d..a94c4b8bd 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/illustration/IllustrationRepoImpl.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/illustration/IllustrationRepoImpl.scala @@ -110,13 +110,14 @@ class IllustrationRepoImpl extends IllustrationRepo { override def update: UpdateBuilder[IllustrationFields, IllustrationRow] = { UpdateBuilder(""""production"."illustration"""", IllustrationFields.structure, IllustrationRow.rowParser) } - override def update(row: IllustrationRow)(implicit c: Connection): Boolean = { + override def update(row: IllustrationRow)(implicit c: Connection): Option[IllustrationRow] = { val illustrationid = row.illustrationid SQL"""update "production"."illustration" set "diagram" = ${ParameterValue(row.diagram, null, ToStatement.optionToStatement(TypoXml.toStatement, TypoXml.parameterMetadata))}::xml, "modifieddate" = ${ParameterValue(row.modifieddate, null, TypoLocalDateTime.toStatement)}::timestamp where "illustrationid" = ${ParameterValue(illustrationid, null, IllustrationId.toStatement)} - """.executeUpdate() > 0 + returning "illustrationid", "diagram", "modifieddate"::text + """.executeInsert(IllustrationRow.rowParser(1).singleOpt) } override def upsert(unsaved: IllustrationRow)(implicit c: Connection): IllustrationRow = { SQL"""insert into "production"."illustration"("illustrationid", "diagram", "modifieddate") diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/illustration/IllustrationRepoMock.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/illustration/IllustrationRepoMock.scala index 6767884d6..5ca98d231 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/illustration/IllustrationRepoMock.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/illustration/IllustrationRepoMock.scala @@ -74,13 +74,10 @@ class IllustrationRepoMock(toRow: Function1[IllustrationRowUnsaved, Illustration override def update: UpdateBuilder[IllustrationFields, IllustrationRow] = { UpdateBuilderMock(UpdateParams.empty, IllustrationFields.structure, map) } - override def update(row: IllustrationRow)(implicit c: Connection): Boolean = { - map.get(row.illustrationid) match { - case Some(`row`) => false - case Some(_) => - map.put(row.illustrationid, row): @nowarn - true - case None => false + override def update(row: IllustrationRow)(implicit c: Connection): Option[IllustrationRow] = { + map.get(row.illustrationid).map { _ => + map.put(row.illustrationid, row): @nowarn + row } } override def upsert(unsaved: IllustrationRow)(implicit c: Connection): IllustrationRow = { diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/location/LocationRepo.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/location/LocationRepo.scala index 0a5620479..74e3fad32 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/location/LocationRepo.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/location/LocationRepo.scala @@ -27,7 +27,7 @@ trait LocationRepo { def selectByIds(locationids: Array[LocationId])(implicit c: Connection): List[LocationRow] def selectByIdsTracked(locationids: Array[LocationId])(implicit c: Connection): Map[LocationId, LocationRow] def update: UpdateBuilder[LocationFields, LocationRow] - def update(row: LocationRow)(implicit c: Connection): Boolean + def update(row: LocationRow)(implicit c: Connection): Option[LocationRow] def upsert(unsaved: LocationRow)(implicit c: Connection): LocationRow def upsertBatch(unsaved: Iterable[LocationRow])(implicit c: Connection): List[LocationRow] /* NOTE: this functionality is not safe if you use auto-commit mode! it runs 3 SQL statements */ diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/location/LocationRepoImpl.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/location/LocationRepoImpl.scala index 1ccf55806..bad87d6ec 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/location/LocationRepoImpl.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/location/LocationRepoImpl.scala @@ -118,7 +118,7 @@ class LocationRepoImpl extends LocationRepo { override def update: UpdateBuilder[LocationFields, LocationRow] = { UpdateBuilder(""""production"."location"""", LocationFields.structure, LocationRow.rowParser) } - override def update(row: LocationRow)(implicit c: Connection): Boolean = { + override def update(row: LocationRow)(implicit c: Connection): Option[LocationRow] = { val locationid = row.locationid SQL"""update "production"."location" set "name" = ${ParameterValue(row.name, null, Name.toStatement)}::varchar, @@ -126,7 +126,8 @@ class LocationRepoImpl extends LocationRepo { "availability" = ${ParameterValue(row.availability, null, ToStatement.scalaBigDecimalToStatement)}::numeric, "modifieddate" = ${ParameterValue(row.modifieddate, null, TypoLocalDateTime.toStatement)}::timestamp where "locationid" = ${ParameterValue(locationid, null, LocationId.toStatement)} - """.executeUpdate() > 0 + returning "locationid", "name", "costrate", "availability", "modifieddate"::text + """.executeInsert(LocationRow.rowParser(1).singleOpt) } override def upsert(unsaved: LocationRow)(implicit c: Connection): LocationRow = { SQL"""insert into "production"."location"("locationid", "name", "costrate", "availability", "modifieddate") diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/location/LocationRepoMock.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/location/LocationRepoMock.scala index b0e7d5c87..671ea6432 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/location/LocationRepoMock.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/location/LocationRepoMock.scala @@ -74,13 +74,10 @@ class LocationRepoMock(toRow: Function1[LocationRowUnsaved, LocationRow], override def update: UpdateBuilder[LocationFields, LocationRow] = { UpdateBuilderMock(UpdateParams.empty, LocationFields.structure, map) } - override def update(row: LocationRow)(implicit c: Connection): Boolean = { - map.get(row.locationid) match { - case Some(`row`) => false - case Some(_) => - map.put(row.locationid, row): @nowarn - true - case None => false + override def update(row: LocationRow)(implicit c: Connection): Option[LocationRow] = { + map.get(row.locationid).map { _ => + map.put(row.locationid, row): @nowarn + row } } override def upsert(unsaved: LocationRow)(implicit c: Connection): LocationRow = { diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/product/ProductRepo.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/product/ProductRepo.scala index ea99bb45f..69e4bc0dd 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/product/ProductRepo.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/product/ProductRepo.scala @@ -27,7 +27,7 @@ trait ProductRepo { def selectByIds(productids: Array[ProductId])(implicit c: Connection): List[ProductRow] def selectByIdsTracked(productids: Array[ProductId])(implicit c: Connection): Map[ProductId, ProductRow] def update: UpdateBuilder[ProductFields, ProductRow] - def update(row: ProductRow)(implicit c: Connection): Boolean + def update(row: ProductRow)(implicit c: Connection): Option[ProductRow] def upsert(unsaved: ProductRow)(implicit c: Connection): ProductRow def upsertBatch(unsaved: Iterable[ProductRow])(implicit c: Connection): List[ProductRow] /* NOTE: this functionality is not safe if you use auto-commit mode! it runs 3 SQL statements */ diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/product/ProductRepoImpl.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/product/ProductRepoImpl.scala index df5439b5a..ab8b3237e 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/product/ProductRepoImpl.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/product/ProductRepoImpl.scala @@ -148,7 +148,7 @@ class ProductRepoImpl extends ProductRepo { override def update: UpdateBuilder[ProductFields, ProductRow] = { UpdateBuilder(""""production"."product"""", ProductFields.structure, ProductRow.rowParser) } - override def update(row: ProductRow)(implicit c: Connection): Boolean = { + override def update(row: ProductRow)(implicit c: Connection): Option[ProductRow] = { val productid = row.productid SQL"""update "production"."product" set "name" = ${ParameterValue(row.name, null, Name.toStatement)}::varchar, @@ -176,7 +176,8 @@ class ProductRepoImpl extends ProductRepo { "rowguid" = ${ParameterValue(row.rowguid, null, TypoUUID.toStatement)}::uuid, "modifieddate" = ${ParameterValue(row.modifieddate, null, TypoLocalDateTime.toStatement)}::timestamp where "productid" = ${ParameterValue(productid, null, ProductId.toStatement)} - """.executeUpdate() > 0 + returning "productid", "name", "productnumber", "makeflag", "finishedgoodsflag", "color", "safetystocklevel", "reorderpoint", "standardcost", "listprice", "size", "sizeunitmeasurecode", "weightunitmeasurecode", "weight", "daystomanufacture", "productline", "class", "style", "productsubcategoryid", "productmodelid", "sellstartdate"::text, "sellenddate"::text, "discontinueddate"::text, "rowguid", "modifieddate"::text + """.executeInsert(ProductRow.rowParser(1).singleOpt) } override def upsert(unsaved: ProductRow)(implicit c: Connection): ProductRow = { SQL"""insert into "production"."product"("productid", "name", "productnumber", "makeflag", "finishedgoodsflag", "color", "safetystocklevel", "reorderpoint", "standardcost", "listprice", "size", "sizeunitmeasurecode", "weightunitmeasurecode", "weight", "daystomanufacture", "productline", "class", "style", "productsubcategoryid", "productmodelid", "sellstartdate", "sellenddate", "discontinueddate", "rowguid", "modifieddate") diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/product/ProductRepoMock.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/product/ProductRepoMock.scala index b2c06c5cb..30b8487d4 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/product/ProductRepoMock.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/product/ProductRepoMock.scala @@ -74,13 +74,10 @@ class ProductRepoMock(toRow: Function1[ProductRowUnsaved, ProductRow], override def update: UpdateBuilder[ProductFields, ProductRow] = { UpdateBuilderMock(UpdateParams.empty, ProductFields.structure, map) } - override def update(row: ProductRow)(implicit c: Connection): Boolean = { - map.get(row.productid) match { - case Some(`row`) => false - case Some(_) => - map.put(row.productid, row): @nowarn - true - case None => false + override def update(row: ProductRow)(implicit c: Connection): Option[ProductRow] = { + map.get(row.productid).map { _ => + map.put(row.productid, row): @nowarn + row } } override def upsert(unsaved: ProductRow)(implicit c: Connection): ProductRow = { diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productcategory/ProductcategoryRepo.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productcategory/ProductcategoryRepo.scala index b9ec06ec3..1ef556e1a 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productcategory/ProductcategoryRepo.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productcategory/ProductcategoryRepo.scala @@ -27,7 +27,7 @@ trait ProductcategoryRepo { def selectByIds(productcategoryids: Array[ProductcategoryId])(implicit c: Connection): List[ProductcategoryRow] def selectByIdsTracked(productcategoryids: Array[ProductcategoryId])(implicit c: Connection): Map[ProductcategoryId, ProductcategoryRow] def update: UpdateBuilder[ProductcategoryFields, ProductcategoryRow] - def update(row: ProductcategoryRow)(implicit c: Connection): Boolean + def update(row: ProductcategoryRow)(implicit c: Connection): Option[ProductcategoryRow] def upsert(unsaved: ProductcategoryRow)(implicit c: Connection): ProductcategoryRow def upsertBatch(unsaved: Iterable[ProductcategoryRow])(implicit c: Connection): List[ProductcategoryRow] /* NOTE: this functionality is not safe if you use auto-commit mode! it runs 3 SQL statements */ diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productcategory/ProductcategoryRepoImpl.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productcategory/ProductcategoryRepoImpl.scala index 276c44bce..1c4e9580a 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productcategory/ProductcategoryRepoImpl.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productcategory/ProductcategoryRepoImpl.scala @@ -114,14 +114,15 @@ class ProductcategoryRepoImpl extends ProductcategoryRepo { override def update: UpdateBuilder[ProductcategoryFields, ProductcategoryRow] = { UpdateBuilder(""""production"."productcategory"""", ProductcategoryFields.structure, ProductcategoryRow.rowParser) } - override def update(row: ProductcategoryRow)(implicit c: Connection): Boolean = { + override def update(row: ProductcategoryRow)(implicit c: Connection): Option[ProductcategoryRow] = { val productcategoryid = row.productcategoryid SQL"""update "production"."productcategory" set "name" = ${ParameterValue(row.name, null, Name.toStatement)}::varchar, "rowguid" = ${ParameterValue(row.rowguid, null, TypoUUID.toStatement)}::uuid, "modifieddate" = ${ParameterValue(row.modifieddate, null, TypoLocalDateTime.toStatement)}::timestamp where "productcategoryid" = ${ParameterValue(productcategoryid, null, ProductcategoryId.toStatement)} - """.executeUpdate() > 0 + returning "productcategoryid", "name", "rowguid", "modifieddate"::text + """.executeInsert(ProductcategoryRow.rowParser(1).singleOpt) } override def upsert(unsaved: ProductcategoryRow)(implicit c: Connection): ProductcategoryRow = { SQL"""insert into "production"."productcategory"("productcategoryid", "name", "rowguid", "modifieddate") diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productcategory/ProductcategoryRepoMock.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productcategory/ProductcategoryRepoMock.scala index 6b343b445..887866ab2 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productcategory/ProductcategoryRepoMock.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productcategory/ProductcategoryRepoMock.scala @@ -74,13 +74,10 @@ class ProductcategoryRepoMock(toRow: Function1[ProductcategoryRowUnsaved, Produc override def update: UpdateBuilder[ProductcategoryFields, ProductcategoryRow] = { UpdateBuilderMock(UpdateParams.empty, ProductcategoryFields.structure, map) } - override def update(row: ProductcategoryRow)(implicit c: Connection): Boolean = { - map.get(row.productcategoryid) match { - case Some(`row`) => false - case Some(_) => - map.put(row.productcategoryid, row): @nowarn - true - case None => false + override def update(row: ProductcategoryRow)(implicit c: Connection): Option[ProductcategoryRow] = { + map.get(row.productcategoryid).map { _ => + map.put(row.productcategoryid, row): @nowarn + row } } override def upsert(unsaved: ProductcategoryRow)(implicit c: Connection): ProductcategoryRow = { diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productcosthistory/ProductcosthistoryRepo.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productcosthistory/ProductcosthistoryRepo.scala index 96d1b517e..4f732a6fc 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productcosthistory/ProductcosthistoryRepo.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productcosthistory/ProductcosthistoryRepo.scala @@ -27,7 +27,7 @@ trait ProductcosthistoryRepo { def selectByIds(compositeIds: Array[ProductcosthistoryId])(implicit c: Connection): List[ProductcosthistoryRow] def selectByIdsTracked(compositeIds: Array[ProductcosthistoryId])(implicit c: Connection): Map[ProductcosthistoryId, ProductcosthistoryRow] def update: UpdateBuilder[ProductcosthistoryFields, ProductcosthistoryRow] - def update(row: ProductcosthistoryRow)(implicit c: Connection): Boolean + def update(row: ProductcosthistoryRow)(implicit c: Connection): Option[ProductcosthistoryRow] def upsert(unsaved: ProductcosthistoryRow)(implicit c: Connection): ProductcosthistoryRow def upsertBatch(unsaved: Iterable[ProductcosthistoryRow])(implicit c: Connection): List[ProductcosthistoryRow] /* NOTE: this functionality is not safe if you use auto-commit mode! it runs 3 SQL statements */ diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productcosthistory/ProductcosthistoryRepoImpl.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productcosthistory/ProductcosthistoryRepoImpl.scala index 6ba3d2e50..54c7981b8 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productcosthistory/ProductcosthistoryRepoImpl.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productcosthistory/ProductcosthistoryRepoImpl.scala @@ -103,7 +103,7 @@ class ProductcosthistoryRepoImpl extends ProductcosthistoryRepo { val startdate = compositeIds.map(_.startdate) SQL"""select "productid", "startdate"::text, "enddate"::text, "standardcost", "modifieddate"::text from "production"."productcosthistory" - where ("productid", "startdate") + where ("productid", "startdate") in (select unnest(${productid}), unnest(${startdate})) """.as(ProductcosthistoryRow.rowParser(1).*) @@ -115,14 +115,15 @@ class ProductcosthistoryRepoImpl extends ProductcosthistoryRepo { override def update: UpdateBuilder[ProductcosthistoryFields, ProductcosthistoryRow] = { UpdateBuilder(""""production"."productcosthistory"""", ProductcosthistoryFields.structure, ProductcosthistoryRow.rowParser) } - override def update(row: ProductcosthistoryRow)(implicit c: Connection): Boolean = { + override def update(row: ProductcosthistoryRow)(implicit c: Connection): Option[ProductcosthistoryRow] = { val compositeId = row.compositeId SQL"""update "production"."productcosthistory" set "enddate" = ${ParameterValue(row.enddate, null, ToStatement.optionToStatement(TypoLocalDateTime.toStatement, TypoLocalDateTime.parameterMetadata))}::timestamp, "standardcost" = ${ParameterValue(row.standardcost, null, ToStatement.scalaBigDecimalToStatement)}::numeric, "modifieddate" = ${ParameterValue(row.modifieddate, null, TypoLocalDateTime.toStatement)}::timestamp where "productid" = ${ParameterValue(compositeId.productid, null, ProductId.toStatement)} AND "startdate" = ${ParameterValue(compositeId.startdate, null, TypoLocalDateTime.toStatement)} - """.executeUpdate() > 0 + returning "productid", "startdate"::text, "enddate"::text, "standardcost", "modifieddate"::text + """.executeInsert(ProductcosthistoryRow.rowParser(1).singleOpt) } override def upsert(unsaved: ProductcosthistoryRow)(implicit c: Connection): ProductcosthistoryRow = { SQL"""insert into "production"."productcosthistory"("productid", "startdate", "enddate", "standardcost", "modifieddate") diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productcosthistory/ProductcosthistoryRepoMock.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productcosthistory/ProductcosthistoryRepoMock.scala index 36a348be4..3b78ee871 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productcosthistory/ProductcosthistoryRepoMock.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productcosthistory/ProductcosthistoryRepoMock.scala @@ -74,13 +74,10 @@ class ProductcosthistoryRepoMock(toRow: Function1[ProductcosthistoryRowUnsaved, override def update: UpdateBuilder[ProductcosthistoryFields, ProductcosthistoryRow] = { UpdateBuilderMock(UpdateParams.empty, ProductcosthistoryFields.structure, map) } - override def update(row: ProductcosthistoryRow)(implicit c: Connection): Boolean = { - map.get(row.compositeId) match { - case Some(`row`) => false - case Some(_) => - map.put(row.compositeId, row): @nowarn - true - case None => false + override def update(row: ProductcosthistoryRow)(implicit c: Connection): Option[ProductcosthistoryRow] = { + map.get(row.compositeId).map { _ => + map.put(row.compositeId, row): @nowarn + row } } override def upsert(unsaved: ProductcosthistoryRow)(implicit c: Connection): ProductcosthistoryRow = { diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productdescription/ProductdescriptionRepo.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productdescription/ProductdescriptionRepo.scala index 9cb988c8b..518ce1426 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productdescription/ProductdescriptionRepo.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productdescription/ProductdescriptionRepo.scala @@ -27,7 +27,7 @@ trait ProductdescriptionRepo { def selectByIds(productdescriptionids: Array[ProductdescriptionId])(implicit c: Connection): List[ProductdescriptionRow] def selectByIdsTracked(productdescriptionids: Array[ProductdescriptionId])(implicit c: Connection): Map[ProductdescriptionId, ProductdescriptionRow] def update: UpdateBuilder[ProductdescriptionFields, ProductdescriptionRow] - def update(row: ProductdescriptionRow)(implicit c: Connection): Boolean + def update(row: ProductdescriptionRow)(implicit c: Connection): Option[ProductdescriptionRow] def upsert(unsaved: ProductdescriptionRow)(implicit c: Connection): ProductdescriptionRow def upsertBatch(unsaved: Iterable[ProductdescriptionRow])(implicit c: Connection): List[ProductdescriptionRow] /* NOTE: this functionality is not safe if you use auto-commit mode! it runs 3 SQL statements */ diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productdescription/ProductdescriptionRepoImpl.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productdescription/ProductdescriptionRepoImpl.scala index b1d5dd035..2f8fa1215 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productdescription/ProductdescriptionRepoImpl.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productdescription/ProductdescriptionRepoImpl.scala @@ -114,14 +114,15 @@ class ProductdescriptionRepoImpl extends ProductdescriptionRepo { override def update: UpdateBuilder[ProductdescriptionFields, ProductdescriptionRow] = { UpdateBuilder(""""production"."productdescription"""", ProductdescriptionFields.structure, ProductdescriptionRow.rowParser) } - override def update(row: ProductdescriptionRow)(implicit c: Connection): Boolean = { + override def update(row: ProductdescriptionRow)(implicit c: Connection): Option[ProductdescriptionRow] = { val productdescriptionid = row.productdescriptionid SQL"""update "production"."productdescription" set "description" = ${ParameterValue(row.description, null, ToStatement.stringToStatement)}, "rowguid" = ${ParameterValue(row.rowguid, null, TypoUUID.toStatement)}::uuid, "modifieddate" = ${ParameterValue(row.modifieddate, null, TypoLocalDateTime.toStatement)}::timestamp where "productdescriptionid" = ${ParameterValue(productdescriptionid, null, ProductdescriptionId.toStatement)} - """.executeUpdate() > 0 + returning "productdescriptionid", "description", "rowguid", "modifieddate"::text + """.executeInsert(ProductdescriptionRow.rowParser(1).singleOpt) } override def upsert(unsaved: ProductdescriptionRow)(implicit c: Connection): ProductdescriptionRow = { SQL"""insert into "production"."productdescription"("productdescriptionid", "description", "rowguid", "modifieddate") diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productdescription/ProductdescriptionRepoMock.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productdescription/ProductdescriptionRepoMock.scala index cc7cd1ad0..778af894e 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productdescription/ProductdescriptionRepoMock.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productdescription/ProductdescriptionRepoMock.scala @@ -74,13 +74,10 @@ class ProductdescriptionRepoMock(toRow: Function1[ProductdescriptionRowUnsaved, override def update: UpdateBuilder[ProductdescriptionFields, ProductdescriptionRow] = { UpdateBuilderMock(UpdateParams.empty, ProductdescriptionFields.structure, map) } - override def update(row: ProductdescriptionRow)(implicit c: Connection): Boolean = { - map.get(row.productdescriptionid) match { - case Some(`row`) => false - case Some(_) => - map.put(row.productdescriptionid, row): @nowarn - true - case None => false + override def update(row: ProductdescriptionRow)(implicit c: Connection): Option[ProductdescriptionRow] = { + map.get(row.productdescriptionid).map { _ => + map.put(row.productdescriptionid, row): @nowarn + row } } override def upsert(unsaved: ProductdescriptionRow)(implicit c: Connection): ProductdescriptionRow = { diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productdocument/ProductdocumentRepo.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productdocument/ProductdocumentRepo.scala index 198e291d8..5407b7835 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productdocument/ProductdocumentRepo.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productdocument/ProductdocumentRepo.scala @@ -27,7 +27,7 @@ trait ProductdocumentRepo { def selectByIds(compositeIds: Array[ProductdocumentId])(implicit c: Connection): List[ProductdocumentRow] def selectByIdsTracked(compositeIds: Array[ProductdocumentId])(implicit c: Connection): Map[ProductdocumentId, ProductdocumentRow] def update: UpdateBuilder[ProductdocumentFields, ProductdocumentRow] - def update(row: ProductdocumentRow)(implicit c: Connection): Boolean + def update(row: ProductdocumentRow)(implicit c: Connection): Option[ProductdocumentRow] def upsert(unsaved: ProductdocumentRow)(implicit c: Connection): ProductdocumentRow def upsertBatch(unsaved: Iterable[ProductdocumentRow])(implicit c: Connection): List[ProductdocumentRow] /* NOTE: this functionality is not safe if you use auto-commit mode! it runs 3 SQL statements */ diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productdocument/ProductdocumentRepoImpl.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productdocument/ProductdocumentRepoImpl.scala index 16f6fe17f..692fb6db5 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productdocument/ProductdocumentRepoImpl.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productdocument/ProductdocumentRepoImpl.scala @@ -104,7 +104,7 @@ class ProductdocumentRepoImpl extends ProductdocumentRepo { val documentnode = compositeIds.map(_.documentnode) SQL"""select "productid", "modifieddate"::text, "documentnode" from "production"."productdocument" - where ("productid", "documentnode") + where ("productid", "documentnode") in (select unnest(${productid}), unnest(${documentnode})) """.as(ProductdocumentRow.rowParser(1).*) @@ -116,12 +116,13 @@ class ProductdocumentRepoImpl extends ProductdocumentRepo { override def update: UpdateBuilder[ProductdocumentFields, ProductdocumentRow] = { UpdateBuilder(""""production"."productdocument"""", ProductdocumentFields.structure, ProductdocumentRow.rowParser) } - override def update(row: ProductdocumentRow)(implicit c: Connection): Boolean = { + override def update(row: ProductdocumentRow)(implicit c: Connection): Option[ProductdocumentRow] = { val compositeId = row.compositeId SQL"""update "production"."productdocument" set "modifieddate" = ${ParameterValue(row.modifieddate, null, TypoLocalDateTime.toStatement)}::timestamp where "productid" = ${ParameterValue(compositeId.productid, null, ProductId.toStatement)} AND "documentnode" = ${ParameterValue(compositeId.documentnode, null, DocumentId.toStatement)} - """.executeUpdate() > 0 + returning "productid", "modifieddate"::text, "documentnode" + """.executeInsert(ProductdocumentRow.rowParser(1).singleOpt) } override def upsert(unsaved: ProductdocumentRow)(implicit c: Connection): ProductdocumentRow = { SQL"""insert into "production"."productdocument"("productid", "modifieddate", "documentnode") diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productdocument/ProductdocumentRepoMock.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productdocument/ProductdocumentRepoMock.scala index 08229c907..4eb3ca2bf 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productdocument/ProductdocumentRepoMock.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productdocument/ProductdocumentRepoMock.scala @@ -74,13 +74,10 @@ class ProductdocumentRepoMock(toRow: Function1[ProductdocumentRowUnsaved, Produc override def update: UpdateBuilder[ProductdocumentFields, ProductdocumentRow] = { UpdateBuilderMock(UpdateParams.empty, ProductdocumentFields.structure, map) } - override def update(row: ProductdocumentRow)(implicit c: Connection): Boolean = { - map.get(row.compositeId) match { - case Some(`row`) => false - case Some(_) => - map.put(row.compositeId, row): @nowarn - true - case None => false + override def update(row: ProductdocumentRow)(implicit c: Connection): Option[ProductdocumentRow] = { + map.get(row.compositeId).map { _ => + map.put(row.compositeId, row): @nowarn + row } } override def upsert(unsaved: ProductdocumentRow)(implicit c: Connection): ProductdocumentRow = { diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productinventory/ProductinventoryRepo.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productinventory/ProductinventoryRepo.scala index 32b1602db..aa9ba0611 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productinventory/ProductinventoryRepo.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productinventory/ProductinventoryRepo.scala @@ -27,7 +27,7 @@ trait ProductinventoryRepo { def selectByIds(compositeIds: Array[ProductinventoryId])(implicit c: Connection): List[ProductinventoryRow] def selectByIdsTracked(compositeIds: Array[ProductinventoryId])(implicit c: Connection): Map[ProductinventoryId, ProductinventoryRow] def update: UpdateBuilder[ProductinventoryFields, ProductinventoryRow] - def update(row: ProductinventoryRow)(implicit c: Connection): Boolean + def update(row: ProductinventoryRow)(implicit c: Connection): Option[ProductinventoryRow] def upsert(unsaved: ProductinventoryRow)(implicit c: Connection): ProductinventoryRow def upsertBatch(unsaved: Iterable[ProductinventoryRow])(implicit c: Connection): List[ProductinventoryRow] /* NOTE: this functionality is not safe if you use auto-commit mode! it runs 3 SQL statements */ diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productinventory/ProductinventoryRepoImpl.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productinventory/ProductinventoryRepoImpl.scala index b919e2c9e..9c5a1e743 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productinventory/ProductinventoryRepoImpl.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productinventory/ProductinventoryRepoImpl.scala @@ -114,7 +114,7 @@ class ProductinventoryRepoImpl extends ProductinventoryRepo { val locationid = compositeIds.map(_.locationid) SQL"""select "productid", "locationid", "shelf", "bin", "quantity", "rowguid", "modifieddate"::text from "production"."productinventory" - where ("productid", "locationid") + where ("productid", "locationid") in (select unnest(${productid}), unnest(${locationid})) """.as(ProductinventoryRow.rowParser(1).*) @@ -126,7 +126,7 @@ class ProductinventoryRepoImpl extends ProductinventoryRepo { override def update: UpdateBuilder[ProductinventoryFields, ProductinventoryRow] = { UpdateBuilder(""""production"."productinventory"""", ProductinventoryFields.structure, ProductinventoryRow.rowParser) } - override def update(row: ProductinventoryRow)(implicit c: Connection): Boolean = { + override def update(row: ProductinventoryRow)(implicit c: Connection): Option[ProductinventoryRow] = { val compositeId = row.compositeId SQL"""update "production"."productinventory" set "shelf" = ${ParameterValue(row.shelf, null, ToStatement.stringToStatement)}, @@ -135,7 +135,8 @@ class ProductinventoryRepoImpl extends ProductinventoryRepo { "rowguid" = ${ParameterValue(row.rowguid, null, TypoUUID.toStatement)}::uuid, "modifieddate" = ${ParameterValue(row.modifieddate, null, TypoLocalDateTime.toStatement)}::timestamp where "productid" = ${ParameterValue(compositeId.productid, null, ProductId.toStatement)} AND "locationid" = ${ParameterValue(compositeId.locationid, null, LocationId.toStatement)} - """.executeUpdate() > 0 + returning "productid", "locationid", "shelf", "bin", "quantity", "rowguid", "modifieddate"::text + """.executeInsert(ProductinventoryRow.rowParser(1).singleOpt) } override def upsert(unsaved: ProductinventoryRow)(implicit c: Connection): ProductinventoryRow = { SQL"""insert into "production"."productinventory"("productid", "locationid", "shelf", "bin", "quantity", "rowguid", "modifieddate") diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productinventory/ProductinventoryRepoMock.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productinventory/ProductinventoryRepoMock.scala index 75c940d7a..77612bf55 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productinventory/ProductinventoryRepoMock.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productinventory/ProductinventoryRepoMock.scala @@ -74,13 +74,10 @@ class ProductinventoryRepoMock(toRow: Function1[ProductinventoryRowUnsaved, Prod override def update: UpdateBuilder[ProductinventoryFields, ProductinventoryRow] = { UpdateBuilderMock(UpdateParams.empty, ProductinventoryFields.structure, map) } - override def update(row: ProductinventoryRow)(implicit c: Connection): Boolean = { - map.get(row.compositeId) match { - case Some(`row`) => false - case Some(_) => - map.put(row.compositeId, row): @nowarn - true - case None => false + override def update(row: ProductinventoryRow)(implicit c: Connection): Option[ProductinventoryRow] = { + map.get(row.compositeId).map { _ => + map.put(row.compositeId, row): @nowarn + row } } override def upsert(unsaved: ProductinventoryRow)(implicit c: Connection): ProductinventoryRow = { diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productlistpricehistory/ProductlistpricehistoryRepo.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productlistpricehistory/ProductlistpricehistoryRepo.scala index f7d65f998..6d6d721a7 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productlistpricehistory/ProductlistpricehistoryRepo.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productlistpricehistory/ProductlistpricehistoryRepo.scala @@ -27,7 +27,7 @@ trait ProductlistpricehistoryRepo { def selectByIds(compositeIds: Array[ProductlistpricehistoryId])(implicit c: Connection): List[ProductlistpricehistoryRow] def selectByIdsTracked(compositeIds: Array[ProductlistpricehistoryId])(implicit c: Connection): Map[ProductlistpricehistoryId, ProductlistpricehistoryRow] def update: UpdateBuilder[ProductlistpricehistoryFields, ProductlistpricehistoryRow] - def update(row: ProductlistpricehistoryRow)(implicit c: Connection): Boolean + def update(row: ProductlistpricehistoryRow)(implicit c: Connection): Option[ProductlistpricehistoryRow] def upsert(unsaved: ProductlistpricehistoryRow)(implicit c: Connection): ProductlistpricehistoryRow def upsertBatch(unsaved: Iterable[ProductlistpricehistoryRow])(implicit c: Connection): List[ProductlistpricehistoryRow] /* NOTE: this functionality is not safe if you use auto-commit mode! it runs 3 SQL statements */ diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productlistpricehistory/ProductlistpricehistoryRepoImpl.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productlistpricehistory/ProductlistpricehistoryRepoImpl.scala index d3719c47d..c5b434edd 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productlistpricehistory/ProductlistpricehistoryRepoImpl.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productlistpricehistory/ProductlistpricehistoryRepoImpl.scala @@ -103,7 +103,7 @@ class ProductlistpricehistoryRepoImpl extends ProductlistpricehistoryRepo { val startdate = compositeIds.map(_.startdate) SQL"""select "productid", "startdate"::text, "enddate"::text, "listprice", "modifieddate"::text from "production"."productlistpricehistory" - where ("productid", "startdate") + where ("productid", "startdate") in (select unnest(${productid}), unnest(${startdate})) """.as(ProductlistpricehistoryRow.rowParser(1).*) @@ -115,14 +115,15 @@ class ProductlistpricehistoryRepoImpl extends ProductlistpricehistoryRepo { override def update: UpdateBuilder[ProductlistpricehistoryFields, ProductlistpricehistoryRow] = { UpdateBuilder(""""production"."productlistpricehistory"""", ProductlistpricehistoryFields.structure, ProductlistpricehistoryRow.rowParser) } - override def update(row: ProductlistpricehistoryRow)(implicit c: Connection): Boolean = { + override def update(row: ProductlistpricehistoryRow)(implicit c: Connection): Option[ProductlistpricehistoryRow] = { val compositeId = row.compositeId SQL"""update "production"."productlistpricehistory" set "enddate" = ${ParameterValue(row.enddate, null, ToStatement.optionToStatement(TypoLocalDateTime.toStatement, TypoLocalDateTime.parameterMetadata))}::timestamp, "listprice" = ${ParameterValue(row.listprice, null, ToStatement.scalaBigDecimalToStatement)}::numeric, "modifieddate" = ${ParameterValue(row.modifieddate, null, TypoLocalDateTime.toStatement)}::timestamp where "productid" = ${ParameterValue(compositeId.productid, null, ProductId.toStatement)} AND "startdate" = ${ParameterValue(compositeId.startdate, null, TypoLocalDateTime.toStatement)} - """.executeUpdate() > 0 + returning "productid", "startdate"::text, "enddate"::text, "listprice", "modifieddate"::text + """.executeInsert(ProductlistpricehistoryRow.rowParser(1).singleOpt) } override def upsert(unsaved: ProductlistpricehistoryRow)(implicit c: Connection): ProductlistpricehistoryRow = { SQL"""insert into "production"."productlistpricehistory"("productid", "startdate", "enddate", "listprice", "modifieddate") diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productlistpricehistory/ProductlistpricehistoryRepoMock.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productlistpricehistory/ProductlistpricehistoryRepoMock.scala index 4e6472f29..68cf7b979 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productlistpricehistory/ProductlistpricehistoryRepoMock.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productlistpricehistory/ProductlistpricehistoryRepoMock.scala @@ -74,13 +74,10 @@ class ProductlistpricehistoryRepoMock(toRow: Function1[ProductlistpricehistoryRo override def update: UpdateBuilder[ProductlistpricehistoryFields, ProductlistpricehistoryRow] = { UpdateBuilderMock(UpdateParams.empty, ProductlistpricehistoryFields.structure, map) } - override def update(row: ProductlistpricehistoryRow)(implicit c: Connection): Boolean = { - map.get(row.compositeId) match { - case Some(`row`) => false - case Some(_) => - map.put(row.compositeId, row): @nowarn - true - case None => false + override def update(row: ProductlistpricehistoryRow)(implicit c: Connection): Option[ProductlistpricehistoryRow] = { + map.get(row.compositeId).map { _ => + map.put(row.compositeId, row): @nowarn + row } } override def upsert(unsaved: ProductlistpricehistoryRow)(implicit c: Connection): ProductlistpricehistoryRow = { diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productmodel/ProductmodelRepo.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productmodel/ProductmodelRepo.scala index 97e574513..3c351933e 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productmodel/ProductmodelRepo.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productmodel/ProductmodelRepo.scala @@ -27,7 +27,7 @@ trait ProductmodelRepo { def selectByIds(productmodelids: Array[ProductmodelId])(implicit c: Connection): List[ProductmodelRow] def selectByIdsTracked(productmodelids: Array[ProductmodelId])(implicit c: Connection): Map[ProductmodelId, ProductmodelRow] def update: UpdateBuilder[ProductmodelFields, ProductmodelRow] - def update(row: ProductmodelRow)(implicit c: Connection): Boolean + def update(row: ProductmodelRow)(implicit c: Connection): Option[ProductmodelRow] def upsert(unsaved: ProductmodelRow)(implicit c: Connection): ProductmodelRow def upsertBatch(unsaved: Iterable[ProductmodelRow])(implicit c: Connection): List[ProductmodelRow] /* NOTE: this functionality is not safe if you use auto-commit mode! it runs 3 SQL statements */ diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productmodel/ProductmodelRepoImpl.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productmodel/ProductmodelRepoImpl.scala index 6c0aff450..097b0a090 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productmodel/ProductmodelRepoImpl.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productmodel/ProductmodelRepoImpl.scala @@ -118,7 +118,7 @@ class ProductmodelRepoImpl extends ProductmodelRepo { override def update: UpdateBuilder[ProductmodelFields, ProductmodelRow] = { UpdateBuilder(""""production"."productmodel"""", ProductmodelFields.structure, ProductmodelRow.rowParser) } - override def update(row: ProductmodelRow)(implicit c: Connection): Boolean = { + override def update(row: ProductmodelRow)(implicit c: Connection): Option[ProductmodelRow] = { val productmodelid = row.productmodelid SQL"""update "production"."productmodel" set "name" = ${ParameterValue(row.name, null, Name.toStatement)}::varchar, @@ -127,7 +127,8 @@ class ProductmodelRepoImpl extends ProductmodelRepo { "rowguid" = ${ParameterValue(row.rowguid, null, TypoUUID.toStatement)}::uuid, "modifieddate" = ${ParameterValue(row.modifieddate, null, TypoLocalDateTime.toStatement)}::timestamp where "productmodelid" = ${ParameterValue(productmodelid, null, ProductmodelId.toStatement)} - """.executeUpdate() > 0 + returning "productmodelid", "name", "catalogdescription", "instructions", "rowguid", "modifieddate"::text + """.executeInsert(ProductmodelRow.rowParser(1).singleOpt) } override def upsert(unsaved: ProductmodelRow)(implicit c: Connection): ProductmodelRow = { SQL"""insert into "production"."productmodel"("productmodelid", "name", "catalogdescription", "instructions", "rowguid", "modifieddate") diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productmodel/ProductmodelRepoMock.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productmodel/ProductmodelRepoMock.scala index 2ac224d6a..80c500851 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productmodel/ProductmodelRepoMock.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productmodel/ProductmodelRepoMock.scala @@ -74,13 +74,10 @@ class ProductmodelRepoMock(toRow: Function1[ProductmodelRowUnsaved, Productmodel override def update: UpdateBuilder[ProductmodelFields, ProductmodelRow] = { UpdateBuilderMock(UpdateParams.empty, ProductmodelFields.structure, map) } - override def update(row: ProductmodelRow)(implicit c: Connection): Boolean = { - map.get(row.productmodelid) match { - case Some(`row`) => false - case Some(_) => - map.put(row.productmodelid, row): @nowarn - true - case None => false + override def update(row: ProductmodelRow)(implicit c: Connection): Option[ProductmodelRow] = { + map.get(row.productmodelid).map { _ => + map.put(row.productmodelid, row): @nowarn + row } } override def upsert(unsaved: ProductmodelRow)(implicit c: Connection): ProductmodelRow = { diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productmodelillustration/ProductmodelillustrationRepo.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productmodelillustration/ProductmodelillustrationRepo.scala index b889f2672..e7d962768 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productmodelillustration/ProductmodelillustrationRepo.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productmodelillustration/ProductmodelillustrationRepo.scala @@ -27,7 +27,7 @@ trait ProductmodelillustrationRepo { def selectByIds(compositeIds: Array[ProductmodelillustrationId])(implicit c: Connection): List[ProductmodelillustrationRow] def selectByIdsTracked(compositeIds: Array[ProductmodelillustrationId])(implicit c: Connection): Map[ProductmodelillustrationId, ProductmodelillustrationRow] def update: UpdateBuilder[ProductmodelillustrationFields, ProductmodelillustrationRow] - def update(row: ProductmodelillustrationRow)(implicit c: Connection): Boolean + def update(row: ProductmodelillustrationRow)(implicit c: Connection): Option[ProductmodelillustrationRow] def upsert(unsaved: ProductmodelillustrationRow)(implicit c: Connection): ProductmodelillustrationRow def upsertBatch(unsaved: Iterable[ProductmodelillustrationRow])(implicit c: Connection): List[ProductmodelillustrationRow] /* NOTE: this functionality is not safe if you use auto-commit mode! it runs 3 SQL statements */ diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productmodelillustration/ProductmodelillustrationRepoImpl.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productmodelillustration/ProductmodelillustrationRepoImpl.scala index a02c59e5e..ecff03b9f 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productmodelillustration/ProductmodelillustrationRepoImpl.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productmodelillustration/ProductmodelillustrationRepoImpl.scala @@ -101,7 +101,7 @@ class ProductmodelillustrationRepoImpl extends ProductmodelillustrationRepo { val illustrationid = compositeIds.map(_.illustrationid) SQL"""select "productmodelid", "illustrationid", "modifieddate"::text from "production"."productmodelillustration" - where ("productmodelid", "illustrationid") + where ("productmodelid", "illustrationid") in (select unnest(${productmodelid}), unnest(${illustrationid})) """.as(ProductmodelillustrationRow.rowParser(1).*) @@ -113,12 +113,13 @@ class ProductmodelillustrationRepoImpl extends ProductmodelillustrationRepo { override def update: UpdateBuilder[ProductmodelillustrationFields, ProductmodelillustrationRow] = { UpdateBuilder(""""production"."productmodelillustration"""", ProductmodelillustrationFields.structure, ProductmodelillustrationRow.rowParser) } - override def update(row: ProductmodelillustrationRow)(implicit c: Connection): Boolean = { + override def update(row: ProductmodelillustrationRow)(implicit c: Connection): Option[ProductmodelillustrationRow] = { val compositeId = row.compositeId SQL"""update "production"."productmodelillustration" set "modifieddate" = ${ParameterValue(row.modifieddate, null, TypoLocalDateTime.toStatement)}::timestamp where "productmodelid" = ${ParameterValue(compositeId.productmodelid, null, ProductmodelId.toStatement)} AND "illustrationid" = ${ParameterValue(compositeId.illustrationid, null, IllustrationId.toStatement)} - """.executeUpdate() > 0 + returning "productmodelid", "illustrationid", "modifieddate"::text + """.executeInsert(ProductmodelillustrationRow.rowParser(1).singleOpt) } override def upsert(unsaved: ProductmodelillustrationRow)(implicit c: Connection): ProductmodelillustrationRow = { SQL"""insert into "production"."productmodelillustration"("productmodelid", "illustrationid", "modifieddate") diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productmodelillustration/ProductmodelillustrationRepoMock.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productmodelillustration/ProductmodelillustrationRepoMock.scala index ae362a4e9..981eef11d 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productmodelillustration/ProductmodelillustrationRepoMock.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productmodelillustration/ProductmodelillustrationRepoMock.scala @@ -74,13 +74,10 @@ class ProductmodelillustrationRepoMock(toRow: Function1[Productmodelillustration override def update: UpdateBuilder[ProductmodelillustrationFields, ProductmodelillustrationRow] = { UpdateBuilderMock(UpdateParams.empty, ProductmodelillustrationFields.structure, map) } - override def update(row: ProductmodelillustrationRow)(implicit c: Connection): Boolean = { - map.get(row.compositeId) match { - case Some(`row`) => false - case Some(_) => - map.put(row.compositeId, row): @nowarn - true - case None => false + override def update(row: ProductmodelillustrationRow)(implicit c: Connection): Option[ProductmodelillustrationRow] = { + map.get(row.compositeId).map { _ => + map.put(row.compositeId, row): @nowarn + row } } override def upsert(unsaved: ProductmodelillustrationRow)(implicit c: Connection): ProductmodelillustrationRow = { diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productmodelproductdescriptionculture/ProductmodelproductdescriptioncultureRepo.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productmodelproductdescriptionculture/ProductmodelproductdescriptioncultureRepo.scala index a6e0f537f..57f7577e8 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productmodelproductdescriptionculture/ProductmodelproductdescriptioncultureRepo.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productmodelproductdescriptionculture/ProductmodelproductdescriptioncultureRepo.scala @@ -27,7 +27,7 @@ trait ProductmodelproductdescriptioncultureRepo { def selectByIds(compositeIds: Array[ProductmodelproductdescriptioncultureId])(implicit c: Connection): List[ProductmodelproductdescriptioncultureRow] def selectByIdsTracked(compositeIds: Array[ProductmodelproductdescriptioncultureId])(implicit c: Connection): Map[ProductmodelproductdescriptioncultureId, ProductmodelproductdescriptioncultureRow] def update: UpdateBuilder[ProductmodelproductdescriptioncultureFields, ProductmodelproductdescriptioncultureRow] - def update(row: ProductmodelproductdescriptioncultureRow)(implicit c: Connection): Boolean + def update(row: ProductmodelproductdescriptioncultureRow)(implicit c: Connection): Option[ProductmodelproductdescriptioncultureRow] def upsert(unsaved: ProductmodelproductdescriptioncultureRow)(implicit c: Connection): ProductmodelproductdescriptioncultureRow def upsertBatch(unsaved: Iterable[ProductmodelproductdescriptioncultureRow])(implicit c: Connection): List[ProductmodelproductdescriptioncultureRow] /* NOTE: this functionality is not safe if you use auto-commit mode! it runs 3 SQL statements */ diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productmodelproductdescriptionculture/ProductmodelproductdescriptioncultureRepoImpl.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productmodelproductdescriptionculture/ProductmodelproductdescriptioncultureRepoImpl.scala index 19171304b..49ccbc248 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productmodelproductdescriptionculture/ProductmodelproductdescriptioncultureRepoImpl.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productmodelproductdescriptionculture/ProductmodelproductdescriptioncultureRepoImpl.scala @@ -105,7 +105,7 @@ class ProductmodelproductdescriptioncultureRepoImpl extends Productmodelproductd val cultureid = compositeIds.map(_.cultureid) SQL"""select "productmodelid", "productdescriptionid", "cultureid", "modifieddate"::text from "production"."productmodelproductdescriptionculture" - where ("productmodelid", "productdescriptionid", "cultureid") + where ("productmodelid", "productdescriptionid", "cultureid") in (select unnest(${productmodelid}), unnest(${productdescriptionid}), unnest(${cultureid})) """.as(ProductmodelproductdescriptioncultureRow.rowParser(1).*) @@ -117,12 +117,13 @@ class ProductmodelproductdescriptioncultureRepoImpl extends Productmodelproductd override def update: UpdateBuilder[ProductmodelproductdescriptioncultureFields, ProductmodelproductdescriptioncultureRow] = { UpdateBuilder(""""production"."productmodelproductdescriptionculture"""", ProductmodelproductdescriptioncultureFields.structure, ProductmodelproductdescriptioncultureRow.rowParser) } - override def update(row: ProductmodelproductdescriptioncultureRow)(implicit c: Connection): Boolean = { + override def update(row: ProductmodelproductdescriptioncultureRow)(implicit c: Connection): Option[ProductmodelproductdescriptioncultureRow] = { val compositeId = row.compositeId SQL"""update "production"."productmodelproductdescriptionculture" set "modifieddate" = ${ParameterValue(row.modifieddate, null, TypoLocalDateTime.toStatement)}::timestamp where "productmodelid" = ${ParameterValue(compositeId.productmodelid, null, ProductmodelId.toStatement)} AND "productdescriptionid" = ${ParameterValue(compositeId.productdescriptionid, null, ProductdescriptionId.toStatement)} AND "cultureid" = ${ParameterValue(compositeId.cultureid, null, CultureId.toStatement)} - """.executeUpdate() > 0 + returning "productmodelid", "productdescriptionid", "cultureid", "modifieddate"::text + """.executeInsert(ProductmodelproductdescriptioncultureRow.rowParser(1).singleOpt) } override def upsert(unsaved: ProductmodelproductdescriptioncultureRow)(implicit c: Connection): ProductmodelproductdescriptioncultureRow = { SQL"""insert into "production"."productmodelproductdescriptionculture"("productmodelid", "productdescriptionid", "cultureid", "modifieddate") diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productmodelproductdescriptionculture/ProductmodelproductdescriptioncultureRepoMock.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productmodelproductdescriptionculture/ProductmodelproductdescriptioncultureRepoMock.scala index ecb8b8245..091c9e737 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productmodelproductdescriptionculture/ProductmodelproductdescriptioncultureRepoMock.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productmodelproductdescriptionculture/ProductmodelproductdescriptioncultureRepoMock.scala @@ -74,13 +74,10 @@ class ProductmodelproductdescriptioncultureRepoMock(toRow: Function1[Productmode override def update: UpdateBuilder[ProductmodelproductdescriptioncultureFields, ProductmodelproductdescriptioncultureRow] = { UpdateBuilderMock(UpdateParams.empty, ProductmodelproductdescriptioncultureFields.structure, map) } - override def update(row: ProductmodelproductdescriptioncultureRow)(implicit c: Connection): Boolean = { - map.get(row.compositeId) match { - case Some(`row`) => false - case Some(_) => - map.put(row.compositeId, row): @nowarn - true - case None => false + override def update(row: ProductmodelproductdescriptioncultureRow)(implicit c: Connection): Option[ProductmodelproductdescriptioncultureRow] = { + map.get(row.compositeId).map { _ => + map.put(row.compositeId, row): @nowarn + row } } override def upsert(unsaved: ProductmodelproductdescriptioncultureRow)(implicit c: Connection): ProductmodelproductdescriptioncultureRow = { diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productphoto/ProductphotoRepo.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productphoto/ProductphotoRepo.scala index 4b8824674..d537f289b 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productphoto/ProductphotoRepo.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productphoto/ProductphotoRepo.scala @@ -27,7 +27,7 @@ trait ProductphotoRepo { def selectByIds(productphotoids: Array[ProductphotoId])(implicit c: Connection): List[ProductphotoRow] def selectByIdsTracked(productphotoids: Array[ProductphotoId])(implicit c: Connection): Map[ProductphotoId, ProductphotoRow] def update: UpdateBuilder[ProductphotoFields, ProductphotoRow] - def update(row: ProductphotoRow)(implicit c: Connection): Boolean + def update(row: ProductphotoRow)(implicit c: Connection): Option[ProductphotoRow] def upsert(unsaved: ProductphotoRow)(implicit c: Connection): ProductphotoRow def upsertBatch(unsaved: Iterable[ProductphotoRow])(implicit c: Connection): List[ProductphotoRow] /* NOTE: this functionality is not safe if you use auto-commit mode! it runs 3 SQL statements */ diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productphoto/ProductphotoRepoImpl.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productphoto/ProductphotoRepoImpl.scala index d24d5620d..e5bf72ec0 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productphoto/ProductphotoRepoImpl.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productphoto/ProductphotoRepoImpl.scala @@ -114,7 +114,7 @@ class ProductphotoRepoImpl extends ProductphotoRepo { override def update: UpdateBuilder[ProductphotoFields, ProductphotoRow] = { UpdateBuilder(""""production"."productphoto"""", ProductphotoFields.structure, ProductphotoRow.rowParser) } - override def update(row: ProductphotoRow)(implicit c: Connection): Boolean = { + override def update(row: ProductphotoRow)(implicit c: Connection): Option[ProductphotoRow] = { val productphotoid = row.productphotoid SQL"""update "production"."productphoto" set "thumbnailphoto" = ${ParameterValue(row.thumbnailphoto, null, ToStatement.optionToStatement(TypoBytea.toStatement, TypoBytea.parameterMetadata))}::bytea, @@ -123,7 +123,8 @@ class ProductphotoRepoImpl extends ProductphotoRepo { "largephotofilename" = ${ParameterValue(row.largephotofilename, null, ToStatement.optionToStatement(ToStatement.stringToStatement, ParameterMetaData.StringParameterMetaData))}, "modifieddate" = ${ParameterValue(row.modifieddate, null, TypoLocalDateTime.toStatement)}::timestamp where "productphotoid" = ${ParameterValue(productphotoid, null, ProductphotoId.toStatement)} - """.executeUpdate() > 0 + returning "productphotoid", "thumbnailphoto", "thumbnailphotofilename", "largephoto", "largephotofilename", "modifieddate"::text + """.executeInsert(ProductphotoRow.rowParser(1).singleOpt) } override def upsert(unsaved: ProductphotoRow)(implicit c: Connection): ProductphotoRow = { SQL"""insert into "production"."productphoto"("productphotoid", "thumbnailphoto", "thumbnailphotofilename", "largephoto", "largephotofilename", "modifieddate") diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productphoto/ProductphotoRepoMock.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productphoto/ProductphotoRepoMock.scala index 56b5cbfec..522b14ee4 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productphoto/ProductphotoRepoMock.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productphoto/ProductphotoRepoMock.scala @@ -74,13 +74,10 @@ class ProductphotoRepoMock(toRow: Function1[ProductphotoRowUnsaved, Productphoto override def update: UpdateBuilder[ProductphotoFields, ProductphotoRow] = { UpdateBuilderMock(UpdateParams.empty, ProductphotoFields.structure, map) } - override def update(row: ProductphotoRow)(implicit c: Connection): Boolean = { - map.get(row.productphotoid) match { - case Some(`row`) => false - case Some(_) => - map.put(row.productphotoid, row): @nowarn - true - case None => false + override def update(row: ProductphotoRow)(implicit c: Connection): Option[ProductphotoRow] = { + map.get(row.productphotoid).map { _ => + map.put(row.productphotoid, row): @nowarn + row } } override def upsert(unsaved: ProductphotoRow)(implicit c: Connection): ProductphotoRow = { diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productproductphoto/ProductproductphotoRepo.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productproductphoto/ProductproductphotoRepo.scala index cd172131d..6b7dd6b8e 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productproductphoto/ProductproductphotoRepo.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productproductphoto/ProductproductphotoRepo.scala @@ -27,7 +27,7 @@ trait ProductproductphotoRepo { def selectByIds(compositeIds: Array[ProductproductphotoId])(implicit c: Connection): List[ProductproductphotoRow] def selectByIdsTracked(compositeIds: Array[ProductproductphotoId])(implicit c: Connection): Map[ProductproductphotoId, ProductproductphotoRow] def update: UpdateBuilder[ProductproductphotoFields, ProductproductphotoRow] - def update(row: ProductproductphotoRow)(implicit c: Connection): Boolean + def update(row: ProductproductphotoRow)(implicit c: Connection): Option[ProductproductphotoRow] def upsert(unsaved: ProductproductphotoRow)(implicit c: Connection): ProductproductphotoRow def upsertBatch(unsaved: Iterable[ProductproductphotoRow])(implicit c: Connection): List[ProductproductphotoRow] /* NOTE: this functionality is not safe if you use auto-commit mode! it runs 3 SQL statements */ diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productproductphoto/ProductproductphotoRepoImpl.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productproductphoto/ProductproductphotoRepoImpl.scala index deeec4a3c..8903f19a2 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productproductphoto/ProductproductphotoRepoImpl.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productproductphoto/ProductproductphotoRepoImpl.scala @@ -106,7 +106,7 @@ class ProductproductphotoRepoImpl extends ProductproductphotoRepo { val productphotoid = compositeIds.map(_.productphotoid) SQL"""select "productid", "productphotoid", "primary", "modifieddate"::text from "production"."productproductphoto" - where ("productid", "productphotoid") + where ("productid", "productphotoid") in (select unnest(${productid}), unnest(${productphotoid})) """.as(ProductproductphotoRow.rowParser(1).*) @@ -118,13 +118,14 @@ class ProductproductphotoRepoImpl extends ProductproductphotoRepo { override def update: UpdateBuilder[ProductproductphotoFields, ProductproductphotoRow] = { UpdateBuilder(""""production"."productproductphoto"""", ProductproductphotoFields.structure, ProductproductphotoRow.rowParser) } - override def update(row: ProductproductphotoRow)(implicit c: Connection): Boolean = { + override def update(row: ProductproductphotoRow)(implicit c: Connection): Option[ProductproductphotoRow] = { val compositeId = row.compositeId SQL"""update "production"."productproductphoto" set "primary" = ${ParameterValue(row.primary, null, Flag.toStatement)}::bool, "modifieddate" = ${ParameterValue(row.modifieddate, null, TypoLocalDateTime.toStatement)}::timestamp where "productid" = ${ParameterValue(compositeId.productid, null, ProductId.toStatement)} AND "productphotoid" = ${ParameterValue(compositeId.productphotoid, null, ProductphotoId.toStatement)} - """.executeUpdate() > 0 + returning "productid", "productphotoid", "primary", "modifieddate"::text + """.executeInsert(ProductproductphotoRow.rowParser(1).singleOpt) } override def upsert(unsaved: ProductproductphotoRow)(implicit c: Connection): ProductproductphotoRow = { SQL"""insert into "production"."productproductphoto"("productid", "productphotoid", "primary", "modifieddate") diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productproductphoto/ProductproductphotoRepoMock.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productproductphoto/ProductproductphotoRepoMock.scala index 8c274815d..9c761a02b 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productproductphoto/ProductproductphotoRepoMock.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productproductphoto/ProductproductphotoRepoMock.scala @@ -74,13 +74,10 @@ class ProductproductphotoRepoMock(toRow: Function1[ProductproductphotoRowUnsaved override def update: UpdateBuilder[ProductproductphotoFields, ProductproductphotoRow] = { UpdateBuilderMock(UpdateParams.empty, ProductproductphotoFields.structure, map) } - override def update(row: ProductproductphotoRow)(implicit c: Connection): Boolean = { - map.get(row.compositeId) match { - case Some(`row`) => false - case Some(_) => - map.put(row.compositeId, row): @nowarn - true - case None => false + override def update(row: ProductproductphotoRow)(implicit c: Connection): Option[ProductproductphotoRow] = { + map.get(row.compositeId).map { _ => + map.put(row.compositeId, row): @nowarn + row } } override def upsert(unsaved: ProductproductphotoRow)(implicit c: Connection): ProductproductphotoRow = { diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productreview/ProductreviewRepo.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productreview/ProductreviewRepo.scala index 16c0c6814..d1db57012 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productreview/ProductreviewRepo.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productreview/ProductreviewRepo.scala @@ -27,7 +27,7 @@ trait ProductreviewRepo { def selectByIds(productreviewids: Array[ProductreviewId])(implicit c: Connection): List[ProductreviewRow] def selectByIdsTracked(productreviewids: Array[ProductreviewId])(implicit c: Connection): Map[ProductreviewId, ProductreviewRow] def update: UpdateBuilder[ProductreviewFields, ProductreviewRow] - def update(row: ProductreviewRow)(implicit c: Connection): Boolean + def update(row: ProductreviewRow)(implicit c: Connection): Option[ProductreviewRow] def upsert(unsaved: ProductreviewRow)(implicit c: Connection): ProductreviewRow def upsertBatch(unsaved: Iterable[ProductreviewRow])(implicit c: Connection): List[ProductreviewRow] /* NOTE: this functionality is not safe if you use auto-commit mode! it runs 3 SQL statements */ diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productreview/ProductreviewRepoImpl.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productreview/ProductreviewRepoImpl.scala index ccfdf1f3d..1fda7d4d7 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productreview/ProductreviewRepoImpl.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productreview/ProductreviewRepoImpl.scala @@ -120,7 +120,7 @@ class ProductreviewRepoImpl extends ProductreviewRepo { override def update: UpdateBuilder[ProductreviewFields, ProductreviewRow] = { UpdateBuilder(""""production"."productreview"""", ProductreviewFields.structure, ProductreviewRow.rowParser) } - override def update(row: ProductreviewRow)(implicit c: Connection): Boolean = { + override def update(row: ProductreviewRow)(implicit c: Connection): Option[ProductreviewRow] = { val productreviewid = row.productreviewid SQL"""update "production"."productreview" set "productid" = ${ParameterValue(row.productid, null, ProductId.toStatement)}::int4, @@ -131,7 +131,8 @@ class ProductreviewRepoImpl extends ProductreviewRepo { "comments" = ${ParameterValue(row.comments, null, ToStatement.optionToStatement(ToStatement.stringToStatement, ParameterMetaData.StringParameterMetaData))}, "modifieddate" = ${ParameterValue(row.modifieddate, null, TypoLocalDateTime.toStatement)}::timestamp where "productreviewid" = ${ParameterValue(productreviewid, null, ProductreviewId.toStatement)} - """.executeUpdate() > 0 + returning "productreviewid", "productid", "reviewername", "reviewdate"::text, "emailaddress", "rating", "comments", "modifieddate"::text + """.executeInsert(ProductreviewRow.rowParser(1).singleOpt) } override def upsert(unsaved: ProductreviewRow)(implicit c: Connection): ProductreviewRow = { SQL"""insert into "production"."productreview"("productreviewid", "productid", "reviewername", "reviewdate", "emailaddress", "rating", "comments", "modifieddate") diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productreview/ProductreviewRepoMock.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productreview/ProductreviewRepoMock.scala index f65ed62d3..b70528b33 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productreview/ProductreviewRepoMock.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productreview/ProductreviewRepoMock.scala @@ -74,13 +74,10 @@ class ProductreviewRepoMock(toRow: Function1[ProductreviewRowUnsaved, Productrev override def update: UpdateBuilder[ProductreviewFields, ProductreviewRow] = { UpdateBuilderMock(UpdateParams.empty, ProductreviewFields.structure, map) } - override def update(row: ProductreviewRow)(implicit c: Connection): Boolean = { - map.get(row.productreviewid) match { - case Some(`row`) => false - case Some(_) => - map.put(row.productreviewid, row): @nowarn - true - case None => false + override def update(row: ProductreviewRow)(implicit c: Connection): Option[ProductreviewRow] = { + map.get(row.productreviewid).map { _ => + map.put(row.productreviewid, row): @nowarn + row } } override def upsert(unsaved: ProductreviewRow)(implicit c: Connection): ProductreviewRow = { diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productsubcategory/ProductsubcategoryRepo.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productsubcategory/ProductsubcategoryRepo.scala index 41fcf6294..fba6b7677 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productsubcategory/ProductsubcategoryRepo.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productsubcategory/ProductsubcategoryRepo.scala @@ -27,7 +27,7 @@ trait ProductsubcategoryRepo { def selectByIds(productsubcategoryids: Array[ProductsubcategoryId])(implicit c: Connection): List[ProductsubcategoryRow] def selectByIdsTracked(productsubcategoryids: Array[ProductsubcategoryId])(implicit c: Connection): Map[ProductsubcategoryId, ProductsubcategoryRow] def update: UpdateBuilder[ProductsubcategoryFields, ProductsubcategoryRow] - def update(row: ProductsubcategoryRow)(implicit c: Connection): Boolean + def update(row: ProductsubcategoryRow)(implicit c: Connection): Option[ProductsubcategoryRow] def upsert(unsaved: ProductsubcategoryRow)(implicit c: Connection): ProductsubcategoryRow def upsertBatch(unsaved: Iterable[ProductsubcategoryRow])(implicit c: Connection): List[ProductsubcategoryRow] /* NOTE: this functionality is not safe if you use auto-commit mode! it runs 3 SQL statements */ diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productsubcategory/ProductsubcategoryRepoImpl.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productsubcategory/ProductsubcategoryRepoImpl.scala index 06b198602..31c39f689 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productsubcategory/ProductsubcategoryRepoImpl.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productsubcategory/ProductsubcategoryRepoImpl.scala @@ -116,7 +116,7 @@ class ProductsubcategoryRepoImpl extends ProductsubcategoryRepo { override def update: UpdateBuilder[ProductsubcategoryFields, ProductsubcategoryRow] = { UpdateBuilder(""""production"."productsubcategory"""", ProductsubcategoryFields.structure, ProductsubcategoryRow.rowParser) } - override def update(row: ProductsubcategoryRow)(implicit c: Connection): Boolean = { + override def update(row: ProductsubcategoryRow)(implicit c: Connection): Option[ProductsubcategoryRow] = { val productsubcategoryid = row.productsubcategoryid SQL"""update "production"."productsubcategory" set "productcategoryid" = ${ParameterValue(row.productcategoryid, null, ProductcategoryId.toStatement)}::int4, @@ -124,7 +124,8 @@ class ProductsubcategoryRepoImpl extends ProductsubcategoryRepo { "rowguid" = ${ParameterValue(row.rowguid, null, TypoUUID.toStatement)}::uuid, "modifieddate" = ${ParameterValue(row.modifieddate, null, TypoLocalDateTime.toStatement)}::timestamp where "productsubcategoryid" = ${ParameterValue(productsubcategoryid, null, ProductsubcategoryId.toStatement)} - """.executeUpdate() > 0 + returning "productsubcategoryid", "productcategoryid", "name", "rowguid", "modifieddate"::text + """.executeInsert(ProductsubcategoryRow.rowParser(1).singleOpt) } override def upsert(unsaved: ProductsubcategoryRow)(implicit c: Connection): ProductsubcategoryRow = { SQL"""insert into "production"."productsubcategory"("productsubcategoryid", "productcategoryid", "name", "rowguid", "modifieddate") diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productsubcategory/ProductsubcategoryRepoMock.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productsubcategory/ProductsubcategoryRepoMock.scala index 62510fdab..5c234f7ea 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productsubcategory/ProductsubcategoryRepoMock.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/productsubcategory/ProductsubcategoryRepoMock.scala @@ -74,13 +74,10 @@ class ProductsubcategoryRepoMock(toRow: Function1[ProductsubcategoryRowUnsaved, override def update: UpdateBuilder[ProductsubcategoryFields, ProductsubcategoryRow] = { UpdateBuilderMock(UpdateParams.empty, ProductsubcategoryFields.structure, map) } - override def update(row: ProductsubcategoryRow)(implicit c: Connection): Boolean = { - map.get(row.productsubcategoryid) match { - case Some(`row`) => false - case Some(_) => - map.put(row.productsubcategoryid, row): @nowarn - true - case None => false + override def update(row: ProductsubcategoryRow)(implicit c: Connection): Option[ProductsubcategoryRow] = { + map.get(row.productsubcategoryid).map { _ => + map.put(row.productsubcategoryid, row): @nowarn + row } } override def upsert(unsaved: ProductsubcategoryRow)(implicit c: Connection): ProductsubcategoryRow = { diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/scrapreason/ScrapreasonRepo.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/scrapreason/ScrapreasonRepo.scala index 7ebfefd6c..621f4051a 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/scrapreason/ScrapreasonRepo.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/scrapreason/ScrapreasonRepo.scala @@ -27,7 +27,7 @@ trait ScrapreasonRepo { def selectByIds(scrapreasonids: Array[ScrapreasonId])(implicit c: Connection): List[ScrapreasonRow] def selectByIdsTracked(scrapreasonids: Array[ScrapreasonId])(implicit c: Connection): Map[ScrapreasonId, ScrapreasonRow] def update: UpdateBuilder[ScrapreasonFields, ScrapreasonRow] - def update(row: ScrapreasonRow)(implicit c: Connection): Boolean + def update(row: ScrapreasonRow)(implicit c: Connection): Option[ScrapreasonRow] def upsert(unsaved: ScrapreasonRow)(implicit c: Connection): ScrapreasonRow def upsertBatch(unsaved: Iterable[ScrapreasonRow])(implicit c: Connection): List[ScrapreasonRow] /* NOTE: this functionality is not safe if you use auto-commit mode! it runs 3 SQL statements */ diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/scrapreason/ScrapreasonRepoImpl.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/scrapreason/ScrapreasonRepoImpl.scala index 82b32bc1e..eb81e78c1 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/scrapreason/ScrapreasonRepoImpl.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/scrapreason/ScrapreasonRepoImpl.scala @@ -109,13 +109,14 @@ class ScrapreasonRepoImpl extends ScrapreasonRepo { override def update: UpdateBuilder[ScrapreasonFields, ScrapreasonRow] = { UpdateBuilder(""""production"."scrapreason"""", ScrapreasonFields.structure, ScrapreasonRow.rowParser) } - override def update(row: ScrapreasonRow)(implicit c: Connection): Boolean = { + override def update(row: ScrapreasonRow)(implicit c: Connection): Option[ScrapreasonRow] = { val scrapreasonid = row.scrapreasonid SQL"""update "production"."scrapreason" set "name" = ${ParameterValue(row.name, null, Name.toStatement)}::varchar, "modifieddate" = ${ParameterValue(row.modifieddate, null, TypoLocalDateTime.toStatement)}::timestamp where "scrapreasonid" = ${ParameterValue(scrapreasonid, null, ScrapreasonId.toStatement)} - """.executeUpdate() > 0 + returning "scrapreasonid", "name", "modifieddate"::text + """.executeInsert(ScrapreasonRow.rowParser(1).singleOpt) } override def upsert(unsaved: ScrapreasonRow)(implicit c: Connection): ScrapreasonRow = { SQL"""insert into "production"."scrapreason"("scrapreasonid", "name", "modifieddate") diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/scrapreason/ScrapreasonRepoMock.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/scrapreason/ScrapreasonRepoMock.scala index 107aa26c2..2556bfce9 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/scrapreason/ScrapreasonRepoMock.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/scrapreason/ScrapreasonRepoMock.scala @@ -74,13 +74,10 @@ class ScrapreasonRepoMock(toRow: Function1[ScrapreasonRowUnsaved, ScrapreasonRow override def update: UpdateBuilder[ScrapreasonFields, ScrapreasonRow] = { UpdateBuilderMock(UpdateParams.empty, ScrapreasonFields.structure, map) } - override def update(row: ScrapreasonRow)(implicit c: Connection): Boolean = { - map.get(row.scrapreasonid) match { - case Some(`row`) => false - case Some(_) => - map.put(row.scrapreasonid, row): @nowarn - true - case None => false + override def update(row: ScrapreasonRow)(implicit c: Connection): Option[ScrapreasonRow] = { + map.get(row.scrapreasonid).map { _ => + map.put(row.scrapreasonid, row): @nowarn + row } } override def upsert(unsaved: ScrapreasonRow)(implicit c: Connection): ScrapreasonRow = { diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/transactionhistory/TransactionhistoryRepo.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/transactionhistory/TransactionhistoryRepo.scala index 0dbc93d54..9e820138e 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/transactionhistory/TransactionhistoryRepo.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/transactionhistory/TransactionhistoryRepo.scala @@ -27,7 +27,7 @@ trait TransactionhistoryRepo { def selectByIds(transactionids: Array[TransactionhistoryId])(implicit c: Connection): List[TransactionhistoryRow] def selectByIdsTracked(transactionids: Array[TransactionhistoryId])(implicit c: Connection): Map[TransactionhistoryId, TransactionhistoryRow] def update: UpdateBuilder[TransactionhistoryFields, TransactionhistoryRow] - def update(row: TransactionhistoryRow)(implicit c: Connection): Boolean + def update(row: TransactionhistoryRow)(implicit c: Connection): Option[TransactionhistoryRow] def upsert(unsaved: TransactionhistoryRow)(implicit c: Connection): TransactionhistoryRow def upsertBatch(unsaved: Iterable[TransactionhistoryRow])(implicit c: Connection): List[TransactionhistoryRow] /* NOTE: this functionality is not safe if you use auto-commit mode! it runs 3 SQL statements */ diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/transactionhistory/TransactionhistoryRepoImpl.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/transactionhistory/TransactionhistoryRepoImpl.scala index 589f189e4..9a4e9ecca 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/transactionhistory/TransactionhistoryRepoImpl.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/transactionhistory/TransactionhistoryRepoImpl.scala @@ -122,7 +122,7 @@ class TransactionhistoryRepoImpl extends TransactionhistoryRepo { override def update: UpdateBuilder[TransactionhistoryFields, TransactionhistoryRow] = { UpdateBuilder(""""production"."transactionhistory"""", TransactionhistoryFields.structure, TransactionhistoryRow.rowParser) } - override def update(row: TransactionhistoryRow)(implicit c: Connection): Boolean = { + override def update(row: TransactionhistoryRow)(implicit c: Connection): Option[TransactionhistoryRow] = { val transactionid = row.transactionid SQL"""update "production"."transactionhistory" set "productid" = ${ParameterValue(row.productid, null, ProductId.toStatement)}::int4, @@ -134,7 +134,8 @@ class TransactionhistoryRepoImpl extends TransactionhistoryRepo { "actualcost" = ${ParameterValue(row.actualcost, null, ToStatement.scalaBigDecimalToStatement)}::numeric, "modifieddate" = ${ParameterValue(row.modifieddate, null, TypoLocalDateTime.toStatement)}::timestamp where "transactionid" = ${ParameterValue(transactionid, null, TransactionhistoryId.toStatement)} - """.executeUpdate() > 0 + returning "transactionid", "productid", "referenceorderid", "referenceorderlineid", "transactiondate"::text, "transactiontype", "quantity", "actualcost", "modifieddate"::text + """.executeInsert(TransactionhistoryRow.rowParser(1).singleOpt) } override def upsert(unsaved: TransactionhistoryRow)(implicit c: Connection): TransactionhistoryRow = { SQL"""insert into "production"."transactionhistory"("transactionid", "productid", "referenceorderid", "referenceorderlineid", "transactiondate", "transactiontype", "quantity", "actualcost", "modifieddate") diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/transactionhistory/TransactionhistoryRepoMock.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/transactionhistory/TransactionhistoryRepoMock.scala index 6eab7339a..431633f60 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/transactionhistory/TransactionhistoryRepoMock.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/transactionhistory/TransactionhistoryRepoMock.scala @@ -74,13 +74,10 @@ class TransactionhistoryRepoMock(toRow: Function1[TransactionhistoryRowUnsaved, override def update: UpdateBuilder[TransactionhistoryFields, TransactionhistoryRow] = { UpdateBuilderMock(UpdateParams.empty, TransactionhistoryFields.structure, map) } - override def update(row: TransactionhistoryRow)(implicit c: Connection): Boolean = { - map.get(row.transactionid) match { - case Some(`row`) => false - case Some(_) => - map.put(row.transactionid, row): @nowarn - true - case None => false + override def update(row: TransactionhistoryRow)(implicit c: Connection): Option[TransactionhistoryRow] = { + map.get(row.transactionid).map { _ => + map.put(row.transactionid, row): @nowarn + row } } override def upsert(unsaved: TransactionhistoryRow)(implicit c: Connection): TransactionhistoryRow = { diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/transactionhistoryarchive/TransactionhistoryarchiveRepo.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/transactionhistoryarchive/TransactionhistoryarchiveRepo.scala index 8d30c0a9b..0cec60f44 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/transactionhistoryarchive/TransactionhistoryarchiveRepo.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/transactionhistoryarchive/TransactionhistoryarchiveRepo.scala @@ -27,7 +27,7 @@ trait TransactionhistoryarchiveRepo { def selectByIds(transactionids: Array[TransactionhistoryarchiveId])(implicit c: Connection): List[TransactionhistoryarchiveRow] def selectByIdsTracked(transactionids: Array[TransactionhistoryarchiveId])(implicit c: Connection): Map[TransactionhistoryarchiveId, TransactionhistoryarchiveRow] def update: UpdateBuilder[TransactionhistoryarchiveFields, TransactionhistoryarchiveRow] - def update(row: TransactionhistoryarchiveRow)(implicit c: Connection): Boolean + def update(row: TransactionhistoryarchiveRow)(implicit c: Connection): Option[TransactionhistoryarchiveRow] def upsert(unsaved: TransactionhistoryarchiveRow)(implicit c: Connection): TransactionhistoryarchiveRow def upsertBatch(unsaved: Iterable[TransactionhistoryarchiveRow])(implicit c: Connection): List[TransactionhistoryarchiveRow] /* NOTE: this functionality is not safe if you use auto-commit mode! it runs 3 SQL statements */ diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/transactionhistoryarchive/TransactionhistoryarchiveRepoImpl.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/transactionhistoryarchive/TransactionhistoryarchiveRepoImpl.scala index 7e73d57ba..502f3ebd7 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/transactionhistoryarchive/TransactionhistoryarchiveRepoImpl.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/transactionhistoryarchive/TransactionhistoryarchiveRepoImpl.scala @@ -118,7 +118,7 @@ class TransactionhistoryarchiveRepoImpl extends TransactionhistoryarchiveRepo { override def update: UpdateBuilder[TransactionhistoryarchiveFields, TransactionhistoryarchiveRow] = { UpdateBuilder(""""production"."transactionhistoryarchive"""", TransactionhistoryarchiveFields.structure, TransactionhistoryarchiveRow.rowParser) } - override def update(row: TransactionhistoryarchiveRow)(implicit c: Connection): Boolean = { + override def update(row: TransactionhistoryarchiveRow)(implicit c: Connection): Option[TransactionhistoryarchiveRow] = { val transactionid = row.transactionid SQL"""update "production"."transactionhistoryarchive" set "productid" = ${ParameterValue(row.productid, null, ToStatement.intToStatement)}::int4, @@ -130,7 +130,8 @@ class TransactionhistoryarchiveRepoImpl extends TransactionhistoryarchiveRepo { "actualcost" = ${ParameterValue(row.actualcost, null, ToStatement.scalaBigDecimalToStatement)}::numeric, "modifieddate" = ${ParameterValue(row.modifieddate, null, TypoLocalDateTime.toStatement)}::timestamp where "transactionid" = ${ParameterValue(transactionid, null, TransactionhistoryarchiveId.toStatement)} - """.executeUpdate() > 0 + returning "transactionid", "productid", "referenceorderid", "referenceorderlineid", "transactiondate"::text, "transactiontype", "quantity", "actualcost", "modifieddate"::text + """.executeInsert(TransactionhistoryarchiveRow.rowParser(1).singleOpt) } override def upsert(unsaved: TransactionhistoryarchiveRow)(implicit c: Connection): TransactionhistoryarchiveRow = { SQL"""insert into "production"."transactionhistoryarchive"("transactionid", "productid", "referenceorderid", "referenceorderlineid", "transactiondate", "transactiontype", "quantity", "actualcost", "modifieddate") diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/transactionhistoryarchive/TransactionhistoryarchiveRepoMock.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/transactionhistoryarchive/TransactionhistoryarchiveRepoMock.scala index b4b9ad1d8..653ed7b4a 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/transactionhistoryarchive/TransactionhistoryarchiveRepoMock.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/transactionhistoryarchive/TransactionhistoryarchiveRepoMock.scala @@ -74,13 +74,10 @@ class TransactionhistoryarchiveRepoMock(toRow: Function1[Transactionhistoryarchi override def update: UpdateBuilder[TransactionhistoryarchiveFields, TransactionhistoryarchiveRow] = { UpdateBuilderMock(UpdateParams.empty, TransactionhistoryarchiveFields.structure, map) } - override def update(row: TransactionhistoryarchiveRow)(implicit c: Connection): Boolean = { - map.get(row.transactionid) match { - case Some(`row`) => false - case Some(_) => - map.put(row.transactionid, row): @nowarn - true - case None => false + override def update(row: TransactionhistoryarchiveRow)(implicit c: Connection): Option[TransactionhistoryarchiveRow] = { + map.get(row.transactionid).map { _ => + map.put(row.transactionid, row): @nowarn + row } } override def upsert(unsaved: TransactionhistoryarchiveRow)(implicit c: Connection): TransactionhistoryarchiveRow = { diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/unitmeasure/UnitmeasureRepo.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/unitmeasure/UnitmeasureRepo.scala index ca017dc08..47b572a52 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/unitmeasure/UnitmeasureRepo.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/unitmeasure/UnitmeasureRepo.scala @@ -27,7 +27,7 @@ trait UnitmeasureRepo { def selectByIds(unitmeasurecodes: Array[UnitmeasureId])(implicit c: Connection): List[UnitmeasureRow] def selectByIdsTracked(unitmeasurecodes: Array[UnitmeasureId])(implicit c: Connection): Map[UnitmeasureId, UnitmeasureRow] def update: UpdateBuilder[UnitmeasureFields, UnitmeasureRow] - def update(row: UnitmeasureRow)(implicit c: Connection): Boolean + def update(row: UnitmeasureRow)(implicit c: Connection): Option[UnitmeasureRow] def upsert(unsaved: UnitmeasureRow)(implicit c: Connection): UnitmeasureRow def upsertBatch(unsaved: Iterable[UnitmeasureRow])(implicit c: Connection): List[UnitmeasureRow] /* NOTE: this functionality is not safe if you use auto-commit mode! it runs 3 SQL statements */ diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/unitmeasure/UnitmeasureRepoImpl.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/unitmeasure/UnitmeasureRepoImpl.scala index 5870a4a57..261cf0891 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/unitmeasure/UnitmeasureRepoImpl.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/unitmeasure/UnitmeasureRepoImpl.scala @@ -106,13 +106,14 @@ class UnitmeasureRepoImpl extends UnitmeasureRepo { override def update: UpdateBuilder[UnitmeasureFields, UnitmeasureRow] = { UpdateBuilder(""""production"."unitmeasure"""", UnitmeasureFields.structure, UnitmeasureRow.rowParser) } - override def update(row: UnitmeasureRow)(implicit c: Connection): Boolean = { + override def update(row: UnitmeasureRow)(implicit c: Connection): Option[UnitmeasureRow] = { val unitmeasurecode = row.unitmeasurecode SQL"""update "production"."unitmeasure" set "name" = ${ParameterValue(row.name, null, Name.toStatement)}::varchar, "modifieddate" = ${ParameterValue(row.modifieddate, null, TypoLocalDateTime.toStatement)}::timestamp where "unitmeasurecode" = ${ParameterValue(unitmeasurecode, null, UnitmeasureId.toStatement)} - """.executeUpdate() > 0 + returning "unitmeasurecode", "name", "modifieddate"::text + """.executeInsert(UnitmeasureRow.rowParser(1).singleOpt) } override def upsert(unsaved: UnitmeasureRow)(implicit c: Connection): UnitmeasureRow = { SQL"""insert into "production"."unitmeasure"("unitmeasurecode", "name", "modifieddate") diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/unitmeasure/UnitmeasureRepoMock.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/unitmeasure/UnitmeasureRepoMock.scala index 95af9d14c..c767dfa2b 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/unitmeasure/UnitmeasureRepoMock.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/unitmeasure/UnitmeasureRepoMock.scala @@ -74,13 +74,10 @@ class UnitmeasureRepoMock(toRow: Function1[UnitmeasureRowUnsaved, UnitmeasureRow override def update: UpdateBuilder[UnitmeasureFields, UnitmeasureRow] = { UpdateBuilderMock(UpdateParams.empty, UnitmeasureFields.structure, map) } - override def update(row: UnitmeasureRow)(implicit c: Connection): Boolean = { - map.get(row.unitmeasurecode) match { - case Some(`row`) => false - case Some(_) => - map.put(row.unitmeasurecode, row): @nowarn - true - case None => false + override def update(row: UnitmeasureRow)(implicit c: Connection): Option[UnitmeasureRow] = { + map.get(row.unitmeasurecode).map { _ => + map.put(row.unitmeasurecode, row): @nowarn + row } } override def upsert(unsaved: UnitmeasureRow)(implicit c: Connection): UnitmeasureRow = { diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/workorder/WorkorderRepo.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/workorder/WorkorderRepo.scala index c2f482859..fa6c15dc8 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/workorder/WorkorderRepo.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/workorder/WorkorderRepo.scala @@ -27,7 +27,7 @@ trait WorkorderRepo { def selectByIds(workorderids: Array[WorkorderId])(implicit c: Connection): List[WorkorderRow] def selectByIdsTracked(workorderids: Array[WorkorderId])(implicit c: Connection): Map[WorkorderId, WorkorderRow] def update: UpdateBuilder[WorkorderFields, WorkorderRow] - def update(row: WorkorderRow)(implicit c: Connection): Boolean + def update(row: WorkorderRow)(implicit c: Connection): Option[WorkorderRow] def upsert(unsaved: WorkorderRow)(implicit c: Connection): WorkorderRow def upsertBatch(unsaved: Iterable[WorkorderRow])(implicit c: Connection): List[WorkorderRow] /* NOTE: this functionality is not safe if you use auto-commit mode! it runs 3 SQL statements */ diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/workorder/WorkorderRepoImpl.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/workorder/WorkorderRepoImpl.scala index a415a2959..05fbe1a66 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/workorder/WorkorderRepoImpl.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/workorder/WorkorderRepoImpl.scala @@ -118,7 +118,7 @@ class WorkorderRepoImpl extends WorkorderRepo { override def update: UpdateBuilder[WorkorderFields, WorkorderRow] = { UpdateBuilder(""""production"."workorder"""", WorkorderFields.structure, WorkorderRow.rowParser) } - override def update(row: WorkorderRow)(implicit c: Connection): Boolean = { + override def update(row: WorkorderRow)(implicit c: Connection): Option[WorkorderRow] = { val workorderid = row.workorderid SQL"""update "production"."workorder" set "productid" = ${ParameterValue(row.productid, null, ProductId.toStatement)}::int4, @@ -130,7 +130,8 @@ class WorkorderRepoImpl extends WorkorderRepo { "scrapreasonid" = ${ParameterValue(row.scrapreasonid, null, ToStatement.optionToStatement(ScrapreasonId.toStatement, ScrapreasonId.parameterMetadata))}::int2, "modifieddate" = ${ParameterValue(row.modifieddate, null, TypoLocalDateTime.toStatement)}::timestamp where "workorderid" = ${ParameterValue(workorderid, null, WorkorderId.toStatement)} - """.executeUpdate() > 0 + returning "workorderid", "productid", "orderqty", "scrappedqty", "startdate"::text, "enddate"::text, "duedate"::text, "scrapreasonid", "modifieddate"::text + """.executeInsert(WorkorderRow.rowParser(1).singleOpt) } override def upsert(unsaved: WorkorderRow)(implicit c: Connection): WorkorderRow = { SQL"""insert into "production"."workorder"("workorderid", "productid", "orderqty", "scrappedqty", "startdate", "enddate", "duedate", "scrapreasonid", "modifieddate") diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/workorder/WorkorderRepoMock.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/workorder/WorkorderRepoMock.scala index f21b6e49a..7b7261533 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/workorder/WorkorderRepoMock.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/workorder/WorkorderRepoMock.scala @@ -74,13 +74,10 @@ class WorkorderRepoMock(toRow: Function1[WorkorderRowUnsaved, WorkorderRow], override def update: UpdateBuilder[WorkorderFields, WorkorderRow] = { UpdateBuilderMock(UpdateParams.empty, WorkorderFields.structure, map) } - override def update(row: WorkorderRow)(implicit c: Connection): Boolean = { - map.get(row.workorderid) match { - case Some(`row`) => false - case Some(_) => - map.put(row.workorderid, row): @nowarn - true - case None => false + override def update(row: WorkorderRow)(implicit c: Connection): Option[WorkorderRow] = { + map.get(row.workorderid).map { _ => + map.put(row.workorderid, row): @nowarn + row } } override def upsert(unsaved: WorkorderRow)(implicit c: Connection): WorkorderRow = { diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/workorderrouting/WorkorderroutingRepo.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/workorderrouting/WorkorderroutingRepo.scala index d87cb2cae..1dad4c2c5 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/workorderrouting/WorkorderroutingRepo.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/workorderrouting/WorkorderroutingRepo.scala @@ -27,7 +27,7 @@ trait WorkorderroutingRepo { def selectByIds(compositeIds: Array[WorkorderroutingId])(implicit c: Connection): List[WorkorderroutingRow] def selectByIdsTracked(compositeIds: Array[WorkorderroutingId])(implicit c: Connection): Map[WorkorderroutingId, WorkorderroutingRow] def update: UpdateBuilder[WorkorderroutingFields, WorkorderroutingRow] - def update(row: WorkorderroutingRow)(implicit c: Connection): Boolean + def update(row: WorkorderroutingRow)(implicit c: Connection): Option[WorkorderroutingRow] def upsert(unsaved: WorkorderroutingRow)(implicit c: Connection): WorkorderroutingRow def upsertBatch(unsaved: Iterable[WorkorderroutingRow])(implicit c: Connection): List[WorkorderroutingRow] /* NOTE: this functionality is not safe if you use auto-commit mode! it runs 3 SQL statements */ diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/workorderrouting/WorkorderroutingRepoImpl.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/workorderrouting/WorkorderroutingRepoImpl.scala index fc1d8f416..e23e554db 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/workorderrouting/WorkorderroutingRepoImpl.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/workorderrouting/WorkorderroutingRepoImpl.scala @@ -115,7 +115,7 @@ class WorkorderroutingRepoImpl extends WorkorderroutingRepo { val operationsequence = compositeIds.map(_.operationsequence) SQL"""select "workorderid", "productid", "operationsequence", "locationid", "scheduledstartdate"::text, "scheduledenddate"::text, "actualstartdate"::text, "actualenddate"::text, "actualresourcehrs", "plannedcost", "actualcost", "modifieddate"::text from "production"."workorderrouting" - where ("workorderid", "productid", "operationsequence") + where ("workorderid", "productid", "operationsequence") in (select unnest(${workorderid}), unnest(${productid}), unnest(${operationsequence})) """.as(WorkorderroutingRow.rowParser(1).*) @@ -127,7 +127,7 @@ class WorkorderroutingRepoImpl extends WorkorderroutingRepo { override def update: UpdateBuilder[WorkorderroutingFields, WorkorderroutingRow] = { UpdateBuilder(""""production"."workorderrouting"""", WorkorderroutingFields.structure, WorkorderroutingRow.rowParser) } - override def update(row: WorkorderroutingRow)(implicit c: Connection): Boolean = { + override def update(row: WorkorderroutingRow)(implicit c: Connection): Option[WorkorderroutingRow] = { val compositeId = row.compositeId SQL"""update "production"."workorderrouting" set "locationid" = ${ParameterValue(row.locationid, null, LocationId.toStatement)}::int2, @@ -140,7 +140,8 @@ class WorkorderroutingRepoImpl extends WorkorderroutingRepo { "actualcost" = ${ParameterValue(row.actualcost, null, ToStatement.optionToStatement(ToStatement.scalaBigDecimalToStatement, ParameterMetaData.BigDecimalParameterMetaData))}::numeric, "modifieddate" = ${ParameterValue(row.modifieddate, null, TypoLocalDateTime.toStatement)}::timestamp where "workorderid" = ${ParameterValue(compositeId.workorderid, null, WorkorderId.toStatement)} AND "productid" = ${ParameterValue(compositeId.productid, null, ToStatement.intToStatement)} AND "operationsequence" = ${ParameterValue(compositeId.operationsequence, null, TypoShort.toStatement)} - """.executeUpdate() > 0 + returning "workorderid", "productid", "operationsequence", "locationid", "scheduledstartdate"::text, "scheduledenddate"::text, "actualstartdate"::text, "actualenddate"::text, "actualresourcehrs", "plannedcost", "actualcost", "modifieddate"::text + """.executeInsert(WorkorderroutingRow.rowParser(1).singleOpt) } override def upsert(unsaved: WorkorderroutingRow)(implicit c: Connection): WorkorderroutingRow = { SQL"""insert into "production"."workorderrouting"("workorderid", "productid", "operationsequence", "locationid", "scheduledstartdate", "scheduledenddate", "actualstartdate", "actualenddate", "actualresourcehrs", "plannedcost", "actualcost", "modifieddate") diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/workorderrouting/WorkorderroutingRepoMock.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/workorderrouting/WorkorderroutingRepoMock.scala index d17a8660d..e9e07720c 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/production/workorderrouting/WorkorderroutingRepoMock.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/production/workorderrouting/WorkorderroutingRepoMock.scala @@ -74,13 +74,10 @@ class WorkorderroutingRepoMock(toRow: Function1[WorkorderroutingRowUnsaved, Work override def update: UpdateBuilder[WorkorderroutingFields, WorkorderroutingRow] = { UpdateBuilderMock(UpdateParams.empty, WorkorderroutingFields.structure, map) } - override def update(row: WorkorderroutingRow)(implicit c: Connection): Boolean = { - map.get(row.compositeId) match { - case Some(`row`) => false - case Some(_) => - map.put(row.compositeId, row): @nowarn - true - case None => false + override def update(row: WorkorderroutingRow)(implicit c: Connection): Option[WorkorderroutingRow] = { + map.get(row.compositeId).map { _ => + map.put(row.compositeId, row): @nowarn + row } } override def upsert(unsaved: WorkorderroutingRow)(implicit c: Connection): WorkorderroutingRow = { diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/public/flaff/FlaffRepo.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/public/flaff/FlaffRepo.scala index caf14d62b..5fc08c931 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/public/flaff/FlaffRepo.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/public/flaff/FlaffRepo.scala @@ -24,7 +24,7 @@ trait FlaffRepo { def selectByIds(compositeIds: Array[FlaffId])(implicit c: Connection): List[FlaffRow] def selectByIdsTracked(compositeIds: Array[FlaffId])(implicit c: Connection): Map[FlaffId, FlaffRow] def update: UpdateBuilder[FlaffFields, FlaffRow] - def update(row: FlaffRow)(implicit c: Connection): Boolean + def update(row: FlaffRow)(implicit c: Connection): Option[FlaffRow] def upsert(unsaved: FlaffRow)(implicit c: Connection): FlaffRow def upsertBatch(unsaved: Iterable[FlaffRow])(implicit c: Connection): List[FlaffRow] /* NOTE: this functionality is not safe if you use auto-commit mode! it runs 3 SQL statements */ diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/public/flaff/FlaffRepoImpl.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/public/flaff/FlaffRepoImpl.scala index 6b6b093a1..a65128ac2 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/public/flaff/FlaffRepoImpl.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/public/flaff/FlaffRepoImpl.scala @@ -70,7 +70,7 @@ class FlaffRepoImpl extends FlaffRepo { val specifier = compositeIds.map(_.specifier) SQL"""select "code", "another_code", "some_number", "specifier", "parentspecifier" from "public"."flaff" - where ("code", "another_code", "some_number", "specifier") + where ("code", "another_code", "some_number", "specifier") in (select unnest(${code}), unnest(${anotherCode}), unnest(${someNumber}), unnest(${specifier})) """.as(FlaffRow.rowParser(1).*) @@ -82,12 +82,13 @@ class FlaffRepoImpl extends FlaffRepo { override def update: UpdateBuilder[FlaffFields, FlaffRow] = { UpdateBuilder(""""public"."flaff"""", FlaffFields.structure, FlaffRow.rowParser) } - override def update(row: FlaffRow)(implicit c: Connection): Boolean = { + override def update(row: FlaffRow)(implicit c: Connection): Option[FlaffRow] = { val compositeId = row.compositeId SQL"""update "public"."flaff" set "parentspecifier" = ${ParameterValue(row.parentspecifier, null, ToStatement.optionToStatement(ShortText.toStatement, ShortText.parameterMetadata))}::text where "code" = ${ParameterValue(compositeId.code, null, ShortText.toStatement)} AND "another_code" = ${ParameterValue(compositeId.anotherCode, null, ToStatement.stringToStatement)} AND "some_number" = ${ParameterValue(compositeId.someNumber, null, ToStatement.intToStatement)} AND "specifier" = ${ParameterValue(compositeId.specifier, null, ShortText.toStatement)} - """.executeUpdate() > 0 + returning "code", "another_code", "some_number", "specifier", "parentspecifier" + """.executeInsert(FlaffRow.rowParser(1).singleOpt) } override def upsert(unsaved: FlaffRow)(implicit c: Connection): FlaffRow = { SQL"""insert into "public"."flaff"("code", "another_code", "some_number", "specifier", "parentspecifier") diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/public/flaff/FlaffRepoMock.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/public/flaff/FlaffRepoMock.scala index 58a5d388d..1b316b4b1 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/public/flaff/FlaffRepoMock.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/public/flaff/FlaffRepoMock.scala @@ -62,13 +62,10 @@ class FlaffRepoMock(map: scala.collection.mutable.Map[FlaffId, FlaffRow] = scala override def update: UpdateBuilder[FlaffFields, FlaffRow] = { UpdateBuilderMock(UpdateParams.empty, FlaffFields.structure, map) } - override def update(row: FlaffRow)(implicit c: Connection): Boolean = { - map.get(row.compositeId) match { - case Some(`row`) => false - case Some(_) => - map.put(row.compositeId, row): @nowarn - true - case None => false + override def update(row: FlaffRow)(implicit c: Connection): Option[FlaffRow] = { + map.get(row.compositeId).map { _ => + map.put(row.compositeId, row): @nowarn + row } } override def upsert(unsaved: FlaffRow)(implicit c: Connection): FlaffRow = { diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/public/identity_test/IdentityTestRepo.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/public/identity_test/IdentityTestRepo.scala index 7f7eca706..9563ba3fb 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/public/identity_test/IdentityTestRepo.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/public/identity_test/IdentityTestRepo.scala @@ -27,7 +27,7 @@ trait IdentityTestRepo { def selectByIds(names: Array[IdentityTestId])(implicit c: Connection): List[IdentityTestRow] def selectByIdsTracked(names: Array[IdentityTestId])(implicit c: Connection): Map[IdentityTestId, IdentityTestRow] def update: UpdateBuilder[IdentityTestFields, IdentityTestRow] - def update(row: IdentityTestRow)(implicit c: Connection): Boolean + def update(row: IdentityTestRow)(implicit c: Connection): Option[IdentityTestRow] def upsert(unsaved: IdentityTestRow)(implicit c: Connection): IdentityTestRow def upsertBatch(unsaved: Iterable[IdentityTestRow])(implicit c: Connection): List[IdentityTestRow] /* NOTE: this functionality is not safe if you use auto-commit mode! it runs 3 SQL statements */ diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/public/identity_test/IdentityTestRepoImpl.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/public/identity_test/IdentityTestRepoImpl.scala index 94393de77..9fda55c12 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/public/identity_test/IdentityTestRepoImpl.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/public/identity_test/IdentityTestRepoImpl.scala @@ -104,12 +104,13 @@ class IdentityTestRepoImpl extends IdentityTestRepo { override def update: UpdateBuilder[IdentityTestFields, IdentityTestRow] = { UpdateBuilder(""""public"."identity-test"""", IdentityTestFields.structure, IdentityTestRow.rowParser) } - override def update(row: IdentityTestRow)(implicit c: Connection): Boolean = { + override def update(row: IdentityTestRow)(implicit c: Connection): Option[IdentityTestRow] = { val name = row.name SQL"""update "public"."identity-test" set "default_generated" = ${ParameterValue(row.defaultGenerated, null, ToStatement.intToStatement)}::int4 where "name" = ${ParameterValue(name, null, IdentityTestId.toStatement)} - """.executeUpdate() > 0 + returning "always_generated", "default_generated", "name" + """.executeInsert(IdentityTestRow.rowParser(1).singleOpt) } override def upsert(unsaved: IdentityTestRow)(implicit c: Connection): IdentityTestRow = { SQL"""insert into "public"."identity-test"("default_generated", "name") diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/public/identity_test/IdentityTestRepoMock.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/public/identity_test/IdentityTestRepoMock.scala index f360aff44..d16d9cbbd 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/public/identity_test/IdentityTestRepoMock.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/public/identity_test/IdentityTestRepoMock.scala @@ -74,13 +74,10 @@ class IdentityTestRepoMock(toRow: Function1[IdentityTestRowUnsaved, IdentityTest override def update: UpdateBuilder[IdentityTestFields, IdentityTestRow] = { UpdateBuilderMock(UpdateParams.empty, IdentityTestFields.structure, map) } - override def update(row: IdentityTestRow)(implicit c: Connection): Boolean = { - map.get(row.name) match { - case Some(`row`) => false - case Some(_) => - map.put(row.name, row): @nowarn - true - case None => false + override def update(row: IdentityTestRow)(implicit c: Connection): Option[IdentityTestRow] = { + map.get(row.name).map { _ => + map.put(row.name, row): @nowarn + row } } override def upsert(unsaved: IdentityTestRow)(implicit c: Connection): IdentityTestRow = { 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 9f7963d1a..45360beba 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 @@ -29,7 +29,7 @@ trait UsersRepo { def selectByIdsTracked(userIds: Array[UsersId])(implicit c: Connection): Map[UsersId, UsersRow] def selectByUniqueEmail(email: TypoUnknownCitext)(implicit c: Connection): Option[UsersRow] def update: UpdateBuilder[UsersFields, UsersRow] - def update(row: UsersRow)(implicit c: Connection): Boolean + def update(row: UsersRow)(implicit c: Connection): Option[UsersRow] def upsert(unsaved: UsersRow)(implicit c: Connection): UsersRow def upsertBatch(unsaved: Iterable[UsersRow])(implicit c: Connection): List[UsersRow] /* NOTE: this functionality is not safe if you use auto-commit mode! it runs 3 SQL statements */ 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 3f2b4f701..02d2feb3d 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 @@ -119,7 +119,7 @@ class UsersRepoImpl extends UsersRepo { override def update: UpdateBuilder[UsersFields, UsersRow] = { UpdateBuilder(""""public"."users"""", UsersFields.structure, UsersRow.rowParser) } - override def update(row: UsersRow)(implicit c: Connection): Boolean = { + override def update(row: UsersRow)(implicit c: Connection): Option[UsersRow] = { val userId = row.userId SQL"""update "public"."users" set "name" = ${ParameterValue(row.name, null, ToStatement.stringToStatement)}, @@ -129,7 +129,8 @@ class UsersRepoImpl extends UsersRepo { "created_at" = ${ParameterValue(row.createdAt, null, TypoInstant.toStatement)}::timestamptz, "verified_on" = ${ParameterValue(row.verifiedOn, null, ToStatement.optionToStatement(TypoInstant.toStatement, TypoInstant.parameterMetadata))}::timestamptz where "user_id" = ${ParameterValue(userId, null, UsersId.toStatement)} - """.executeUpdate() > 0 + returning "user_id", "name", "last_name", "email"::text, "password", "created_at"::text, "verified_on"::text + """.executeInsert(UsersRow.rowParser(1).singleOpt) } override def upsert(unsaved: UsersRow)(implicit c: Connection): UsersRow = { SQL"""insert into "public"."users"("user_id", "name", "last_name", "email", "password", "created_at", "verified_on") 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 24abf7a4a..c10e31f9f 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 @@ -78,13 +78,10 @@ class UsersRepoMock(toRow: Function1[UsersRowUnsaved, UsersRow], override def update: UpdateBuilder[UsersFields, UsersRow] = { UpdateBuilderMock(UpdateParams.empty, UsersFields.structure, map) } - override def update(row: UsersRow)(implicit c: Connection): Boolean = { - map.get(row.userId) match { - case Some(`row`) => false - case Some(_) => - map.put(row.userId, row): @nowarn - true - case None => false + override def update(row: UsersRow)(implicit c: Connection): Option[UsersRow] = { + map.get(row.userId).map { _ => + map.put(row.userId, row): @nowarn + row } } override def upsert(unsaved: UsersRow)(implicit c: Connection): UsersRow = { diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/purchasing/productvendor/ProductvendorRepo.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/purchasing/productvendor/ProductvendorRepo.scala index f485e415e..1fadc4a24 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/purchasing/productvendor/ProductvendorRepo.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/purchasing/productvendor/ProductvendorRepo.scala @@ -27,7 +27,7 @@ trait ProductvendorRepo { def selectByIds(compositeIds: Array[ProductvendorId])(implicit c: Connection): List[ProductvendorRow] def selectByIdsTracked(compositeIds: Array[ProductvendorId])(implicit c: Connection): Map[ProductvendorId, ProductvendorRow] def update: UpdateBuilder[ProductvendorFields, ProductvendorRow] - def update(row: ProductvendorRow)(implicit c: Connection): Boolean + def update(row: ProductvendorRow)(implicit c: Connection): Option[ProductvendorRow] def upsert(unsaved: ProductvendorRow)(implicit c: Connection): ProductvendorRow def upsertBatch(unsaved: Iterable[ProductvendorRow])(implicit c: Connection): List[ProductvendorRow] /* NOTE: this functionality is not safe if you use auto-commit mode! it runs 3 SQL statements */ diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/purchasing/productvendor/ProductvendorRepoImpl.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/purchasing/productvendor/ProductvendorRepoImpl.scala index 463ba64e2..056e3e13d 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/purchasing/productvendor/ProductvendorRepoImpl.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/purchasing/productvendor/ProductvendorRepoImpl.scala @@ -112,7 +112,7 @@ class ProductvendorRepoImpl extends ProductvendorRepo { val businessentityid = compositeIds.map(_.businessentityid) SQL"""select "productid", "businessentityid", "averageleadtime", "standardprice", "lastreceiptcost", "lastreceiptdate"::text, "minorderqty", "maxorderqty", "onorderqty", "unitmeasurecode", "modifieddate"::text from "purchasing"."productvendor" - where ("productid", "businessentityid") + where ("productid", "businessentityid") in (select unnest(${productid}), unnest(${businessentityid})) """.as(ProductvendorRow.rowParser(1).*) @@ -124,7 +124,7 @@ class ProductvendorRepoImpl extends ProductvendorRepo { override def update: UpdateBuilder[ProductvendorFields, ProductvendorRow] = { UpdateBuilder(""""purchasing"."productvendor"""", ProductvendorFields.structure, ProductvendorRow.rowParser) } - override def update(row: ProductvendorRow)(implicit c: Connection): Boolean = { + override def update(row: ProductvendorRow)(implicit c: Connection): Option[ProductvendorRow] = { val compositeId = row.compositeId SQL"""update "purchasing"."productvendor" set "averageleadtime" = ${ParameterValue(row.averageleadtime, null, ToStatement.intToStatement)}::int4, @@ -137,7 +137,8 @@ class ProductvendorRepoImpl extends ProductvendorRepo { "unitmeasurecode" = ${ParameterValue(row.unitmeasurecode, null, UnitmeasureId.toStatement)}::bpchar, "modifieddate" = ${ParameterValue(row.modifieddate, null, TypoLocalDateTime.toStatement)}::timestamp where "productid" = ${ParameterValue(compositeId.productid, null, ProductId.toStatement)} AND "businessentityid" = ${ParameterValue(compositeId.businessentityid, null, BusinessentityId.toStatement)} - """.executeUpdate() > 0 + returning "productid", "businessentityid", "averageleadtime", "standardprice", "lastreceiptcost", "lastreceiptdate"::text, "minorderqty", "maxorderqty", "onorderqty", "unitmeasurecode", "modifieddate"::text + """.executeInsert(ProductvendorRow.rowParser(1).singleOpt) } override def upsert(unsaved: ProductvendorRow)(implicit c: Connection): ProductvendorRow = { SQL"""insert into "purchasing"."productvendor"("productid", "businessentityid", "averageleadtime", "standardprice", "lastreceiptcost", "lastreceiptdate", "minorderqty", "maxorderqty", "onorderqty", "unitmeasurecode", "modifieddate") diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/purchasing/productvendor/ProductvendorRepoMock.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/purchasing/productvendor/ProductvendorRepoMock.scala index 5d51e3fe3..6f5942803 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/purchasing/productvendor/ProductvendorRepoMock.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/purchasing/productvendor/ProductvendorRepoMock.scala @@ -74,13 +74,10 @@ class ProductvendorRepoMock(toRow: Function1[ProductvendorRowUnsaved, Productven override def update: UpdateBuilder[ProductvendorFields, ProductvendorRow] = { UpdateBuilderMock(UpdateParams.empty, ProductvendorFields.structure, map) } - override def update(row: ProductvendorRow)(implicit c: Connection): Boolean = { - map.get(row.compositeId) match { - case Some(`row`) => false - case Some(_) => - map.put(row.compositeId, row): @nowarn - true - case None => false + override def update(row: ProductvendorRow)(implicit c: Connection): Option[ProductvendorRow] = { + map.get(row.compositeId).map { _ => + map.put(row.compositeId, row): @nowarn + row } } override def upsert(unsaved: ProductvendorRow)(implicit c: Connection): ProductvendorRow = { diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/purchasing/purchaseorderdetail/PurchaseorderdetailRepoImpl.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/purchasing/purchaseorderdetail/PurchaseorderdetailRepoImpl.scala index 14839fa18..8c7135243 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/purchasing/purchaseorderdetail/PurchaseorderdetailRepoImpl.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/purchasing/purchaseorderdetail/PurchaseorderdetailRepoImpl.scala @@ -35,7 +35,7 @@ class PurchaseorderdetailRepoImpl extends PurchaseorderdetailRepo { val purchaseorderdetailid = compositeIds.map(_.purchaseorderdetailid) SQL"""select "purchaseorderid", "purchaseorderdetailid", "duedate"::text, "orderqty", "productid", "unitprice", "receivedqty", "rejectedqty", "modifieddate"::text from "purchasing"."purchaseorderdetail" - where ("purchaseorderid", "purchaseorderdetailid") + where ("purchaseorderid", "purchaseorderdetailid") in (select unnest(${purchaseorderid}), unnest(${purchaseorderdetailid})) """.as(PurchaseorderdetailRow.rowParser(1).*) diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/purchasing/purchaseorderheader/PurchaseorderheaderRepo.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/purchasing/purchaseorderheader/PurchaseorderheaderRepo.scala index 35c18c78c..02ec677d5 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/purchasing/purchaseorderheader/PurchaseorderheaderRepo.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/purchasing/purchaseorderheader/PurchaseorderheaderRepo.scala @@ -27,7 +27,7 @@ trait PurchaseorderheaderRepo { def selectByIds(purchaseorderids: Array[PurchaseorderheaderId])(implicit c: Connection): List[PurchaseorderheaderRow] def selectByIdsTracked(purchaseorderids: Array[PurchaseorderheaderId])(implicit c: Connection): Map[PurchaseorderheaderId, PurchaseorderheaderRow] def update: UpdateBuilder[PurchaseorderheaderFields, PurchaseorderheaderRow] - def update(row: PurchaseorderheaderRow)(implicit c: Connection): Boolean + def update(row: PurchaseorderheaderRow)(implicit c: Connection): Option[PurchaseorderheaderRow] def upsert(unsaved: PurchaseorderheaderRow)(implicit c: Connection): PurchaseorderheaderRow def upsertBatch(unsaved: Iterable[PurchaseorderheaderRow])(implicit c: Connection): List[PurchaseorderheaderRow] /* NOTE: this functionality is not safe if you use auto-commit mode! it runs 3 SQL statements */ diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/purchasing/purchaseorderheader/PurchaseorderheaderRepoImpl.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/purchasing/purchaseorderheader/PurchaseorderheaderRepoImpl.scala index 1d450f099..86083b816 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/purchasing/purchaseorderheader/PurchaseorderheaderRepoImpl.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/purchasing/purchaseorderheader/PurchaseorderheaderRepoImpl.scala @@ -139,7 +139,7 @@ class PurchaseorderheaderRepoImpl extends PurchaseorderheaderRepo { override def update: UpdateBuilder[PurchaseorderheaderFields, PurchaseorderheaderRow] = { UpdateBuilder(""""purchasing"."purchaseorderheader"""", PurchaseorderheaderFields.structure, PurchaseorderheaderRow.rowParser) } - override def update(row: PurchaseorderheaderRow)(implicit c: Connection): Boolean = { + override def update(row: PurchaseorderheaderRow)(implicit c: Connection): Option[PurchaseorderheaderRow] = { val purchaseorderid = row.purchaseorderid SQL"""update "purchasing"."purchaseorderheader" set "revisionnumber" = ${ParameterValue(row.revisionnumber, null, TypoShort.toStatement)}::int2, @@ -154,7 +154,8 @@ class PurchaseorderheaderRepoImpl extends PurchaseorderheaderRepo { "freight" = ${ParameterValue(row.freight, null, ToStatement.scalaBigDecimalToStatement)}::numeric, "modifieddate" = ${ParameterValue(row.modifieddate, null, TypoLocalDateTime.toStatement)}::timestamp where "purchaseorderid" = ${ParameterValue(purchaseorderid, null, PurchaseorderheaderId.toStatement)} - """.executeUpdate() > 0 + returning "purchaseorderid", "revisionnumber", "status", "employeeid", "vendorid", "shipmethodid", "orderdate"::text, "shipdate"::text, "subtotal", "taxamt", "freight", "modifieddate"::text + """.executeInsert(PurchaseorderheaderRow.rowParser(1).singleOpt) } override def upsert(unsaved: PurchaseorderheaderRow)(implicit c: Connection): PurchaseorderheaderRow = { SQL"""insert into "purchasing"."purchaseorderheader"("purchaseorderid", "revisionnumber", "status", "employeeid", "vendorid", "shipmethodid", "orderdate", "shipdate", "subtotal", "taxamt", "freight", "modifieddate") diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/purchasing/purchaseorderheader/PurchaseorderheaderRepoMock.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/purchasing/purchaseorderheader/PurchaseorderheaderRepoMock.scala index f94480732..9239f37b2 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/purchasing/purchaseorderheader/PurchaseorderheaderRepoMock.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/purchasing/purchaseorderheader/PurchaseorderheaderRepoMock.scala @@ -74,13 +74,10 @@ class PurchaseorderheaderRepoMock(toRow: Function1[PurchaseorderheaderRowUnsaved override def update: UpdateBuilder[PurchaseorderheaderFields, PurchaseorderheaderRow] = { UpdateBuilderMock(UpdateParams.empty, PurchaseorderheaderFields.structure, map) } - override def update(row: PurchaseorderheaderRow)(implicit c: Connection): Boolean = { - map.get(row.purchaseorderid) match { - case Some(`row`) => false - case Some(_) => - map.put(row.purchaseorderid, row): @nowarn - true - case None => false + override def update(row: PurchaseorderheaderRow)(implicit c: Connection): Option[PurchaseorderheaderRow] = { + map.get(row.purchaseorderid).map { _ => + map.put(row.purchaseorderid, row): @nowarn + row } } override def upsert(unsaved: PurchaseorderheaderRow)(implicit c: Connection): PurchaseorderheaderRow = { diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/purchasing/shipmethod/ShipmethodRepo.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/purchasing/shipmethod/ShipmethodRepo.scala index a0a41b3e8..eba80f30c 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/purchasing/shipmethod/ShipmethodRepo.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/purchasing/shipmethod/ShipmethodRepo.scala @@ -27,7 +27,7 @@ trait ShipmethodRepo { def selectByIds(shipmethodids: Array[ShipmethodId])(implicit c: Connection): List[ShipmethodRow] def selectByIdsTracked(shipmethodids: Array[ShipmethodId])(implicit c: Connection): Map[ShipmethodId, ShipmethodRow] def update: UpdateBuilder[ShipmethodFields, ShipmethodRow] - def update(row: ShipmethodRow)(implicit c: Connection): Boolean + def update(row: ShipmethodRow)(implicit c: Connection): Option[ShipmethodRow] def upsert(unsaved: ShipmethodRow)(implicit c: Connection): ShipmethodRow def upsertBatch(unsaved: Iterable[ShipmethodRow])(implicit c: Connection): List[ShipmethodRow] /* NOTE: this functionality is not safe if you use auto-commit mode! it runs 3 SQL statements */ diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/purchasing/shipmethod/ShipmethodRepoImpl.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/purchasing/shipmethod/ShipmethodRepoImpl.scala index 3e7257521..b2829c475 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/purchasing/shipmethod/ShipmethodRepoImpl.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/purchasing/shipmethod/ShipmethodRepoImpl.scala @@ -123,7 +123,7 @@ class ShipmethodRepoImpl extends ShipmethodRepo { override def update: UpdateBuilder[ShipmethodFields, ShipmethodRow] = { UpdateBuilder(""""purchasing"."shipmethod"""", ShipmethodFields.structure, ShipmethodRow.rowParser) } - override def update(row: ShipmethodRow)(implicit c: Connection): Boolean = { + override def update(row: ShipmethodRow)(implicit c: Connection): Option[ShipmethodRow] = { val shipmethodid = row.shipmethodid SQL"""update "purchasing"."shipmethod" set "name" = ${ParameterValue(row.name, null, Name.toStatement)}::varchar, @@ -132,7 +132,8 @@ class ShipmethodRepoImpl extends ShipmethodRepo { "rowguid" = ${ParameterValue(row.rowguid, null, TypoUUID.toStatement)}::uuid, "modifieddate" = ${ParameterValue(row.modifieddate, null, TypoLocalDateTime.toStatement)}::timestamp where "shipmethodid" = ${ParameterValue(shipmethodid, null, ShipmethodId.toStatement)} - """.executeUpdate() > 0 + returning "shipmethodid", "name", "shipbase", "shiprate", "rowguid", "modifieddate"::text + """.executeInsert(ShipmethodRow.rowParser(1).singleOpt) } override def upsert(unsaved: ShipmethodRow)(implicit c: Connection): ShipmethodRow = { SQL"""insert into "purchasing"."shipmethod"("shipmethodid", "name", "shipbase", "shiprate", "rowguid", "modifieddate") diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/purchasing/shipmethod/ShipmethodRepoMock.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/purchasing/shipmethod/ShipmethodRepoMock.scala index 0786b7a24..4a92b8d10 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/purchasing/shipmethod/ShipmethodRepoMock.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/purchasing/shipmethod/ShipmethodRepoMock.scala @@ -74,13 +74,10 @@ class ShipmethodRepoMock(toRow: Function1[ShipmethodRowUnsaved, ShipmethodRow], override def update: UpdateBuilder[ShipmethodFields, ShipmethodRow] = { UpdateBuilderMock(UpdateParams.empty, ShipmethodFields.structure, map) } - override def update(row: ShipmethodRow)(implicit c: Connection): Boolean = { - map.get(row.shipmethodid) match { - case Some(`row`) => false - case Some(_) => - map.put(row.shipmethodid, row): @nowarn - true - case None => false + override def update(row: ShipmethodRow)(implicit c: Connection): Option[ShipmethodRow] = { + map.get(row.shipmethodid).map { _ => + map.put(row.shipmethodid, row): @nowarn + row } } override def upsert(unsaved: ShipmethodRow)(implicit c: Connection): ShipmethodRow = { diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/purchasing/vendor/VendorRepo.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/purchasing/vendor/VendorRepo.scala index 539bc68ba..cedf15ac7 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/purchasing/vendor/VendorRepo.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/purchasing/vendor/VendorRepo.scala @@ -28,7 +28,7 @@ trait VendorRepo { def selectByIds(businessentityids: Array[BusinessentityId])(implicit c: Connection): List[VendorRow] def selectByIdsTracked(businessentityids: Array[BusinessentityId])(implicit c: Connection): Map[BusinessentityId, VendorRow] def update: UpdateBuilder[VendorFields, VendorRow] - def update(row: VendorRow)(implicit c: Connection): Boolean + def update(row: VendorRow)(implicit c: Connection): Option[VendorRow] def upsert(unsaved: VendorRow)(implicit c: Connection): VendorRow def upsertBatch(unsaved: Iterable[VendorRow])(implicit c: Connection): List[VendorRow] /* NOTE: this functionality is not safe if you use auto-commit mode! it runs 3 SQL statements */ diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/purchasing/vendor/VendorRepoImpl.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/purchasing/vendor/VendorRepoImpl.scala index 1d92822f8..c785f1e0d 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/purchasing/vendor/VendorRepoImpl.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/purchasing/vendor/VendorRepoImpl.scala @@ -123,7 +123,7 @@ class VendorRepoImpl extends VendorRepo { override def update: UpdateBuilder[VendorFields, VendorRow] = { UpdateBuilder(""""purchasing"."vendor"""", VendorFields.structure, VendorRow.rowParser) } - override def update(row: VendorRow)(implicit c: Connection): Boolean = { + override def update(row: VendorRow)(implicit c: Connection): Option[VendorRow] = { val businessentityid = row.businessentityid SQL"""update "purchasing"."vendor" set "accountnumber" = ${ParameterValue(row.accountnumber, null, AccountNumber.toStatement)}::varchar, @@ -134,7 +134,8 @@ class VendorRepoImpl extends VendorRepo { "purchasingwebserviceurl" = ${ParameterValue(row.purchasingwebserviceurl, null, ToStatement.optionToStatement(ToStatement.stringToStatement, ParameterMetaData.StringParameterMetaData))}, "modifieddate" = ${ParameterValue(row.modifieddate, null, TypoLocalDateTime.toStatement)}::timestamp where "businessentityid" = ${ParameterValue(businessentityid, null, BusinessentityId.toStatement)} - """.executeUpdate() > 0 + returning "businessentityid", "accountnumber", "name", "creditrating", "preferredvendorstatus", "activeflag", "purchasingwebserviceurl", "modifieddate"::text + """.executeInsert(VendorRow.rowParser(1).singleOpt) } override def upsert(unsaved: VendorRow)(implicit c: Connection): VendorRow = { SQL"""insert into "purchasing"."vendor"("businessentityid", "accountnumber", "name", "creditrating", "preferredvendorstatus", "activeflag", "purchasingwebserviceurl", "modifieddate") diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/purchasing/vendor/VendorRepoMock.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/purchasing/vendor/VendorRepoMock.scala index efc42e397..b5f9ae64a 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/purchasing/vendor/VendorRepoMock.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/purchasing/vendor/VendorRepoMock.scala @@ -75,13 +75,10 @@ class VendorRepoMock(toRow: Function1[VendorRowUnsaved, VendorRow], override def update: UpdateBuilder[VendorFields, VendorRow] = { UpdateBuilderMock(UpdateParams.empty, VendorFields.structure, map) } - override def update(row: VendorRow)(implicit c: Connection): Boolean = { - map.get(row.businessentityid) match { - case Some(`row`) => false - case Some(_) => - map.put(row.businessentityid, row): @nowarn - true - case None => false + override def update(row: VendorRow)(implicit c: Connection): Option[VendorRow] = { + map.get(row.businessentityid).map { _ => + map.put(row.businessentityid, row): @nowarn + row } } override def upsert(unsaved: VendorRow)(implicit c: Connection): VendorRow = { diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/countryregioncurrency/CountryregioncurrencyRepo.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/countryregioncurrency/CountryregioncurrencyRepo.scala index 3c7005e55..a8337c576 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/countryregioncurrency/CountryregioncurrencyRepo.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/countryregioncurrency/CountryregioncurrencyRepo.scala @@ -27,7 +27,7 @@ trait CountryregioncurrencyRepo { def selectByIds(compositeIds: Array[CountryregioncurrencyId])(implicit c: Connection): List[CountryregioncurrencyRow] def selectByIdsTracked(compositeIds: Array[CountryregioncurrencyId])(implicit c: Connection): Map[CountryregioncurrencyId, CountryregioncurrencyRow] def update: UpdateBuilder[CountryregioncurrencyFields, CountryregioncurrencyRow] - def update(row: CountryregioncurrencyRow)(implicit c: Connection): Boolean + def update(row: CountryregioncurrencyRow)(implicit c: Connection): Option[CountryregioncurrencyRow] def upsert(unsaved: CountryregioncurrencyRow)(implicit c: Connection): CountryregioncurrencyRow def upsertBatch(unsaved: Iterable[CountryregioncurrencyRow])(implicit c: Connection): List[CountryregioncurrencyRow] /* NOTE: this functionality is not safe if you use auto-commit mode! it runs 3 SQL statements */ diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/countryregioncurrency/CountryregioncurrencyRepoImpl.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/countryregioncurrency/CountryregioncurrencyRepoImpl.scala index 96c50f2ce..d035994cc 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/countryregioncurrency/CountryregioncurrencyRepoImpl.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/countryregioncurrency/CountryregioncurrencyRepoImpl.scala @@ -101,7 +101,7 @@ class CountryregioncurrencyRepoImpl extends CountryregioncurrencyRepo { val currencycode = compositeIds.map(_.currencycode) SQL"""select "countryregioncode", "currencycode", "modifieddate"::text from "sales"."countryregioncurrency" - where ("countryregioncode", "currencycode") + where ("countryregioncode", "currencycode") in (select unnest(${countryregioncode}), unnest(${currencycode})) """.as(CountryregioncurrencyRow.rowParser(1).*) @@ -113,12 +113,13 @@ class CountryregioncurrencyRepoImpl extends CountryregioncurrencyRepo { override def update: UpdateBuilder[CountryregioncurrencyFields, CountryregioncurrencyRow] = { UpdateBuilder(""""sales"."countryregioncurrency"""", CountryregioncurrencyFields.structure, CountryregioncurrencyRow.rowParser) } - override def update(row: CountryregioncurrencyRow)(implicit c: Connection): Boolean = { + override def update(row: CountryregioncurrencyRow)(implicit c: Connection): Option[CountryregioncurrencyRow] = { val compositeId = row.compositeId SQL"""update "sales"."countryregioncurrency" set "modifieddate" = ${ParameterValue(row.modifieddate, null, TypoLocalDateTime.toStatement)}::timestamp where "countryregioncode" = ${ParameterValue(compositeId.countryregioncode, null, CountryregionId.toStatement)} AND "currencycode" = ${ParameterValue(compositeId.currencycode, null, CurrencyId.toStatement)} - """.executeUpdate() > 0 + returning "countryregioncode", "currencycode", "modifieddate"::text + """.executeInsert(CountryregioncurrencyRow.rowParser(1).singleOpt) } override def upsert(unsaved: CountryregioncurrencyRow)(implicit c: Connection): CountryregioncurrencyRow = { SQL"""insert into "sales"."countryregioncurrency"("countryregioncode", "currencycode", "modifieddate") diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/countryregioncurrency/CountryregioncurrencyRepoMock.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/countryregioncurrency/CountryregioncurrencyRepoMock.scala index 534ddb8c1..0da87138b 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/countryregioncurrency/CountryregioncurrencyRepoMock.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/countryregioncurrency/CountryregioncurrencyRepoMock.scala @@ -74,13 +74,10 @@ class CountryregioncurrencyRepoMock(toRow: Function1[CountryregioncurrencyRowUns override def update: UpdateBuilder[CountryregioncurrencyFields, CountryregioncurrencyRow] = { UpdateBuilderMock(UpdateParams.empty, CountryregioncurrencyFields.structure, map) } - override def update(row: CountryregioncurrencyRow)(implicit c: Connection): Boolean = { - map.get(row.compositeId) match { - case Some(`row`) => false - case Some(_) => - map.put(row.compositeId, row): @nowarn - true - case None => false + override def update(row: CountryregioncurrencyRow)(implicit c: Connection): Option[CountryregioncurrencyRow] = { + map.get(row.compositeId).map { _ => + map.put(row.compositeId, row): @nowarn + row } } override def upsert(unsaved: CountryregioncurrencyRow)(implicit c: Connection): CountryregioncurrencyRow = { diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/creditcard/CreditcardRepo.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/creditcard/CreditcardRepo.scala index 926492190..864065a6e 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/creditcard/CreditcardRepo.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/creditcard/CreditcardRepo.scala @@ -29,7 +29,7 @@ trait CreditcardRepo { def selectByIds(creditcardids: Array[/* user-picked */ CustomCreditcardId])(implicit c: Connection, toStatement0: ToStatement[Array[/* user-picked */ CustomCreditcardId]]): List[CreditcardRow] def selectByIdsTracked(creditcardids: Array[/* user-picked */ CustomCreditcardId])(implicit c: Connection, toStatement0: ToStatement[Array[/* user-picked */ CustomCreditcardId]]): Map[/* user-picked */ CustomCreditcardId, CreditcardRow] def update: UpdateBuilder[CreditcardFields, CreditcardRow] - def update(row: CreditcardRow)(implicit c: Connection): Boolean + def update(row: CreditcardRow)(implicit c: Connection): Option[CreditcardRow] def upsert(unsaved: CreditcardRow)(implicit c: Connection): CreditcardRow def upsertBatch(unsaved: Iterable[CreditcardRow])(implicit c: Connection): List[CreditcardRow] /* NOTE: this functionality is not safe if you use auto-commit mode! it runs 3 SQL statements */ diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/creditcard/CreditcardRepoImpl.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/creditcard/CreditcardRepoImpl.scala index ba908c803..b536de536 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/creditcard/CreditcardRepoImpl.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/creditcard/CreditcardRepoImpl.scala @@ -114,7 +114,7 @@ class CreditcardRepoImpl extends CreditcardRepo { override def update: UpdateBuilder[CreditcardFields, CreditcardRow] = { UpdateBuilder(""""sales"."creditcard"""", CreditcardFields.structure, CreditcardRow.rowParser) } - override def update(row: CreditcardRow)(implicit c: Connection): Boolean = { + override def update(row: CreditcardRow)(implicit c: Connection): Option[CreditcardRow] = { val creditcardid = row.creditcardid SQL"""update "sales"."creditcard" set "cardtype" = ${ParameterValue(row.cardtype, null, ToStatement.stringToStatement)}, @@ -123,7 +123,8 @@ class CreditcardRepoImpl extends CreditcardRepo { "expyear" = ${ParameterValue(row.expyear, null, TypoShort.toStatement)}::int2, "modifieddate" = ${ParameterValue(row.modifieddate, null, TypoLocalDateTime.toStatement)}::timestamp where "creditcardid" = ${ParameterValue(creditcardid, null, /* user-picked */ CustomCreditcardId.toStatement)} - """.executeUpdate() > 0 + returning "creditcardid", "cardtype", "cardnumber", "expmonth", "expyear", "modifieddate"::text + """.executeInsert(CreditcardRow.rowParser(1).singleOpt) } override def upsert(unsaved: CreditcardRow)(implicit c: Connection): CreditcardRow = { SQL"""insert into "sales"."creditcard"("creditcardid", "cardtype", "cardnumber", "expmonth", "expyear", "modifieddate") diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/creditcard/CreditcardRepoMock.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/creditcard/CreditcardRepoMock.scala index 0cfc1066d..ebfb1369b 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/creditcard/CreditcardRepoMock.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/creditcard/CreditcardRepoMock.scala @@ -76,13 +76,10 @@ class CreditcardRepoMock(toRow: Function1[CreditcardRowUnsaved, CreditcardRow], override def update: UpdateBuilder[CreditcardFields, CreditcardRow] = { UpdateBuilderMock(UpdateParams.empty, CreditcardFields.structure, map) } - override def update(row: CreditcardRow)(implicit c: Connection): Boolean = { - map.get(row.creditcardid) match { - case Some(`row`) => false - case Some(_) => - map.put(row.creditcardid, row): @nowarn - true - case None => false + override def update(row: CreditcardRow)(implicit c: Connection): Option[CreditcardRow] = { + map.get(row.creditcardid).map { _ => + map.put(row.creditcardid, row): @nowarn + row } } override def upsert(unsaved: CreditcardRow)(implicit c: Connection): CreditcardRow = { diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/currency/CurrencyRepo.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/currency/CurrencyRepo.scala index 5b394ac6b..e4c15f3bd 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/currency/CurrencyRepo.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/currency/CurrencyRepo.scala @@ -27,7 +27,7 @@ trait CurrencyRepo { def selectByIds(currencycodes: Array[CurrencyId])(implicit c: Connection): List[CurrencyRow] def selectByIdsTracked(currencycodes: Array[CurrencyId])(implicit c: Connection): Map[CurrencyId, CurrencyRow] def update: UpdateBuilder[CurrencyFields, CurrencyRow] - def update(row: CurrencyRow)(implicit c: Connection): Boolean + def update(row: CurrencyRow)(implicit c: Connection): Option[CurrencyRow] def upsert(unsaved: CurrencyRow)(implicit c: Connection): CurrencyRow def upsertBatch(unsaved: Iterable[CurrencyRow])(implicit c: Connection): List[CurrencyRow] /* NOTE: this functionality is not safe if you use auto-commit mode! it runs 3 SQL statements */ diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/currency/CurrencyRepoImpl.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/currency/CurrencyRepoImpl.scala index 0152004af..ec65413a7 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/currency/CurrencyRepoImpl.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/currency/CurrencyRepoImpl.scala @@ -106,13 +106,14 @@ class CurrencyRepoImpl extends CurrencyRepo { override def update: UpdateBuilder[CurrencyFields, CurrencyRow] = { UpdateBuilder(""""sales"."currency"""", CurrencyFields.structure, CurrencyRow.rowParser) } - override def update(row: CurrencyRow)(implicit c: Connection): Boolean = { + override def update(row: CurrencyRow)(implicit c: Connection): Option[CurrencyRow] = { val currencycode = row.currencycode SQL"""update "sales"."currency" set "name" = ${ParameterValue(row.name, null, Name.toStatement)}::varchar, "modifieddate" = ${ParameterValue(row.modifieddate, null, TypoLocalDateTime.toStatement)}::timestamp where "currencycode" = ${ParameterValue(currencycode, null, CurrencyId.toStatement)} - """.executeUpdate() > 0 + returning "currencycode", "name", "modifieddate"::text + """.executeInsert(CurrencyRow.rowParser(1).singleOpt) } override def upsert(unsaved: CurrencyRow)(implicit c: Connection): CurrencyRow = { SQL"""insert into "sales"."currency"("currencycode", "name", "modifieddate") diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/currency/CurrencyRepoMock.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/currency/CurrencyRepoMock.scala index f486159d6..b94747f12 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/currency/CurrencyRepoMock.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/currency/CurrencyRepoMock.scala @@ -74,13 +74,10 @@ class CurrencyRepoMock(toRow: Function1[CurrencyRowUnsaved, CurrencyRow], override def update: UpdateBuilder[CurrencyFields, CurrencyRow] = { UpdateBuilderMock(UpdateParams.empty, CurrencyFields.structure, map) } - override def update(row: CurrencyRow)(implicit c: Connection): Boolean = { - map.get(row.currencycode) match { - case Some(`row`) => false - case Some(_) => - map.put(row.currencycode, row): @nowarn - true - case None => false + override def update(row: CurrencyRow)(implicit c: Connection): Option[CurrencyRow] = { + map.get(row.currencycode).map { _ => + map.put(row.currencycode, row): @nowarn + row } } override def upsert(unsaved: CurrencyRow)(implicit c: Connection): CurrencyRow = { diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/currencyrate/CurrencyrateRepo.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/currencyrate/CurrencyrateRepo.scala index 6c5512626..274280741 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/currencyrate/CurrencyrateRepo.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/currencyrate/CurrencyrateRepo.scala @@ -27,7 +27,7 @@ trait CurrencyrateRepo { def selectByIds(currencyrateids: Array[CurrencyrateId])(implicit c: Connection): List[CurrencyrateRow] def selectByIdsTracked(currencyrateids: Array[CurrencyrateId])(implicit c: Connection): Map[CurrencyrateId, CurrencyrateRow] def update: UpdateBuilder[CurrencyrateFields, CurrencyrateRow] - def update(row: CurrencyrateRow)(implicit c: Connection): Boolean + def update(row: CurrencyrateRow)(implicit c: Connection): Option[CurrencyrateRow] def upsert(unsaved: CurrencyrateRow)(implicit c: Connection): CurrencyrateRow def upsertBatch(unsaved: Iterable[CurrencyrateRow])(implicit c: Connection): List[CurrencyrateRow] /* NOTE: this functionality is not safe if you use auto-commit mode! it runs 3 SQL statements */ diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/currencyrate/CurrencyrateRepoImpl.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/currencyrate/CurrencyrateRepoImpl.scala index f85165ca0..9354cc815 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/currencyrate/CurrencyrateRepoImpl.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/currencyrate/CurrencyrateRepoImpl.scala @@ -114,7 +114,7 @@ class CurrencyrateRepoImpl extends CurrencyrateRepo { override def update: UpdateBuilder[CurrencyrateFields, CurrencyrateRow] = { UpdateBuilder(""""sales"."currencyrate"""", CurrencyrateFields.structure, CurrencyrateRow.rowParser) } - override def update(row: CurrencyrateRow)(implicit c: Connection): Boolean = { + override def update(row: CurrencyrateRow)(implicit c: Connection): Option[CurrencyrateRow] = { val currencyrateid = row.currencyrateid SQL"""update "sales"."currencyrate" set "currencyratedate" = ${ParameterValue(row.currencyratedate, null, TypoLocalDateTime.toStatement)}::timestamp, @@ -124,7 +124,8 @@ class CurrencyrateRepoImpl extends CurrencyrateRepo { "endofdayrate" = ${ParameterValue(row.endofdayrate, null, ToStatement.scalaBigDecimalToStatement)}::numeric, "modifieddate" = ${ParameterValue(row.modifieddate, null, TypoLocalDateTime.toStatement)}::timestamp where "currencyrateid" = ${ParameterValue(currencyrateid, null, CurrencyrateId.toStatement)} - """.executeUpdate() > 0 + returning "currencyrateid", "currencyratedate"::text, "fromcurrencycode", "tocurrencycode", "averagerate", "endofdayrate", "modifieddate"::text + """.executeInsert(CurrencyrateRow.rowParser(1).singleOpt) } override def upsert(unsaved: CurrencyrateRow)(implicit c: Connection): CurrencyrateRow = { SQL"""insert into "sales"."currencyrate"("currencyrateid", "currencyratedate", "fromcurrencycode", "tocurrencycode", "averagerate", "endofdayrate", "modifieddate") diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/currencyrate/CurrencyrateRepoMock.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/currencyrate/CurrencyrateRepoMock.scala index 19c9ef7ba..49862be14 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/currencyrate/CurrencyrateRepoMock.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/currencyrate/CurrencyrateRepoMock.scala @@ -74,13 +74,10 @@ class CurrencyrateRepoMock(toRow: Function1[CurrencyrateRowUnsaved, Currencyrate override def update: UpdateBuilder[CurrencyrateFields, CurrencyrateRow] = { UpdateBuilderMock(UpdateParams.empty, CurrencyrateFields.structure, map) } - override def update(row: CurrencyrateRow)(implicit c: Connection): Boolean = { - map.get(row.currencyrateid) match { - case Some(`row`) => false - case Some(_) => - map.put(row.currencyrateid, row): @nowarn - true - case None => false + override def update(row: CurrencyrateRow)(implicit c: Connection): Option[CurrencyrateRow] = { + map.get(row.currencyrateid).map { _ => + map.put(row.currencyrateid, row): @nowarn + row } } override def upsert(unsaved: CurrencyrateRow)(implicit c: Connection): CurrencyrateRow = { diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/customer/CustomerRepo.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/customer/CustomerRepo.scala index 1b7a03b0e..e6c26f051 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/customer/CustomerRepo.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/customer/CustomerRepo.scala @@ -27,7 +27,7 @@ trait CustomerRepo { def selectByIds(customerids: Array[CustomerId])(implicit c: Connection): List[CustomerRow] def selectByIdsTracked(customerids: Array[CustomerId])(implicit c: Connection): Map[CustomerId, CustomerRow] def update: UpdateBuilder[CustomerFields, CustomerRow] - def update(row: CustomerRow)(implicit c: Connection): Boolean + def update(row: CustomerRow)(implicit c: Connection): Option[CustomerRow] def upsert(unsaved: CustomerRow)(implicit c: Connection): CustomerRow def upsertBatch(unsaved: Iterable[CustomerRow])(implicit c: Connection): List[CustomerRow] /* NOTE: this functionality is not safe if you use auto-commit mode! it runs 3 SQL statements */ diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/customer/CustomerRepoImpl.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/customer/CustomerRepoImpl.scala index 27b0baacc..901dc2588 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/customer/CustomerRepoImpl.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/customer/CustomerRepoImpl.scala @@ -118,7 +118,7 @@ class CustomerRepoImpl extends CustomerRepo { override def update: UpdateBuilder[CustomerFields, CustomerRow] = { UpdateBuilder(""""sales"."customer"""", CustomerFields.structure, CustomerRow.rowParser) } - override def update(row: CustomerRow)(implicit c: Connection): Boolean = { + override def update(row: CustomerRow)(implicit c: Connection): Option[CustomerRow] = { val customerid = row.customerid SQL"""update "sales"."customer" set "personid" = ${ParameterValue(row.personid, null, ToStatement.optionToStatement(BusinessentityId.toStatement, BusinessentityId.parameterMetadata))}::int4, @@ -127,7 +127,8 @@ class CustomerRepoImpl extends CustomerRepo { "rowguid" = ${ParameterValue(row.rowguid, null, TypoUUID.toStatement)}::uuid, "modifieddate" = ${ParameterValue(row.modifieddate, null, TypoLocalDateTime.toStatement)}::timestamp where "customerid" = ${ParameterValue(customerid, null, CustomerId.toStatement)} - """.executeUpdate() > 0 + returning "customerid", "personid", "storeid", "territoryid", "rowguid", "modifieddate"::text + """.executeInsert(CustomerRow.rowParser(1).singleOpt) } override def upsert(unsaved: CustomerRow)(implicit c: Connection): CustomerRow = { SQL"""insert into "sales"."customer"("customerid", "personid", "storeid", "territoryid", "rowguid", "modifieddate") diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/customer/CustomerRepoMock.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/customer/CustomerRepoMock.scala index e50c0773e..e43051bff 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/customer/CustomerRepoMock.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/customer/CustomerRepoMock.scala @@ -74,13 +74,10 @@ class CustomerRepoMock(toRow: Function1[CustomerRowUnsaved, CustomerRow], override def update: UpdateBuilder[CustomerFields, CustomerRow] = { UpdateBuilderMock(UpdateParams.empty, CustomerFields.structure, map) } - override def update(row: CustomerRow)(implicit c: Connection): Boolean = { - map.get(row.customerid) match { - case Some(`row`) => false - case Some(_) => - map.put(row.customerid, row): @nowarn - true - case None => false + override def update(row: CustomerRow)(implicit c: Connection): Option[CustomerRow] = { + map.get(row.customerid).map { _ => + map.put(row.customerid, row): @nowarn + row } } override def upsert(unsaved: CustomerRow)(implicit c: Connection): CustomerRow = { diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/personcreditcard/PersoncreditcardRepo.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/personcreditcard/PersoncreditcardRepo.scala index 0aeb4a01d..d865cb4c8 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/personcreditcard/PersoncreditcardRepo.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/personcreditcard/PersoncreditcardRepo.scala @@ -29,7 +29,7 @@ trait PersoncreditcardRepo { def selectByIds(compositeIds: Array[PersoncreditcardId])(implicit c: Connection, toStatement0: ToStatement[Array[/* user-picked */ CustomCreditcardId]]): List[PersoncreditcardRow] def selectByIdsTracked(compositeIds: Array[PersoncreditcardId])(implicit c: Connection, toStatement0: ToStatement[Array[/* user-picked */ CustomCreditcardId]]): Map[PersoncreditcardId, PersoncreditcardRow] def update: UpdateBuilder[PersoncreditcardFields, PersoncreditcardRow] - def update(row: PersoncreditcardRow)(implicit c: Connection): Boolean + def update(row: PersoncreditcardRow)(implicit c: Connection): Option[PersoncreditcardRow] def upsert(unsaved: PersoncreditcardRow)(implicit c: Connection): PersoncreditcardRow def upsertBatch(unsaved: Iterable[PersoncreditcardRow])(implicit c: Connection): List[PersoncreditcardRow] /* NOTE: this functionality is not safe if you use auto-commit mode! it runs 3 SQL statements */ diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/personcreditcard/PersoncreditcardRepoImpl.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/personcreditcard/PersoncreditcardRepoImpl.scala index 14cb2e941..6ba416a32 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/personcreditcard/PersoncreditcardRepoImpl.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/personcreditcard/PersoncreditcardRepoImpl.scala @@ -102,7 +102,7 @@ class PersoncreditcardRepoImpl extends PersoncreditcardRepo { val creditcardid = compositeIds.map(_.creditcardid) SQL"""select "businessentityid", "creditcardid", "modifieddate"::text from "sales"."personcreditcard" - where ("businessentityid", "creditcardid") + where ("businessentityid", "creditcardid") in (select unnest(${businessentityid}), unnest(${creditcardid})) """.as(PersoncreditcardRow.rowParser(1).*) @@ -114,12 +114,13 @@ class PersoncreditcardRepoImpl extends PersoncreditcardRepo { override def update: UpdateBuilder[PersoncreditcardFields, PersoncreditcardRow] = { UpdateBuilder(""""sales"."personcreditcard"""", PersoncreditcardFields.structure, PersoncreditcardRow.rowParser) } - override def update(row: PersoncreditcardRow)(implicit c: Connection): Boolean = { + override def update(row: PersoncreditcardRow)(implicit c: Connection): Option[PersoncreditcardRow] = { val compositeId = row.compositeId SQL"""update "sales"."personcreditcard" set "modifieddate" = ${ParameterValue(row.modifieddate, null, TypoLocalDateTime.toStatement)}::timestamp where "businessentityid" = ${ParameterValue(compositeId.businessentityid, null, BusinessentityId.toStatement)} AND "creditcardid" = ${ParameterValue(compositeId.creditcardid, null, /* user-picked */ CustomCreditcardId.toStatement)} - """.executeUpdate() > 0 + returning "businessentityid", "creditcardid", "modifieddate"::text + """.executeInsert(PersoncreditcardRow.rowParser(1).singleOpt) } override def upsert(unsaved: PersoncreditcardRow)(implicit c: Connection): PersoncreditcardRow = { SQL"""insert into "sales"."personcreditcard"("businessentityid", "creditcardid", "modifieddate") diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/personcreditcard/PersoncreditcardRepoMock.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/personcreditcard/PersoncreditcardRepoMock.scala index ae1bb5b94..949e3fd67 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/personcreditcard/PersoncreditcardRepoMock.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/personcreditcard/PersoncreditcardRepoMock.scala @@ -76,13 +76,10 @@ class PersoncreditcardRepoMock(toRow: Function1[PersoncreditcardRowUnsaved, Pers override def update: UpdateBuilder[PersoncreditcardFields, PersoncreditcardRow] = { UpdateBuilderMock(UpdateParams.empty, PersoncreditcardFields.structure, map) } - override def update(row: PersoncreditcardRow)(implicit c: Connection): Boolean = { - map.get(row.compositeId) match { - case Some(`row`) => false - case Some(_) => - map.put(row.compositeId, row): @nowarn - true - case None => false + override def update(row: PersoncreditcardRow)(implicit c: Connection): Option[PersoncreditcardRow] = { + map.get(row.compositeId).map { _ => + map.put(row.compositeId, row): @nowarn + row } } override def upsert(unsaved: PersoncreditcardRow)(implicit c: Connection): PersoncreditcardRow = { diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesorderdetail/SalesorderdetailRepo.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesorderdetail/SalesorderdetailRepo.scala index 0b1e009ea..b132f6738 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesorderdetail/SalesorderdetailRepo.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesorderdetail/SalesorderdetailRepo.scala @@ -27,7 +27,7 @@ trait SalesorderdetailRepo { def selectByIds(compositeIds: Array[SalesorderdetailId])(implicit c: Connection): List[SalesorderdetailRow] def selectByIdsTracked(compositeIds: Array[SalesorderdetailId])(implicit c: Connection): Map[SalesorderdetailId, SalesorderdetailRow] def update: UpdateBuilder[SalesorderdetailFields, SalesorderdetailRow] - def update(row: SalesorderdetailRow)(implicit c: Connection): Boolean + def update(row: SalesorderdetailRow)(implicit c: Connection): Option[SalesorderdetailRow] def upsert(unsaved: SalesorderdetailRow)(implicit c: Connection): SalesorderdetailRow def upsertBatch(unsaved: Iterable[SalesorderdetailRow])(implicit c: Connection): List[SalesorderdetailRow] /* NOTE: this functionality is not safe if you use auto-commit mode! it runs 3 SQL statements */ diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesorderdetail/SalesorderdetailRepoImpl.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesorderdetail/SalesorderdetailRepoImpl.scala index 6aa4576f5..8e9a1f2ed 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesorderdetail/SalesorderdetailRepoImpl.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesorderdetail/SalesorderdetailRepoImpl.scala @@ -122,7 +122,7 @@ class SalesorderdetailRepoImpl extends SalesorderdetailRepo { val salesorderdetailid = compositeIds.map(_.salesorderdetailid) SQL"""select "salesorderid", "salesorderdetailid", "carriertrackingnumber", "orderqty", "productid", "specialofferid", "unitprice", "unitpricediscount", "rowguid", "modifieddate"::text from "sales"."salesorderdetail" - where ("salesorderid", "salesorderdetailid") + where ("salesorderid", "salesorderdetailid") in (select unnest(${salesorderid}), unnest(${salesorderdetailid})) """.as(SalesorderdetailRow.rowParser(1).*) @@ -134,7 +134,7 @@ class SalesorderdetailRepoImpl extends SalesorderdetailRepo { override def update: UpdateBuilder[SalesorderdetailFields, SalesorderdetailRow] = { UpdateBuilder(""""sales"."salesorderdetail"""", SalesorderdetailFields.structure, SalesorderdetailRow.rowParser) } - override def update(row: SalesorderdetailRow)(implicit c: Connection): Boolean = { + override def update(row: SalesorderdetailRow)(implicit c: Connection): Option[SalesorderdetailRow] = { val compositeId = row.compositeId SQL"""update "sales"."salesorderdetail" set "carriertrackingnumber" = ${ParameterValue(row.carriertrackingnumber, null, ToStatement.optionToStatement(ToStatement.stringToStatement, ParameterMetaData.StringParameterMetaData))}, @@ -146,7 +146,8 @@ class SalesorderdetailRepoImpl extends SalesorderdetailRepo { "rowguid" = ${ParameterValue(row.rowguid, null, TypoUUID.toStatement)}::uuid, "modifieddate" = ${ParameterValue(row.modifieddate, null, TypoLocalDateTime.toStatement)}::timestamp where "salesorderid" = ${ParameterValue(compositeId.salesorderid, null, SalesorderheaderId.toStatement)} AND "salesorderdetailid" = ${ParameterValue(compositeId.salesorderdetailid, null, ToStatement.intToStatement)} - """.executeUpdate() > 0 + returning "salesorderid", "salesorderdetailid", "carriertrackingnumber", "orderqty", "productid", "specialofferid", "unitprice", "unitpricediscount", "rowguid", "modifieddate"::text + """.executeInsert(SalesorderdetailRow.rowParser(1).singleOpt) } override def upsert(unsaved: SalesorderdetailRow)(implicit c: Connection): SalesorderdetailRow = { SQL"""insert into "sales"."salesorderdetail"("salesorderid", "salesorderdetailid", "carriertrackingnumber", "orderqty", "productid", "specialofferid", "unitprice", "unitpricediscount", "rowguid", "modifieddate") diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesorderdetail/SalesorderdetailRepoMock.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesorderdetail/SalesorderdetailRepoMock.scala index 53b9aada2..617219446 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesorderdetail/SalesorderdetailRepoMock.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesorderdetail/SalesorderdetailRepoMock.scala @@ -74,13 +74,10 @@ class SalesorderdetailRepoMock(toRow: Function1[SalesorderdetailRowUnsaved, Sale override def update: UpdateBuilder[SalesorderdetailFields, SalesorderdetailRow] = { UpdateBuilderMock(UpdateParams.empty, SalesorderdetailFields.structure, map) } - override def update(row: SalesorderdetailRow)(implicit c: Connection): Boolean = { - map.get(row.compositeId) match { - case Some(`row`) => false - case Some(_) => - map.put(row.compositeId, row): @nowarn - true - case None => false + override def update(row: SalesorderdetailRow)(implicit c: Connection): Option[SalesorderdetailRow] = { + map.get(row.compositeId).map { _ => + map.put(row.compositeId, row): @nowarn + row } } override def upsert(unsaved: SalesorderdetailRow)(implicit c: Connection): SalesorderdetailRow = { diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesorderheader/SalesorderheaderRepo.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesorderheader/SalesorderheaderRepo.scala index c5a3c7c10..3a4964183 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesorderheader/SalesorderheaderRepo.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesorderheader/SalesorderheaderRepo.scala @@ -27,7 +27,7 @@ trait SalesorderheaderRepo { def selectByIds(salesorderids: Array[SalesorderheaderId])(implicit c: Connection): List[SalesorderheaderRow] def selectByIdsTracked(salesorderids: Array[SalesorderheaderId])(implicit c: Connection): Map[SalesorderheaderId, SalesorderheaderRow] def update: UpdateBuilder[SalesorderheaderFields, SalesorderheaderRow] - def update(row: SalesorderheaderRow)(implicit c: Connection): Boolean + def update(row: SalesorderheaderRow)(implicit c: Connection): Option[SalesorderheaderRow] def upsert(unsaved: SalesorderheaderRow)(implicit c: Connection): SalesorderheaderRow def upsertBatch(unsaved: Iterable[SalesorderheaderRow])(implicit c: Connection): List[SalesorderheaderRow] /* NOTE: this functionality is not safe if you use auto-commit mode! it runs 3 SQL statements */ diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesorderheader/SalesorderheaderRepoImpl.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesorderheader/SalesorderheaderRepoImpl.scala index 0049f4c42..1e916bed3 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesorderheader/SalesorderheaderRepoImpl.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesorderheader/SalesorderheaderRepoImpl.scala @@ -168,7 +168,7 @@ class SalesorderheaderRepoImpl extends SalesorderheaderRepo { override def update: UpdateBuilder[SalesorderheaderFields, SalesorderheaderRow] = { UpdateBuilder(""""sales"."salesorderheader"""", SalesorderheaderFields.structure, SalesorderheaderRow.rowParser) } - override def update(row: SalesorderheaderRow)(implicit c: Connection): Boolean = { + override def update(row: SalesorderheaderRow)(implicit c: Connection): Option[SalesorderheaderRow] = { val salesorderid = row.salesorderid SQL"""update "sales"."salesorderheader" set "revisionnumber" = ${ParameterValue(row.revisionnumber, null, TypoShort.toStatement)}::int2, @@ -196,7 +196,8 @@ class SalesorderheaderRepoImpl extends SalesorderheaderRepo { "rowguid" = ${ParameterValue(row.rowguid, null, TypoUUID.toStatement)}::uuid, "modifieddate" = ${ParameterValue(row.modifieddate, null, TypoLocalDateTime.toStatement)}::timestamp where "salesorderid" = ${ParameterValue(salesorderid, null, SalesorderheaderId.toStatement)} - """.executeUpdate() > 0 + returning "salesorderid", "revisionnumber", "orderdate"::text, "duedate"::text, "shipdate"::text, "status", "onlineorderflag", "purchaseordernumber", "accountnumber", "customerid", "salespersonid", "territoryid", "billtoaddressid", "shiptoaddressid", "shipmethodid", "creditcardid", "creditcardapprovalcode", "currencyrateid", "subtotal", "taxamt", "freight", "totaldue", "comment", "rowguid", "modifieddate"::text + """.executeInsert(SalesorderheaderRow.rowParser(1).singleOpt) } override def upsert(unsaved: SalesorderheaderRow)(implicit c: Connection): SalesorderheaderRow = { SQL"""insert into "sales"."salesorderheader"("salesorderid", "revisionnumber", "orderdate", "duedate", "shipdate", "status", "onlineorderflag", "purchaseordernumber", "accountnumber", "customerid", "salespersonid", "territoryid", "billtoaddressid", "shiptoaddressid", "shipmethodid", "creditcardid", "creditcardapprovalcode", "currencyrateid", "subtotal", "taxamt", "freight", "totaldue", "comment", "rowguid", "modifieddate") diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesorderheader/SalesorderheaderRepoMock.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesorderheader/SalesorderheaderRepoMock.scala index ba7cbbc6a..f1a4cc36d 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesorderheader/SalesorderheaderRepoMock.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesorderheader/SalesorderheaderRepoMock.scala @@ -74,13 +74,10 @@ class SalesorderheaderRepoMock(toRow: Function1[SalesorderheaderRowUnsaved, Sale override def update: UpdateBuilder[SalesorderheaderFields, SalesorderheaderRow] = { UpdateBuilderMock(UpdateParams.empty, SalesorderheaderFields.structure, map) } - override def update(row: SalesorderheaderRow)(implicit c: Connection): Boolean = { - map.get(row.salesorderid) match { - case Some(`row`) => false - case Some(_) => - map.put(row.salesorderid, row): @nowarn - true - case None => false + override def update(row: SalesorderheaderRow)(implicit c: Connection): Option[SalesorderheaderRow] = { + map.get(row.salesorderid).map { _ => + map.put(row.salesorderid, row): @nowarn + row } } override def upsert(unsaved: SalesorderheaderRow)(implicit c: Connection): SalesorderheaderRow = { diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesorderheadersalesreason/SalesorderheadersalesreasonRepo.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesorderheadersalesreason/SalesorderheadersalesreasonRepo.scala index af2bcd495..5d217b49d 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesorderheadersalesreason/SalesorderheadersalesreasonRepo.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesorderheadersalesreason/SalesorderheadersalesreasonRepo.scala @@ -27,7 +27,7 @@ trait SalesorderheadersalesreasonRepo { def selectByIds(compositeIds: Array[SalesorderheadersalesreasonId])(implicit c: Connection): List[SalesorderheadersalesreasonRow] def selectByIdsTracked(compositeIds: Array[SalesorderheadersalesreasonId])(implicit c: Connection): Map[SalesorderheadersalesreasonId, SalesorderheadersalesreasonRow] def update: UpdateBuilder[SalesorderheadersalesreasonFields, SalesorderheadersalesreasonRow] - def update(row: SalesorderheadersalesreasonRow)(implicit c: Connection): Boolean + def update(row: SalesorderheadersalesreasonRow)(implicit c: Connection): Option[SalesorderheadersalesreasonRow] def upsert(unsaved: SalesorderheadersalesreasonRow)(implicit c: Connection): SalesorderheadersalesreasonRow def upsertBatch(unsaved: Iterable[SalesorderheadersalesreasonRow])(implicit c: Connection): List[SalesorderheadersalesreasonRow] /* NOTE: this functionality is not safe if you use auto-commit mode! it runs 3 SQL statements */ diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesorderheadersalesreason/SalesorderheadersalesreasonRepoImpl.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesorderheadersalesreason/SalesorderheadersalesreasonRepoImpl.scala index 2c8507b46..292c8b717 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesorderheadersalesreason/SalesorderheadersalesreasonRepoImpl.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesorderheadersalesreason/SalesorderheadersalesreasonRepoImpl.scala @@ -101,7 +101,7 @@ class SalesorderheadersalesreasonRepoImpl extends SalesorderheadersalesreasonRep val salesreasonid = compositeIds.map(_.salesreasonid) SQL"""select "salesorderid", "salesreasonid", "modifieddate"::text from "sales"."salesorderheadersalesreason" - where ("salesorderid", "salesreasonid") + where ("salesorderid", "salesreasonid") in (select unnest(${salesorderid}), unnest(${salesreasonid})) """.as(SalesorderheadersalesreasonRow.rowParser(1).*) @@ -113,12 +113,13 @@ class SalesorderheadersalesreasonRepoImpl extends SalesorderheadersalesreasonRep override def update: UpdateBuilder[SalesorderheadersalesreasonFields, SalesorderheadersalesreasonRow] = { UpdateBuilder(""""sales"."salesorderheadersalesreason"""", SalesorderheadersalesreasonFields.structure, SalesorderheadersalesreasonRow.rowParser) } - override def update(row: SalesorderheadersalesreasonRow)(implicit c: Connection): Boolean = { + override def update(row: SalesorderheadersalesreasonRow)(implicit c: Connection): Option[SalesorderheadersalesreasonRow] = { val compositeId = row.compositeId SQL"""update "sales"."salesorderheadersalesreason" set "modifieddate" = ${ParameterValue(row.modifieddate, null, TypoLocalDateTime.toStatement)}::timestamp where "salesorderid" = ${ParameterValue(compositeId.salesorderid, null, SalesorderheaderId.toStatement)} AND "salesreasonid" = ${ParameterValue(compositeId.salesreasonid, null, SalesreasonId.toStatement)} - """.executeUpdate() > 0 + returning "salesorderid", "salesreasonid", "modifieddate"::text + """.executeInsert(SalesorderheadersalesreasonRow.rowParser(1).singleOpt) } override def upsert(unsaved: SalesorderheadersalesreasonRow)(implicit c: Connection): SalesorderheadersalesreasonRow = { SQL"""insert into "sales"."salesorderheadersalesreason"("salesorderid", "salesreasonid", "modifieddate") diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesorderheadersalesreason/SalesorderheadersalesreasonRepoMock.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesorderheadersalesreason/SalesorderheadersalesreasonRepoMock.scala index 2e5885ff3..6c25231cc 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesorderheadersalesreason/SalesorderheadersalesreasonRepoMock.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesorderheadersalesreason/SalesorderheadersalesreasonRepoMock.scala @@ -74,13 +74,10 @@ class SalesorderheadersalesreasonRepoMock(toRow: Function1[Salesorderheadersales override def update: UpdateBuilder[SalesorderheadersalesreasonFields, SalesorderheadersalesreasonRow] = { UpdateBuilderMock(UpdateParams.empty, SalesorderheadersalesreasonFields.structure, map) } - override def update(row: SalesorderheadersalesreasonRow)(implicit c: Connection): Boolean = { - map.get(row.compositeId) match { - case Some(`row`) => false - case Some(_) => - map.put(row.compositeId, row): @nowarn - true - case None => false + override def update(row: SalesorderheadersalesreasonRow)(implicit c: Connection): Option[SalesorderheadersalesreasonRow] = { + map.get(row.compositeId).map { _ => + map.put(row.compositeId, row): @nowarn + row } } override def upsert(unsaved: SalesorderheadersalesreasonRow)(implicit c: Connection): SalesorderheadersalesreasonRow = { diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesperson/SalespersonRepo.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesperson/SalespersonRepo.scala index a4a6408d4..cfbb6a2a5 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesperson/SalespersonRepo.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesperson/SalespersonRepo.scala @@ -28,7 +28,7 @@ trait SalespersonRepo { def selectByIds(businessentityids: Array[BusinessentityId])(implicit c: Connection): List[SalespersonRow] def selectByIdsTracked(businessentityids: Array[BusinessentityId])(implicit c: Connection): Map[BusinessentityId, SalespersonRow] def update: UpdateBuilder[SalespersonFields, SalespersonRow] - def update(row: SalespersonRow)(implicit c: Connection): Boolean + def update(row: SalespersonRow)(implicit c: Connection): Option[SalespersonRow] def upsert(unsaved: SalespersonRow)(implicit c: Connection): SalespersonRow def upsertBatch(unsaved: Iterable[SalespersonRow])(implicit c: Connection): List[SalespersonRow] /* NOTE: this functionality is not safe if you use auto-commit mode! it runs 3 SQL statements */ diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesperson/SalespersonRepoImpl.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesperson/SalespersonRepoImpl.scala index 21e7c6fc7..d5f57b633 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesperson/SalespersonRepoImpl.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesperson/SalespersonRepoImpl.scala @@ -131,7 +131,7 @@ class SalespersonRepoImpl extends SalespersonRepo { override def update: UpdateBuilder[SalespersonFields, SalespersonRow] = { UpdateBuilder(""""sales"."salesperson"""", SalespersonFields.structure, SalespersonRow.rowParser) } - override def update(row: SalespersonRow)(implicit c: Connection): Boolean = { + override def update(row: SalespersonRow)(implicit c: Connection): Option[SalespersonRow] = { val businessentityid = row.businessentityid SQL"""update "sales"."salesperson" set "territoryid" = ${ParameterValue(row.territoryid, null, ToStatement.optionToStatement(SalesterritoryId.toStatement, SalesterritoryId.parameterMetadata))}::int4, @@ -143,7 +143,8 @@ class SalespersonRepoImpl extends SalespersonRepo { "rowguid" = ${ParameterValue(row.rowguid, null, TypoUUID.toStatement)}::uuid, "modifieddate" = ${ParameterValue(row.modifieddate, null, TypoLocalDateTime.toStatement)}::timestamp where "businessentityid" = ${ParameterValue(businessentityid, null, BusinessentityId.toStatement)} - """.executeUpdate() > 0 + returning "businessentityid", "territoryid", "salesquota", "bonus", "commissionpct", "salesytd", "saleslastyear", "rowguid", "modifieddate"::text + """.executeInsert(SalespersonRow.rowParser(1).singleOpt) } override def upsert(unsaved: SalespersonRow)(implicit c: Connection): SalespersonRow = { SQL"""insert into "sales"."salesperson"("businessentityid", "territoryid", "salesquota", "bonus", "commissionpct", "salesytd", "saleslastyear", "rowguid", "modifieddate") diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesperson/SalespersonRepoMock.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesperson/SalespersonRepoMock.scala index e85ebc3e7..890512cda 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesperson/SalespersonRepoMock.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesperson/SalespersonRepoMock.scala @@ -75,13 +75,10 @@ class SalespersonRepoMock(toRow: Function1[SalespersonRowUnsaved, SalespersonRow override def update: UpdateBuilder[SalespersonFields, SalespersonRow] = { UpdateBuilderMock(UpdateParams.empty, SalespersonFields.structure, map) } - override def update(row: SalespersonRow)(implicit c: Connection): Boolean = { - map.get(row.businessentityid) match { - case Some(`row`) => false - case Some(_) => - map.put(row.businessentityid, row): @nowarn - true - case None => false + override def update(row: SalespersonRow)(implicit c: Connection): Option[SalespersonRow] = { + map.get(row.businessentityid).map { _ => + map.put(row.businessentityid, row): @nowarn + row } } override def upsert(unsaved: SalespersonRow)(implicit c: Connection): SalespersonRow = { diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salespersonquotahistory/SalespersonquotahistoryRepo.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salespersonquotahistory/SalespersonquotahistoryRepo.scala index ed542cb20..e1edee8f2 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salespersonquotahistory/SalespersonquotahistoryRepo.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salespersonquotahistory/SalespersonquotahistoryRepo.scala @@ -27,7 +27,7 @@ trait SalespersonquotahistoryRepo { def selectByIds(compositeIds: Array[SalespersonquotahistoryId])(implicit c: Connection): List[SalespersonquotahistoryRow] def selectByIdsTracked(compositeIds: Array[SalespersonquotahistoryId])(implicit c: Connection): Map[SalespersonquotahistoryId, SalespersonquotahistoryRow] def update: UpdateBuilder[SalespersonquotahistoryFields, SalespersonquotahistoryRow] - def update(row: SalespersonquotahistoryRow)(implicit c: Connection): Boolean + def update(row: SalespersonquotahistoryRow)(implicit c: Connection): Option[SalespersonquotahistoryRow] def upsert(unsaved: SalespersonquotahistoryRow)(implicit c: Connection): SalespersonquotahistoryRow def upsertBatch(unsaved: Iterable[SalespersonquotahistoryRow])(implicit c: Connection): List[SalespersonquotahistoryRow] /* NOTE: this functionality is not safe if you use auto-commit mode! it runs 3 SQL statements */ diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salespersonquotahistory/SalespersonquotahistoryRepoImpl.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salespersonquotahistory/SalespersonquotahistoryRepoImpl.scala index 49476d833..7e01065bb 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salespersonquotahistory/SalespersonquotahistoryRepoImpl.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salespersonquotahistory/SalespersonquotahistoryRepoImpl.scala @@ -107,7 +107,7 @@ class SalespersonquotahistoryRepoImpl extends SalespersonquotahistoryRepo { val quotadate = compositeIds.map(_.quotadate) SQL"""select "businessentityid", "quotadate"::text, "salesquota", "rowguid", "modifieddate"::text from "sales"."salespersonquotahistory" - where ("businessentityid", "quotadate") + where ("businessentityid", "quotadate") in (select unnest(${businessentityid}), unnest(${quotadate})) """.as(SalespersonquotahistoryRow.rowParser(1).*) @@ -119,14 +119,15 @@ class SalespersonquotahistoryRepoImpl extends SalespersonquotahistoryRepo { override def update: UpdateBuilder[SalespersonquotahistoryFields, SalespersonquotahistoryRow] = { UpdateBuilder(""""sales"."salespersonquotahistory"""", SalespersonquotahistoryFields.structure, SalespersonquotahistoryRow.rowParser) } - override def update(row: SalespersonquotahistoryRow)(implicit c: Connection): Boolean = { + override def update(row: SalespersonquotahistoryRow)(implicit c: Connection): Option[SalespersonquotahistoryRow] = { val compositeId = row.compositeId SQL"""update "sales"."salespersonquotahistory" set "salesquota" = ${ParameterValue(row.salesquota, null, ToStatement.scalaBigDecimalToStatement)}::numeric, "rowguid" = ${ParameterValue(row.rowguid, null, TypoUUID.toStatement)}::uuid, "modifieddate" = ${ParameterValue(row.modifieddate, null, TypoLocalDateTime.toStatement)}::timestamp where "businessentityid" = ${ParameterValue(compositeId.businessentityid, null, BusinessentityId.toStatement)} AND "quotadate" = ${ParameterValue(compositeId.quotadate, null, TypoLocalDateTime.toStatement)} - """.executeUpdate() > 0 + returning "businessentityid", "quotadate"::text, "salesquota", "rowguid", "modifieddate"::text + """.executeInsert(SalespersonquotahistoryRow.rowParser(1).singleOpt) } override def upsert(unsaved: SalespersonquotahistoryRow)(implicit c: Connection): SalespersonquotahistoryRow = { SQL"""insert into "sales"."salespersonquotahistory"("businessentityid", "quotadate", "salesquota", "rowguid", "modifieddate") diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salespersonquotahistory/SalespersonquotahistoryRepoMock.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salespersonquotahistory/SalespersonquotahistoryRepoMock.scala index a48b8a6cc..56b621f04 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salespersonquotahistory/SalespersonquotahistoryRepoMock.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salespersonquotahistory/SalespersonquotahistoryRepoMock.scala @@ -74,13 +74,10 @@ class SalespersonquotahistoryRepoMock(toRow: Function1[SalespersonquotahistoryRo override def update: UpdateBuilder[SalespersonquotahistoryFields, SalespersonquotahistoryRow] = { UpdateBuilderMock(UpdateParams.empty, SalespersonquotahistoryFields.structure, map) } - override def update(row: SalespersonquotahistoryRow)(implicit c: Connection): Boolean = { - map.get(row.compositeId) match { - case Some(`row`) => false - case Some(_) => - map.put(row.compositeId, row): @nowarn - true - case None => false + override def update(row: SalespersonquotahistoryRow)(implicit c: Connection): Option[SalespersonquotahistoryRow] = { + map.get(row.compositeId).map { _ => + map.put(row.compositeId, row): @nowarn + row } } override def upsert(unsaved: SalespersonquotahistoryRow)(implicit c: Connection): SalespersonquotahistoryRow = { diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesreason/SalesreasonRepo.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesreason/SalesreasonRepo.scala index 9bf894689..3d40693a7 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesreason/SalesreasonRepo.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesreason/SalesreasonRepo.scala @@ -27,7 +27,7 @@ trait SalesreasonRepo { def selectByIds(salesreasonids: Array[SalesreasonId])(implicit c: Connection): List[SalesreasonRow] def selectByIdsTracked(salesreasonids: Array[SalesreasonId])(implicit c: Connection): Map[SalesreasonId, SalesreasonRow] def update: UpdateBuilder[SalesreasonFields, SalesreasonRow] - def update(row: SalesreasonRow)(implicit c: Connection): Boolean + def update(row: SalesreasonRow)(implicit c: Connection): Option[SalesreasonRow] def upsert(unsaved: SalesreasonRow)(implicit c: Connection): SalesreasonRow def upsertBatch(unsaved: Iterable[SalesreasonRow])(implicit c: Connection): List[SalesreasonRow] /* NOTE: this functionality is not safe if you use auto-commit mode! it runs 3 SQL statements */ diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesreason/SalesreasonRepoImpl.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesreason/SalesreasonRepoImpl.scala index 427aa7145..1773d02c3 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesreason/SalesreasonRepoImpl.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesreason/SalesreasonRepoImpl.scala @@ -110,14 +110,15 @@ class SalesreasonRepoImpl extends SalesreasonRepo { override def update: UpdateBuilder[SalesreasonFields, SalesreasonRow] = { UpdateBuilder(""""sales"."salesreason"""", SalesreasonFields.structure, SalesreasonRow.rowParser) } - override def update(row: SalesreasonRow)(implicit c: Connection): Boolean = { + override def update(row: SalesreasonRow)(implicit c: Connection): Option[SalesreasonRow] = { val salesreasonid = row.salesreasonid SQL"""update "sales"."salesreason" set "name" = ${ParameterValue(row.name, null, Name.toStatement)}::varchar, "reasontype" = ${ParameterValue(row.reasontype, null, Name.toStatement)}::varchar, "modifieddate" = ${ParameterValue(row.modifieddate, null, TypoLocalDateTime.toStatement)}::timestamp where "salesreasonid" = ${ParameterValue(salesreasonid, null, SalesreasonId.toStatement)} - """.executeUpdate() > 0 + returning "salesreasonid", "name", "reasontype", "modifieddate"::text + """.executeInsert(SalesreasonRow.rowParser(1).singleOpt) } override def upsert(unsaved: SalesreasonRow)(implicit c: Connection): SalesreasonRow = { SQL"""insert into "sales"."salesreason"("salesreasonid", "name", "reasontype", "modifieddate") diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesreason/SalesreasonRepoMock.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesreason/SalesreasonRepoMock.scala index c318e40fa..260ec9ec0 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesreason/SalesreasonRepoMock.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesreason/SalesreasonRepoMock.scala @@ -74,13 +74,10 @@ class SalesreasonRepoMock(toRow: Function1[SalesreasonRowUnsaved, SalesreasonRow override def update: UpdateBuilder[SalesreasonFields, SalesreasonRow] = { UpdateBuilderMock(UpdateParams.empty, SalesreasonFields.structure, map) } - override def update(row: SalesreasonRow)(implicit c: Connection): Boolean = { - map.get(row.salesreasonid) match { - case Some(`row`) => false - case Some(_) => - map.put(row.salesreasonid, row): @nowarn - true - case None => false + override def update(row: SalesreasonRow)(implicit c: Connection): Option[SalesreasonRow] = { + map.get(row.salesreasonid).map { _ => + map.put(row.salesreasonid, row): @nowarn + row } } override def upsert(unsaved: SalesreasonRow)(implicit c: Connection): SalesreasonRow = { diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salestaxrate/SalestaxrateRepo.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salestaxrate/SalestaxrateRepo.scala index 4bbc19adb..ab09aed96 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salestaxrate/SalestaxrateRepo.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salestaxrate/SalestaxrateRepo.scala @@ -27,7 +27,7 @@ trait SalestaxrateRepo { def selectByIds(salestaxrateids: Array[SalestaxrateId])(implicit c: Connection): List[SalestaxrateRow] def selectByIdsTracked(salestaxrateids: Array[SalestaxrateId])(implicit c: Connection): Map[SalestaxrateId, SalestaxrateRow] def update: UpdateBuilder[SalestaxrateFields, SalestaxrateRow] - def update(row: SalestaxrateRow)(implicit c: Connection): Boolean + def update(row: SalestaxrateRow)(implicit c: Connection): Option[SalestaxrateRow] def upsert(unsaved: SalestaxrateRow)(implicit c: Connection): SalestaxrateRow def upsertBatch(unsaved: Iterable[SalestaxrateRow])(implicit c: Connection): List[SalestaxrateRow] /* NOTE: this functionality is not safe if you use auto-commit mode! it runs 3 SQL statements */ diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salestaxrate/SalestaxrateRepoImpl.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salestaxrate/SalestaxrateRepoImpl.scala index b9d29e95b..62ed690f9 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salestaxrate/SalestaxrateRepoImpl.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salestaxrate/SalestaxrateRepoImpl.scala @@ -123,7 +123,7 @@ class SalestaxrateRepoImpl extends SalestaxrateRepo { override def update: UpdateBuilder[SalestaxrateFields, SalestaxrateRow] = { UpdateBuilder(""""sales"."salestaxrate"""", SalestaxrateFields.structure, SalestaxrateRow.rowParser) } - override def update(row: SalestaxrateRow)(implicit c: Connection): Boolean = { + override def update(row: SalestaxrateRow)(implicit c: Connection): Option[SalestaxrateRow] = { val salestaxrateid = row.salestaxrateid SQL"""update "sales"."salestaxrate" set "stateprovinceid" = ${ParameterValue(row.stateprovinceid, null, StateprovinceId.toStatement)}::int4, @@ -133,7 +133,8 @@ class SalestaxrateRepoImpl extends SalestaxrateRepo { "rowguid" = ${ParameterValue(row.rowguid, null, TypoUUID.toStatement)}::uuid, "modifieddate" = ${ParameterValue(row.modifieddate, null, TypoLocalDateTime.toStatement)}::timestamp where "salestaxrateid" = ${ParameterValue(salestaxrateid, null, SalestaxrateId.toStatement)} - """.executeUpdate() > 0 + returning "salestaxrateid", "stateprovinceid", "taxtype", "taxrate", "name", "rowguid", "modifieddate"::text + """.executeInsert(SalestaxrateRow.rowParser(1).singleOpt) } override def upsert(unsaved: SalestaxrateRow)(implicit c: Connection): SalestaxrateRow = { SQL"""insert into "sales"."salestaxrate"("salestaxrateid", "stateprovinceid", "taxtype", "taxrate", "name", "rowguid", "modifieddate") diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salestaxrate/SalestaxrateRepoMock.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salestaxrate/SalestaxrateRepoMock.scala index 2f0a9fc17..8dd65d29c 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salestaxrate/SalestaxrateRepoMock.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salestaxrate/SalestaxrateRepoMock.scala @@ -74,13 +74,10 @@ class SalestaxrateRepoMock(toRow: Function1[SalestaxrateRowUnsaved, Salestaxrate override def update: UpdateBuilder[SalestaxrateFields, SalestaxrateRow] = { UpdateBuilderMock(UpdateParams.empty, SalestaxrateFields.structure, map) } - override def update(row: SalestaxrateRow)(implicit c: Connection): Boolean = { - map.get(row.salestaxrateid) match { - case Some(`row`) => false - case Some(_) => - map.put(row.salestaxrateid, row): @nowarn - true - case None => false + override def update(row: SalestaxrateRow)(implicit c: Connection): Option[SalestaxrateRow] = { + map.get(row.salestaxrateid).map { _ => + map.put(row.salestaxrateid, row): @nowarn + row } } override def upsert(unsaved: SalestaxrateRow)(implicit c: Connection): SalestaxrateRow = { diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesterritory/SalesterritoryRepo.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesterritory/SalesterritoryRepo.scala index a589bdd6f..ded83a40f 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesterritory/SalesterritoryRepo.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesterritory/SalesterritoryRepo.scala @@ -27,7 +27,7 @@ trait SalesterritoryRepo { def selectByIds(territoryids: Array[SalesterritoryId])(implicit c: Connection): List[SalesterritoryRow] def selectByIdsTracked(territoryids: Array[SalesterritoryId])(implicit c: Connection): Map[SalesterritoryId, SalesterritoryRow] def update: UpdateBuilder[SalesterritoryFields, SalesterritoryRow] - def update(row: SalesterritoryRow)(implicit c: Connection): Boolean + def update(row: SalesterritoryRow)(implicit c: Connection): Option[SalesterritoryRow] def upsert(unsaved: SalesterritoryRow)(implicit c: Connection): SalesterritoryRow def upsertBatch(unsaved: Iterable[SalesterritoryRow])(implicit c: Connection): List[SalesterritoryRow] /* NOTE: this functionality is not safe if you use auto-commit mode! it runs 3 SQL statements */ diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesterritory/SalesterritoryRepoImpl.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesterritory/SalesterritoryRepoImpl.scala index 96288ab8a..d6e70e3ba 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesterritory/SalesterritoryRepoImpl.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesterritory/SalesterritoryRepoImpl.scala @@ -134,7 +134,7 @@ class SalesterritoryRepoImpl extends SalesterritoryRepo { override def update: UpdateBuilder[SalesterritoryFields, SalesterritoryRow] = { UpdateBuilder(""""sales"."salesterritory"""", SalesterritoryFields.structure, SalesterritoryRow.rowParser) } - override def update(row: SalesterritoryRow)(implicit c: Connection): Boolean = { + override def update(row: SalesterritoryRow)(implicit c: Connection): Option[SalesterritoryRow] = { val territoryid = row.territoryid SQL"""update "sales"."salesterritory" set "name" = ${ParameterValue(row.name, null, Name.toStatement)}::varchar, @@ -147,7 +147,8 @@ class SalesterritoryRepoImpl extends SalesterritoryRepo { "rowguid" = ${ParameterValue(row.rowguid, null, TypoUUID.toStatement)}::uuid, "modifieddate" = ${ParameterValue(row.modifieddate, null, TypoLocalDateTime.toStatement)}::timestamp where "territoryid" = ${ParameterValue(territoryid, null, SalesterritoryId.toStatement)} - """.executeUpdate() > 0 + returning "territoryid", "name", "countryregioncode", "group", "salesytd", "saleslastyear", "costytd", "costlastyear", "rowguid", "modifieddate"::text + """.executeInsert(SalesterritoryRow.rowParser(1).singleOpt) } override def upsert(unsaved: SalesterritoryRow)(implicit c: Connection): SalesterritoryRow = { SQL"""insert into "sales"."salesterritory"("territoryid", "name", "countryregioncode", "group", "salesytd", "saleslastyear", "costytd", "costlastyear", "rowguid", "modifieddate") diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesterritory/SalesterritoryRepoMock.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesterritory/SalesterritoryRepoMock.scala index aa2ee9e26..46880c4fb 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesterritory/SalesterritoryRepoMock.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesterritory/SalesterritoryRepoMock.scala @@ -74,13 +74,10 @@ class SalesterritoryRepoMock(toRow: Function1[SalesterritoryRowUnsaved, Salester override def update: UpdateBuilder[SalesterritoryFields, SalesterritoryRow] = { UpdateBuilderMock(UpdateParams.empty, SalesterritoryFields.structure, map) } - override def update(row: SalesterritoryRow)(implicit c: Connection): Boolean = { - map.get(row.territoryid) match { - case Some(`row`) => false - case Some(_) => - map.put(row.territoryid, row): @nowarn - true - case None => false + override def update(row: SalesterritoryRow)(implicit c: Connection): Option[SalesterritoryRow] = { + map.get(row.territoryid).map { _ => + map.put(row.territoryid, row): @nowarn + row } } override def upsert(unsaved: SalesterritoryRow)(implicit c: Connection): SalesterritoryRow = { diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesterritoryhistory/SalesterritoryhistoryRepo.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesterritoryhistory/SalesterritoryhistoryRepo.scala index 18089225f..3fb8a8c71 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesterritoryhistory/SalesterritoryhistoryRepo.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesterritoryhistory/SalesterritoryhistoryRepo.scala @@ -27,7 +27,7 @@ trait SalesterritoryhistoryRepo { def selectByIds(compositeIds: Array[SalesterritoryhistoryId])(implicit c: Connection): List[SalesterritoryhistoryRow] def selectByIdsTracked(compositeIds: Array[SalesterritoryhistoryId])(implicit c: Connection): Map[SalesterritoryhistoryId, SalesterritoryhistoryRow] def update: UpdateBuilder[SalesterritoryhistoryFields, SalesterritoryhistoryRow] - def update(row: SalesterritoryhistoryRow)(implicit c: Connection): Boolean + def update(row: SalesterritoryhistoryRow)(implicit c: Connection): Option[SalesterritoryhistoryRow] def upsert(unsaved: SalesterritoryhistoryRow)(implicit c: Connection): SalesterritoryhistoryRow def upsertBatch(unsaved: Iterable[SalesterritoryhistoryRow])(implicit c: Connection): List[SalesterritoryhistoryRow] /* NOTE: this functionality is not safe if you use auto-commit mode! it runs 3 SQL statements */ diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesterritoryhistory/SalesterritoryhistoryRepoImpl.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesterritoryhistory/SalesterritoryhistoryRepoImpl.scala index 109f63f89..b26a3fc03 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesterritoryhistory/SalesterritoryhistoryRepoImpl.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesterritoryhistory/SalesterritoryhistoryRepoImpl.scala @@ -111,7 +111,7 @@ class SalesterritoryhistoryRepoImpl extends SalesterritoryhistoryRepo { val territoryid = compositeIds.map(_.territoryid) SQL"""select "businessentityid", "territoryid", "startdate"::text, "enddate"::text, "rowguid", "modifieddate"::text from "sales"."salesterritoryhistory" - where ("businessentityid", "startdate", "territoryid") + where ("businessentityid", "startdate", "territoryid") in (select unnest(${businessentityid}), unnest(${startdate}), unnest(${territoryid})) """.as(SalesterritoryhistoryRow.rowParser(1).*) @@ -123,14 +123,15 @@ class SalesterritoryhistoryRepoImpl extends SalesterritoryhistoryRepo { override def update: UpdateBuilder[SalesterritoryhistoryFields, SalesterritoryhistoryRow] = { UpdateBuilder(""""sales"."salesterritoryhistory"""", SalesterritoryhistoryFields.structure, SalesterritoryhistoryRow.rowParser) } - override def update(row: SalesterritoryhistoryRow)(implicit c: Connection): Boolean = { + override def update(row: SalesterritoryhistoryRow)(implicit c: Connection): Option[SalesterritoryhistoryRow] = { val compositeId = row.compositeId SQL"""update "sales"."salesterritoryhistory" set "enddate" = ${ParameterValue(row.enddate, null, ToStatement.optionToStatement(TypoLocalDateTime.toStatement, TypoLocalDateTime.parameterMetadata))}::timestamp, "rowguid" = ${ParameterValue(row.rowguid, null, TypoUUID.toStatement)}::uuid, "modifieddate" = ${ParameterValue(row.modifieddate, null, TypoLocalDateTime.toStatement)}::timestamp where "businessentityid" = ${ParameterValue(compositeId.businessentityid, null, BusinessentityId.toStatement)} AND "startdate" = ${ParameterValue(compositeId.startdate, null, TypoLocalDateTime.toStatement)} AND "territoryid" = ${ParameterValue(compositeId.territoryid, null, SalesterritoryId.toStatement)} - """.executeUpdate() > 0 + returning "businessentityid", "territoryid", "startdate"::text, "enddate"::text, "rowguid", "modifieddate"::text + """.executeInsert(SalesterritoryhistoryRow.rowParser(1).singleOpt) } override def upsert(unsaved: SalesterritoryhistoryRow)(implicit c: Connection): SalesterritoryhistoryRow = { SQL"""insert into "sales"."salesterritoryhistory"("businessentityid", "territoryid", "startdate", "enddate", "rowguid", "modifieddate") diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesterritoryhistory/SalesterritoryhistoryRepoMock.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesterritoryhistory/SalesterritoryhistoryRepoMock.scala index 3163857d0..90df1fd90 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesterritoryhistory/SalesterritoryhistoryRepoMock.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/salesterritoryhistory/SalesterritoryhistoryRepoMock.scala @@ -74,13 +74,10 @@ class SalesterritoryhistoryRepoMock(toRow: Function1[SalesterritoryhistoryRowUns override def update: UpdateBuilder[SalesterritoryhistoryFields, SalesterritoryhistoryRow] = { UpdateBuilderMock(UpdateParams.empty, SalesterritoryhistoryFields.structure, map) } - override def update(row: SalesterritoryhistoryRow)(implicit c: Connection): Boolean = { - map.get(row.compositeId) match { - case Some(`row`) => false - case Some(_) => - map.put(row.compositeId, row): @nowarn - true - case None => false + override def update(row: SalesterritoryhistoryRow)(implicit c: Connection): Option[SalesterritoryhistoryRow] = { + map.get(row.compositeId).map { _ => + map.put(row.compositeId, row): @nowarn + row } } override def upsert(unsaved: SalesterritoryhistoryRow)(implicit c: Connection): SalesterritoryhistoryRow = { diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/shoppingcartitem/ShoppingcartitemRepo.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/shoppingcartitem/ShoppingcartitemRepo.scala index 521676b4d..75aad9245 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/shoppingcartitem/ShoppingcartitemRepo.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/shoppingcartitem/ShoppingcartitemRepo.scala @@ -27,7 +27,7 @@ trait ShoppingcartitemRepo { def selectByIds(shoppingcartitemids: Array[ShoppingcartitemId])(implicit c: Connection): List[ShoppingcartitemRow] def selectByIdsTracked(shoppingcartitemids: Array[ShoppingcartitemId])(implicit c: Connection): Map[ShoppingcartitemId, ShoppingcartitemRow] def update: UpdateBuilder[ShoppingcartitemFields, ShoppingcartitemRow] - def update(row: ShoppingcartitemRow)(implicit c: Connection): Boolean + def update(row: ShoppingcartitemRow)(implicit c: Connection): Option[ShoppingcartitemRow] def upsert(unsaved: ShoppingcartitemRow)(implicit c: Connection): ShoppingcartitemRow def upsertBatch(unsaved: Iterable[ShoppingcartitemRow])(implicit c: Connection): List[ShoppingcartitemRow] /* NOTE: this functionality is not safe if you use auto-commit mode! it runs 3 SQL statements */ diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/shoppingcartitem/ShoppingcartitemRepoImpl.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/shoppingcartitem/ShoppingcartitemRepoImpl.scala index 935d2dcd3..e655ad285 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/shoppingcartitem/ShoppingcartitemRepoImpl.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/shoppingcartitem/ShoppingcartitemRepoImpl.scala @@ -119,7 +119,7 @@ class ShoppingcartitemRepoImpl extends ShoppingcartitemRepo { override def update: UpdateBuilder[ShoppingcartitemFields, ShoppingcartitemRow] = { UpdateBuilder(""""sales"."shoppingcartitem"""", ShoppingcartitemFields.structure, ShoppingcartitemRow.rowParser) } - override def update(row: ShoppingcartitemRow)(implicit c: Connection): Boolean = { + override def update(row: ShoppingcartitemRow)(implicit c: Connection): Option[ShoppingcartitemRow] = { val shoppingcartitemid = row.shoppingcartitemid SQL"""update "sales"."shoppingcartitem" set "shoppingcartid" = ${ParameterValue(row.shoppingcartid, null, ToStatement.stringToStatement)}, @@ -128,7 +128,8 @@ class ShoppingcartitemRepoImpl extends ShoppingcartitemRepo { "datecreated" = ${ParameterValue(row.datecreated, null, TypoLocalDateTime.toStatement)}::timestamp, "modifieddate" = ${ParameterValue(row.modifieddate, null, TypoLocalDateTime.toStatement)}::timestamp where "shoppingcartitemid" = ${ParameterValue(shoppingcartitemid, null, ShoppingcartitemId.toStatement)} - """.executeUpdate() > 0 + returning "shoppingcartitemid", "shoppingcartid", "quantity", "productid", "datecreated"::text, "modifieddate"::text + """.executeInsert(ShoppingcartitemRow.rowParser(1).singleOpt) } override def upsert(unsaved: ShoppingcartitemRow)(implicit c: Connection): ShoppingcartitemRow = { SQL"""insert into "sales"."shoppingcartitem"("shoppingcartitemid", "shoppingcartid", "quantity", "productid", "datecreated", "modifieddate") diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/shoppingcartitem/ShoppingcartitemRepoMock.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/shoppingcartitem/ShoppingcartitemRepoMock.scala index 6ac6f7838..e2b0e0bb6 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/shoppingcartitem/ShoppingcartitemRepoMock.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/shoppingcartitem/ShoppingcartitemRepoMock.scala @@ -74,13 +74,10 @@ class ShoppingcartitemRepoMock(toRow: Function1[ShoppingcartitemRowUnsaved, Shop override def update: UpdateBuilder[ShoppingcartitemFields, ShoppingcartitemRow] = { UpdateBuilderMock(UpdateParams.empty, ShoppingcartitemFields.structure, map) } - override def update(row: ShoppingcartitemRow)(implicit c: Connection): Boolean = { - map.get(row.shoppingcartitemid) match { - case Some(`row`) => false - case Some(_) => - map.put(row.shoppingcartitemid, row): @nowarn - true - case None => false + override def update(row: ShoppingcartitemRow)(implicit c: Connection): Option[ShoppingcartitemRow] = { + map.get(row.shoppingcartitemid).map { _ => + map.put(row.shoppingcartitemid, row): @nowarn + row } } override def upsert(unsaved: ShoppingcartitemRow)(implicit c: Connection): ShoppingcartitemRow = { diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/specialoffer/SpecialofferRepo.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/specialoffer/SpecialofferRepo.scala index 0f2b28cbe..703c9b804 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/specialoffer/SpecialofferRepo.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/specialoffer/SpecialofferRepo.scala @@ -27,7 +27,7 @@ trait SpecialofferRepo { def selectByIds(specialofferids: Array[SpecialofferId])(implicit c: Connection): List[SpecialofferRow] def selectByIdsTracked(specialofferids: Array[SpecialofferId])(implicit c: Connection): Map[SpecialofferId, SpecialofferRow] def update: UpdateBuilder[SpecialofferFields, SpecialofferRow] - def update(row: SpecialofferRow)(implicit c: Connection): Boolean + def update(row: SpecialofferRow)(implicit c: Connection): Option[SpecialofferRow] def upsert(unsaved: SpecialofferRow)(implicit c: Connection): SpecialofferRow def upsertBatch(unsaved: Iterable[SpecialofferRow])(implicit c: Connection): List[SpecialofferRow] /* NOTE: this functionality is not safe if you use auto-commit mode! it runs 3 SQL statements */ diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/specialoffer/SpecialofferRepoImpl.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/specialoffer/SpecialofferRepoImpl.scala index 39c8898ee..56a07538d 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/specialoffer/SpecialofferRepoImpl.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/specialoffer/SpecialofferRepoImpl.scala @@ -128,7 +128,7 @@ class SpecialofferRepoImpl extends SpecialofferRepo { override def update: UpdateBuilder[SpecialofferFields, SpecialofferRow] = { UpdateBuilder(""""sales"."specialoffer"""", SpecialofferFields.structure, SpecialofferRow.rowParser) } - override def update(row: SpecialofferRow)(implicit c: Connection): Boolean = { + override def update(row: SpecialofferRow)(implicit c: Connection): Option[SpecialofferRow] = { val specialofferid = row.specialofferid SQL"""update "sales"."specialoffer" set "description" = ${ParameterValue(row.description, null, ToStatement.stringToStatement)}, @@ -142,7 +142,8 @@ class SpecialofferRepoImpl extends SpecialofferRepo { "rowguid" = ${ParameterValue(row.rowguid, null, TypoUUID.toStatement)}::uuid, "modifieddate" = ${ParameterValue(row.modifieddate, null, TypoLocalDateTime.toStatement)}::timestamp where "specialofferid" = ${ParameterValue(specialofferid, null, SpecialofferId.toStatement)} - """.executeUpdate() > 0 + returning "specialofferid", "description", "discountpct", "type", "category", "startdate"::text, "enddate"::text, "minqty", "maxqty", "rowguid", "modifieddate"::text + """.executeInsert(SpecialofferRow.rowParser(1).singleOpt) } override def upsert(unsaved: SpecialofferRow)(implicit c: Connection): SpecialofferRow = { SQL"""insert into "sales"."specialoffer"("specialofferid", "description", "discountpct", "type", "category", "startdate", "enddate", "minqty", "maxqty", "rowguid", "modifieddate") diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/specialoffer/SpecialofferRepoMock.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/specialoffer/SpecialofferRepoMock.scala index a9ff1c23a..d7970ac0f 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/specialoffer/SpecialofferRepoMock.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/specialoffer/SpecialofferRepoMock.scala @@ -74,13 +74,10 @@ class SpecialofferRepoMock(toRow: Function1[SpecialofferRowUnsaved, Specialoffer override def update: UpdateBuilder[SpecialofferFields, SpecialofferRow] = { UpdateBuilderMock(UpdateParams.empty, SpecialofferFields.structure, map) } - override def update(row: SpecialofferRow)(implicit c: Connection): Boolean = { - map.get(row.specialofferid) match { - case Some(`row`) => false - case Some(_) => - map.put(row.specialofferid, row): @nowarn - true - case None => false + override def update(row: SpecialofferRow)(implicit c: Connection): Option[SpecialofferRow] = { + map.get(row.specialofferid).map { _ => + map.put(row.specialofferid, row): @nowarn + row } } override def upsert(unsaved: SpecialofferRow)(implicit c: Connection): SpecialofferRow = { diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/specialofferproduct/SpecialofferproductRepo.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/specialofferproduct/SpecialofferproductRepo.scala index b2ee0e0b3..620a4f49c 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/specialofferproduct/SpecialofferproductRepo.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/specialofferproduct/SpecialofferproductRepo.scala @@ -27,7 +27,7 @@ trait SpecialofferproductRepo { def selectByIds(compositeIds: Array[SpecialofferproductId])(implicit c: Connection): List[SpecialofferproductRow] def selectByIdsTracked(compositeIds: Array[SpecialofferproductId])(implicit c: Connection): Map[SpecialofferproductId, SpecialofferproductRow] def update: UpdateBuilder[SpecialofferproductFields, SpecialofferproductRow] - def update(row: SpecialofferproductRow)(implicit c: Connection): Boolean + def update(row: SpecialofferproductRow)(implicit c: Connection): Option[SpecialofferproductRow] def upsert(unsaved: SpecialofferproductRow)(implicit c: Connection): SpecialofferproductRow def upsertBatch(unsaved: Iterable[SpecialofferproductRow])(implicit c: Connection): List[SpecialofferproductRow] /* NOTE: this functionality is not safe if you use auto-commit mode! it runs 3 SQL statements */ diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/specialofferproduct/SpecialofferproductRepoImpl.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/specialofferproduct/SpecialofferproductRepoImpl.scala index c3bf1a00c..5763a5c32 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/specialofferproduct/SpecialofferproductRepoImpl.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/specialofferproduct/SpecialofferproductRepoImpl.scala @@ -106,7 +106,7 @@ class SpecialofferproductRepoImpl extends SpecialofferproductRepo { val productid = compositeIds.map(_.productid) SQL"""select "specialofferid", "productid", "rowguid", "modifieddate"::text from "sales"."specialofferproduct" - where ("specialofferid", "productid") + where ("specialofferid", "productid") in (select unnest(${specialofferid}), unnest(${productid})) """.as(SpecialofferproductRow.rowParser(1).*) @@ -118,13 +118,14 @@ class SpecialofferproductRepoImpl extends SpecialofferproductRepo { override def update: UpdateBuilder[SpecialofferproductFields, SpecialofferproductRow] = { UpdateBuilder(""""sales"."specialofferproduct"""", SpecialofferproductFields.structure, SpecialofferproductRow.rowParser) } - override def update(row: SpecialofferproductRow)(implicit c: Connection): Boolean = { + override def update(row: SpecialofferproductRow)(implicit c: Connection): Option[SpecialofferproductRow] = { val compositeId = row.compositeId SQL"""update "sales"."specialofferproduct" set "rowguid" = ${ParameterValue(row.rowguid, null, TypoUUID.toStatement)}::uuid, "modifieddate" = ${ParameterValue(row.modifieddate, null, TypoLocalDateTime.toStatement)}::timestamp where "specialofferid" = ${ParameterValue(compositeId.specialofferid, null, SpecialofferId.toStatement)} AND "productid" = ${ParameterValue(compositeId.productid, null, ProductId.toStatement)} - """.executeUpdate() > 0 + returning "specialofferid", "productid", "rowguid", "modifieddate"::text + """.executeInsert(SpecialofferproductRow.rowParser(1).singleOpt) } override def upsert(unsaved: SpecialofferproductRow)(implicit c: Connection): SpecialofferproductRow = { SQL"""insert into "sales"."specialofferproduct"("specialofferid", "productid", "rowguid", "modifieddate") diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/specialofferproduct/SpecialofferproductRepoMock.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/specialofferproduct/SpecialofferproductRepoMock.scala index 72eb67df5..7cb3280b2 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/specialofferproduct/SpecialofferproductRepoMock.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/specialofferproduct/SpecialofferproductRepoMock.scala @@ -74,13 +74,10 @@ class SpecialofferproductRepoMock(toRow: Function1[SpecialofferproductRowUnsaved override def update: UpdateBuilder[SpecialofferproductFields, SpecialofferproductRow] = { UpdateBuilderMock(UpdateParams.empty, SpecialofferproductFields.structure, map) } - override def update(row: SpecialofferproductRow)(implicit c: Connection): Boolean = { - map.get(row.compositeId) match { - case Some(`row`) => false - case Some(_) => - map.put(row.compositeId, row): @nowarn - true - case None => false + override def update(row: SpecialofferproductRow)(implicit c: Connection): Option[SpecialofferproductRow] = { + map.get(row.compositeId).map { _ => + map.put(row.compositeId, row): @nowarn + row } } override def upsert(unsaved: SpecialofferproductRow)(implicit c: Connection): SpecialofferproductRow = { diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/store/StoreRepo.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/store/StoreRepo.scala index 403d3e978..4c50ba152 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/store/StoreRepo.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/store/StoreRepo.scala @@ -28,7 +28,7 @@ trait StoreRepo { def selectByIds(businessentityids: Array[BusinessentityId])(implicit c: Connection): List[StoreRow] def selectByIdsTracked(businessentityids: Array[BusinessentityId])(implicit c: Connection): Map[BusinessentityId, StoreRow] def update: UpdateBuilder[StoreFields, StoreRow] - def update(row: StoreRow)(implicit c: Connection): Boolean + def update(row: StoreRow)(implicit c: Connection): Option[StoreRow] def upsert(unsaved: StoreRow)(implicit c: Connection): StoreRow def upsertBatch(unsaved: Iterable[StoreRow])(implicit c: Connection): List[StoreRow] /* NOTE: this functionality is not safe if you use auto-commit mode! it runs 3 SQL statements */ diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/store/StoreRepoImpl.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/store/StoreRepoImpl.scala index b3fe2ed61..9a89ec69f 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/store/StoreRepoImpl.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/store/StoreRepoImpl.scala @@ -116,7 +116,7 @@ class StoreRepoImpl extends StoreRepo { override def update: UpdateBuilder[StoreFields, StoreRow] = { UpdateBuilder(""""sales"."store"""", StoreFields.structure, StoreRow.rowParser) } - override def update(row: StoreRow)(implicit c: Connection): Boolean = { + override def update(row: StoreRow)(implicit c: Connection): Option[StoreRow] = { val businessentityid = row.businessentityid SQL"""update "sales"."store" set "name" = ${ParameterValue(row.name, null, Name.toStatement)}::varchar, @@ -125,7 +125,8 @@ class StoreRepoImpl extends StoreRepo { "rowguid" = ${ParameterValue(row.rowguid, null, TypoUUID.toStatement)}::uuid, "modifieddate" = ${ParameterValue(row.modifieddate, null, TypoLocalDateTime.toStatement)}::timestamp where "businessentityid" = ${ParameterValue(businessentityid, null, BusinessentityId.toStatement)} - """.executeUpdate() > 0 + returning "businessentityid", "name", "salespersonid", "demographics", "rowguid", "modifieddate"::text + """.executeInsert(StoreRow.rowParser(1).singleOpt) } override def upsert(unsaved: StoreRow)(implicit c: Connection): StoreRow = { SQL"""insert into "sales"."store"("businessentityid", "name", "salespersonid", "demographics", "rowguid", "modifieddate") diff --git a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/store/StoreRepoMock.scala b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/store/StoreRepoMock.scala index 545c28a5b..b7e36debd 100644 --- a/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/store/StoreRepoMock.scala +++ b/typo-tester-anorm/generated-and-checked-in/adventureworks/sales/store/StoreRepoMock.scala @@ -75,13 +75,10 @@ class StoreRepoMock(toRow: Function1[StoreRowUnsaved, StoreRow], override def update: UpdateBuilder[StoreFields, StoreRow] = { UpdateBuilderMock(UpdateParams.empty, StoreFields.structure, map) } - override def update(row: StoreRow)(implicit c: Connection): Boolean = { - map.get(row.businessentityid) match { - case Some(`row`) => false - case Some(_) => - map.put(row.businessentityid, row): @nowarn - true - case None => false + override def update(row: StoreRow)(implicit c: Connection): Option[StoreRow] = { + map.get(row.businessentityid).map { _ => + map.put(row.businessentityid, row): @nowarn + row } } override def upsert(unsaved: StoreRow)(implicit c: Connection): StoreRow = { diff --git a/typo-tester-anorm/src/scala/adventureworks/production/product/ProductTest.scala b/typo-tester-anorm/src/scala/adventureworks/production/product/ProductTest.scala index 251414997..679285843 100644 --- a/typo-tester-anorm/src/scala/adventureworks/production/product/ProductTest.scala +++ b/typo-tester-anorm/src/scala/adventureworks/production/product/ProductTest.scala @@ -121,7 +121,7 @@ class ProductTest extends SnapshotTest { productRepo.update(saved1.copy(modifieddate = newModifiedDate)): @nowarn val List(saved3) = productRepo.selectAll: @unchecked assert(saved3.modifieddate == newModifiedDate): @nowarn - assert(productRepo.update(saved3.copy(size = None))): @nowarn + assert(productRepo.update(saved3.copy(size = None)).isDefined): @nowarn val query0 = productRepo.select .joinFk(_.fkProductmodel)(projectModelRepo.select) diff --git a/typo/src/scala/typo/internal/codegen/DbLibAnorm.scala b/typo/src/scala/typo/internal/codegen/DbLibAnorm.scala index dbfb7ce68..2a2e05844 100644 --- a/typo/src/scala/typo/internal/codegen/DbLibAnorm.scala +++ b/typo/src/scala/typo/internal/codegen/DbLibAnorm.scala @@ -218,7 +218,7 @@ class DbLibAnorm(pkg: sc.QIdent, inlineImplicits: Boolean, default: ComputedDefa case RepoMethod.UpdateFieldValues(_, id, varargs, _, _, _) => Right(code"def $name(${id.param}, $varargs)(implicit c: ${TypesJava.Connection}): ${TypesScala.Boolean}") case RepoMethod.Update(_, _, _, param, _) => - Right(code"def $name($param)(implicit c: ${TypesJava.Connection}): ${TypesScala.Boolean}") + Right(code"def $name($param)(implicit c: ${TypesJava.Connection}): ${TypesScala.Option.of(param.tpe)}") case RepoMethod.Insert(_, _, unsavedParam, rowType, _) => Right(code"def $name($unsavedParam)(implicit c: ${TypesJava.Connection}): $rowType") case RepoMethod.InsertStreaming(_, rowType, _) => @@ -275,13 +275,13 @@ class DbLibAnorm(pkg: sc.QIdent, inlineImplicits: Boolean, default: ComputedDefa case RepoMethod.SelectByIds(relName, cols, computedId, idsParam, rowType) => val joinedColNames = dbNames(cols, isRead = true) computedId match { - case x: IdComputed.Composite => - val vals = x.cols.map(col => code"val ${col.name} = ${idsParam.name}.map(_.${col.name})").mkCode("\n") + case compositeId: IdComputed.Composite => + val vals = compositeId.cols.map(col => code"val ${col.name} = ${idsParam.name}.map(_.${col.name})").mkCode("\n") val sql = SQL { code"""|select ${joinedColNames} |from $relName - |where (${x.cols.map(col => col.dbCol.name.code).mkCode(", ")}) - |in (select ${x.cols.map(col => code"unnest(${runtimeInterpolateValue(col.name, col.tpe, forbidInline = true)})").mkCode(", ")}) + |where (${compositeId.cols.map(col => col.dbCol.name.code).mkCode(", ")}) + |in (select ${compositeId.cols.map(col => code"unnest(${runtimeInterpolateValue(col.name, col.tpe, forbidInline = true)})").mkCode(", ")}) |""".stripMargin } code"""|$vals @@ -381,7 +381,7 @@ class DbLibAnorm(pkg: sc.QIdent, inlineImplicits: Boolean, default: ComputedDefa | .executeUpdate() > 0 |} |""".stripMargin - case RepoMethod.Update(relName, _, id, param, writeableColumnsNotId) => + case RepoMethod.Update(relName, cols, id, param, writeableColumnsNotId) => val sql = SQL { val setCols = writeableColumnsNotId.map { col => code"${col.dbName.code} = ${runtimeInterpolateValue(code"${param.name}.${col.name}", col.tpe)}${SqlCast.toPgCode(col)}" @@ -389,10 +389,11 @@ class DbLibAnorm(pkg: sc.QIdent, inlineImplicits: Boolean, default: ComputedDefa code"""|update $relName |set ${setCols.mkCode(",\n")} |where ${matchId(id)} + |returning ${dbNames(cols, isRead = true)} |""".stripMargin } code"""|val ${id.paramName} = ${param.name}.${id.paramName} - |$sql.executeUpdate() > 0""" + |$sql.executeInsert(${rowParserFor(param.tpe)}.singleOpt)""" case RepoMethod.Insert(relName, cols, unsavedParam, rowType, writeableColumnsWithId) => val values = writeableColumnsWithId.map { c => @@ -655,13 +656,10 @@ class DbLibAnorm(pkg: sc.QIdent, inlineImplicits: Boolean, default: ComputedDefa case RepoMethod.UpdateBuilder(_, fieldsType, _) => code"${sc.Type.dsl.UpdateBuilderMock}(${sc.Type.dsl.UpdateParams}.empty, $fieldsType.structure, map)" case RepoMethod.Update(_, _, _, param, _) => - code"""map.get(${param.name}.${id.paramName}) match { - | case ${TypesScala.Some}(`${param.name}`) => false - | case ${TypesScala.Some}(_) => - | map.put(${param.name}.${id.paramName}, ${param.name}): @${TypesScala.nowarn} - | true - | case ${TypesScala.None} => false - |}""".stripMargin + code"""|map.get(${param.name}.${id.paramName}).map { _ => + | map.put(${param.name}.${id.paramName}, ${param.name}): @nowarn + | ${param.name} + |}""".stripMargin case RepoMethod.Insert(_, _, unsavedParam, _, _) => code"""|val _ = if (map.contains(${unsavedParam.name}.${id.paramName})) | sys.error(s"id $${${unsavedParam.name}.${id.paramName}} already exists")