Hello; can anyone help me, please?

I have a number of identical databases - or nearly so: the minor changes 
are hidden behind identically structured views that return the same fields 
but perform joins on different tables.  These views are read-only, though 
that is not enforced (how would I do that?).

I need to report on the same things for each database, so I use sharding 
and enumerate over the servers to return records.

Each record "knows" which shard it came from so that associations "just 
work".  [Aside: how can I find which shard a given dataset is bound to, 
please?]

However, associations do NOT just work if they reference a view rather than 
a table.  That is, given a Model...

class VerificationTask < Sequel::Model(:csm_verification_tasks) # itself a 
view
  many_to_one :course # a genuine table
  many_to_one :submission # a view hiding joins between tables
end

then for a given instance vt = VerificationTask.server(x).first we find 
vt.course selects correctly: *SELECT * FROM mdl_course WHERE id = <the 
correct id> LIMIT 1*.  But vt.submission does NOT work: *SELECT * FROM 
csm_submissions LIMIT 1*.  Notice that there is no id = clause.  Naturally 
this simply picks up the first entry in the view.

This happens with or without use of server(x), i.e. it happens on the 
default database too.  And yes, the views do have an id field (it's usually 
the id from the most important underlying table).

This looks like a bug but maybe pilot error :-). The views are established 
using Sequel::Model just like the tables are.  The associations are 
established in identical fashion.  Why do the table associations work and 
the views don't?

Thanks for any help you can give.

Best wishes,
   Jerry

-- 
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/d/optout.

Reply via email to