require'set'moduleActiveRecord# :stopdoc:moduleConnectionAdapters# An abstract definition of a column in a table.classColumnTRUE_VALUES=[true,1,'1','t','T','true','TRUE','on','ON'].to_setFALSE_VALUES=[false,0,'0','f','F','false','FALSE','off','OFF'].to_setmoduleFormatISO_DATE=/\A(\d{4})-(\d\d)-(\d\d)\z/ISO_DATETIME=/\A(\d{4})-(\d\d)-(\d\d) (\d\d):(\d\d):(\d\d)(\.\d+)?\z/endattr_reader:name,:cast_type,:null,:sql_type,:default,:default_functiondelegate:type,:precision,:scale,:limit,:klass,:accessor,:number?,:binary?,:changed?,:type_cast_from_user,:type_cast_from_database,:type_cast_for_database,:type_cast_for_schema,to: :cast_type# Instantiates a new column in the table.## +name+ is the column's name, such as <tt>supplier_id</tt> in <tt>supplier_id int(11)</tt>.# +default+ is the type-casted default value, such as +new+ in <tt>sales_stage varchar(20) default 'new'</tt>.# +cast_type+ is the object used for type casting and type information.# +sql_type+ is used to extract the column's length, if necessary. For example +60+ in# <tt>company_name varchar(60)</tt>.# It will be mapped to one of the standard Rails SQL types in the <tt>type</tt> attribute.# +null+ determines if this column allows +NULL+ values.definitialize(name,default,cast_type,sql_type=nil,null=true)@name=name@cast_type=cast_type@sql_type=sql_type@null=null@default=default@default_function=nilenddefhas_default?!default.nil?end# Returns the human name of the column name.## ===== Examples# Column.new('sales_stage', ...).human_name # => 'Sales stage'defhuman_nameBase.human_attribute_name(@name)enddefwith_type(type)dup.tapdo|clone|clone.instance_variable_set('@cast_type',type)endenddef==(other)other.name==name&&other.default==default&&other.cast_type==cast_type&&other.sql_type==sql_type&&other.null==null&&other.default_function==default_functionendalias:eql?:==defhashattributes_for_hash.hashendprivatedefattributes_for_hash[self.class,name,default,cast_type,sql_type,null,default_function]endendend# :startdoc:end