[Lift] Re: Bug in HasManyThough causing unexpected deletions?

2009-09-14 Thread harryh

I'm still seeing this on M5.  My diagnosis of the prolem in my 2nd e-
mail is incorrect, but there is definitely a problem here.

-harryh

On Aug 28, 1:39 pm, harryh har...@gmail.com wrote:
 Tips are on TipLists based on TipListBinds.
 Tips are also hooked to a Venue:

 class Tip extends LongKeyedMapper[Tip] with IdPK {
   // other unrelated stuff stuff
   object venueid extends MappedLongForeignKey(this, Venue)
   object lists extendsHasManyThrough(this, TipList, TipListBind,
 TipListBind.tipid, TipListBind.listid)

 }

 In an ajax request I am setting the venueid on a collection of Tips to
 Empty.  This is, for somewhat confusing reasons, causing the Tip to be
 removed from the lists it is on (the TipListBindings are being
 deleted).  I am fairly certain this is happening because ofHasManyThrough.

 INFO - com.mysql.jdbc.preparedstatem...@2b48c3: UPDATE tips SET
 venueid = ** NOT SPECIFIED ** WHERE id = ** NOT SPECIFIED **:2ms
 INFO - com.mysql.jdbc.preparedstatem...@69827c: SELECT  DISTINCT
 tipxlist.listid, tipxlist.id, tipxlist.tipid FROM tipxlist   WHERE
 tipid = 21128 :1ms
 INFO - com.mysql.jdbc.preparedstatem...@69827c: SELECT  DISTINCT
 tipxlist.listid, tipxlist.id, tipxlist.tipid FROM tipxlist   WHERE
 tipid = ** NOT SPECIFIED ** :22ms
 INFO - com.mysql.jdbc.preparedstatem...@ca8d17: DELETE FROM tipxlist
 WHERE id = ** NOT SPECIFIED **:1ms

 Currently thinking through what's going on inHasManyThrough::afterUpdate

 -harryh
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Lift group.
To post to this group, send email to liftweb@googlegroups.com
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



[Lift] Re: Bug in HasManyThough causing unexpected deletions?

2009-08-28 Thread harryh

 Currently thinking through what's going on in
 HasManyThrough::afterUpdate

override def afterUpdate {
  val current = through.findAll(By
(throughFromField,owner.primaryKeyField))

  val newKeys = new HashSet[ThroughType];

  theSetList.foreach(i = newKeys += i)
  val toDelete = current.filter(c = !newKeys.contains
(throughToField.actualField(c).is))
  toDelete.foreach(_.delete_!)

  // function continues
}

Unless I'm misunderstanding something (a distinct possibility) newKeys
will be (in my case) a HashSet[TipListBind] containing all the
TipListBinds associated with my specifi Tip.

But then when doing the filter it checks to see if newKeys contains a
given long corresponding to (again, in my case) the listid on all the
current TipListBinds.  Since the types aren't right here, it will
never contain this so toDelete will end up beind all of current, and
all the bindings will always be deleted.  Is this really what is
happening here?

-harryh

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Lift group.
To post to this group, send email to liftweb@googlegroups.com
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---