Skip to content

Handle columns from activerecord-postgis-adapter #694

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 18, 2019
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
2 changes: 1 addition & 1 deletion .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ Lint/ShadowingOuterLocalVariable:

# Offense count: 20
Metrics/AbcSize:
Max: 139
Max: 141

# Offense count: 28
# Configuration parameters: CountComments, ExcludedMethods.
Expand Down
2 changes: 1 addition & 1 deletion lib/annotate/annotate_models.rb
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ def get_schema_info(klass, header, options = {})

if col_type == 'decimal'
col_type << "(#{col.precision}, #{col.scale})"
elsif col_type != 'spatial'
elsif !%w[spatial geometry geography].include?(col_type)
if col.limit
if col.limit.is_a? Array
attrs << "(#{col.limit.join(', ')})"
Expand Down
26 changes: 26 additions & 0 deletions spec/lib/annotate/annotate_models_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1055,6 +1055,32 @@ def self.when_called_with(options = {})
#
EOS

mocked_columns_with_geometries = [
[:id, :integer, { limit: 8 }],
[:active, :boolean, { default: false, null: false }],
[:geometry, :geometry, {
geometric_type: 'Geometry', srid: 4326,
limit: { srid: 4326, type: 'geometry' }
}],
[:location, :geography, {
geometric_type: 'Point', srid: 0,
limit: { srid: 0, type: 'geometry' }
}]
]

when_called_with with_columns: mocked_columns_with_geometries, returns:
<<-EOS.strip_heredoc
# Schema Info
#
# Table name: users
#
# id :integer not null, primary key
# active :boolean default(FALSE), not null
# geometry :geometry not null, geometry, 4326
# location :geography not null, point, 0
#
EOS

it 'should get schema info as RDoc' do
klass = mock_class(:users,
:id,
Expand Down