Sha256: 6d4f9b3285df8865c171d04ae68b7785dbe6475c4ba78da195db3b89e304ebdd

Contents?: true

Size: 683 Bytes

Versions: 10

Compression:

Stored size: 683 Bytes

Contents

class Upsert
  class ColumnDefinition
    # @private
    class Mysql < ColumnDefinition
      class << self
        def all(connection, table_name)
          connection.execute("SHOW COLUMNS FROM #{connection.quote_ident(table_name)}").map do |row|
            # {"Field"=>"name", "Type"=>"varchar(255)", "Null"=>"NO", "Key"=>"PRI", "Default"=>nil, "Extra"=>""}
            name = row['Field'] || row['COLUMN_NAME']
            type = row['Type'] || row['COLUMN_TYPE']
            default = row['Default'] || row['COLUMN_DEFAULT']
            new connection, name, type, default
          end.sort_by do |cd|
            cd.name
          end
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
upsert-2.0.1 lib/upsert/column_definition/mysql.rb
upsert-2.0.0 lib/upsert/column_definition/mysql.rb
upsert-1.2.0 lib/upsert/column_definition/mysql.rb
upsert-1.1.7 lib/upsert/column_definition/mysql.rb
upsert-1.1.6 lib/upsert/column_definition/mysql.rb
upsert-1.1.5 lib/upsert/column_definition/mysql.rb
upsert-1.1.4 lib/upsert/column_definition/mysql.rb
upsert-1.1.3 lib/upsert/column_definition/mysql.rb
upsert-1.1.1 lib/upsert/column_definition/mysql.rb
upsert-1.1.0 lib/upsert/column_definition/mysql.rb