Forum: Ferret Unique :key not maintained after add_indexes?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Abaafd84fcc0d2eef3ba41d2bafaf711?d=identicon&s=25 Lars Olsson (Guest)
on 2007-06-07 18:22
(Received via mailing list)

When adding an index to another one using add_indexes I get duplicates
even though I use the :key attribute. For example:

def test_add_indexes_uniqueness
        index1 = => :id)
        index2 = => :id)

        # Add two items with same id
        index1 << {:id => 23, :data => "This is the data..."}
        index1 << {:id => 23, :data => "This is the new data..."}
        assert_equal(1, index1.size)

        index2 << {:id => 23, :data => "This is the new data..."}
        assert_equal(1, index2.size)

        # Add index2 to index1

        #Size should still be 1 as the items in both indexes have id 23
        assert_equal(1, index1.size)

Here the final assertion fails because the size is 2. What have I
misunderstood? How can I maintain uniqueness when merging indexes?

This topic is locked and can not be replied to.