コード例 #1
0
 def test_table_ref(self):
     ''' Testing table info in TableRef
         Class: TableInfo
     '''
     table_info = TableInfo('TAIPAI', 'Schema', 'Database')
     table_ref_obj = TableRef(table_info)
     select_stmt_new = SelectStatement()
     select_stmt_new.from_table = table_ref_obj
     self.assertEqual(select_stmt_new.from_table.table_info.table_name,
                      'TAIPAI')
     self.assertEqual(select_stmt_new.from_table.table_info.schema_name,
                      'Schema')
     self.assertEqual(select_stmt_new.from_table.table_info.database_name,
                      'Database')
コード例 #2
0
    def test_select_statement_class(self):
        ''' Testing setting different clauses for Select
        Statement class
        Class: SelectStatement'''

        select_stmt_new = SelectStatement()
        parser = Parser()

        select_query_new = "SELECT CLASS, REDNESS FROM TAIPAI \
            WHERE (CLASS = 'VAN' AND REDNESS < 400 ) OR REDNESS > 700;"

        eva_statement_list = parser.parse(select_query_new)
        select_stmt = eva_statement_list[0]

        select_stmt_new.where_clause = select_stmt.where_clause
        select_stmt_new.target_list = select_stmt.target_list
        select_stmt_new.from_table = select_stmt.from_table

        self.assertEqual(select_stmt_new.where_clause,
                         select_stmt.where_clause)
        self.assertEqual(select_stmt_new.target_list, select_stmt.target_list)
        self.assertEqual(select_stmt_new.from_table, select_stmt.from_table)
        self.assertEqual(str(select_stmt_new), str(select_stmt))