RavenDB Decimal querying with trailing zeroes does not work

124 views
Skip to first unread message

alwin

unread,
Feb 6, 2012, 1:38:10 AM2/6/12
to ravendb

When I save something with a decimal property with value 10.00m (two
zeroes after the comma), it gets stored as
"Amount": 10.0
(one zero after the comma)

When I then query for "Amount == 10.00m", Raven cannot find a matching
document.
Querying for "Amount == 10m" works.
Apparently in Raven, 10m is different from 10.00m
In .net they are the same:
[Fact]
public void DecimalZeroesDontMatter()
{
// This passes
Assert.Equal(10.00m, 10m);
}

When I turn on logging, I see that Raven actually queries for "Amount
== 10.00m", with zeroes.
But it does not store the documents with these zeroes. Is there a
mismatch here?

I have a failing test here:
http://pastebin.com/rtz4pLa7

Oren Eini (Ayende Rahien)

unread,
Feb 6, 2012, 7:51:25 AM2/6/12
to rav...@googlegroups.com
Thanks, fixed.

Tobi

unread,
Feb 6, 2012, 8:12:45 AM2/6/12
to rav...@googlegroups.com
On 06.02.2012 13:51, Oren Eini (Ayende Rahien) wrote:

> Thanks, fixed.

Such bugs make me kinda nervous putting the current stable into production.

When will there be a new stable release? I would like to see bug-fixes
appear much earlier in a new stable releases.

Tobias

Oren Eini (Ayende Rahien)

unread,
Feb 6, 2012, 8:20:16 AM2/6/12
to rav...@googlegroups.com
Hi Tobi,
This is currently scheduled to go on unstable 641 and the stable version is scheduled for 20 Feb.

alwin

unread,
Feb 21, 2012, 6:43:18 PM2/21/12
to ravendb
Hi, I just tried with 1.0.654-Unstable
The old failing test now passes.

But I have a new problem, that wasn't happening before.
When I save this:
session.Store(new Model { Amount = 12.34m });
And then query for that amount, this is logged:
Executing query 'Amount:12,34' on index 'dynamic/Models' in 'memory
#18544551'
There are no results, notice the comma in the query. This is a culture
thing, I think.

Here a some tests:
(Use "session.Store(new Model { Amount = 12.34m });" in setup)

/// <summary>
/// passes
/// </summary>
[Fact]
public void CanFindNotRoundedDecimal_InvariantCulture()
{
System.Threading.Thread.CurrentThread.CurrentCulture =
CultureInfo.InvariantCulture;

using (var session = OpenSession())
{
decimal amount = 12.34m;
var found = session.Query<Model>().FirstOrDefault(model =>
model.Amount == amount);
Assert.NotNull(found);
}
}

/// <summary>
/// fails
/// </summary>
[Fact]
public void CanFindNotRoundedDecimal_NL_Culture()
{
System.Threading.Thread.CurrentThread.CurrentCulture =
CultureInfo.GetCultureInfo("NL");

using (var session = OpenSession())
{
decimal amount = 12.34m;
var found = session.Query<Model>().FirstOrDefault(model =>
model.Amount == amount);
Assert.NotNull(found);
}
}

On Feb 6, 1:51 pm, "Oren Eini (Ayende Rahien)" <aye...@ayende.com>
wrote:

alwin

unread,
Feb 21, 2012, 7:47:50 PM2/21/12
to ravendb
I got GitHub to work, I think i fixed the bug, running all the tests
now.

Hopefully I can send a patch request soon.

alwin

unread,
Feb 21, 2012, 8:18:38 PM2/21/12
to ravendb
Ok here goes: https://github.com/ayende/ravendb/pull/89
First pull request ever :)

Oren Eini (Ayende Rahien)

unread,
Feb 21, 2012, 9:59:21 PM2/21/12
to rav...@googlegroups.com
Alwin,
Can you also send us the CLA? 

alwin

unread,
Feb 24, 2012, 5:59:52 PM2/24/12
to ravendb
Hi Ayende, I've sent the CLA to your private email.
FYI, when I go to http://ravendb.net/contributing and then click the
link "send us", I can't send the CLA with that form and there is no
email address mentioned.


On Feb 22, 3:59 am, "Oren Eini (Ayende Rahien)" <aye...@ayende.com>
wrote:
> Alwin,
> Can you also send us the CLA?http://ravendb.net/contributing
Reply all
Reply to author
Forward
0 new messages