Sha256: 77829f9535db10f03409686fcf3ad91ed1359a31a0f90af93ba021efdae2d961

Contents?: true

Size: 716 Bytes

Versions: 2

Compression:

Stored size: 716 Bytes

Contents

module Scenic
  module Adapters
    class Mysql

      module TablesDefinition

        def tables(name = nil, database = nil, like = nil)
          sql = "SELECT table_name FROM information_schema.tables"

          wheres = ["table_type = 'BASE TABLE'"]

          if database
            wheres << "table_schema = #{quote_table_name(database)}"
          else
            wheres << "table_schema = SCHEMA()"
          end
          wheres << "table_name LIKE #{quote(like)}" if like

          sql << " WHERE #{wheres.join(' AND ')}" if wheres.present?

          execute_and_free(sql, 'SCHEMA') do |result|
            result.collect { |field| field.first }
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
scenic_mysql-0.1.3 lib/scenic/adapters/mysql/tables_definition.rb
scenic_mysql-0.1.2 lib/scenic/adapters/mysql/tables_definition.rb