Fix for create_table_sql for Buffer table

This commit is contained in:
emakarov 2017-02-07 20:41:26 +03:00
parent c9697de56c
commit d19787cb9f
2 changed files with 3 additions and 3 deletions

View File

@ -80,11 +80,11 @@ class Buffer(Engine):
self.max_bytes = max_bytes
def create_table_sql(self, db_name, target):
def create_table_sql(self, db_name, main_model):
# Overriden create_table_sql example:
#sql = 'ENGINE = Buffer(merge, hits, 16, 10, 100, 10000, 1000000, 10000000, 100000000)'
sql = 'ENGINE = Buffer(%s, %s, %d, %d, %d, %d, %d, %d, %d)' % (
db_name, target.table_name(), self.num_layers,
db_name, main_model.table_name(), self.num_layers,
self.min_time, self.max_time, self.min_rows,
self.max_rows, self.min_bytes, self.max_bytes
)

View File

@ -168,6 +168,6 @@ class BufferModel(Model):
Returns the SQL command for creating a table for this model.
'''
parts = ['CREATE TABLE IF NOT EXISTS `%s`.`%s` AS `%s`.`%s`' % (db_name, cls.table_name(), db_name, cls.main_model.table_name())]
engine_str = cls.engine.create_table_sql(db_name, cls)
engine_str = cls.engine.create_table_sql(db_name, cls.main_model)
parts.append(engine_str)
return ' '.join(parts)