Merge branch 'carrotquest-develop' into develop

This commit is contained in:
Itai Shirav 2017-10-30 15:00:17 +02:00
commit 48c08b869e
2 changed files with 9 additions and 2 deletions

View File

@ -146,10 +146,11 @@ class Merge(Engine):
self.table_regex = table_regex
# Use current database as default
self.db_name = 'currentDatabase()'
self.db_name = None
def create_table_sql(self):
return "Merge(%s, '%s')" % (self.db_name, self.table_regex)
db_name = ("`%s`" % self.db_name) if self.db_name else 'currentDatabase()'
return "Merge(%s, '%s')" % (db_name, self.table_regex)
def set_db_name(self, db_name):
assert isinstance(db_name, six.string_types), "'db_name' parameter must be string"

View File

@ -274,3 +274,9 @@ class MergeModel(Model):
res = super(MergeModel, self).set_database(db)
self.engine.set_db_name(db.db_name)
return res
@classmethod
def create_table_sql(cls, db_name):
assert isinstance(cls.engine, Merge), "engine must be engines.Merge instance"
cls.engine.set_db_name(db_name)
return super(MergeModel, cls).create_table_sql(db_name)