-
Notifications
You must be signed in to change notification settings - Fork 563
Closed
Description
In SchemaStatements#view_information line 337:
view_info[:VIEW_DEFINITION] = begin
select_values("EXEC sp_helptext #{quote_table_name(table_name)}", 'SCHEMA').join
rescue
warn "No view definition found, possible permissions problem.\nPlease run GRANT VIEW DEFINITION TO your_user;"
nil
endThe condition indicated by the warn is serious enough to require a raise instead.
For example, one of our read-only models uses a view. Since there is no migration, it is critical that permission to run sp_helptext is granted, but since this assignment returns nil, we get a meaningless error somewhere later in Model.find():
ReportDetails view exception: undefined method `match' for nil:NilClass This error comes from deep in the rails stack without providing a clear indication of what happened. For the curious it's caused by the function views_real_column_name in line 351 in schema_statements.rb which is invoked during find():
match_data = view_definition.match(/([\w-]*)\s+as\s+#{column_name}/im)Metadata
Metadata
Assignees
Labels
No labels