From c386ff91d686bc4ee24cffac10c724b6db1386b4 Mon Sep 17 00:00:00 2001 From: Arik Fraimovich Date: Tue, 29 Nov 2016 17:54:57 +0200 Subject: [PATCH] Fix data source models tests --- redash/models.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/redash/models.py b/redash/models.py index 4cb2a26a..b8fc5b6a 100644 --- a/redash/models.py +++ b/redash/models.py @@ -402,8 +402,10 @@ class DataSource(BelongsToOrgMixin, db.Model): @classmethod def create_with_group(cls, *args, **kwargs): - data_source = cls.create(*args, **kwargs) - DataSourceGroup.create(data_source=data_source, group=data_source.org.default_group) + data_source = cls(*args, **kwargs) + data_source_group = DataSourceGroup(data_source=data_source, group=data_source.org.default_group) + + db.session.add_all([data_source, data_source_group]) return data_source def get_schema(self, refresh=False):