vendor/plugins/spatial_adapter/lib/spatial_adapter/schema_dumper.rb
# Build specification for a table column
Build specification for a table column
Build specification for a table column
def column_spec(column)
    spec = {}
    spec[:name]      = column.name.inspect
    spec[:type]      = if column.type == :integer && [/^numeric/, /^decimal/].any? { |e| e.match(column.sql_type) }
                         'decimal'
                       else
                         column.type.to_s
                       end
    spec[:limit]     = column.limit.inspect if column.limit != @types[column.type][:limit] && spec[:type] != 'decimal'
    spec[:precision] = column.precision.inspect if !column.precision.nil?
    spec[:scale]     = column.scale.inspect if !column.scale.nil?
    spec[:null]      = 'false' if !column.null
    spec[:default]   = default_string(column.default) if column.has_default?
    if column.is_a?(SpatialColumn)
      spec[:type]    = column.geometry_type.to_s
      spec[:srid]    = column.srid.inspect if column.srid != -1
      spec[:with_z]  = 'true' if column.with_z
      spec[:with_m]  = 'true' if column.with_m
      spec[:geographic] = 'true' if column.geographic?
    end
    spec
  end
def column_spec ( column ) spec = { } spec [ :name ] = column . name . inspect spec [ :type ] = if column . type == :integer && [ / ^numeric / , / ^decimal / ] . any? { | e | e . match ( column . sql_type ) } 'decimal' else column . type . to_s end spec [ :limit ] = column . limit . inspect if column . limit != @types [ column . type ] [ :limit ] && spec [ :type ] != 'decimal' spec [ :precision ] = column . precision . inspect if ! column . precision . nil? spec [ :scale ] = column . scale . inspect if ! column . scale . nil? spec [ :null ] = 'false' if ! column . null spec [ :default ] = default_string ( column . default ) if column . has_default? if column . is_a? ( SpatialColumn ) spec [ :type ] = column . geometry_type . to_s spec [ :srid ] = column . srid . inspect if column . srid != - 1 spec [ :with_z ] = 'true' if column . with_z spec [ :with_m ] = 'true' if column . with_m spec [ :geographic ] = 'true' if column . geographic? end spec end
Build specification for a table column
Build specification for a table column
# AR has an optimisation which handles zero-scale decimals as integers.  This # code ensures that the dumper still dumps the column as a decimal. # Additions for spatial columns # Override with specific geometry type
column