method

data_source_sql

Importance_0
v7.0.0 - Show latest stable - 0 notes - Class: SchemaStatements
data_source_sql(name = nil, type: nil) private

No documentation

This method has no description. You can help the Ruby on Rails community by adding new notes.

Hide source
# File activerecord/lib/active_record/connection_adapters/mysql/schema_statements.rb, line 206
          def data_source_sql(name = nil, type: nil)
            scope = quoted_scope(name, type: type)

            sql = +"SELECT table_name FROM (SELECT table_name, table_type FROM information_schema.tables "
            sql << " WHERE table_schema = #{scope[:schema]}) _subquery"
            if scope[:type] || scope[:name]
              conditions = []
              conditions << "_subquery.table_type = #{scope[:type]}" if scope[:type]
              conditions << "_subquery.table_name = #{scope[:name]}" if scope[:name]
              sql << " WHERE #{conditions.join(" AND ")}"
            end
            sql
          end
Register or log in to add new notes.