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


Python operators.add方法代码示例

本文整理汇总了Python中sqlalchemy.sql.operators.add方法的典型用法代码示例。如果您正苦于以下问题:Python operators.add方法的具体用法?Python operators.add怎么用?Python operators.add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sqlalchemy.sql.operators的用法示例。


在下文中一共展示了operators.add方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _expression_adaptations

# 需要导入模块: from sqlalchemy.sql import operators [as 别名]
# 或者: from sqlalchemy.sql.operators import add [as 别名]
def _expression_adaptations(self):
        return {
            operators.mul: {
                Interval: Interval,
                Numeric: self.__class__,
                Integer: self.__class__,
            },
            operators.div: {
                Numeric: self.__class__,
                Integer: self.__class__,
            },
            operators.truediv: {
                Numeric: self.__class__,
                Integer: self.__class__,
            },
            operators.add: {
                Numeric: self.__class__,
                Integer: self.__class__,
            },
            operators.sub: {
                Numeric: self.__class__,
                Integer: self.__class__,
            }
        } 
开发者ID:yfauser,项目名称:planespotter,代码行数:26,代码来源:sqltypes.py

示例2: _expression_adaptations

# 需要导入模块: from sqlalchemy.sql import operators [as 别名]
# 或者: from sqlalchemy.sql.operators import add [as 别名]
def _expression_adaptations(self):
        # TODO: need a dictionary object that will
        # handle operators generically here, this is incomplete
        return {
            operators.add: {
                Date: Date,
                Integer: self.__class__,
                Numeric: Numeric,
            },
            operators.mul: {
                Interval: Interval,
                Integer: self.__class__,
                Numeric: Numeric,
            },
            operators.div: {Integer: self.__class__, Numeric: Numeric},
            operators.truediv: {Integer: self.__class__, Numeric: Numeric},
            operators.sub: {Integer: self.__class__, Numeric: Numeric},
        } 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:20,代码来源:sqltypes.py

示例3: _all_types

# 需要导入模块: from sqlalchemy.sql import operators [as 别名]
# 或者: from sqlalchemy.sql.operators import add [as 别名]
def _all_types(omit_special_types=False):
    seen = set()
    for typ in _types_for_mod(types):
        if omit_special_types and typ in (
            types.TypeDecorator,
            types.TypeEngine,
            types.Variant,
        ):
            continue

        if typ in seen:
            continue
        seen.add(typ)
        yield typ
    for dialect in _all_dialect_modules():
        for typ in _types_for_mod(dialect):
            if typ in seen:
                continue
            seen.add(typ)
            yield typ 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:22,代码来源:test_types.py

示例4: test_concatenable_adapt

# 需要导入模块: from sqlalchemy.sql import operators [as 别名]
# 或者: from sqlalchemy.sql.operators import add [as 别名]
def test_concatenable_adapt(self):
        class TypeOne(Concatenable, TypeEngine):
            pass

        class TypeTwo(Concatenable, TypeEngine):
            pass

        class TypeThree(TypeEngine):
            pass

        expr = column("x", TypeOne()) - column("y", TypeTwo())
        is_(expr.type._type_affinity, TypeOne)
        is_(expr.operator, operator.sub)

        expr = column("x", TypeOne()) + column("y", TypeTwo())
        is_(expr.type._type_affinity, TypeOne)
        is_(expr.operator, operators.concat_op)

        expr = column("x", TypeOne()) - column("y", TypeThree())
        is_(expr.type._type_affinity, TypeOne)
        is_(expr.operator, operator.sub)

        expr = column("x", TypeOne()) + column("y", TypeThree())
        is_(expr.type._type_affinity, TypeOne)
        is_(expr.operator, operator.add) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:27,代码来源:test_operators.py

示例5: test_related_eagerload_against_text

# 需要导入模块: from sqlalchemy.sql import operators [as 别名]
# 或者: from sqlalchemy.sql.operators import add [as 别名]
def test_related_eagerload_against_text(self, add_columns, loader_option):
        # new in 1.4.   textual selects have columns so subqueryloaders
        # and selectinloaders can join onto them.   we add columns
        # automatiacally to TextClause as well, however subqueryloader
        # is not working at the moment due to execution model refactor,
        # it creates a subquery w/ adapter before those columns are
        # available.  this is a super edge case and as we want to rewrite
        # the loaders to use select(), maybe we can get it then.
        User = self.classes.User

        text_clause = text("select * from users")
        if add_columns:
            text_clause = text_clause.columns(User.id, User.name)

        s = create_session()
        q = (
            s.query(User)
            .from_statement(text_clause)
            .options(loader_option(User.addresses))
        )

        def go():
            eq_(set(q.all()), set(self.static.user_address_result))

        self.assert_sql_count(testing.db, go, 2) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:27,代码来源:test_query.py

示例6: test_with_pending_autoflush

# 需要导入模块: from sqlalchemy.sql import operators [as 别名]
# 或者: from sqlalchemy.sql.operators import add [as 别名]
def test_with_pending_autoflush(self):
        Order, User = self.classes.Order, self.classes.User

        sess = Session()

        o1 = sess.query(Order).first()
        opending = Order(id=20, user_id=o1.user_id)
        sess.add(opending)
        eq_(
            sess.query(User).with_parent(opending, "user").one(),
            User(id=o1.user_id),
        )
        eq_(
            sess.query(User).filter(with_parent(opending, "user")).one(),
            User(id=o1.user_id),
        ) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:18,代码来源:test_query.py

示例7: test_filter_with_persistent_non_pk_col_is_default_null

# 需要导入模块: from sqlalchemy.sql import operators [as 别名]
# 或者: from sqlalchemy.sql.operators import add [as 别名]
def test_filter_with_persistent_non_pk_col_is_default_null(self):
        # test #4676 - comparison to a persistent column that is
        # NULL in the database, but is not fetched
        self._fixture1()
        Dingaling, HasDingaling = (
            self.classes.Dingaling,
            self.classes.HasDingaling,
        )
        s = Session()
        d = Dingaling(id=1)
        s.add(d)
        s.flush()
        assert "data" not in d.__dict__

        q = s.query(HasDingaling).filter_by(dingaling=d)

        with expect_warnings("Got None for value of column"):
            self.assert_compile(
                q,
                "SELECT has_dingaling.id AS has_dingaling_id, "
                "has_dingaling.dingaling_id AS has_dingaling_dingaling_id "
                "FROM has_dingaling WHERE :param_1 = "
                "has_dingaling.dingaling_id AND :param_2 = :data_1",
                checkparams={"param_1": 1, "param_2": None, "data_1": "hi"},
            ) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:27,代码来源:test_query.py

示例8: test_filter_with_detached_non_pk_col_has_value

# 需要导入模块: from sqlalchemy.sql import operators [as 别名]
# 或者: from sqlalchemy.sql.operators import add [as 别名]
def test_filter_with_detached_non_pk_col_has_value(self):
        self._fixture1()
        Dingaling, HasDingaling = (
            self.classes.Dingaling,
            self.classes.HasDingaling,
        )
        s = Session()
        d = Dingaling(data="some data")
        s.add(d)
        s.commit()
        s.expire(d)
        assert "data" not in d.__dict__

        q = s.query(HasDingaling).filter_by(dingaling=d)

        self.assert_compile(
            q,
            "SELECT has_dingaling.id AS has_dingaling_id, "
            "has_dingaling.dingaling_id AS has_dingaling_dingaling_id "
            "FROM has_dingaling WHERE :param_1 = "
            "has_dingaling.dingaling_id AND :param_2 = :data_1",
            checkparams={"param_1": 1, "param_2": "some data", "data_1": "hi"},
        ) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:25,代码来源:test_query.py

示例9: _adapt_expression

# 需要导入模块: from sqlalchemy.sql import operators [as 别名]
# 或者: from sqlalchemy.sql.operators import add [as 别名]
def _adapt_expression(self, op, other_comparator):
            if (op is operators.add and
                    isinstance(
                        other_comparator,
                        (Concatenable.Comparator, NullType.Comparator)
                    )):
                return operators.concat_op, self.expr.type
            else:
                return super(Concatenable.Comparator, self)._adapt_expression(
                    op, other_comparator) 
开发者ID:yfauser,项目名称:planespotter,代码行数:12,代码来源:sqltypes.py

示例10: _adapt_expression

# 需要导入模块: from sqlalchemy.sql import operators [as 别名]
# 或者: from sqlalchemy.sql.operators import add [as 别名]
def _adapt_expression(self, op, other_comparator):
            if op is operators.add and isinstance(
                other_comparator,
                (Concatenable.Comparator, NullType.Comparator),
            ):
                return operators.concat_op, self.expr.type
            else:
                return super(Concatenable.Comparator, self)._adapt_expression(
                    op, other_comparator
                ) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:12,代码来源:sqltypes.py


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