connection_manager 1.1.2 → 1.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/connection_manager/using.rb +55 -0
- data/lib/connection_manager/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NjMyYTlkY2I0ZmFlNTI5ZDc1OGIyY2I1ZDUyZmQ3NTZhMTZmYzg3NQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NWQzNjkxN2UxODYyNmQyNjllYmIwMWRhYzYzYjUwYmMyMmE1NTg5YQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MmMyNTdiZjg0NmIwMDYxNTkzNzg5MjQ0MjYwNDdjOWZjNTIxYzQ4Yzg0MDgw
|
10
|
+
OGNkODg1ZGE4NGU0OTQ0ZWFiNTUxMzY2MjA2ZmE0YzRjOGU0N2U1ZDEwMTQ0
|
11
|
+
YmZhZGY3NzBmNDUwODlhZjM4M2RkNTBhMTk1ZjM3NzM4YmYzYTk=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MTk0NTg1MDViZjM0MmUyYjhmY2YzZDQ1YzRmOTkwNTFlZDAyYThkY2UzNWU1
|
14
|
+
YjVjMGFkNTU4MDBiZTRhMTFjMTA4YWJhZWY0YWVjMDk0Nzc0NzEyOTJlOTRl
|
15
|
+
Zjk3N2Q2M2JlNDA3YmVmNGQxYjNiMzcxYmQxN2MzN2Q4ZGQwMDM=
|
@@ -63,6 +63,61 @@ module ConnectionManager
|
|
63
63
|
@klass.parent
|
64
64
|
end
|
65
65
|
|
66
|
+
if ActiveRecord::VERSION::MAJOR == 3 && ActiveRecord::VERSION::MINOR == 0
|
67
|
+
# Rails 3.0
|
68
|
+
def find_by_sql(sql)
|
69
|
+
connection.select_all(sanitize_sql(sql), "#{name} Load").collect! { |record| instantiate(record) }
|
70
|
+
end
|
71
|
+
|
72
|
+
elsif ActiveRecord::VERSION::MAJOR == 3 && ActiveRecord::VERSION::MINOR == 1
|
73
|
+
# Rails 3.1
|
74
|
+
def find_by_sql(sql, binds = [])
|
75
|
+
connection.select_all(sanitize_sql(sql), "#{name} Load", binds).collect! { |record| instantiate(record) }
|
76
|
+
end
|
77
|
+
|
78
|
+
elsif ActiveRecord::VERSION::MAJOR == 3
|
79
|
+
# Rails 3.2
|
80
|
+
def find_by_sql(sql, binds = [])
|
81
|
+
logging_query_plan do
|
82
|
+
connection.select_all(sanitize_sql(sql), "#{name} Load", binds).collect! { |record| instantiate(record) }
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
elsif ActiveRecord::VERSION::MAJOR == 4 && ActiveRecord::VERSION::MINOR <= 1
|
87
|
+
#Rails 4.0 & 4.1
|
88
|
+
def find_by_sql(sql, binds = [])
|
89
|
+
result_set = connection.select_all(sanitize_sql(sql), "#{name} Load", binds)
|
90
|
+
column_types = {}
|
91
|
+
if result_set.respond_to? :column_types
|
92
|
+
column_types = result_set.column_types
|
93
|
+
else
|
94
|
+
ActiveSupport::Deprecation.warn "the object returned from `select_all` must respond to `column_types`"
|
95
|
+
end
|
96
|
+
result_set.map { |record| instantiate(record, column_types) }
|
97
|
+
end
|
98
|
+
|
99
|
+
else
|
100
|
+
# Edge Rails
|
101
|
+
def find_by_sql(sql, binds = [])
|
102
|
+
result_set = connection.select_all(sanitize_sql(sql), "#{name} Load", binds)
|
103
|
+
column_types = result_set.column_types.dup
|
104
|
+
columns_hash.each_key { |k| column_types.delete k }
|
105
|
+
message_bus = ActiveSupport::Notifications.instrumenter
|
106
|
+
payload = {
|
107
|
+
record_count: result_set.length,
|
108
|
+
class_name: name
|
109
|
+
}
|
110
|
+
message_bus.instrument('instantiation.active_record', payload) do
|
111
|
+
result_set.map { |record| instantiate(record, column_types) }
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
def count_by_sql(sql)
|
117
|
+
sql = sanitize_conditions(sql)
|
118
|
+
connection.select_value(sql, "#{name} Count").to_i
|
119
|
+
end
|
120
|
+
|
66
121
|
# Pass all methods to @klass, this ensures objects
|
67
122
|
# build from the query are the correct class and
|
68
123
|
# any settings in the model like table_name_prefix
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: connection_manager
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joshua Mckinney
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-11-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -214,7 +214,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
214
214
|
version: '0'
|
215
215
|
requirements: []
|
216
216
|
rubyforge_project: connection_manager
|
217
|
-
rubygems_version: 2.
|
217
|
+
rubygems_version: 2.4.2
|
218
218
|
signing_key:
|
219
219
|
specification_version: 4
|
220
220
|
summary: Cross-schema, replication and mutli-DMS gem for ActiveRecord.
|