On 01/12/2010 9:37 PM, Jeremy Evans wrote:
On Dec 1, 12:08 pm, Gary Doades<[email protected]> wrote:
(so the :default server and the :bev1234 server should be the same?)
If they should be the same, use:
servers[:bev1234] = {}
That was just for the test, in reality they are not the same.
This is is expected. The read_only shard is used by default for all
SELECT times (anything using Dataset#each). You should probably add
a :read_only=>{} entry to the servers hash to avoid this.
Ahah. That was the magic incantation for me. If I include a :read_only
shard in the servers hash then everything seems to work as expected
including Model initialisation and raising an error if a non-existent
shard is used.
I repeated the same code, adding :bev1234 and :demo123 connecting to
different databases. :default has the same connection as :bev1234 as
does :read_only
So:
DB[:client].first
reads from the :read_only (also now the :default) shard
DB[:client].server(:default).first
Also reads from the default (also :read_only) shard
DB[:client].server(:bev1234).first
reads from the :bev1234 shard
DB[:client].server(:demo123).first
reads from the :demo123 shard
and
DB[:client].server(:bob).first
Raises an exception (correctly)
So it seems that I MUST add a valid :read_only entry to the servers hash
or bizarre behaviour ensues. This may or not be the intended behaviour.
If so it needs documenting I think.
I'll do a few more tests in the next few days to make sure of this.
Cheers,
Gary.
--
You received this message because you are subscribed to the Google Groups
"sequel-talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sequel-talk?hl=en.