diff --git a/chain/src/main/scala/org/bitcoins/chain/models/ChainStateDescriptorDAO.scala b/chain/src/main/scala/org/bitcoins/chain/models/ChainStateDescriptorDAO.scala index 496185e8e8..448dd8238d 100644 --- a/chain/src/main/scala/org/bitcoins/chain/models/ChainStateDescriptorDAO.scala +++ b/chain/src/main/scala/org/bitcoins/chain/models/ChainStateDescriptorDAO.scala @@ -48,14 +48,14 @@ case class ChainStateDescriptorDAO()(implicit } override def findByPrimaryKey(id: ChainStateDescriptorType): Query[ - Table[_], + Table[ChainStateDescriptorDb], ChainStateDescriptorDb, Seq] = { table.filter(_.tpe === id) } override def findAll(ts: Vector[ChainStateDescriptorDb]): Query[ - Table[_], + Table[ChainStateDescriptorDb], ChainStateDescriptorDb, Seq] = findByPrimaryKeys(ts.map(_.tpe)) diff --git a/chain/src/main/scala/org/bitcoins/chain/models/CompactFilterDAO.scala b/chain/src/main/scala/org/bitcoins/chain/models/CompactFilterDAO.scala index 49e3a27311..009834e0d2 100644 --- a/chain/src/main/scala/org/bitcoins/chain/models/CompactFilterDAO.scala +++ b/chain/src/main/scala/org/bitcoins/chain/models/CompactFilterDAO.scala @@ -75,8 +75,10 @@ case class CompactFilterDAO()(implicit table.filter(_.blockHash.inSet(ids)) } - override protected def findAll( - ts: Vector[CompactFilterDb]): Query[Table[_], CompactFilterDb, Seq] = { + override protected def findAll(ts: Vector[CompactFilterDb]): Query[ + Table[CompactFilterDb], + CompactFilterDb, + Seq] = { findByPrimaryKeys(ts.map(_.blockHashBE)) } diff --git a/chain/src/main/scala/org/bitcoins/chain/models/CompactFilterHeaderDAO.scala b/chain/src/main/scala/org/bitcoins/chain/models/CompactFilterHeaderDAO.scala index 98cafba444..1a57414d59 100644 --- a/chain/src/main/scala/org/bitcoins/chain/models/CompactFilterHeaderDAO.scala +++ b/chain/src/main/scala/org/bitcoins/chain/models/CompactFilterHeaderDAO.scala @@ -71,7 +71,7 @@ case class CompactFilterHeaderDAO()(implicit table.filter(_.hash.inSet(ids)) override protected def findAll(ts: Vector[CompactFilterHeaderDb]): Query[ - Table[_], + Table[CompactFilterHeaderDb], CompactFilterHeaderDb, Seq] = findByPrimaryKeys(ts.map(_.hashBE)) diff --git a/db-commons/src/main/scala/org/bitcoins/db/CRUDAction.scala b/db-commons/src/main/scala/org/bitcoins/db/CRUDAction.scala index 9780d25fa2..db00a103ce 100644 --- a/db-commons/src/main/scala/org/bitcoins/db/CRUDAction.scala +++ b/db-commons/src/main/scala/org/bitcoins/db/CRUDAction.scala @@ -30,10 +30,10 @@ abstract class CRUDAction[T, PrimaryKeyType](implicit /** return all rows that have a certain primary key * - * @param id + * @param id primary key of the row to return * @return Query object corresponding to the selected rows */ - protected def findByPrimaryKey(id: PrimaryKeyType): Query[Table[_], T, Seq] = + protected def findByPrimaryKey(id: PrimaryKeyType): Query[Table[T], T, Seq] = findByPrimaryKeys(Vector(id)) /** Finds the rows that correlate to the given primary keys */ @@ -58,9 +58,9 @@ abstract class CRUDAction[T, PrimaryKeyType](implicit .map(_.headOption) } - protected def find(t: T): Query[Table[_], T, Seq] = findAll(Vector(t)) + protected def find(t: T): Query[Table[T], T, Seq] = findAll(Vector(t)) - protected def findAll(ts: Vector[T]): Query[Table[_], T, Seq] + protected def findAll(ts: Vector[T]): Query[Table[T], T, Seq] def findAllAction(): DBIOAction[ Vector[T], diff --git a/db-commons/src/main/scala/org/bitcoins/db/CRUDAutoInc.scala b/db-commons/src/main/scala/org/bitcoins/db/CRUDAutoInc.scala index ed6a31abb6..cac1e20a58 100644 --- a/db-commons/src/main/scala/org/bitcoins/db/CRUDAutoInc.scala +++ b/db-commons/src/main/scala/org/bitcoins/db/CRUDAutoInc.scala @@ -32,6 +32,10 @@ abstract class CRUDAutoInc[T <: DbRowAutoInc[T]](implicit safeDatabase.runVec(actions) } + override protected def findByPrimaryKey( + id: Long): Query[TableAutoInc[T], T, Seq] = + table.filter(_.id === id) + override def findByPrimaryKeys( ids: Vector[Long]): Query[TableAutoInc[T], T, Seq] = { table.filter { t => @@ -39,7 +43,7 @@ abstract class CRUDAutoInc[T <: DbRowAutoInc[T]](implicit } } - override def findAll(ts: Vector[T]): Query[Table[_], T, Seq] = { + override def findAll(ts: Vector[T]): Query[Table[T], T, Seq] = { val ids = ts.filter(_.id.isDefined).map(_.id.get) findByPrimaryKeys(ids) } diff --git a/db-commons/src/main/scala/org/bitcoins/db/models/MasterXPubDAO.scala b/db-commons/src/main/scala/org/bitcoins/db/models/MasterXPubDAO.scala index b6a5338437..b786ff7376 100644 --- a/db-commons/src/main/scala/org/bitcoins/db/models/MasterXPubDAO.scala +++ b/db-commons/src/main/scala/org/bitcoins/db/models/MasterXPubDAO.scala @@ -87,7 +87,7 @@ case class MasterXPubDAO()(implicit override protected def findAll( ts: Vector[ExtPublicKeyDTO]): profile.api.Query[ - profile.api.Table[_], + profile.api.Table[ExtPublicKeyDTO], ExtPublicKeyDTO, Seq] = { findByPrimaryKeys(ts.map(_.publicKey)) diff --git a/dlc-wallet/src/main/scala/org/bitcoins/dlc/wallet/models/DLCAnnouncementDAO.scala b/dlc-wallet/src/main/scala/org/bitcoins/dlc/wallet/models/DLCAnnouncementDAO.scala index c7672c779a..90092afecd 100644 --- a/dlc-wallet/src/main/scala/org/bitcoins/dlc/wallet/models/DLCAnnouncementDAO.scala +++ b/dlc-wallet/src/main/scala/org/bitcoins/dlc/wallet/models/DLCAnnouncementDAO.scala @@ -63,7 +63,7 @@ case class DLCAnnouncementDAO()(implicit } override def find(t: DLCAnnouncementDb): profile.api.Query[ - Table[_], + Table[DLCAnnouncementDb], DLCAnnouncementDb, Seq] = { findByPrimaryKey(DLCAnnouncementPrimaryKey(t.dlcId, t.announcementId)) diff --git a/dlc-wallet/src/main/scala/org/bitcoins/dlc/wallet/models/IncomingDLCOfferDAO.scala b/dlc-wallet/src/main/scala/org/bitcoins/dlc/wallet/models/IncomingDLCOfferDAO.scala index 6e316b3721..2194947f6b 100644 --- a/dlc-wallet/src/main/scala/org/bitcoins/dlc/wallet/models/IncomingDLCOfferDAO.scala +++ b/dlc-wallet/src/main/scala/org/bitcoins/dlc/wallet/models/IncomingDLCOfferDAO.scala @@ -38,7 +38,7 @@ case class IncomingDLCOfferDAO()(implicit table.filter(_.hash.inSet(ids)) override protected def findAll(ts: Vector[IncomingDLCOfferDb]): Query[ - Table[_], + Table[IncomingDLCOfferDb], IncomingDLCOfferDb, Seq] = findByPrimaryKeys(ts.map(_.hash)) diff --git a/dlc-wallet/src/main/scala/org/bitcoins/dlc/wallet/models/OracleNonceDAO.scala b/dlc-wallet/src/main/scala/org/bitcoins/dlc/wallet/models/OracleNonceDAO.scala index 7879079d28..f44d4df49d 100644 --- a/dlc-wallet/src/main/scala/org/bitcoins/dlc/wallet/models/OracleNonceDAO.scala +++ b/dlc-wallet/src/main/scala/org/bitcoins/dlc/wallet/models/OracleNonceDAO.scala @@ -49,19 +49,22 @@ case class OracleNonceDAO()(implicit override protected def findByPrimaryKey( id: OracleNoncePrimaryKey): profile.api.Query[ - profile.api.Table[_], + profile.api.Table[OracleNonceDb], OracleNonceDb, Seq] = { table.filter(t => t.announcementId === id.announcementId && t.index === id.index) } - override def find(t: OracleNonceDb): Query[Table[_], OracleNonceDb, Seq] = { + override def find( + t: OracleNonceDb): Query[Table[OracleNonceDb], OracleNonceDb, Seq] = { findByPrimaryKey(OracleNoncePrimaryKey(t.announcementId, t.index)) } - override protected def findAll( - ts: Vector[OracleNonceDb]): Query[Table[_], OracleNonceDb, Seq] = + override protected def findAll(ts: Vector[OracleNonceDb]): Query[ + Table[OracleNonceDb], + OracleNonceDb, + Seq] = findByPrimaryKeys( ts.map(t => OracleNoncePrimaryKey(t.announcementId, t.index))) diff --git a/node/src/main/scala/org/bitcoins/node/models/NodeStateDescriptorDAO.scala b/node/src/main/scala/org/bitcoins/node/models/NodeStateDescriptorDAO.scala index e3ade02801..9cdaff5e51 100644 --- a/node/src/main/scala/org/bitcoins/node/models/NodeStateDescriptorDAO.scala +++ b/node/src/main/scala/org/bitcoins/node/models/NodeStateDescriptorDAO.scala @@ -42,14 +42,14 @@ case class NodeStateDescriptorDAO()(implicit } override def findByPrimaryKey(id: NodeStateDescriptorType): Query[ - Table[_], + Table[NodeStateDescriptorDb], NodeStateDescriptorDb, Seq] = { table.filter(_.tpe === id) } override def findAll(ts: Vector[NodeStateDescriptorDb]): Query[ - Table[_], + Table[NodeStateDescriptorDb], NodeStateDescriptorDb, Seq] = findByPrimaryKeys(ts.map(_.tpe)) diff --git a/node/src/main/scala/org/bitcoins/node/models/PeerDAO.scala b/node/src/main/scala/org/bitcoins/node/models/PeerDAO.scala index 800c57b80e..7d8f365041 100644 --- a/node/src/main/scala/org/bitcoins/node/models/PeerDAO.scala +++ b/node/src/main/scala/org/bitcoins/node/models/PeerDAO.scala @@ -38,8 +38,8 @@ case class PeerDAO()(implicit ec: ExecutionContext, appConfig: NodeAppConfig) } override protected def findAll( - ts: Vector[PeerDb]): Query[Table[_], PeerDb, Seq] = findByPrimaryKeys( - ts.map(_.address)) + ts: Vector[PeerDb]): Query[Table[PeerDb], PeerDb, Seq] = + findByPrimaryKeys(ts.map(_.address)) def deleteByKey(address: String): Future[Int] = { val bytes = ByteVector(address.getBytes) diff --git a/wallet/src/main/scala/org/bitcoins/wallet/models/AddressTagDAO.scala b/wallet/src/main/scala/org/bitcoins/wallet/models/AddressTagDAO.scala index cc2ceaee50..1aefb31af4 100644 --- a/wallet/src/main/scala/org/bitcoins/wallet/models/AddressTagDAO.scala +++ b/wallet/src/main/scala/org/bitcoins/wallet/models/AddressTagDAO.scala @@ -60,7 +60,7 @@ case class AddressTagDAO()(implicit } override def findByPrimaryKey(id: (BitcoinAddress, AddressTagType)): Query[ - Table[_], + Table[AddressTagDb], AddressTagDb, Seq] = { val (address, tagType) = id @@ -70,7 +70,7 @@ case class AddressTagDAO()(implicit } override def findAll( - ts: Vector[AddressTagDb]): Query[Table[_], AddressTagDb, Seq] = + ts: Vector[AddressTagDb]): Query[Table[AddressTagDb], AddressTagDb, Seq] = findByPrimaryKeys(ts.map(t => (t.address, t.tagType))) def findByAddressAction(address: BitcoinAddress): DBIOAction[ diff --git a/wallet/src/main/scala/org/bitcoins/wallet/models/WalletStateDescriptorDAO.scala b/wallet/src/main/scala/org/bitcoins/wallet/models/WalletStateDescriptorDAO.scala index 74470a080d..f62ad67576 100644 --- a/wallet/src/main/scala/org/bitcoins/wallet/models/WalletStateDescriptorDAO.scala +++ b/wallet/src/main/scala/org/bitcoins/wallet/models/WalletStateDescriptorDAO.scala @@ -47,14 +47,14 @@ case class WalletStateDescriptorDAO()(implicit } override def findByPrimaryKey(id: WalletStateDescriptorType): Query[ - Table[_], + Table[WalletStateDescriptorDb], WalletStateDescriptorDb, Seq] = { table.filter(_.tpe === id) } override def findAll(ts: Vector[WalletStateDescriptorDb]): Query[ - Table[_], + Table[WalletStateDescriptorDb], WalletStateDescriptorDb, Seq] = findByPrimaryKeys(ts.map(_.tpe))