diff --git a/lib/annotate/annotate_models.rb b/lib/annotate/annotate_models.rb index ac214ffb4..c104455c1 100644 --- a/lib/annotate/annotate_models.rb +++ b/lib/annotate/annotate_models.rb @@ -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 diff --git a/spec/lib/annotate/annotate_models_spec.rb b/spec/lib/annotate/annotate_models_spec.rb index 370298f3c..d6bd6b94a 100644 --- a/spec/lib/annotate/annotate_models_spec.rb +++ b/spec/lib/annotate/annotate_models_spec.rb @@ -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 @@ -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