Description
Issue
The update to support table names containing spaces (#1206) modified the SchemaStatements#get_raw_table_name
method to expect the passed sql parameter not to be nil. If the sql parameter is nil, an exception is raised:
No view definition found, possible permissions problem.
Please run GRANT VIEW DEFINITION TO your_user;
undefined method `gsub' for nil (NoMethodError)
s = sql.gsub(/^\s*EXEC sp_executesql N'/i, "")
I'm dealing with a database view where most likely the view definition is not available due to a permissions problem, as reported by the code. However, the data in these views was still accessible in versions < 7.1.5 without the view definition being defined.
This is probably an edge case situation, but for those of us that don't have control over DB permissions, it can result in the inability to access some database views.
Expected behavior
Return the data of the view object.
Actual behavior
Exception raised
undefined method `gsub' for nil (NoMethodError)
s = sql.gsub(/^\s*EXEC sp_executesql N'/i, "")
How to reproduce
You would need to have a view object with permissions not allowing the view definition to be loaded with EXEC sp_helptext
and thereby returning nil
from SchemaStatements#view_information[:VIEW_DEFINITION]
.
Details
-
Rails version:
7.1.3.4
-
SQL Server adapter version:
7.1.5
-
TinyTDS version:
2.1.7
-
FreeTDS details:
Version: freetds v1.4.19 freetds.conf directory: /opt/homebrew/etc MS db-lib source compatibility: no Sybase binary compatibility: yes Thread safety: yes iconv library: yes TDS version: 7.3 iODBC: no unixodbc: yes SSPI "trusted" logins: no Kerberos: yes OpenSSL: yes GnuTLS: no MARS: yes