当前位置: 首页>>代码示例>>Python>>正文


Python operators.custom_op方法代码示例

本文整理汇总了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 
开发者ID:cea-sec,项目名称:ivre,代码行数:23,代码来源:tables.py

示例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 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:27,代码来源:test_operators.py

示例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) 
开发者ID:jpush,项目名称:jbox,代码行数:8,代码来源:base.py

示例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 
开发者ID:jpush,项目名称:jbox,代码行数:5,代码来源:operators.py

示例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 
开发者ID:jpush,项目名称:jbox,代码行数:5,代码来源:operators.py

示例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 
开发者ID:yfauser,项目名称:planespotter,代码行数:5,代码来源:operators.py

示例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('~')) 
开发者ID:Netflix-Skunkworks,项目名称:aardvark,代码行数:4,代码来源:sqla_regex.py

示例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('~*')) 
开发者ID:Netflix-Skunkworks,项目名称:aardvark,代码行数:4,代码来源:sqla_regex.py

示例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('!~')) 
开发者ID:Netflix-Skunkworks,项目名称:aardvark,代码行数:4,代码来源:sqla_regex.py

示例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('!~*')) 
开发者ID:Netflix-Skunkworks,项目名称:aardvark,代码行数:4,代码来源:sqla_regex.py

示例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 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:4,代码来源:operators.py

示例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 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:4,代码来源:operators.py

示例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
    ) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:8,代码来源:operators.py

示例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,
        ) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:13,代码来源:test_operators.py

示例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}) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:16,代码来源:test_operators.py


注:本文中的sqlalchemy.sql.operators.custom_op方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。