SubSonic Forums
All Your Database Are Belong To Us

InnerJoin NullReferenceException

Latest post 07-17-2008 5:19 AM by Torrent. 5 replies.
  • 05-07-2008 7:26 AM

    InnerJoin NullReferenceException

    Hi guys,

    We've come across a bug where the following code throws a NullReferenceException (on SVN r432):


                SubSonic.SqlQuery q = new Select().From(Northwind.Tables.OrderDetail)
                    .InnerJoin(Northwind.Tables.Product)
                    .Where("CategoryID").IsEqualTo(5);

    A workaround for the time being is for us to pass DataService.Provider into the constructor for Select(), but a better fix would be for the default constructor on SqlQuery to set the provider to this in the first place, rather than leaving it as null (I'll be posting a patch to CodePlex with this fix)

    Thanks,

    Steve

  • 05-07-2008 7:44 AM In reply to

    Re: InnerJoin NullReferenceException

  • 05-08-2008 12:05 PM In reply to

    Re: InnerJoin NullReferenceException

    Reply |Contact |Answer

     FIxed in Revision 434.

    Found a bug? Help us fix it by submitting a Work Item!

  • 05-10-2008 7:52 AM In reply to

    Re: InnerJoin NullReferenceException

     Thanks

  • 07-15-2008 3:50 AM In reply to

    • GeoffB
    • Not Ranked
    • Joined on 07-15-2008
    • Posts 1

    Re: InnerJoin NullReferenceException

     I have just downloaded 2.1 Final and am having a similar problem.

    SubSonic.SqlQuery q = new Select().From<Northwind.OrderDetail>
                    .InnerJoin<Northwind.Product>
                   .Where(Northwind.Product.CategoryIdColumn).IsEqualTo(5);

    (This is not the exact code, I don't have Northwind installed, but illustrates my problem)

    As far a I can tell, if the column is not in a From table, the NullReferenceException is fired.

    I tracked the offending line down to ANSISqlGenerator.cs Line: 230. The FindColumn method returns null.

    Unfortunately I do not have enough knowledge of subsonics innards to fix the problem.

  • 07-17-2008 5:19 AM In reply to

    Re: InnerJoin NullReferenceException

    I encountered this exact problem this morning as well.  To add a little more info, I did some digging in the SVN logs and found that the problem may come from a change in around June 26. Not trying to cast blame, just hope it will help to know how long this has been around.  The case to check if col!=null is in an else now. However, when I do debug and get it to skip that If as if Col was checked for Null and found wanting, the rest of the code running as is no Column was found and I still get errors.

    I claim equal ignorance to the inner workings as to not want to add a fix without fear it will break other things.  Took me most of the morning to figure this much out.

Page 1 of 1 (6 items) | RSS