コード例 #1
0
 def test_within_clause_error(self):
     with self.assertRaises(exceptions.CompileError) as context:
         compiler.compile_text(
             'SELECT r1.s, COUNT(r1.s) WITHIN r2 AS '
             'num_s_in_r1 FROM record_table', self.tables_by_name)
         self.assertTrue(
             'WITHIN clause syntax error' in str(context.exception))
コード例 #2
0
 def make_view(self, view_name, query):
     # TODO: Figure out the schema by compiling the query, and refactor the
     # code so that the compiler can use the schema instead of expecting
     # every TableId to have actual Columns. For now, we just validate that
     # the view works, and things will break later if the view is actually
     # used.
     compiler.compile_text(query, self.tables_by_name)
     return View(view_name, query)
コード例 #3
0
ファイル: tinyquery.py プロジェクト: Khan/tinyquery
 def make_view(self, view_name, query):
     # TODO: Figure out the schema by compiling the query, and refactor the
     # code so that the compiler can use the schema instead of expecting
     # every TableId to have actual Columns. For now, we just validate that
     # the view works, and things will break later if the view is actually
     # used.
     compiler.compile_text(query, self.tables_by_name)
     return View(view_name, query)
コード例 #4
0
 def test_strange_arithmetic(self):
     try:
         compiler.compile_text(
             'SELECT times + ints + floats + bools FROM '
             'rainbow_table', self.tables_by_name)
     except exceptions.CompileError:
         self.fail('Compiler exception on arithmetic across all numeric '
                   'types.')
コード例 #5
0
ファイル: compiler_test.py プロジェクト: burnhamup/tinyquery
 def assert_compiled_select(self, text, expected_ast):
     ast = compiler.compile_text(text, self.tables_by_name)
     self.assertEqual(expected_ast, ast)
コード例 #6
0
 def evaluate_query(self, query):
     select_ast = compiler.compile_text(query, self.tables_by_name)
     select_evaluator = evaluator.Evaluator(self.tables_by_name)
     return select_evaluator.evaluate_select(select_ast)
コード例 #7
0
ファイル: tinyquery.py プロジェクト: Khan/tinyquery
 def evaluate_query(self, query):
     select_ast = compiler.compile_text(query, self.tables_by_name)
     select_evaluator = evaluator.Evaluator(self.tables_by_name)
     return select_evaluator.evaluate_select(select_ast)
コード例 #8
0
 def test_mistyped_function_call(self):
     with self.assertRaises(exceptions.CompileError) as context:
         compiler.compile_text('SELECT SUM(strings) FROM rainbow_table',
                               self.tables_by_name)
     self.assertTrue('Invalid types for function' in str(context.exception))
コード例 #9
0
 def test_mistyped_binary_operator(self):
     with self.assertRaises(exceptions.CompileError) as context:
         compiler.compile_text(
             'SELECT ints CONTAINS strings FROM '
             'rainbow_table', self.tables_by_name)
     self.assertTrue('Invalid types for operator' in str(context.exception))
コード例 #10
0
 def assert_compiled_select(self, text, expected_ast):
     ast = compiler.compile_text(text, self.tables_by_name)
     self.assertEqual(expected_ast, ast)