aboutsummaryrefslogblamecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/mysql/column.rb
blob: fa1541019d1e384e005fb660370ee473d3cfd2f0 (plain) (tree)
1
2
3
4
5
6
7
8
9

                             



                                                         
                                                                
 
                     
                                                       


                           
                                                 


                           
                                   
           



                                                           



         
# frozen_string_literal: true

module ActiveRecord
  module ConnectionAdapters
    module MySQL
      class Column < ConnectionAdapters::Column # :nodoc:
        delegate :extra, to: :sql_type_metadata, allow_nil: true

        def unsigned?
          /\bunsigned(?: zerofill)?\z/.match?(sql_type)
        end

        def case_sensitive?
          collation && !/_ci\z/.match?(collation)
        end

        def auto_increment?
          extra == "auto_increment"
        end

        def virtual?
          /\b(?:VIRTUAL|STORED|PERSISTENT)\b/.match?(extra)
        end
      end
    end
  end
end