Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ handle spatial datatypes in the following databases:

- PostgreSQL (using PostGIS)
- MySQL (using Spatial Extensions)
- Oracle (using Locator or Oracle Spatial)

== Dependencies

Expand Down Expand Up @@ -55,6 +56,7 @@ where [database] should be replaced with one of the following:

- postgresql
- mysql
- oracle_enhanced

For example to use the PostgreSQL spatial adapter:

Expand Down Expand Up @@ -104,6 +106,8 @@ Here is a related statement valid for MySql version <= 5.0.16:
can have spatial columns. In addition, only MyISAM tables may have spatial
indexes.

- On Oracle, :with_m is not supported.

=== Models

Create your ActiveRecord models normally. Spatial Adapter will automatically
Expand Down
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'rubygems'
require 'spec/rake/spectask'

[:mysql, :postgresql].each do |adapter|
[:mysql, :postgresql, :oracle_enhanced].each do |adapter|
desc "Run specs for #{adapter} adapter"
Spec::Rake::SpecTask.new("spec:#{adapter.to_s}") do |t|
t.spec_files = FileList["spec/#{adapter}/*_spec.rb"]
Expand Down
1 change: 0 additions & 1 deletion lib/spatial_adapter/common/schema_definitions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

ActiveRecord::ConnectionAdapters::IndexDefinition.class_eval do
attr_accessor :spatial

alias_method :initialize_without_spatial, :initialize
def initialize(table, name, unique, columns, spatial = false)
initialize_without_spatial(table, name, unique, columns)
Expand Down
14 changes: 11 additions & 3 deletions lib/spatial_adapter/common/schema_dumper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,12 @@ def table(table, stream)
stream.print tbl.read
rescue => e
stream.puts "# Could not dump table #{table.inspect} because of following #{e.class}"
stream.puts "# #{e.message}"
stream.puts "# #{e.message} #{e.backtrace.join("\n")}"
stream.puts
puts "# Could not dump table #{table.inspect} because of following #{e.class}"
puts "# #{e.message} #{e.backtrace.join("\n")}"
puts
raise e
end

stream
Expand Down Expand Up @@ -116,7 +120,7 @@ def column_spec(column)
else
column.type.to_s
end
spec[:limit] = column.limit.inspect if column.limit != @types[column.type][:limit] && spec[:type] != 'decimal'
spec[:limit] = column.limit.inspect if column.limit && 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
Expand All @@ -126,7 +130,11 @@ def column_spec(column)
if column.is_a?(SpatialColumn)
# Override with specific geometry type
spec[:type] = column.geometry_type.to_s
spec[:srid] = column.srid.inspect if column.srid != -1
if column.srid == @connection.default_srid
spec[:srid] = ":default_srid"
elsif column.srid != -1
spec[:srid] = column.srid.inspect
end
spec[:with_z] = 'true' if column.with_z
spec[:with_m] = 'true' if column.with_m
spec[:geographic] = 'true' if column.geographic?
Expand Down
4 changes: 4 additions & 0 deletions lib/spatial_adapter/mysql.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ def supports_geographic?
false
end

def default_srid
4326
end

alias :original_native_database_types :native_database_types
def native_database_types
original_native_database_types.merge!(geometry_data_types)
Expand Down
Loading