class Upsert::ColumnDefinition
@private
Constants
- TIME_DETECTOR
Attributes
default[R]
name[R]
quoted_name[R]
quoted_selector_name[R]
quoted_setter_name[R]
sql_type[R]
Public Class Methods
all(connection, table_name)
click to toggle source
activerecord-3.2.X/lib/active_record/connection_adapters/XXXXXXXXX_adapter.rb#column_definitions
# File lib/upsert/column_definition.rb, line 6 def all(connection, table_name) raise "not impl" end
new(connection, name, sql_type, default)
click to toggle source
# File lib/upsert/column_definition.rb, line 20 def initialize(connection, name, sql_type, default) @name = name @sql_type = sql_type @temporal_query = !!(sql_type =~ TIME_DETECTOR) @default = default @quoted_name = connection.quote_ident name @quoted_selector_name = connection.quote_ident "#{name}_sel" @quoted_setter_name = connection.quote_ident "#{name}_set" end
Public Instance Methods
arg_type()
click to toggle source
# File lib/upsert/column_definition.rb, line 54 def arg_type if temporal? 'character varying(255)' else sql_type end end
equality(left, right)
click to toggle source
# File lib/upsert/column_definition.rb, line 50 def equality(left, right) "(#{left} = #{right} OR (#{left} IS NULL AND #{right} IS NULL))" end
temporal?()
click to toggle source
# File lib/upsert/column_definition.rb, line 46 def temporal? @temporal_query end
to_selector()
click to toggle source
# File lib/upsert/column_definition.rb, line 42 def to_selector equality(quoted_name, to_selector_value) end
to_selector_arg()
click to toggle source
# File lib/upsert/column_definition.rb, line 30 def to_selector_arg "#{quoted_selector_name} #{arg_type}" end
to_selector_value()
click to toggle source
# File lib/upsert/column_definition.rb, line 70 def to_selector_value if temporal? "CAST(#{quoted_selector_name} AS #{sql_type})" else quoted_selector_name end end
to_setter()
click to toggle source
# File lib/upsert/column_definition.rb, line 38 def to_setter "#{quoted_name} = #{to_setter_value}" end
to_setter_arg()
click to toggle source
# File lib/upsert/column_definition.rb, line 34 def to_setter_arg "#{quoted_setter_name} #{arg_type}" end
to_setter_value()
click to toggle source
# File lib/upsert/column_definition.rb, line 62 def to_setter_value if temporal? "CAST(#{quoted_setter_name} AS #{sql_type})" else quoted_setter_name end end