Skip to content
This repository has been archived by the owner on Apr 17, 2018. It is now read-only.

Aggregate does not accept properties on relationships in :fields #13

Open
tpitale opened this issue Jun 27, 2011 · 2 comments
Open

Aggregate does not accept properties on relationships in :fields #13

tpitale opened this issue Jun 27, 2011 · 2 comments
Milestone

Comments

@tpitale
Copy link
Member

tpitale commented Jun 27, 2011

Problem.aggregate(:id.count, :fields => [:user_id, "users.email"], :unique => true, :links => [:user])

ArgumentError: +field+ should be DataMapper::Query::Operator or Symbol or DataMapper::Property, but was String
from /Users/tpitale/.rvm/gems/ruby-1.9.2-p180@docket/gems/dm-aggregates-1.1.0/lib/dm-aggregates/functions.rb:158:in block in aggregate' from /Users/tpitale/.rvm/gems/ruby-1.9.2-p180@docket/gems/dm-aggregates-1.1.0/lib/dm-aggregates/functions.rb:158:inmap!'
from /Users/tpitale/.rvm/gems/ruby-1.9.2-p180@docket/gems/dm-aggregates-1.1.0/lib/dm-aggregates/functions.rb:158:in aggregate' from (irb):2 from /Users/tpitale/.rvm/gems/ruby-1.9.2-p180@docket/gems/railties-3.0.8/lib/rails/commands/console.rb:44:instart'
from /Users/tpitale/.rvm/gems/ruby-1.9.2-p180@docket/gems/railties-3.0.8/lib/rails/commands/console.rb:8:in start' from /Users/tpitale/.rvm/gems/ruby-1.9.2-p180@docket/gems/railties-3.0.8/lib/rails/commands.rb:23:in<top (required)>'
from script/rails:6:in require' from script/rails:6:in

'

@jpr5
Copy link
Member

jpr5 commented Jun 27, 2011

I've never tried it before, so YMMV, but if :fields => [] can have DM::Property's in it, then try it?

Problem.aggregate(:id.count, :fields => [User.id, User.email], :unique => true, ...)

@tpitale
Copy link
Member Author

tpitale commented Jun 27, 2011

Thanks for the suggestion. I tried it a few different ways, all with differing errors.

Problem.aggregate(:id.count, :fields => [:user_id, User.email], :unique => true)
ArgumentError: +options[:field]+ entry :email does not map to a property in Problem
from /Users/tpitale/.rvm/gems/ruby-1.9.2-p180@docket/gems/dm-core-1.1.0/lib/dm-core/query.rb:805:in block in assert_valid_fields' from /Users/tpitale/.rvm/gems/ruby-1.9.2-p180@docket/gems/dm-core-1.1.0/lib/dm-core/query.rb:796:ineach'
from /Users/tpitale/.rvm/gems/ruby-1.9.2-p180@docket/gems/dm-core-1.1.0/lib/dm-core/query.rb:796:in assert_valid_fields' from /Users/tpitale/.rvm/gems/ruby-1.9.2-p180@docket/gems/dm-aggregates-1.1.0/lib/dm-aggregates/query.rb:23:inassert_valid_fields_with_operator'
from /Users/tpitale/.rvm/gems/ruby-1.9.2-p180@docket/gems/dm-core-1.1.0/lib/dm-core/query.rb:768:in block in assert_valid_options' from /Users/tpitale/.rvm/gems/ruby-1.9.2-p180@docket/gems/dm-core-1.1.0/lib/dm-core/query.rb:766:ineach'
from /Users/tpitale/.rvm/gems/ruby-1.9.2-p180@docket/gems/dm-core-1.1.0/lib/dm-core/query.rb:766:in assert_valid_options' from /Users/tpitale/.rvm/gems/ruby-1.9.2-p180@docket/gems/dm-core-1.1.0/lib/dm-core/query.rb:363:inupdate'
from /Users/tpitale/.rvm/gems/ruby-1.9.2-p180@docket/gems/dm-core-1.1.0/lib/dm-core/query.rb:386:in merge' from /Users/tpitale/.rvm/gems/ruby-1.9.2-p180@docket/gems/dm-core-1.1.0/lib/dm-core/model.rb:753:inscoped_query'
from /Users/tpitale/.rvm/gems/ruby-1.9.2-p180@docket/gems/dm-aggregates-1.1.0/lib/dm-aggregates/functions.rb:180:in aggregate' from (irb):7 from /Users/tpitale/.rvm/gems/ruby-1.9.2-p180@docket/gems/railties-3.0.8/lib/rails/commands/console.rb:44:instart'
from /Users/tpitale/.rvm/gems/ruby-1.9.2-p180@docket/gems/railties-3.0.8/lib/rails/commands/console.rb:8:in start' from /Users/tpitale/.rvm/gems/ruby-1.9.2-p180@docket/gems/railties-3.0.8/lib/rails/commands.rb:23:in<top (required)>'
from script/rails:6:in require' from script/rails:6:in


Problem.aggregate(:id.count, :fields => [:user_id, Problem.user.email], :unique => true)
ArgumentError: +options[:fields]+ entry nil of an unsupported object NilClass
from /Users/tpitale/.rvm/gems/ruby-1.9.2-p180@docket/gems/dm-core-1.1.0/lib/dm-core/query.rb:809:in block in assert_valid_fields' from /Users/tpitale/.rvm/gems/ruby-1.9.2-p180@docket/gems/dm-core-1.1.0/lib/dm-core/query.rb:796:ineach'
from /Users/tpitale/.rvm/gems/ruby-1.9.2-p180@docket/gems/dm-core-1.1.0/lib/dm-core/query.rb:796:in assert_valid_fields' from /Users/tpitale/.rvm/gems/ruby-1.9.2-p180@docket/gems/dm-aggregates-1.1.0/lib/dm-aggregates/query.rb:23:inassert_valid_fields_with_operator'
from /Users/tpitale/.rvm/gems/ruby-1.9.2-p180@docket/gems/dm-core-1.1.0/lib/dm-core/query.rb:768:in block in assert_valid_options' from /Users/tpitale/.rvm/gems/ruby-1.9.2-p180@docket/gems/dm-core-1.1.0/lib/dm-core/query.rb:766:ineach'
from /Users/tpitale/.rvm/gems/ruby-1.9.2-p180@docket/gems/dm-core-1.1.0/lib/dm-core/query.rb:766:in assert_valid_options' from /Users/tpitale/.rvm/gems/ruby-1.9.2-p180@docket/gems/dm-core-1.1.0/lib/dm-core/query.rb:363:inupdate'
from /Users/tpitale/.rvm/gems/ruby-1.9.2-p180@docket/gems/dm-core-1.1.0/lib/dm-core/query.rb:386:in merge' from /Users/tpitale/.rvm/gems/ruby-1.9.2-p180@docket/gems/dm-core-1.1.0/lib/dm-core/model.rb:753:inscoped_query'
from /Users/tpitale/.rvm/gems/ruby-1.9.2-p180@docket/gems/dm-aggregates-1.1.0/lib/dm-aggregates/functions.rb:180:in aggregate' from (irb):9 from /Users/tpitale/.rvm/gems/ruby-1.9.2-p180@docket/gems/railties-3.0.8/lib/rails/commands/console.rb:44:instart'
from /Users/tpitale/.rvm/gems/ruby-1.9.2-p180@docket/gems/railties-3.0.8/lib/rails/commands/console.rb:8:in start' from /Users/tpitale/.rvm/gems/ruby-1.9.2-p180@docket/gems/railties-3.0.8/lib/rails/commands.rb:23:in<top (required)>'
from script/rails:6:in require' from script/rails:6:in

'


Problem.aggregate(:id.count, :fields => [:user_id, Problem.user], :unique => true)
ArgumentError: +field+ should be DataMapper::Query::Operator or Symbol or DataMapper::Property, but was DataMapper::Query::Path
from /Users/tpitale/.rvm/gems/ruby-1.9.2-p180@docket/gems/dm-aggregates-1.1.0/lib/dm-aggregates/functions.rb:158:in block in aggregate' from /Users/tpitale/.rvm/gems/ruby-1.9.2-p180@docket/gems/dm-aggregates-1.1.0/lib/dm-aggregates/functions.rb:158:inmap!'
from /Users/tpitale/.rvm/gems/ruby-1.9.2-p180@docket/gems/dm-aggregates-1.1.0/lib/dm-aggregates/functions.rb:158:in aggregate' from (irb):14 from /Users/tpitale/.rvm/gems/ruby-1.9.2-p180@docket/gems/railties-3.0.8/lib/rails/commands/console.rb:44:instart'
from /Users/tpitale/.rvm/gems/ruby-1.9.2-p180@docket/gems/railties-3.0.8/lib/rails/commands/console.rb:8:in start' from /Users/tpitale/.rvm/gems/ruby-1.9.2-p180@docket/gems/railties-3.0.8/lib/rails/commands.rb:23:in<top (required)>'
from script/rails:6:in require' from script/rails:6:in

'

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants