Skip to content

Commit

Permalink
Don't try to create a column twice on import
Browse files Browse the repository at this point in the history
  • Loading branch information
danniel committed Jul 24, 2023
1 parent e3cbfbb commit b9b25c6
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions api/paul_api/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,11 +201,9 @@ def create(self, request):
csv_import = models.CsvImport.objects.get(pk=csv_import_pk)

for field in fields:
table_column, _ = models.TableColumn.objects.get_or_create(
table_column = models.TableColumn.objects.get(
table=table,
name=utils.snake_case(field["display_name"]),
display_name=field["display_name"],
field_type=field["field_type"],
)
csv_field_map = models.CsvFieldMap.objects.create(
table=table,
Expand All @@ -215,6 +213,7 @@ def create(self, request):
field_format=field["field_format"],
table_column=table_column
)
table_column.field_type = field["field_type"]
table_column.required = field.get('required', False)
table_column.unique = field.get('unique', False)
table_column.save()
Expand Down

0 comments on commit b9b25c6

Please sign in to comment.