This project is archived and is in readonly mode.
[PATCH] bug in #construct_quoted_owner_attributes at ActiveRecord::Associations::ThroughAssociationScope
Reported by Will St. Clair | July 7th, 2010 @ 06:27 PM | in 3.x
(rails 3.0.0.beta4, naturally)
I have an Event model which belongs_to my Account model like
so:
class Event < ActiveRecord::Base
belongs_to :account
...and a Session model which has an Account through its ownership by Event, like so:
class Session < ActiveRecord::Base
belongs_to :event
has_one :account, :through => :event
However, on testing to see if Session knows who its account is,
SQLite spits out a parse error because the ID is a naked
string:
1) Error: test_knows_who_its_account_is(SessionTest):
ActiveRecord::StatementInvalid: SQLite3::SQLException: unrecognized
token: "87b8": SELECT "accounts".* FROM "accounts" INNER JOIN
"events" ON "accounts".id = "events".account_id WHERE (("events".id
= bf486316-4230-4579-87b8-1f56080a3356)) LIMIT 1
A little bit of puts
ing revealed that the
elsif reflection.macro == :belongs_to
branch in
ActiveRecord::Associations::ThroughAssociationScope#construct_quoted_owner_attributes
does not return a quoted string. The attached patch quotes it, and
results in my tests passing. Whether or not this is actually the
right place to fix it is probably better determined by someone
else.
Comments and changes to this ticket
-
Neeraj Singh July 8th, 2010 @ 01:50 PM
- Milestone set to 3.x
- Assigned user set to José Valim
- State changed from new to open
- Tag set to activerecord, patch, rails3
- Importance changed from to Low
Attached is test cases for the patch.
-
José Valim July 8th, 2010 @ 09:32 PM
Will, could you please provide a patch following the conventions at: http://rails.lighthouseapp.com/projects/8994/sending-patches
Thanks!
-
José Valim July 8th, 2010 @ 10:16 PM
- Title changed from [PATCH] bug in ActiveRecord::Associations::ThroughAssociationScope#construct_quoted_owner_attributes to [PATCH] bug in #construct_quoted_owner_attributes at ActiveRecord::Associations::ThroughAssociationScope
-
Will St. Clair July 10th, 2010 @ 07:27 PM
Neeraj --
Thanks for the tests! Working on this today and pulled latest rails and now there is a conflict between the patch and your commits to rails core. Any preference on how I resolve this?
Thanks,
Will -
Will St. Clair July 10th, 2010 @ 07:56 PM
Ah, I see more clearly now; I will just rename Car in the patch to something else to avoid conflicting with your fix for 4984
-
Repository July 13th, 2010 @ 07:37 AM
- State changed from open to resolved
(from [b520d602ffb85f3816f4407ff9dd5c7721a2da7d]) string IDs are now quoted correctly [#5064 state:resolved]
Signed-off-by: José Valim jose.valim@gmail.com
http://github.com/rails/rails/commit/b520d602ffb85f3816f4407ff9dd5c...
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>
People watching this ticket
Attachments
Tags
Referenced by
- 5064 [PATCH] bug in #construct_quoted_owner_attributes at ActiveRecord::Associations::ThroughAssociationScope (from [b520d602ffb85f3816f4407ff9dd5c7721a2da7d]) string ...