本文整理汇总了Python中django.db.models.expressions.Value.resolve_expression方法的典型用法代码示例。如果您正苦于以下问题:Python Value.resolve_expression方法的具体用法?Python Value.resolve_expression怎么用?Python Value.resolve_expression使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类django.db.models.expressions.Value
的用法示例。
在下文中一共展示了Value.resolve_expression方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: process_rhs
# 需要导入模块: from django.db.models.expressions import Value [as 别名]
# 或者: from django.db.models.expressions.Value import resolve_expression [as 别名]
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'):
return compiler.compile(value)
else:
return self.get_db_prep_lookup(value, connection)
示例2: batch_process_rhs
# 需要导入模块: from django.db.models.expressions import Value [as 别名]
# 或者: from django.db.models.expressions.Value import resolve_expression [as 别名]
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
示例3: process_rhs
# 需要导入模块: from django.db.models.expressions import Value [as 别名]
# 或者: from django.db.models.expressions.Value import resolve_expression [as 别名]
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)
# Due to historical reasons there are a couple of different
# ways to produce sql here. get_compiler is likely a Query
# instance and as_sql just something with as_sql. Finally the value
# can of course be just plain Python value.
if hasattr(value, 'get_compiler'):
value = value.get_compiler(connection=connection)
if hasattr(value, 'as_sql'):
sql, params = compiler.compile(value)
return '(' + sql + ')', params
else:
return self.get_db_prep_lookup(value, connection)
示例4:
# 需要导入模块: from django.db.models.expressions import Value [as 别名]
# 或者: from django.db.models.expressions.Value import resolve_expression [as 别名]
from copy import copy