Skip to content

Commit 9b743fa

Browse files
committed
Merge pull request #139 from keyme/support_more_postgis
support the PostGIS adapter
2 parents 5534a83 + d6e4692 commit 9b743fa

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

README.rdoc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ The schema comment looks like this:
3333
. . .
3434

3535
It also annotates geometrical columns, geom type and srid, when using
36-
`SpatialAdapter` or `PostgisAdapter`:
36+
`SpatialAdapter`, `PostgisAdapter` or `PostGISAdapter`:
3737

3838
# == Schema Info
3939
#
@@ -237,6 +237,7 @@ extra carefully, and consider using one.
237237
- Fabrication: http://github.com/paulelliott/fabrication
238238
- SpatialAdapter: http://github.com/pdeffendol/spatial_adapter
239239
- PostgisAdapter: http://github.com/nofxx/postgis_adapter
240+
- PostGISAdapter: https://github.com/dazuma/activerecord-postgis-adapter
240241

241242

242243
== License

lib/annotate/annotate_models.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,10 @@ def get_schema_info(klass, header, options = {})
118118
col_type = (col.type || col.sql_type).to_s
119119
if col_type == "decimal"
120120
col_type << "(#{col.precision}, #{col.scale})"
121-
else
121+
elsif col_type != "spatial"
122122
if (col.limit)
123123
if col.limit.is_a? Array
124-
attrs << "(#{col.limit.join(', ')})"
124+
attrs << "(#{col.limit.join(', ')})"
125125
else
126126
col_type << "(#{col.limit})" unless NO_LIMIT_COL_TYPES.include?(col_type)
127127
end
@@ -132,6 +132,8 @@ def get_schema_info(klass, header, options = {})
132132
# and print the type and SRID
133133
if col.respond_to?(:geometry_type)
134134
attrs << "#{col.geometry_type}, #{col.srid}"
135+
elsif col.respond_to?(:geometric_type) and col.geometric_type.present?
136+
attrs << "#{col.geometric_type.to_s.downcase}, #{col.srid}"
135137
end
136138

137139
# Check if the column has indices and print "indexed" if true

0 commit comments

Comments
 (0)