Null doesn't work with WHERE on C#, Editor, sql server
Null doesn't work with WHERE on C#, Editor, sql server
grenzi
Posts: 4Questions: 1Answers: 0
in Bug reports
I'm unable to get NULL to work with the .net api.
used the generator online (and patched the resultant javascript link - it links to an old version of datatables out of the box)
works fine without the where. works fine with where set to a value.
this gives an "object reference not set" exception.
using (var db = new Database("sqlserver", "secretconnectionstring"))
{
var response = new Editor(db, "Titles", "TitleId")
.Model<TitlesModel>()
.Where("EEDARTitleId", null)
.Field(new Field("CreatedOn")
.Validator(Validation.DateFormat(Format.DATE_ISO_8601))
.GetFormatter(Format.DateSqlToFormat(Format.DATE_ISO_8601))
.SetFormatter(Format.DateFormatToSql(Format.DATE_ISO_8601))
)
.Process(request)
.Data();
return Json(response);
}
(i'm a little frustrated - just paid for this today because it's exactly what i need and i'm working on a deadline - have spent the last couple hours now trying to debug.
This discussion has been closed.
Answers
specifically, json returned is this
{"draw":null,"data":[],"recordsTotal":null,"recordsFiltered":null,"error":"Object reference not set to an instance of an object.","fieldErrors":[],"id":null,"meta":{},"options":{},"files":{},"upload":{"id":null}}
Oops - thank you. I will fix that!
I'm sorry to say that you've hit a bug in the Editor .NET libraries here. I will look into this as soon as possible tomorrow and post back here with the fix required in the library.
Regards,
Allan
ugh. this seems to work. not sure a null was ever tested - can't see how the code would have ever worked, which is pretty frustrating after spending a hundred bucks.
also need to appropriately surround this
Hi,
I hope you'll accept my apologies for this error slipping through. It is a regression error that was caused by the introduction of the overload for
Where()
that accepts anIEnumerable
as the second parameter. Because the second parameter being passed asnull
could be match either of:the compiler will always select the second since it is more specific. When that method was introduced it snapped up any
null
values, causing this error.The second part was a refactoring at the same time that should also have been caught - it should be
else if
rather than justelse
for the bind (which is basically what you've done with the wrapper).I've added tests for this now (which should have been present before) and the update will ship with the next version of Editor (likely 1.5.4).
Regards,
Allan
Allan - thanks. I appreciate you explaining the history there - makes sense and seems a lot less of a @#$#! moment. (I was also grumpy working to try and get some things knocked out quickly on very little sleep.)
Congrats on your new arrival. My first thought on your newest family member - https://xkcd.com/327/
Hoping mom and the little one are doing well.
Haha - the number of times I've tried to persuade my wife that we should call him little Bobby Tables...! I got overruled in the end :-).
I'm planning to release Editor 1.5.4 with this fix at the end of the week.
Allan
Did this fix get released with the update? I'm receiving the exact same error (Object reference not set to an instance of an object) when using:
Thanks :)
Yes, from the release notes:
Are you using the 1.5.4 dll when you see the same error?
Thanks,
Allan