diff --git a/lib/active_record/connection_adapters/sqlserver/schema_statements.rb b/lib/active_record/connection_adapters/sqlserver/schema_statements.rb index 2c6082d73..d5d0bb95c 100644 --- a/lib/active_record/connection_adapters/sqlserver/schema_statements.rb +++ b/lib/active_record/connection_adapters/sqlserver/schema_statements.rb @@ -735,14 +735,13 @@ def view_information(table_name) view_info = select_one("SELECT * FROM #{information_query_table} WITH (NOLOCK) WHERE TABLE_NAME = #{quote(identifier.object)}", "SCHEMA") if view_info - view_info = view_info.to_h.with_indifferent_access # TODO: Fix so doesnt use hash. - if view_info[:VIEW_DEFINITION].blank? || view_info[:VIEW_DEFINITION].length == 4000 - view_info[:VIEW_DEFINITION] = begin - select_values("EXEC sp_helptext #{identifier.object_quoted}", "SCHEMA").join - rescue - warn "No view definition found, possible permissions problem.\nPlease run GRANT VIEW DEFINITION TO your_user;" - nil - end + if view_info['VIEW_DEFINITION'].blank? || view_info['VIEW_DEFINITION'].length == 4000 + view_info['VIEW_DEFINITION'] = begin + select_values("EXEC sp_helptext #{identifier.object_quoted}", "SCHEMA").join + rescue + warn "No view definition found, possible permissions problem.\nPlease run GRANT VIEW DEFINITION TO your_user;" + nil + end end end @@ -751,7 +750,7 @@ def view_information(table_name) end def views_real_column_name(table_name, column_name) - view_definition = view_information(table_name)[:VIEW_DEFINITION] + view_definition = view_information(table_name)['VIEW_DEFINITION'] return column_name unless view_definition # Remove "CREATE VIEW ... AS SELECT ..." and then match the column name.