switchman 1.5.7 → 1.5.8
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6d7676d7b016d87da297714bb0ac6c4e6b2d2114
|
4
|
+
data.tar.gz: 67746d37c000d95e9f59a8be237a3a602b8d2e89
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3dfceefb5d04a739ac608d547f502133d0f3fa0185b17092087c9b2b2526c2bf947f8aa1657448341302cf4ce706b1b95cbc8110f738e62d752a0be409ea6f30
|
7
|
+
data.tar.gz: d1a2c684c4e720ed9e3e1777ac7c343ff83a9d8871e458b4644f8d1280ebec0bbfd52cd147d35ae9fec790599093623657209268efe43995e2ab01542e2bb12d
|
@@ -180,6 +180,40 @@ module Switchman
|
|
180
180
|
name.quoted
|
181
181
|
end
|
182
182
|
end
|
183
|
+
|
184
|
+
if ::Rails.version >= '4.2'
|
185
|
+
def foreign_keys(table_name)
|
186
|
+
schema = shard.name if use_qualified_names?
|
187
|
+
|
188
|
+
# mostly copy-pasted from AR - only change is to the nspname condition for qualified names support
|
189
|
+
fk_info = select_all <<-SQL.strip_heredoc
|
190
|
+
SELECT t2.oid::regclass::text AS to_table, a1.attname AS column, a2.attname AS primary_key, c.conname AS name, c.confupdtype AS on_update, c.confdeltype AS on_delete
|
191
|
+
FROM pg_constraint c
|
192
|
+
JOIN pg_class t1 ON c.conrelid = t1.oid
|
193
|
+
JOIN pg_class t2 ON c.confrelid = t2.oid
|
194
|
+
JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
|
195
|
+
JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
|
196
|
+
JOIN pg_namespace t3 ON c.connamespace = t3.oid
|
197
|
+
WHERE c.contype = 'f'
|
198
|
+
AND t1.relname = #{quote(table_name)}
|
199
|
+
AND t3.nspname = #{schema ? "'#{schema}'" : 'ANY (current_schemas(false))'}
|
200
|
+
ORDER BY c.conname
|
201
|
+
SQL
|
202
|
+
|
203
|
+
fk_info.map do |row|
|
204
|
+
options = {
|
205
|
+
column: row['column'],
|
206
|
+
name: row['name'],
|
207
|
+
primary_key: row['primary_key']
|
208
|
+
}
|
209
|
+
|
210
|
+
options[:on_delete] = extract_foreign_key_action(row['on_delete'])
|
211
|
+
options[:on_update] = extract_foreign_key_action(row['on_update'])
|
212
|
+
|
213
|
+
::ActiveRecord::ConnectionAdapters::ForeignKeyDefinition.new(table_name, row['to_table'], options)
|
214
|
+
end
|
215
|
+
end
|
216
|
+
end
|
183
217
|
end
|
184
218
|
end
|
185
219
|
end
|
@@ -91,6 +91,19 @@ module Switchman
|
|
91
91
|
end
|
92
92
|
end
|
93
93
|
|
94
|
+
if ::Rails.version >= '4.2' && ::Rails.version < '5'
|
95
|
+
# fixes an issue in Rails 4.2 with `reverse_sql_order` and qualified names
|
96
|
+
# where quoted_table_name is called before shard(s) have been activated
|
97
|
+
# if there's no ordering
|
98
|
+
def reverse_order!
|
99
|
+
orders = order_values.uniq
|
100
|
+
orders.reject!(&:blank?)
|
101
|
+
orders = [arel_table[primary_key].desc] if orders.empty?
|
102
|
+
|
103
|
+
self.order_values = reverse_sql_order(orders)
|
104
|
+
self
|
105
|
+
end
|
106
|
+
end
|
94
107
|
|
95
108
|
private
|
96
109
|
|
data/lib/switchman/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: switchman
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
4
|
+
version: 1.5.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cody Cutrer
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2016-06-
|
13
|
+
date: 2016-06-10 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: railties
|