Skip to content
Merged
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: 2 additions & 2 deletions lib/annotate/annotate_models.rb
Original file line number Diff line number Diff line change
Expand Up @@ -889,9 +889,9 @@ def get_attributes(column, column_type, klass, options)
# Check out if we got a geometric column
# and print the type and SRID
if column.respond_to?(:geometry_type)
attrs << "#{column.geometry_type}, #{column.srid}"
attrs << [column.geometry_type, column.try(:srid)].compact.join(', ')
elsif column.respond_to?(:geometric_type) && column.geometric_type.present?
attrs << "#{column.geometric_type.to_s.downcase}, #{column.srid}"
attrs << [column.geometric_type.to_s.downcase, column.try(:srid)].compact.join(', ')
end

# Check if the column has indices and print "indexed" if true
Expand Down
6 changes: 5 additions & 1 deletion spec/lib/annotate/annotate_models_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1168,7 +1168,10 @@ def mock_column(name, type, options = {})
limit: { srid: 4326, type: 'geometry' }),
mock_column(:location, :geography,
geometric_type: 'Point', srid: 0,
limit: { srid: 0, type: 'geometry' })
limit: { srid: 0, type: 'geometry' }),
mock_column(:non_srid, :geography,
geometric_type: 'Point',
limit: { type: 'geometry' })
]
end

Expand All @@ -1182,6 +1185,7 @@ def mock_column(name, type, options = {})
# active :boolean default(FALSE), not null
# geometry :geometry not null, geometry, 4326
# location :geography not null, point, 0
# non_srid :geography not null, point
#
EOS
end
Expand Down