Skip to content

Commit

Permalink
Schema refreshes should not overwrite column 'example' field.
Browse files Browse the repository at this point in the history
  • Loading branch information
Marina Samuel committed Apr 18, 2019
1 parent daf9a5a commit d460516
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
1 change: 0 additions & 1 deletion redash/tasks/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,6 @@ def refresh_schema(data_source_id):
'table_id': table.id,
'name': column,
'type': None,
'example': None,
'exists': True
}

Expand Down
20 changes: 20 additions & 0 deletions tests/tasks/test_refresh_schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,3 +278,23 @@ def test_refresh_samples_refreshes(self):
TableMetadata.sample_updated_at.isnot(None)
)
self.assertTrue(table_metadata_list.first().sample_updated_at > TIME_BEFORE_UPDATE)

def test_refresh_schema_doesnt_overwrite_samples(self):
self.factory.data_source.query_runner.configuration['samples'] = True

refresh_schema(self.factory.data_source.id)
column_metadata = ColumnMetadata.query.first()
self.assertEqual(column_metadata.example, None)

update_sample(
self.factory.data_source.id,
'table',
1
)
column_metadata = ColumnMetadata.query.first()
self.assertEqual(column_metadata.example, self.COLUMN_EXAMPLE)

# Check that a schema refresh doesn't overwrite examples
refresh_schema(self.factory.data_source.id)
column_metadata = ColumnMetadata.query.first()
self.assertEqual(column_metadata.example, self.COLUMN_EXAMPLE)

0 comments on commit d460516

Please sign in to comment.