[sqllab] templating refactor (#1504)

* Add support for jinja templates in WHERE/HAVING clauses

* Generalizing

* bugfix
This commit is contained in:
Maxime Beauchemin
2016-11-02 13:22:07 -07:00
committed by GitHub
parent 0bab15b213
commit 1700a807e9
5 changed files with 55 additions and 51 deletions

View File

@@ -358,8 +358,10 @@ class CoreTests(CaravelTestCase):
'ab_permission_view/panoramix/'.format(**locals()))
def test_process_template(self):
maindb = self.get_main_database(db.session)
sql = "SELECT '{{ datetime(2017, 1, 1).isoformat() }}'"
rendered = jinja_context.process_template(sql)
tp = jinja_context.get_template_processor(database=maindb)
rendered = tp.process_template(sql)
self.assertEqual("SELECT '2017-01-01T00:00:00'", rendered)
def test_templated_sql_json(self):