File tree Expand file tree Collapse file tree 3 files changed +24
-13
lines changed
lib/active_record/connection_adapters Expand file tree Collapse file tree 3 files changed +24
-13
lines changed Original file line number Diff line number Diff line change 1+ ## v5.0.3
2+
3+ #### Changed
4+
5+ * Reduce view information reflection to per table vs. column. Fixes #552
6+
7+
18## v5.0.2
29
310#### Fixed
Original file line number Diff line number Diff line change @@ -470,20 +470,23 @@ def view_table_name(table_name)
470470 end
471471
472472 def view_information ( table_name )
473- identifier = SQLServer ::Utils . extract_identifiers ( table_name )
474- view_info = select_one "SELECT * FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = '#{ identifier . object } '" , 'SCHEMA'
475- if view_info
476- view_info = view_info . with_indifferent_access
477- if view_info [ :VIEW_DEFINITION ] . blank? || view_info [ :VIEW_DEFINITION ] . length == 4000
478- view_info [ :VIEW_DEFINITION ] = begin
479- select_values ( "EXEC sp_helptext #{ identifier . object_quoted } " , 'SCHEMA' ) . join
480- rescue
481- warn "No view definition found, possible permissions problem.\n Please run GRANT VIEW DEFINITION TO your_user;"
482- nil
473+ @view_information ||= { }
474+ @view_information [ table_name ] ||= begin
475+ identifier = SQLServer ::Utils . extract_identifiers ( table_name )
476+ view_info = select_one "SELECT * FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = '#{ identifier . object } '" , 'SCHEMA'
477+ if view_info
478+ view_info = view_info . with_indifferent_access
479+ if view_info [ :VIEW_DEFINITION ] . blank? || view_info [ :VIEW_DEFINITION ] . length == 4000
480+ view_info [ :VIEW_DEFINITION ] = begin
481+ select_values ( "EXEC sp_helptext #{ identifier . object_quoted } " , 'SCHEMA' ) . join
482+ rescue
483+ warn "No view definition found, possible permissions problem.\n Please run GRANT VIEW DEFINITION TO your_user;"
484+ nil
485+ end
483486 end
484487 end
488+ view_info
485489 end
486- view_info
487490 end
488491
489492 def views_real_column_name ( table_name , column_name )
Original file line number Diff line number Diff line change @@ -176,11 +176,12 @@ def disconnect!
176176 @connection . close rescue nil
177177 end
178178 @connection = nil
179+ @spid = nil
180+ @collation = nil
179181 end
180182
181183 def clear_cache!
182- @spid = nil
183- @collation = nil
184+ @view_information = nil
184185 super
185186 end
186187
You can’t perform that action at this time.
0 commit comments