Skip to content

Commit

Permalink
Merge 102425c into 7a58639
Browse files Browse the repository at this point in the history
  • Loading branch information
roll committed Mar 26, 2020
2 parents 7a58639 + 102425c commit e58b9bf
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tableschema/schema.py
Expand Up @@ -215,8 +215,8 @@ def remove_field(self, name):
field = self.get_field(name)
if field:
predicat = lambda field: field.get('name') != name
self.__current_descriptor['fields'] = filter(
predicat, self.__current_descriptor['fields'])
self.__current_descriptor['fields'] = list(filter(
predicat, self.__current_descriptor['fields']))
self.__build()
return field

Expand Down
13 changes: 13 additions & 0 deletions tests/test_schema.py
Expand Up @@ -420,3 +420,16 @@ def test_schema_field_time_format_issue_177():
descriptor = {'fields':[{'name':'myfield', 'type':'time', 'format':'%H:%M:%S'}]}
schema = Schema(descriptor)
assert schema


def test_schema_add_remove_field_issue_218():
descriptor = {
'fields': [
{'name': 'test_1', 'type': 'string', 'format': 'default'},
{'name': 'test_2', 'type': 'string', 'format': 'default'},
{'name': 'test_3', 'type': 'string', 'format': 'default'},
]
}
test_schema = Schema(descriptor)
test_schema.remove_field('test_1')
test_schema.add_field({'name': 'test_4', 'type': 'string', 'format': 'default'})

0 comments on commit e58b9bf

Please sign in to comment.