nested joins / do the specs work in the git repo?

3 views
Skip to first unread message

Oliver Steele

unread,
Mar 15, 2008, 2:47:14 PM3/15/08
to ambition.rb
I've got a patch to fix nested joins like User.select { |it|
it.group.venue.name == 'Boston' }. Currently this builds a hash like
{:conditions=>"groups.`name` = 'Boston'", :include=>[:group]}, the
same as if you'd said it.group.name instead of it.groups.venue.name.
It ought to make something like {:conditions=>"venues.`name` =
'Boston'", :include=>{:group=>:venue}}.

I was thinking of contributing this to the project, if this hasn't
already been done, and if there's interest. It requires some new
specs, and some changes to the existing specs. (It makes currently
changes the :includes from arrays like [:account] to hashes like
{:account => {}}. I could fix this with extra code if it were
necessary, but I don't think it is.)

I haven't even been able to get the existing specs to run, though. Is
this an operator error? -- does the repo version work?

"rake test:adapters:activerecord" gets 13 errors. The first four of
them start like this:

1) Error:
test_spec {ActiveRecord Adapter Count} 001 [size](ActiveRecord Adapter
Count):
SystemStackError: stack level too deep
./adapters/ambitious_activerecord/test/../../../lib/ambition/
api.rb:28:in `size'
./adapters/ambitious_activerecord/test/../../../lib/ambition/
api.rb:28:in `size'
./adapters/ambitious_activerecord/test/count_test.rb:12:in
`test_spec {ActiveRecord Adapter Count} 001 [size]'
/opt/local/lib/ruby/gems/1.8/gems/mocha-0.5.6/lib/mocha/
test_case_adapter.rb:19:in `__send__'
/opt/local/lib/ruby/gems/1.8/gems/mocha-0.5.6/lib/mocha/
test_case_adapter.rb:19:in `run'

and then there's five along these lines:

7) Error:
test_spec {ActiveRecord Adapter PostgreSQL specific} 001 [quoting of
column name](ActiveRecord Adapter PostgreSQL specific):
ArgumentError: wrong number of arguments (2 for 0)
./adapters/ambitious_activerecord/test/select_test.rb:183:in
`initialize'
./adapters/ambitious_activerecord/test/select_test.rb:183:in `new'
./adapters/ambitious_activerecord/test/select_test.rb:183
/opt/local/lib/ruby/gems/1.8/gems/mocha-0.5.6/lib/mocha/
test_case_adapter.rb:18:in `run'

and four like this:

12) Error:
test_spec {ActiveRecord Adapter MySQL specific} 001 [quoting of column
name](ActiveRecord Adapter MySQL specific):
ArgumentError: wrong number of arguments (4 for 0)
./adapters/ambitious_activerecord/test/helper.rb:29:in
`initialize'
./adapters/ambitious_activerecord/test/helper.rb:29:in
`initialize'
./adapters/ambitious_activerecord/test/select_test.rb:219:in `new'
./adapters/ambitious_activerecord/test/select_test.rb:219
/opt/local/lib/ruby/gems/1.8/gems/mocha-0.5.6/lib/mocha/
test_case_adapter.rb:18:in `run'

Oliver Steele

unread,
Mar 17, 2008, 9:07:19 AM3/17/08
to ambition.rb
Oliver Steele wrote:
> I've got a patch to fix nested joins like User.select { |it|
> it.group.venue.name == 'Boston' }.

Oops -- "nested join" means something else in SQL. I should have
called this an "n-deep chain". It translates into a Rails
"nested :include" or "nested association", which generates *multiple*
joins, not *nested* joins. Sorry for the confusion!
Reply all
Reply to author
Forward
0 new messages