datamapper / dm-aggregates

DataMapper plugin providing support for aggregates on collections
http://datamapper.org/
MIT License
16 stars 15 forks source link

aggegrates don't work in Ruby 2.0 #20

Open strallhofer opened 11 years ago

strallhofer commented 11 years ago

require 'data_mapper' require 'dm-migrations' require 'dm-aggregates'

class DmNilTest include DataMapper::Resource property :id, Serial property :test_value, Float end

DataMapper::Logger.new(STDOUT, :debug) DataMapper.setup(:default, 'postgres://elmar@localhost/dm_nil')

DataMapper.auto_upgrade! DataMapper.finalize

DmNilTest.all.destroy 10.times do DmNilTest.create(test_value: rand) end

puts DmNilTest.aggregate(:test_value.min, :test_value.max, :test_value.avg).inspect

SQL statement is the same both in Ruby 1.9.3 and 2.0.0: SELECT MIN("test_value"), MAX("test_value"), AVG("test_value") FROM "dm_nil_tests"

but in the latter case the result is [nil, nil, nil]

dkubb commented 11 years ago

@strallhofer Try using the latest release-1.2 branches for dm-core, dm-aggregates and any other DM gems you use.

I believe this is a typecasting issue which was recently fixed. If the problem persists please let me know.

strallhofer commented 11 years ago

Hi Dan,

I tested again, with dm-core, dm-aggregates and dm-postgres-adapter, all with branch "release-1.2", and now it works! Thanks a lot for the quick fix!