Skip to content

Commit

Permalink
Merge pull request #11 from docmarionum1/master
Browse files Browse the repository at this point in the history
Fix Error With GenericRelation
  • Loading branch information
trollefson authored Oct 1, 2020
2 parents e41f026 + bea0737 commit c6b4626
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion rest_framework_mvt/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def _get_non_geom_columns(self):
for field in self.model._meta.get_fields():
if hasattr(field, "get_attname_column"):
column_name = field.get_attname_column()[1]
if column_name != self.geo_col:
if column_name and column_name != self.geo_col:
columns.append(column_name)
return columns

Expand Down
4 changes: 4 additions & 0 deletions test/unit/test_mvt_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ def mvt_manager_no_col():
get_attname_column=MagicMock(return_value=("jazzy_geo", "jazzy_geo"))
),
MagicMock(get_attname_column=MagicMock(return_value=("city", "city"))),
MagicMock(
get_attname_column=MagicMock(return_value=("generic_relation", None))
),
]
meta.get_fields.return_value = fields
mvt_manager_no_col.model = MagicMock(_meta=meta)
Expand Down Expand Up @@ -99,6 +102,7 @@ def test_mvt_manager_build_query__no_geo_col(get_conn, only, mvt_manager_no_col)

assert expected_query == query
assert expected_parameters == parameters
only.assert_called_once_with("other_column", "jazzy_geo", "city")


@patch("rest_framework_mvt.managers.MVTManager.filter")
Expand Down

0 comments on commit c6b4626

Please sign in to comment.