Skip to content

Commit

Permalink
Remove conversion to hash
Browse files Browse the repository at this point in the history
  • Loading branch information
aidanharan committed Aug 14, 2024
1 parent 1960d8e commit 19cc61e
Showing 1 changed file with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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.
Expand Down

0 comments on commit 19cc61e

Please sign in to comment.