Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Mapper: Make ManyToMany use FieldFinder too

  • Loading branch information...
commit 77f6e67e5472e1121799930dc885516bd32c4ab7 1 parent 461ffaa
@nafg nafg authored
View
8 persistence/mapper/src/main/scala/net/liftweb/mapper/ManyToMany.scala
@@ -30,7 +30,12 @@ trait ManyToMany extends BaseKeyedMapper {
type K = TheKeyType
type T = KeyedMapperType
- private var manyToManyFields: List[MappedManyToMany[_,_,_]] = Nil
+ private[mapper] lazy val manyToManyFields: List[MappedManyToMany[_,_,_]] = {
+ new FieldFinder[MappedManyToMany[_,_,_]](
+ getSingleton,
+ net.liftweb.common.Logger(classOf[ManyToMany])
+ ).accessorMethods map (_.invoke(this).asInstanceOf[MappedManyToMany[_,_,_]])
+ }
/**
* An override for save to propagate the save to all children
@@ -89,7 +94,6 @@ trait ManyToMany extends BaseKeyedMapper {
refresh
- manyToManyFields ::= this
protected def isJoinForChild(e: T2)(join: O) = otherField.actualField(join).is == e.primaryKeyField.is
protected def joinForChild(e: T2): Option[O] =
View
7 persistence/mapper/src/test/scala/net/liftweb/mapper/ManyToManySpecs.scala
@@ -67,6 +67,13 @@ object ManyToManySpec extends Specification("ManyToMany Specification") {
person.companies.insertAll(7, Seq(c))
person.companies(7).name.is must_== "new"
}
+ "detect all MappedManyToMany fields" in {
+ setupDB
+ val person = Person.create
+ val fields = person.manyToManyFields
+ fields.length must_== 1
+ fields(0).asInstanceOf[Any] must_== person.companies
+ }
// from Florian
Please sign in to comment.
Something went wrong with that request. Please try again.