db-charmer 1.5.0 → 1.5.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +12 -0
- data/VERSION +1 -1
- data/db-charmer.gemspec +3 -2
- data/lib/db_charmer.rb +3 -0
- data/lib/db_charmer/abstract_adapter_extensions.rb +22 -0
- data/lib/db_charmer/active_record_extensions.rb +1 -0
- metadata +4 -3
data/CHANGES
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
1.5.0 -> 1.5.1:
|
2
|
+
|
3
|
+
In this version we've added support for connection names logging in Rails queries log.
|
4
|
+
New log records have [connection_name] prefix for all queries that are executed on
|
5
|
+
non-standard connections:
|
6
|
+
|
7
|
+
[logs] LogRecord Columns (1.1ms) SHOW FIELDS FROM `log_records`
|
8
|
+
[logs] User Delete all (0.1ms) DELETE FROM `users`
|
9
|
+
[slave01] User Load (0.2ms) SELECT * FROM `users` WHERE (`users`.`login` = 'foo')
|
10
|
+
|
11
|
+
----------------------------------------------------------------------------------------
|
12
|
+
|
1
13
|
1.4.6 -> 1.5.0:
|
2
14
|
|
3
15
|
Major change in this version of DbCharmer is association preload support. For example,
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.5.
|
1
|
+
1.5.1
|
data/db-charmer.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{db-charmer}
|
8
|
-
s.version = "1.5.
|
8
|
+
s.version = "1.5.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Alexey Kovyrin"]
|
12
|
-
s.date = %q{2010-03-
|
12
|
+
s.date = %q{2010-03-06}
|
13
13
|
s.description = %q{ActiveRecord Connections Magic (slaves, multiple connections, etc)}
|
14
14
|
s.email = %q{alexey@kovyrin.net}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -27,6 +27,7 @@ Gem::Specification.new do |s|
|
|
27
27
|
"db-charmer.gemspec",
|
28
28
|
"init.rb",
|
29
29
|
"lib/db_charmer.rb",
|
30
|
+
"lib/db_charmer/abstract_adapter_extensions.rb",
|
30
31
|
"lib/db_charmer/active_record_extensions.rb",
|
31
32
|
"lib/db_charmer/association_preload.rb",
|
32
33
|
"lib/db_charmer/connection_factory.rb",
|
data/lib/db_charmer.rb
CHANGED
@@ -37,6 +37,8 @@ require 'blankslate'
|
|
37
37
|
#puts "Extending AR..."
|
38
38
|
|
39
39
|
require 'db_charmer/active_record_extensions'
|
40
|
+
require 'db_charmer/abstract_adapter_extensions'
|
41
|
+
|
40
42
|
require 'db_charmer/connection_factory'
|
41
43
|
require 'db_charmer/connection_proxy'
|
42
44
|
require 'db_charmer/connection_switch'
|
@@ -45,6 +47,7 @@ require 'db_charmer/multi_db_proxy'
|
|
45
47
|
|
46
48
|
# Enable misc AR extensions
|
47
49
|
ActiveRecord::Base.extend(DbCharmer::ActiveRecordExtensions::ClassMethods)
|
50
|
+
ActiveRecord::ConnectionAdapters::AbstractAdapter.send(:include, DbCharmer::AbstractAdapterExtensions::InstanceMethods)
|
48
51
|
|
49
52
|
# Enable connections switching in AR
|
50
53
|
ActiveRecord::Base.extend(DbCharmer::ConnectionSwitch::ClassMethods)
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module DbCharmer
|
2
|
+
module AbstractAdapterExtensions
|
3
|
+
module InstanceMethods
|
4
|
+
def self.included(base)
|
5
|
+
base.alias_method_chain :format_log_entry, :connection_name
|
6
|
+
end
|
7
|
+
|
8
|
+
def connection_name
|
9
|
+
@connection_name
|
10
|
+
end
|
11
|
+
|
12
|
+
def connection_name=(name)
|
13
|
+
@connection_name = name
|
14
|
+
end
|
15
|
+
|
16
|
+
def format_log_entry_with_connection_name(message, dump = nil)
|
17
|
+
msg = connection_name ? "[#{connection_name}] " : ''
|
18
|
+
msg << format_log_entry_without_connection_name(message, dump)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -8,6 +8,7 @@ module DbCharmer
|
|
8
8
|
raise ArgumentError, "Invalid connection name (does not exist in database.yml): #{RAILS_ENV}/#{name}"
|
9
9
|
end
|
10
10
|
establish_connection(config) if config
|
11
|
+
connection.connection_name = name.to_s
|
11
12
|
end
|
12
13
|
|
13
14
|
#-----------------------------------------------------------------------------
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 1
|
7
7
|
- 5
|
8
|
-
-
|
9
|
-
version: 1.5.
|
8
|
+
- 1
|
9
|
+
version: 1.5.1
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Alexey Kovyrin
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-03-
|
17
|
+
date: 2010-03-06 00:00:00 -05:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -63,6 +63,7 @@ files:
|
|
63
63
|
- db-charmer.gemspec
|
64
64
|
- init.rb
|
65
65
|
- lib/db_charmer.rb
|
66
|
+
- lib/db_charmer/abstract_adapter_extensions.rb
|
66
67
|
- lib/db_charmer/active_record_extensions.rb
|
67
68
|
- lib/db_charmer/association_preload.rb
|
68
69
|
- lib/db_charmer/connection_factory.rb
|