datamapper/dm-core — Issue #179: Model.all every returns first element on tables without `id` column.
Author: wyldrodney
Created: 2012-02-09 04:47:07+00:00
State: open

I have a table with columns: site, keyword and price. This table doesn't contain id column with unique key.

class Sitekeyword
include DataMapper::Resource

property :site, String
property :keywordid, Integer
property :price, Integer

# There must be 'property :id, Serial', but if not...
end

If a run 'array = Sitekeyword.all.map { |m| m.keywordid }' I get an array with only dulicates.

'Sitekeyword.first.site == Sitekeyword.last.site' also returns 'true', but first and last elements aren't the same.

Piece of code:

irb(main):444:0> DataMapper.repository(:external) do
irb(main):445:1* puts Sitekeyword[0].site
irb(main):446:1> puts Sitekeyword[5].site
irb(main):447:1> end
bagiradance.ru
bagiradance.ru
=> nil
irb(main):448:0> DataMapper.repository(:external) do
irb(main):449:1* puts Sitekeyword[5].site
irb(main):450:1> end
mskstroydom.ru
=> nil
irb(main):451:0>

#Sorry for my ugly english.