Share Pastebin
Guest
Public paste!

oberhamsi

By: a guest | Jan 18th, 2010 | Syntax: JavaScript | Size: 1.32 KB | Hits: 123 | Expires: Never
Copy text to clipboard
  1. I showed that bug to hannes in RealLife. until then i gathered more info that hints towards a problem with the grouped collection being internally re-used when first removed (by emptying it) & then re-added within the same request.
  2.  
  3. i will try to explain with a simple code example:
  4.  
  5. example 1, this demonstrates the problem. the collection is first emptied, correctly dissappears but later when i add *one* element to it it re-appears with size() === 2:
  6.  
  7.  > relations.get('foo').size()
  8.  1
  9.  > relations.remove(oldFooRelation)
  10.  > oldFooRelation.remove()
  11.  > relations.get('foo') === undefined
  12.  true
  13.  > relations.add(newFooRelation)
  14.  > relations.get('foo').size()
  15.  2 /// !!! it should be 1.
  16.  
  17. not only the size() is wrong. i can also list() over the 2 items.
  18.  
  19.  
  20.  example 2, this works because the grouped collection 'foo' is never empty:
  21.  > relations.get('foo').size()
  22.  5
  23.  > relations.remove(oldFooRelation)
  24.  > relations.get('foo').size()
  25.  4
  26.  > relations.add(newFooRelation)
  27.  > relations.get('foo').size()
  28.  5 // correct
  29.  
  30.  
  31. my collection looks like this.
  32.  
  33. relations              = collection (Relation)
  34. relations.accessname   = REL_DST_ID
  35. relations.local.1      = $id
  36. relations.foreign.1    = REL_SRC_ID
  37. relations.local.2      = $prototype
  38. relations.foreign.2    = REL_SRC_PROTOTYPE
  39. relations.group        = REL_TYPE