I'm not sure if this is an intended feature or a bug but I couldn't find 
any documentation about this. 

ex.
class Person < Sequel::Model
one_to_one :pet, key: :pet_type, primary_key: :pet_type
end

class Pet < Sequel::Model
end

Pet.create(pet_type: 'Cat')
Pet.create(pet_type: 'Dog')

person = Person.create(pet_type: 'Cat')

puts person.pet_type # outputs: Cat
puts person.pet.pet_type # outputs: Cat

person.update(pet_type: 'Dog')

puts person.pet_type # outputs: Dog
puts person.pet.pet_type # outputs: Cat ???


I'm guessing it's some kind of caching issue but this seems kind of 
counterintuitive. This has caused issues if I check if an association 
exists on an instance, then update the foreign key for that association and 
try to access the new/updated association, I get the original association, 
not the new/updated one. The same issue happens if the foreign key is 
null/the original association doesn't exist and then gets updated.

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sequel-talk.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/c63f9e18-8d7a-4587-a529-54147727c442%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to