db-charmer 1.6.2 → 1.6.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +6 -0
- data/VERSION +1 -1
- data/db-charmer.gemspec +1 -1
- data/lib/db_charmer/db_magic.rb +14 -1
- data/lib/db_charmer/stub_connection.rb +4 -0
- metadata +2 -2
data/CHANGES
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
1.6.3 (2010-04-03):
|
2
|
+
|
3
|
+
Bugfix release: Modified stub connection initialization code to set default connections
|
4
|
+
for sharded models using shards enumeration or default shard features of sharding methods.
|
5
|
+
|
6
|
+
----------------------------------------------------------------------------------------
|
1
7
|
1.6.2 (2010-04-03):
|
2
8
|
|
3
9
|
Bugfix release: Modified our stub connection used on sharded models to fail on db-calling
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.6.
|
1
|
+
1.6.3
|
data/db-charmer.gemspec
CHANGED
data/lib/db_charmer/db_magic.rb
CHANGED
@@ -23,7 +23,20 @@ module DbCharmer
|
|
23
23
|
if opt[:sharded]
|
24
24
|
raise ArgumentError, "Can't use sharding on a model with slaves!" if opt[:slaves].any?
|
25
25
|
setup_sharding_magic(opt[:sharded])
|
26
|
-
|
26
|
+
|
27
|
+
# If method supports shards enumeration, get the first shard
|
28
|
+
conns = sharded_connection.shard_connections || []
|
29
|
+
real_conn = conns.first
|
30
|
+
|
31
|
+
# If connection we do not have real connection yet, try to use the default one
|
32
|
+
real_conn ||= sharded_connection.sharder.shard_for_key(:default) if sharded_connection.support_default_shard?
|
33
|
+
|
34
|
+
# Create stub connection
|
35
|
+
real_conn = coerce_to_connection_proxy(real_conn, DbCharmer.connections_should_exist?) if real_conn
|
36
|
+
stub_conn = DbCharmer::StubConnection.new(real_conn)
|
37
|
+
|
38
|
+
# ... and set it as the default one for this model
|
39
|
+
setup_connection_magic(stub_conn)
|
27
40
|
end
|
28
41
|
end
|
29
42
|
|