Unverified Commit ecf70d8f by Hiroki Koike Committed by GitHub

Fix undefined method error when geometric columns have no `srid` (#920)

parent 69ab1842
...@@ -887,9 +887,9 @@ module AnnotateModels ...@@ -887,9 +887,9 @@ module AnnotateModels
# Check out if we got a geometric column # Check out if we got a geometric column
# and print the type and SRID # and print the type and SRID
if column.respond_to?(:geometry_type) 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? 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 end
# Check if the column has indices and print "indexed" if true # Check if the column has indices and print "indexed" if true
......
...@@ -1168,7 +1168,10 @@ describe AnnotateModels do ...@@ -1168,7 +1168,10 @@ describe AnnotateModels do
limit: { srid: 4326, type: 'geometry' }), limit: { srid: 4326, type: 'geometry' }),
mock_column(:location, :geography, mock_column(:location, :geography,
geometric_type: 'Point', srid: 0, 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 end
...@@ -1182,6 +1185,7 @@ describe AnnotateModels do ...@@ -1182,6 +1185,7 @@ describe AnnotateModels do
# active :boolean default(FALSE), not null # active :boolean default(FALSE), not null
# geometry :geometry not null, geometry, 4326 # geometry :geometry not null, geometry, 4326
# location :geography not null, point, 0 # location :geography not null, point, 0
# non_srid :geography not null, point
# #
EOS EOS
end end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment