Sha256: 0d56fc5cdddd9b59a7bca8408b55e3e41f7dc679c1a1b5b3afef89b894add97c

Contents?: true

Size: 859 Bytes

Versions: 4

Compression:

Stored size: 859 Bytes

Contents

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

      def equality(left, right)
        "#{left} <=> #{right}"
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
upsert-2.9.10-java lib/upsert/column_definition/mysql.rb
upsert-2.9.10 lib/upsert/column_definition/mysql.rb
upsert-2.9.9-universal-java-11 lib/upsert/column_definition/mysql.rb
upsert-2.9.9 lib/upsert/column_definition/mysql.rb