I am using Sequel to access the database for an API server. I am using 
Sequel 4.3.0 with a PostgreSQL 9.1 database. 

Through the API, foreign keys on tables may be updated. It seems that 
Sequel does not automatically reload the association cache when the foreign 
key is updated and I'm curious if there is any way to do this.

For example:

irb(main):003:0> r = Roster.first :id => 153
> => #<Roster @values={:id=>153, :player_id=>44}>
> irb(main):004:0> r.player
> => #<Player @values={:id=>44}>
> irb(main):005:0> r.player_id = 46
> => 46
> irb(main):007:0> r.player
> => #<Player @values={:id=>44}>


Saving the record doesn't seem to force the association cache to clear 
either.

It is not until I either call r.player(true) or delete the association:

irb(main):012:0> r.associations.delete :player


that the association is reloaded.

Is there any feature built into the library to automatically accomplish 
this? or a plugin? I saw something in the association docs which *appears* 
to hint at such a feature, but I couldn't see any other details on it:

autoreloading_associations [R]
>
> Hash <http://sequel.rubyforge.org/rdoc/classes/Hash.html> with column 
> symbol keys and arrays of 
> #many_to_one<http://sequel.rubyforge.org/rdoc/classes/Sequel/Model/Associations/ClassMethods.html#method-i-many_to_one>association
>  symbols that should be cleared when the column value changes.


I'd like this to apply across all of my models.

Thanks for the awesome library!

-- 
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 http://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to