create a patch with a failing test and we'd be happy to look at the problem... and try to fix it of course
On Tue, Jul 28, 2009 at 9:54 PM, Nelson <[email protected]> wrote: > > Nobody to confirm that bug? I do not want to add it to JIRA without > nobody validating it. > Is the previous message unclear? > > On Jul 27, 9:06 pm, Nelson <[email protected]> wrote: > > Hello open people, > > > > I think I founded a bug in NHibernate 2.1. > > Before reading that message and throwing me stones, please know that I > > founded it at work and I'm pretty tired and lazy now. So if I am not > > giving enough details, please don't kill me! I prefered posting > > something before forgetting about it. > > > > *** Observations *** > > > > The bug happened when saving/loading a collection of element of > > nullable .net types. > > When saving a List<double?>, mapped as a list of element > > (kindof this : > > <list name="toto"> > > <key.../> > > <index .../> > > <element ../> <<< a 'double?' > > </list> > > containing {9,null, null,8,null}, NHibernate insert tuples <0,9>, > > <3,8>, not inserting null values (which is great). > > > > When loading it inserts null values into the list (cool). << > > cockroach > > > > *** Why cockroach? *** > > > > Here is the ReadFrom function from > > NHibernate.Collection.PersistentList.cs > > > > public override object ReadFrom(IDataReader rs, > ICollectionPersister > > role, ICollectionAliases descriptor, object owner) > > { > > object element = role.ReadElement(rs, owner, > > descriptor.SuffixedElementAliases, Session); > > int index = (int) role.ReadIndex(rs, > > descriptor.SuffixedIndexAliases, Session); > > > > //pad with nulls from the current last element up > to the new index > > for (int i = list.Count; i <= index; i++) > > { > > list.Insert(i, DefaultForType); > > } > > > > list[index] = element; > > return element; > > } > > > > See that line ? "list.Insert(i, DefaultForType);" Default for double? > > is null. So we do have list.Insert(i,null) here. What is 'list'? > > > > public class PersistentList : AbstractPersistentCollection, IList > > { > > protected IList list; > > > > An IList, which is initialized in the constructor by > > > > public PersistentList(ISessionImplementor session, IList list) : base > > (session) > > { > > this.list = list; > > SetInitialized(); > > IsDirectlyAccessible = true; > > } > > > > So the concrete code, in case of List<double?> is > > > > IList list = new List<double?>(); > > > > followed by > > > > list.Add(i,null) << an exception is thrown cuz List<double?> checks if > > null is a double? and it says it is not. > > > > Sorry for the lazy and badly written message in English. I'm a monkey, > > it is difficult for us monkey to speak English. > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nhusers?hl=en -~----------~----~----~----~------~----~------~--~---
