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.84 app/mysql_types.rb
sqlui-0.1.83 app/mysql_types.rb
sqlui-0.1.82 app/mysql_types.rb
sqlui-0.1.81 app/mysql_types.rb
sqlui-0.1.80 app/mysql_types.rb
sqlui-0.1.79 app/mysql_types.rb
sqlui-0.1.78 app/mysql_types.rb
sqlui-0.1.77 app/mysql_types.rb
sqlui-0.1.76 app/mysql_types.rb
sqlui-0.1.75 app/mysql_types.rb
sqlui-0.1.74 app/mysql_types.rb
sqlui-0.1.73 app/mysql_types.rb
sqlui-0.1.72 app/mysql_types.rb
sqlui-0.1.71 app/mysql_types.rb
sqlui-0.1.70 app/mysql_types.rb
sqlui-0.1.69 app/mysql_types.rb
sqlui-0.1.68 app/mysql_types.rb
sqlui-0.1.67 app/mysql_types.rb
sqlui-0.1.66 app/mysql_types.rb
sqlui-0.1.65 app/mysql_types.rb