本文整理匯總了Python中sqlalchemy.sql.operators.json_getitem_op方法的典型用法代碼示例。如果您正苦於以下問題:Python operators.json_getitem_op方法的具體用法?Python operators.json_getitem_op怎麽用?Python operators.json_getitem_op使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類sqlalchemy.sql.operators
的用法示例。
在下文中一共展示了operators.json_getitem_op方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: extend_binary_expression
# 需要導入模塊: from sqlalchemy.sql import operators [as 別名]
# 或者: from sqlalchemy.sql.operators import json_getitem_op [as 別名]
def extend_binary_expression(element, compiler, **kwargs):
if isinstance(element.operator, custom_op):
opstring = element.operator.opstring
if opstring == '~':
return compiler.process(func.REGEXP(element.left, element.right))
if opstring == '~*':
return compiler.process(func.IREGEXP(element.left, element.right))
if opstring == '->':
return compiler.process(func.ACCESS(element.left, element.right))
if opstring == '->>':
return compiler.process(func.ACCESS_TXT(element.left,
element.right))
if opstring == '?':
return compiler.process(func.HAS_KEY(element.left, element.right))
# FIXME: Variant base type Comparator seems to be used here.
if element.operator is json_getitem_op:
return compiler.process(func.ACCESS(element.left, element.right))
return compiler.visit_binary(element)
# Types
示例2: _setup_getitem
# 需要導入模塊: from sqlalchemy.sql import operators [as 別名]
# 或者: from sqlalchemy.sql.operators import json_getitem_op [as 別名]
def _setup_getitem(self, default_comparator, index):
if not isinstance(index, util.string_types) and \
isinstance(index, collections.Sequence):
index = default_comparator._check_literal(
self.expr, operators.json_path_getitem_op,
index, bindparam_type=JSON.JSONPathType
)
operator = operators.json_path_getitem_op
else:
index = default_comparator._check_literal(
self.expr, operators.json_getitem_op,
index, bindparam_type=JSON.JSONIndexType
)
operator = operators.json_getitem_op
return operator, index, self.type
示例3: _setup_getitem
# 需要導入模塊: from sqlalchemy.sql import operators [as 別名]
# 或者: from sqlalchemy.sql.operators import json_getitem_op [as 別名]
def _setup_getitem(self, index):
if not isinstance(index, util.string_types) and isinstance(
index, compat.collections_abc.Sequence
):
index = coercions.expect(
roles.BinaryElementRole,
index,
expr=self.expr,
operator=operators.json_path_getitem_op,
bindparam_type=JSON.JSONPathType,
)
operator = operators.json_path_getitem_op
else:
index = coercions.expect(
roles.BinaryElementRole,
index,
expr=self.expr,
operator=operators.json_getitem_op,
bindparam_type=JSON.JSONIndexType,
)
operator = operators.json_getitem_op
return operator, index, self.type
示例4: _binary_w_type
# 需要導入模塊: from sqlalchemy.sql import operators [as 別名]
# 或者: from sqlalchemy.sql.operators import json_getitem_op [as 別名]
def _binary_w_type(self, typ, method_name):
if not isinstance(
self.expr, elements.BinaryExpression
) or self.expr.operator not in (
operators.json_getitem_op,
operators.json_path_getitem_op,
):
raise exc.InvalidRequestError(
"The JSON cast operator JSON.%s() only works with a JSON "
"index expression e.g. col['q'].%s()"
% (method_name, method_name)
)
expr = self.expr._clone()
expr.type = typ
return expr