Sha256: 23f1525a4f8da218ba1ec705357599fe292b9ab665d1faeaffb7c94e30165261

Contents?: true

Size: 875 Bytes

Versions: 64

Compression:

Stored size: 875 Bytes

Contents

# frozen_string_literal: true

# Maps MySQL data types to type descriptions the client can use.
class MysqlTypes
  def initialize
    raise "can't instantiate #{self.class}"
  end

  class << self
    def map_to_google_charts_types(types)
      types.map do |type|
        type = type.gsub(/\([^)]*\)/, '').strip
        case type
        when 'bool', 'boolean'
          'boolean'
        when /double/, 'bigint', 'bit', 'dec', 'decimal', 'float', 'int', 'integer', 'mediumint', 'smallint', 'tinyint'
          'number'
        when /char/, /binary/, /blob/, /text/, 'enum', 'set', /image/
          'string'
        when 'date', 'year'
          'date'
        when 'datetime', 'timestamp'
          'datetime'
        when 'time'
          'timeofday'
        else
          puts "unexpected MySQL type: #{type}"
          'string'
        end
      end
    end
  end
end

Version data entries

64 entries across 64 versions & 1 rubygems

Version Path
sqlui-0.1.64 app/mysql_types.rb
sqlui-0.1.63 app/mysql_types.rb
sqlui-0.1.62 app/mysql_types.rb
sqlui-0.1.61 app/mysql_types.rb
sqlui-0.1.60 app/mysql_types.rb
sqlui-0.1.59 app/mysql_types.rb
sqlui-0.1.58 app/mysql_types.rb
sqlui-0.1.57 app/mysql_types.rb
sqlui-0.1.56 app/mysql_types.rb
sqlui-0.1.55 app/mysql_types.rb
sqlui-0.1.54 app/mysql_types.rb
sqlui-0.1.53 app/mysql_types.rb
sqlui-0.1.52 app/mysql_types.rb
sqlui-0.1.51 app/mysql_types.rb
sqlui-0.1.50 app/mysql_types.rb
sqlui-0.1.49 app/mysql_types.rb
sqlui-0.1.48 app/mysql_types.rb
sqlui-0.1.47 app/mysql_types.rb
sqlui-0.1.46 app/mysql_types.rb
sqlui-0.1.45 app/mysql_types.rb