craiggwilson / Simple.Data.MongoDB

MongoDB adapter for Simple.Data
35 stars 10 forks source link

FindAll by null not working #11

Closed eibrahim closed 12 years ago

eibrahim commented 12 years ago

I have a bunch of documents with a date property called LastCheckedOn. Initially this is null... I want to select all docs where the lastcheckedon date is null, so I ran this query:

db.Feeds.FindAll(db.Feeds.LastCheckedOn == null)

This throws an exception, here is the stack trace:

at Simple.Data.MongoDB.ExpressionFormatter.EqualExpression(SimpleExpression expression) at Simple.Data.MongoDB.ExpressionFormatter.Format(SimpleExpression expression) at Simple.Data.MongoDB.MongoAdapterFinder.CreateCursor(MongoCollection1 collection, SimpleExpression criteria) at Simple.Data.MongoDB.MongoAdapterFinder.Find(MongoCollection1 collection, SimpleQuery query, IEnumerable1& unhandledClauses) at Simple.Data.MongoDB.MongoAdapter.RunQuery(SimpleQuery query, IEnumerable1& unhandledClauses) at Simple.Data.SimpleQuery.Run() at Simple.Data.SimpleQuery.GetEnumerator() at System.Linq.SystemCore_EnumerableDebugView.get_Items()

This same code works in SQL and also work for anything other than null... For example, this works:

db.Feeds.FindAll(db.Feeds.LastCheckedOn == DateTime.Now)

Can you please point me in the right direction? I am kind of stuck..

craiggwilson commented 12 years ago

Looks like this is a change that was made in the 1.4 mongo driver. It is throwing an exception where it previously allowed an invalid state, so not a breaking change, just seems that way. I'll address this issue in the next update.

craiggwilson commented 12 years ago

Pushed a new version to nuget. Post back if it doesn't work.