Skip to content

Commit

Permalink
0.7.2: add KeyedEntity.apply (returns SavedEntity typed as KeyedEntity)
Browse files Browse the repository at this point in the history
  • Loading branch information
nafg committed Aug 27, 2017
1 parent 460da07 commit b8c23d7
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

| Slick version | SBT dependency |
|---------------|------------------------------------------------------|
| 3.2.1 | `"io.github.nafg" %% "slick-additions" % "0.7.1"` |
| 3.2.1 | `"io.github.nafg" %% "slick-additions" % "0.7.2"` |
| 3.2.0 | `"io.github.nafg" %% "slick-additions" % "0.7.0"` |
| 3.1.1 | `"io.github.nafg" %% "slick-additions" % "0.6.1"` |
| 3.0.3 | `"io.github.nafg" %% "slick-additions" % "0.5.2"` |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ sealed trait KeyedEntity[K, +A] extends Entity[K, A] with Lookup[K, A] {
override def map[B >: A](f: A => B): ModifiedEntity[K, B] = ModifiedEntity[K, B](key, f(value))
}
object KeyedEntity {
def apply[K, A](key: K, value: A): KeyedEntity[K, A] = SavedEntity[K, A](key, value)
def unapply[K, A](ke: KeyedEntity[K, A]): Option[(K, A)] = Some((ke.key, ke.value))
}
case class SavedEntity[K, +A](key: K, value: A) extends KeyedEntity[K, A] {
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/slick/additions/KeyedTableComponent.scala
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ trait KeyedTableComponentBase {
val ksv = kc.shaped
val ssv: ShapedValue[Src, Unpacked] = source.shaped
(ksv zip ssv).<>[KeyedEntity[K, MappedAs]](
{ case (k, v) => SavedEntity(k, construct(Some(k))(v)): KeyedEntity[K, MappedAs] },
{ case (k, v) => KeyedEntity(k, construct(Some(k))(v)) },
ke => Some((ke.key, extract(ke.value))))
}
}
Expand Down
2 changes: 1 addition & 1 deletion version.sbt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version in ThisBuild := "0.7.1"
version in ThisBuild := "0.7.2"

0 comments on commit b8c23d7

Please sign in to comment.