Merge branch 'dollar_issue_fix' of https://github.com/carrotquest/infi.clickhouse_orm into carrotquest-dollar_issue_fix

This commit is contained in:
Itai Shirav 2017-10-30 15:30:31 +02:00
commit b758333f42
2 changed files with 5 additions and 1 deletions

View File

@ -274,7 +274,7 @@ class Database(object):
mapping = dict(db="`%s`" % self.db_name)
if model_class:
mapping['table'] = "`%s`.`%s`" % (self.db_name, model_class.table_name())
query = Template(query).substitute(mapping)
query = Template(query).safe_substitute(mapping)
return query
def _get_server_timezone(self):

View File

@ -39,6 +39,10 @@ class DatabaseTestCase(TestCaseWithData):
self.assertEqual(results[0].get_database(), self.database)
self.assertEqual(results[1].get_database(), self.database)
def test_dollar_in_select(self):
query = "SELECT * FROM $table WHERE first_name = '$utm_source'"
list(self.database.select(query, Person))
def test_select_partial_fields(self):
self._insert_and_check(self._sample_data(), len(data))
query = "SELECT first_name, last_name FROM `test-db`.person WHERE first_name = 'Whitney' ORDER BY last_name"