Skip to content

Commit 3ef4853

Browse files
committed
Merge pull request #169 from bts/ar_3_1-fiber_patches
update fiber_patches to reflect latest AR ConnectionPool#initialize impl
2 parents dbb90b2 + 0c51db0 commit 3ef4853

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

lib/active_record/fiber_patches.rb

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,34 @@ def initialize(spec)
6767

6868
@connections = []
6969
@checked_out = []
70+
@automatic_reconnect = true
71+
@tables = {}
72+
73+
@columns = Hash.new do |h, table_name|
74+
h[table_name] = with_connection do |conn|
75+
76+
# Fetch a list of columns
77+
conn.columns(table_name, "#{table_name} Columns").tap do |columns|
78+
79+
# set primary key information
80+
columns.each do |column|
81+
column.primary = column.name == primary_keys[table_name]
82+
end
83+
end
84+
end
85+
end
86+
87+
@columns_hash = Hash.new do |h, table_name|
88+
h[table_name] = Hash[columns[table_name].map { |col|
89+
[col.name, col]
90+
}]
91+
end
92+
93+
@primary_keys = Hash.new do |h, table_name|
94+
h[table_name] = with_connection do |conn|
95+
table_exists?(table_name) ? conn.primary_key(table_name) : 'id'
96+
end
97+
end
7098
end
7199

72100
def clear_stale_cached_connections!
@@ -101,4 +129,4 @@ def checkout_and_verify(c)
101129
end
102130

103131
end
104-
end
132+
end

0 commit comments

Comments
 (0)