コード例 #1
0
 def process_rhs(self, compiler, connection):
     value = self.rhs
     if self.bilateral_transforms:
         if self.rhs_is_direct_value():
             # Do not call get_db_prep_lookup here as the value will be
             # transformed before being used for lookup
             value = Value(value, output_field=self.lhs.output_field)
         value = self.apply_bilateral_transforms(value)
         value = value.resolve_expression(compiler.query)
     if hasattr(value, 'as_sql'):
         sql, params = compiler.compile(value)
         return '(' + sql + ')', params
     else:
         return self.get_db_prep_lookup(value, connection)
コード例 #2
0
 def batch_process_rhs(self, compiler, connection, rhs=None):
     if rhs is None:
         rhs = self.rhs
     if self.bilateral_transforms:
         sqls, sqls_params = [], []
         for p in rhs:
             value = Value(p, output_field=self.lhs.output_field)
             value = self.apply_bilateral_transforms(value)
             value = value.resolve_expression(compiler.query)
             sql, sql_params = compiler.compile(value)
             sqls.append(sql)
             sqls_params.extend(sql_params)
     else:
         _, params = self.get_db_prep_lookup(rhs, connection)
         sqls, sqls_params = ['%s'] * len(params), params
     return sqls, sqls_params