Bug? Problems with Indizes and type long.

42 views
Skip to first unread message

Thomas Bandt

unread,
May 23, 2013, 4:04:52 PM5/23/13
to rav...@googlegroups.com
I ran into extremely strange behaviours of my static indizes after switching ids from int to long. After 2 hours of debugging the result seams clear: Raven isn't working with long properly.

Let's take the following map:

Map = bar => from foo in bar
select new FooResult
{
Items = (from item in foo.Items
select new Item
{
ID = item.Key, 
}).ToArray()
};

foo.Items is of type Dictionary<long,SomeOtherType>.

Let's say we have a dictionary of type Dictionary<long, Entity>. So every attempt to access the key results in

docs.bar.Select(foo => new {
    Items = Enumerable.ToArray((foo.Items).Select(item => new {
        ID = (long)item.Key
    }))
})

And that fails.

If I change the type of the key within the dictionary to Int64 everything works as expected.

Thomas

Thomas Bandt

unread,
May 23, 2013, 4:55:15 PM5/23/13
to rav...@googlegroups.com
followup: Int64 doesn't work neither. It's also converted to long internally (whatever happens there ...).

I'll switch back to int hoping this gets fixed in a future release.

Kijana Woodard

unread,
May 23, 2013, 9:55:29 PM5/23/13
to rav...@googlegroups.com
When you say "fails" what do you mean? Throws an error when the index is created? Errors when you try to query it? Doesn't return results?


What are you trying to Map in the index? It seems a bit odd that you would create an array of type Item in a Map. Are you trying to search for the foos that have items with some key?

How about 
Items = foo.Items.Select(x => x.Key)


--
You received this message because you are subscribed to the Google Groups "ravendb" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Oren Eini (Ayende Rahien)

unread,
May 24, 2013, 1:39:18 AM5/24/13
to ravendb
Also, Ids are always string in RavenDB

Thomas Bandt

unread,
May 24, 2013, 6:28:56 PM5/24/13
to rav...@googlegroups.com
Whatever you're trying to work around this issue fails, even a select of the dictionary key. The reason seems to be the cast (long)whatever whenever accessing that key. All that results in not mapping that field or returning nothing.

I switched the type of the dictionary key back to int and everything works again. To be honest, that sucks.

I will provide a running example when I find the time.

Kijana Woodard

unread,
May 24, 2013, 6:39:47 PM5/24/13
to rav...@googlegroups.com
What does FooResult look like?


Kijana Woodard

unread,
May 24, 2013, 7:33:04 PM5/24/13
to rav...@googlegroups.com
Ok. Here's a failing test: https://gist.github.com/kijanawoodard/0a34b847086c02ada95d

If I switch the Foo.Items key type to int, it passes.
If I query on Long, directly in Foo, it passes.
A created field worked for int key and fails for long key.

Thomas Bandt

unread,
May 24, 2013, 8:03:54 PM5/24/13
to rav...@googlegroups.com
Perfect, thank you.

Oren Eini (Ayende Rahien)

unread,
May 26, 2013, 6:49:38 AM5/26/13
to ravendb
Okay, found the problem. Will have a fix in the next build.
Reply all
Reply to author
Forward
0 new messages