本文整理汇总了Python中sqlalchemy.sql.operators.custom_op方法的典型用法代码示例。如果您正苦于以下问题:Python operators.custom_op方法的具体用法?Python operators.custom_op怎么用?Python operators.custom_op使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sqlalchemy.sql.operators
的用法示例。
在下文中一共展示了operators.custom_op方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: extend_binary_expression
# 需要导入模块: from sqlalchemy.sql import operators [as 别名]
# 或者: from sqlalchemy.sql.operators import custom_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: factorial
# 需要导入模块: from sqlalchemy.sql import operators [as 别名]
# 或者: from sqlalchemy.sql.operators import custom_op [as 别名]
def factorial(self):
class MyInteger(Integer):
class comparator_factory(Integer.Comparator):
def factorial(self):
return UnaryExpression(
self.expr,
modifier=operators.custom_op("!"),
type_=MyInteger,
)
def factorial_prefix(self):
return UnaryExpression(
self.expr,
operator=operators.custom_op("!!"),
type_=MyInteger,
)
def __invert__(self):
return UnaryExpression(
self.expr,
operator=operators.custom_op("!!!"),
type_=MyInteger,
)
return MyInteger
示例3: _adapt_expression
# 需要导入模块: from sqlalchemy.sql import operators [as 别名]
# 或者: from sqlalchemy.sql.operators import custom_op [as 别名]
def _adapt_expression(self, op, other_comparator):
if isinstance(op, operators.custom_op):
if op.opstring in ['@>', '<@', '&&']:
return op, sqltypes.Boolean
return sqltypes.Concatenable.Comparator.\
_adapt_expression(self, op, other_comparator)
示例4: __eq__
# 需要导入模块: from sqlalchemy.sql import operators [as 别名]
# 或者: from sqlalchemy.sql.operators import custom_op [as 别名]
def __eq__(self, other):
return isinstance(other, custom_op) and \
other.opstring == self.opstring
示例5: is_comparison
# 需要导入模块: from sqlalchemy.sql import operators [as 别名]
# 或者: from sqlalchemy.sql.operators import custom_op [as 别名]
def is_comparison(op):
return op in _comparison or \
isinstance(op, custom_op) and op.is_comparison
示例6: is_natural_self_precedent
# 需要导入模块: from sqlalchemy.sql import operators [as 别名]
# 或者: from sqlalchemy.sql.operators import custom_op [as 别名]
def is_natural_self_precedent(op):
return op in _natural_self_precedent or \
isinstance(op, custom_op) and op.natural_self_precedent
示例7: regexp
# 需要导入模块: from sqlalchemy.sql import operators [as 别名]
# 或者: from sqlalchemy.sql.operators import custom_op [as 别名]
def regexp(self, other):
return RegexMatchExpression(self.expr, literal(other), custom_op('~'))
示例8: iregexp
# 需要导入模块: from sqlalchemy.sql import operators [as 别名]
# 或者: from sqlalchemy.sql.operators import custom_op [as 别名]
def iregexp(self, other):
return RegexMatchExpression(self.expr, literal(other), custom_op('~*'))
示例9: not_regexp
# 需要导入模块: from sqlalchemy.sql import operators [as 别名]
# 或者: from sqlalchemy.sql.operators import custom_op [as 别名]
def not_regexp(self, other):
return RegexMatchExpression(self.expr, literal(other), custom_op('!~'))
示例10: not_iregexp
# 需要导入模块: from sqlalchemy.sql import operators [as 别名]
# 或者: from sqlalchemy.sql.operators import custom_op [as 别名]
def not_iregexp(self, other):
return RegexMatchExpression(self.expr, literal(other), custom_op('!~*'))
示例11: __eq__
# 需要导入模块: from sqlalchemy.sql import operators [as 别名]
# 或者: from sqlalchemy.sql.operators import custom_op [as 别名]
def __eq__(self, other):
return isinstance(other, custom_op) and other.opstring == self.opstring
示例12: is_comparison
# 需要导入模块: from sqlalchemy.sql import operators [as 别名]
# 或者: from sqlalchemy.sql.operators import custom_op [as 别名]
def is_comparison(op):
return op in _comparison or isinstance(op, custom_op) and op.is_comparison
示例13: is_natural_self_precedent
# 需要导入模块: from sqlalchemy.sql import operators [as 别名]
# 或者: from sqlalchemy.sql.operators import custom_op [as 别名]
def is_natural_self_precedent(op):
return (
op in _natural_self_precedent
or isinstance(op, custom_op)
and op.natural_self_precedent
)
示例14: test_unary_both_ops
# 需要导入模块: from sqlalchemy.sql import operators [as 别名]
# 或者: from sqlalchemy.sql.operators import custom_op [as 别名]
def test_unary_both_ops(self):
assert_raises_message(
exc.CompileError,
"Unary expression does not support operator and "
"modifier simultaneously",
UnaryExpression(
literal("x"),
operator=operators.custom_op("x"),
modifier=operators.custom_op("y"),
).compile,
)
示例15: test_override_operators
# 需要导入模块: from sqlalchemy.sql import operators [as 别名]
# 或者: from sqlalchemy.sql.operators import custom_op [as 别名]
def test_override_operators(self):
special_index_op = operators.custom_op("->")
class MyOtherType(Indexable, TypeEngine):
__visit_name__ = "myothertype"
class Comparator(TypeEngine.Comparator):
def _adapt_expression(self, op, other_comparator):
return special_index_op, MyOtherType()
comparator_factory = Comparator
col = Column("x", MyOtherType())
self.assert_compile(col[5], "x -> :x_1", checkparams={"x_1": 5})