Ayende @ Rahien

My name is Oren Eini
Founder of Hibernating Rhinos LTD and RavenDB.
You can reach me by phone or email:


+972 52-548-6969

, @ Q c

Posts: 6,124 | Comments: 45,474

filter by tags archive



Reflector tells me that you are not using nunit but xunit and that xunit does not do a reference comparison in Assert.Equals which I hat expected.

Second guess: you have to call SaveChanges.


< should be <= ?


My guess: You already have a value in the DB with a value about 1.331m?

Thomas Freudenberg

@configurator: the first line in the tests creates a fresh db


I don't have 2 hours, sorry, but maybe something wrong with Range indexing for decimal values (i.e. in your Where (x=> x.M ...) )? Cast or something? As far as I remember Db create 2 indexes, maybe it use wrong one and you get not correct result? ;-)

Kristian Erbou

You set up your test using float and decimal. I remember from somewhere (maybe the first time I've actually put an MS certification into use) that float is stored as binary and should not be used in situations where you need to verify equality on large numbers.


Needs more round trips to the server


Either decimal will accurately represent 1.33 and so your 1.331 comparison will fail, or you need to use a tolerance value for comparison, like absolute value of val - 1.33 > 0.01?

Steve Py

Hmm, there's nothing wrong with the comparison & data types, unless there's something odd with the unit test framework you're using. (I've verified the behaviour of the data type comparisons with NUnit.)

I don't know much about RavenDB but my guess would be that you haven't told it to retrieve the data, there is no Select or SelectFields, so would the Linq2Object .Where() condition have anything to search through?


The session.Store() does nothing until the session ends. So session.Query() will never find anything because it is not stored yet.

Wrapping session.Store() in its own session, and 2x session.Quer() in another will pass the test.

Or does calling session.Query() flush first?


@Alwin, @Thomas Freudenberg etc - I think its not necessary to call session.SaveChanges() due to usage of WaitForNonStaleResults, or?

My another attempt: maybe you forgot to do initialization (i.e. say documentStore.Initialize();) in NewDocumentStore() method that you forgot to show here as well :D

But still I feel that something wrong with Where(...) and decimal values like from my previous comment :)

Common, Ayende, let us know issue that you spend 2 hours :)

I assume that if you spend 2 hours debugging it, it's simply not so easy to found such bug in just few minutes that most of us have :D

Ayende Rahien


Actually, the bug is that there is no SaveChanges, so stuff doesn't get to the server, and doesn't get saved.

The reason it took me so long to figure it out was that I simply didn't notice that SaveChanges was missing


ha ha ha :D Nice that such things happens not only with me :D

P.S. I was think that WaitForNonStaleResults should actually do promote changes in context into database for given index... i.e. it's little bit confusing to wait for index to updated in storage with fact that you still have some documents in memory that not yet added to index......

Comment preview

Comments have been closed on this topic.


  1. RavenDB 3.5 whirl wind tour: You want all the data, you can’t handle all the data - about one day from now
  2. The design of RavenDB 4.0: Making Lucene reliable - 2 days from now
  3. RavenDB 3.5 whirl wind tour: I’ll find who is taking my I/O bandwidth and they SHALL pay - 3 days from now
  4. The design of RavenDB 4.0: Physically segregating collections - 4 days from now
  5. RavenDB 3.5 Whirlwind tour: I need to be free to explore my data - 5 days from now

And 14 more posts are pending...

There are posts all the way to May 30, 2016


  1. RavenDB 3.5 whirl wind tour (14):
    29 Apr 2016 - A large cluster goes into a bar and order N^2 drinks
  2. The design of RavenDB 4.0 (13):
    28 Apr 2016 - The implications of the blittable format
  3. Tasks for the new comer (2):
    15 Apr 2016 - Quartz.NET with RavenDB
  4. Code through the looking glass (5):
    18 Mar 2016 - And a linear search to rule them
  5. Find the bug (8):
    29 Feb 2016 - When you can't rely on your own identity
View all series



Main feed Feed Stats
Comments feed   Comments Feed Stats