Repository: DOV-Vlaanderen/pydov

Issue:
Cannot use fields from a subtype as return fields.
* PyDOV version: master
* Python version: 3.6
* Operating System: Windows 10

### Description

Specifying a field from a subtype as return field gives an error if the resulting dataframe is non-empty.

### What I Did

```
import pydov.search.boring
from owslib.fes import PropertyIsEqualTo

bs = pydov.search.boring.BoringSearch()

bs.search(query=query, return_fields=('pkey_boring',))
                                         pkey_boring
0  https://www.dov.vlaanderen.be/data/boring/2004...

bs.search(query=query, return_fields=('pkey_boring', 'boormethode'))
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "C:\Projecten\PyDov\pydov_git\pydov\search\boring.py", line 114, in search
    columns=Boring.get_field_names(return_fields))
  File "C:\Users\rhbav33\python_virtualenvs\3.6_dev\lib\site-packages\pandas\core\frame.py", line 364, in __init__
    data = list(data)
  File "C:\Projecten\PyDov\pydov_git\pydov\types\abstract.py", line 467, in to_df_array
    result = item.get_df_array(return_fields)
  File "C:\Projecten\PyDov\pydov_git\pydov\types\abstract.py", line 524, in get_df_array
    return_fields=return_fields)
  File "C:\Projecten\PyDov\pydov_git\pydov\types\abstract.py", line 386, in get_field_names
    raise InvalidFieldError("Unknown return field: '%s'" % rf)
pydov.util.errors.InvalidFieldError: Unknown return field: 'boormethode'
```


Discussion:

Patch:
diff --git a/pydov/types/abstract.py b/pydov/types/abstract.py
index e0398f9..b5217b0 100644
--- a/pydov/types/abstract.py
+++ b/pydov/types/abstract.py
@@ -520,8 +520,7 @@ class AbstractDovType(AbstractCommon):
 
         """
         fields = self.get_field_names(return_fields)
-        ownfields = self.get_field_names(include_subtypes=False,
-                                         return_fields=return_fields)
+        ownfields = self.get_field_names(include_subtypes=False)
         subfields = [f for f in fields if f not in ownfields]
 
         if len(subfields) > 0:


Test patch:
diff --git a/tests/test_search_boring.py b/tests/test_search_boring.py
index 8da9d97..d31f72a 100644
--- a/tests/test_search_boring.py
+++ b/tests/test_search_boring.py
@@ -365,6 +365,36 @@ class TestBoringSearch(AbstractTestSearch):
         assert list(df) == ['pkey_boring', 'boornummer', 'diepte_boring_tot',
                             'datum_aanvang']
 
+    def test_search_returnfields_subtype(self, mp_remote_wfs_feature,
+                                         boringsearch):
+        """Test the search method with the query parameter and a selection of
+        return fields, including fields from a subtype.
+
+        Test whether the output dataframe contains only the selected return
+        fields.
+
+        Parameters
+        ----------
+        mp_remote_wfs_feature : pytest.fixture
+            Monkeypatch the call to get WFS features.
+        boringsearch : pytest.fixture returning pydov.search.BoringSearch
+            An instance of BoringSearch to perform search operations on the DOV
+            type 'Boring'.
+
+        """
+        query = PropertyIsEqualTo(propertyname='boornummer',
+                                  literal='GEO-04/169-BNo-B1')
+
+        df = boringsearch.search(query=query,
+                                 return_fields=('pkey_boring', 'boornummer',
+                                                'diepte_methode_van',
+                                                'diepte_methode_tot'))
+
+        assert type(df) is DataFrame
+
+        assert list(df) == ['pkey_boring', 'boornummer', 'diepte_methode_van',
+                            'diepte_methode_tot']
+
     def test_search_returnfields_order(self, mp_remote_wfs_feature,
                                        boringsearch):
         """Test the search method with the query parameter and a selection of
diff --git a/tests/test_search_grondwaterfilter.py b/tests/test_search_grondwaterfilter.py
index 5916163..d6c4ff7 100644
--- a/tests/test_search_grondwaterfilter.py
+++ b/tests/test_search_grondwaterfilter.py
@@ -380,6 +380,37 @@ class TestGrondwaterFilterSearch(AbstractTestSearch):
 
         assert list(df) == ['pkey_filter', 'gw_id', 'filternummer']
 
+    def test_search_returnfields_subtype(self, mp_remote_wfs_feature,
+                                         grondwaterfiltersearch):
+        """Test the search method with the query parameter and a selection of
+        return fields, including fields from a subtype.
+
+        Test whether the output dataframe contains only the selected return
+        fields.
+
+        Parameters
+        ----------
+        mp_remote_wfs_feature : pytest.fixture
+            Monkeypatch the call to get WFS features.
+        grondwaterfiltersearch : pytest.fixture returning
+            pydov.search.GrondwaterFilterSearch
+            An instance of GrondwaterFilterSearch to perform search operations
+            on the DOV type 'GrondwaterFilter'.
+
+        """
+        query = PropertyIsEqualTo(propertyname='filterfiche',
+                                  literal='https://www.dov.vlaanderen.be/'
+                                          'data/filter/2003-004471')
+
+        df = grondwaterfiltersearch.search(
+            query=query, return_fields=('pkey_filter', 'gw_id',
+                                        'filternummer', 'peil_mtaw'))
+
+        assert type(df) is DataFrame
+
+        assert list(df) == ['pkey_filter', 'gw_id', 'filternummer',
+                            'peil_mtaw']
+
     def test_search_returnfields_order(self, mp_remote_wfs_feature,
                                        grondwaterfiltersearch):
         """Test the search method with the query parameter and a selection of