This project is archived and is in readonly mode.
Using a where clause on a different table in a scope with a lambda overwrites itself
-
Neeraj Singh
I am not able to reproduce this error with rails edge.
class Car < AR def self.lab c = Car.scoped c = c.id_or_name(:companies, '1') c = c.id_or_name(:divisions, 'engineering') puts c.to_sql end endCar.lab is producing following sql
SELECT "cars".* FROM "cars" WHERE ("companies"."id" = '1') AND ("divisions"."name" = 'engineering') -
darkhelmetlive
I just cloned my repo (http://github.com/darkhelmet/scope_bug) and tried it again with edge, and it fails.
If I run the console and do User.lab it prints the wrong SQL. Is there something I'm missing? Is there some subtle difference between what you are doing to repro and what I did?
class User def self.lab u = User.scoped u = u.id_or_name(:companies, '1') u = u.id_or_name(:divisions, '2') puts u.to_sql end enduser@shell: ./script/rails console Loading development environment (Rails 3.0.0.beta3) irb(main):001:0> User.lab SELECT "users".* FROM "users" WHERE ("divisions"."id" = '2') => nil irb(main):002:0> -
Ryan Bigg
- Tag changed from active_record, arel, rails3, scope to active_record, arel, bugmash, rails3, scope
- State changed from new to incomplete
Please provide a failing test case and patch for this issue.
-
darkhelmetlive
I tried to write a test case to replicate it, but it worked as it's supposed to. I'm either doing something wrong, or it was broken in beta3 and I didn't properly setup my Gemfile to use full edge for everything.
This can be marked as invalid or whatever is appropriate.
-
Rohit Arondekar
- State changed from incomplete to invalid