• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1from django.db.backends.mysql import compiler as mysql_compiler
2from autotest_lib.frontend.afe.model_logic import _quote_name
3
4class SQLCompiler(mysql_compiler.SQLCompiler):
5    def get_from_clause(self):
6        from_, params = super(SQLCompiler, self).get_from_clause()
7
8        if hasattr(self.query, "_custom_joins"):
9            for join_dict in self.query._custom_joins:
10                from_.append('%s %s AS %s ON (%s)'
11                             % (join_dict['join_type'],
12                                _quote_name(join_dict['table']),
13                                _quote_name(join_dict['alias']),
14                                join_dict['condition']))
15                params.extend(join_dict['condition_values'])
16
17        return from_, params
18
19class SQLInsertCompiler(mysql_compiler.SQLInsertCompiler, SQLCompiler):
20    pass
21
22class SQLDeleteCompiler(mysql_compiler.SQLDeleteCompiler, SQLCompiler):
23    pass
24
25class SQLUpdateCompiler(mysql_compiler.SQLUpdateCompiler, SQLCompiler):
26    pass
27
28class SQLAggregateCompiler(mysql_compiler.SQLAggregateCompiler, SQLCompiler):
29    pass
30
31class SQLDateCompiler(mysql_compiler.SQLDateCompiler, SQLCompiler):
32    pass
33