Class: ActiveRecord::ConnectionAdapters::MysqlAdapter
- Inherits:
-
Object
- Object
- ActiveRecord::ConnectionAdapters::MysqlAdapter
- Defined in:
- lib/rails_sql_views/connection_adapters/mysql_adapter.rb
Instance Method Summary collapse
-
#supports_views? ⇒ Boolean
Returns true as this adapter supports views.
-
#tables(name = nil) ⇒ Object
:nodoc:.
-
#view_select_statement(view, name = nil) ⇒ Object
Get the view select statement for the specified table.
-
#views(name = nil) ⇒ Object
:nodoc:.
Instance Method Details
#supports_views? ⇒ Boolean
Returns true as this adapter supports views.
5 6 7 |
# File 'lib/rails_sql_views/connection_adapters/mysql_adapter.rb', line 5 def supports_views? true end |
#tables(name = nil) ⇒ Object
:nodoc:
9 10 11 12 13 |
# File 'lib/rails_sql_views/connection_adapters/mysql_adapter.rb', line 9 def tables(name = nil) #:nodoc: tables = [] execute("SHOW TABLE STATUS", name).each { |row| tables << row[0] if row[17] != 'VIEW' } tables end |
#view_select_statement(view, name = nil) ⇒ Object
Get the view select statement for the specified table.
22 23 24 25 26 27 |
# File 'lib/rails_sql_views/connection_adapters/mysql_adapter.rb', line 22 def view_select_statement(view, name=nil) row = execute("SHOW CREATE VIEW #{view}", name).each do |row| return convert_statement(row[1]) if row[0] == view end raise "No view called #{view} found" end |
#views(name = nil) ⇒ Object
:nodoc:
15 16 17 18 19 |
# File 'lib/rails_sql_views/connection_adapters/mysql_adapter.rb', line 15 def views(name = nil) #:nodoc: views = [] execute("SHOW TABLE STATUS", name).each { |row| views << row[0] if row[17] == 'VIEW' } views end |