Closed CyborgMaster closed 9 years ago
That's interesting. It probably mean the schema wasn't loaded yet, might be related to machinist.
If you manage to have a small repro app, I'll make a pleasure to dig into this.
Thanks for the offer to help, no example app so far. I'll let you know if I end up putting one together.
It looks like it might be an interaction with composite_primary_keys
. The stack trace shows up when writing an association and when I patch the coder_for
method to print the attribute name like so:
def coder_for(attr_name)
ap attr_name.to_s
column = self.class.columns_hash[attr_name.to_s]
return unless column.cast_type.is_a?(::ActiveRecord::Type::Serialized)
column.cast_type.coder
end
I got the following right before the crash:
"[:patient_id, :source_id]"
I'm not completely sure yet (still dealing with some weird test failures, but I think they are unrelated), but changing coder for like follows seems to work:
def coder_for(attr_name)
column = self.class.columns_hash[attr_name.to_s]
return unless column && column.cast_type.is_a?(::ActiveRecord::Type::Serialized)
column.cast_type.coder
end
An extra existence check may be all we need
Right, so it's basically the same mistake that 9103a3a1892fc5c2f152da06c29b54a0f1fff60c fixed. In some circumstances the columns might be missing.
Do you want to submit a PR?
Sure! I will submit a PR as soon as I get our full test suite passing, so probably sometime this evening.
Then don't worry it will be faster if I do :)
Oh ok. Thanks! Sorry. I just wanted to make sure it was actually the solution to my problem before I pushed it your way. At this point, I'm 90% sure it is, so go for it.
On Thu, Feb 5, 2015 at 3:19 PM, Jean Boussier notifications@github.com wrote:
Then don't worry it will be faster if I do :)
— Reply to this email directly or view it on GitHub https://github.com/byroot/activerecord-typedstore/issues/29#issuecomment-73142211 .
I just released a 0.5.2
. Thanks a lot for your report.
Well awesome. You're super speedy! Thanks!
I just upgraded our project to Rails 4.2 and now I'm getting the following crash when creating objects in our tests. I'm still digging into it, but I thought I would post here in case anyone had seen this before.