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


Python elements.ClauseElement方法代码示例

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


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

示例1: test_cache_key_no_method

# 需要导入模块: from sqlalchemy.sql import elements [as 别名]
# 或者: from sqlalchemy.sql.elements import ClauseElement [as 别名]
def test_cache_key_no_method(self):
        class Foobar1(ClauseElement):
            pass

        class Foobar2(ColumnElement):
            pass

        # the None for cache key will prevent objects
        # which contain these elements from being cached.
        f1 = Foobar1()
        eq_(f1._generate_cache_key(), None)

        f2 = Foobar2()
        eq_(f2._generate_cache_key(), None)

        s1 = select([column("q"), Foobar2()])

        eq_(s1._generate_cache_key(), None) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:20,代码来源:test_compare.py

示例2: test_all_present

# 需要导入模块: from sqlalchemy.sql import elements [as 别名]
# 或者: from sqlalchemy.sql.elements import ClauseElement [as 别名]
def test_all_present(self):
        need = set(
            cls
            for cls in class_hierarchy(ClauseElement)
            if issubclass(cls, (ColumnElement, Selectable, LambdaElement))
            and (
                "__init__" in cls.__dict__
                or issubclass(cls, AliasedReturnsRows)
            )
            and not issubclass(cls, (Annotated))
            and "orm" not in cls.__module__
            and "compiler" not in cls.__module__
            and "crud" not in cls.__module__
            and "dialects" not in cls.__module__  # TODO: dialects?
        ).difference({ColumnElement, UnaryExpression})

        for fixture in self.fixtures + self.dont_compare_values_fixtures:
            case_a = fixture()
            for elem in case_a:
                for mro in type(elem).__mro__:
                    need.discard(mro)

        is_false(bool(need), "%d Remaining classes: %r" % (len(need), need)) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:25,代码来源:test_compare.py

示例3: _between_sql

# 需要导入模块: from sqlalchemy.sql import elements [as 别名]
# 或者: from sqlalchemy.sql.elements import ClauseElement [as 别名]
def _between_sql(x, left, right, default = None) -> ClauseElement:
    """
    Example:
        >>> print(between(sql.column('a'), 1, 2))
        a BETWEEN :a_1 AND :a_2

        >>> print(between(sql.column('a'), 1, 2, default = False))
        coalesce(a BETWEEN :a_1 AND :a_2, :coalesce_1)

    """
    
    if default is not False:
        # TODO: warn
        pass

    if default is None:
        return x.between(left, right)

    return sql.functions.coalesce(x.between(left, right), default)

# coalesce -------------------------------------------------------------------- 
开发者ID:machow,项目名称:siuba,代码行数:23,代码来源:vector.py

示例4: get_sqlalchemy_sql

# 需要导入模块: from sqlalchemy.sql import elements [as 别名]
# 或者: from sqlalchemy.sql.elements import ClauseElement [as 别名]
def get_sqlalchemy_sql(query: ClauseElement) -> str:
    dialect = get_sqlalchemy_connection().dialect
    comp = query.compile(dialect=dialect)
    return str(comp) 
开发者ID:zulip,项目名称:zulip,代码行数:6,代码来源:test_narrow.py

示例5: get_sqlalchemy_query_params

# 需要导入模块: from sqlalchemy.sql import elements [as 别名]
# 或者: from sqlalchemy.sql.elements import ClauseElement [as 别名]
def get_sqlalchemy_query_params(query: ClauseElement) -> Dict[str, object]:
    dialect = get_sqlalchemy_connection().dialect
    comp = query.compile(dialect=dialect)
    return comp.params 
开发者ID:zulip,项目名称:zulip,代码行数:6,代码来源:test_narrow.py

示例6: test_cache_key_unknown_traverse

# 需要导入模块: from sqlalchemy.sql import elements [as 别名]
# 或者: from sqlalchemy.sql.elements import ClauseElement [as 别名]
def test_cache_key_unknown_traverse(self):
        class Foobar1(ClauseElement):
            _traverse_internals = [
                ("key", InternalTraversal.dp_anon_name),
                ("type_", InternalTraversal.dp_unknown_structure),
            ]

            def __init__(self, key, type_):
                self.key = key
                self.type_ = type_

        f1 = Foobar1("foo", String())
        eq_(f1._generate_cache_key(), None) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:15,代码来源:test_compare.py

示例7: test_get_children_no_method

# 需要导入模块: from sqlalchemy.sql import elements [as 别名]
# 或者: from sqlalchemy.sql.elements import ClauseElement [as 别名]
def test_get_children_no_method(self):
        class Foobar1(ClauseElement):
            pass

        class Foobar2(ColumnElement):
            pass

        f1 = Foobar1()
        eq_(f1.get_children(), [])

        f2 = Foobar2()
        eq_(f2.get_children(), []) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:14,代码来源:test_compare.py

示例8: test_copy_internals_no_method

# 需要导入模块: from sqlalchemy.sql import elements [as 别名]
# 或者: from sqlalchemy.sql.elements import ClauseElement [as 别名]
def test_copy_internals_no_method(self):
        class Foobar1(ClauseElement):
            pass

        class Foobar2(ColumnElement):
            pass

        f1 = Foobar1()
        f2 = Foobar2()

        f1._copy_internals()
        f2._copy_internals() 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:14,代码来源:test_compare.py

示例9: copy_object

# 需要导入模块: from sqlalchemy.sql import elements [as 别名]
# 或者: from sqlalchemy.sql.elements import ClauseElement [as 别名]
def copy_object(self):
        cls = type(self)
        obj = cls(
            (n, v)
            for n, v in dict.items(self)
            if not isinstance(v, ClauseElement))
        return obj 
开发者ID:dvhb,项目名称:dvhb-hybrid,代码行数:9,代码来源:model.py

示例10: _str_c_sql

# 需要导入模块: from sqlalchemy.sql import elements [as 别名]
# 或者: from sqlalchemy.sql.elements import ClauseElement [as 别名]
def _str_c_sql(x, *args, sep = "", collapse = None) -> ClauseElement:
    """
    Example:
    """

    if collapse is not None:
        raise NotImplementedError("For SQL, collapse argument of str_c not supported")

    if sep != "":
        raise NotImplementedError('For SQL, sep argument of str_c must be ""')

    return sql.func.concat(x, *args) 
开发者ID:machow,项目名称:siuba,代码行数:14,代码来源:string.py

示例11: _desc_sql

# 需要导入模块: from sqlalchemy.sql import elements [as 别名]
# 或者: from sqlalchemy.sql.elements import ClauseElement [as 别名]
def _desc_sql(x) -> ClauseElement:
    """
    Example:
        >>> print(desc(sql.column('a')))
        a DESC
    """
    return x.desc()


# ranking functions -----------------------------------------------------------
# note: here we don't use the decorator syntax, but maybe we should for
#       consistency
# TODO: remove repetition in rank definitions 
开发者ID:machow,项目名称:siuba,代码行数:15,代码来源:vector.py

示例12: _coalesce_sql

# 需要导入模块: from sqlalchemy.sql import elements [as 别名]
# 或者: from sqlalchemy.sql.elements import ClauseElement [as 别名]
def _coalesce_sql(x, *args) -> ClauseElement:
    """
    Example:
        >>> print(coalesce(sql.column('a'), sql.column('b')))
        coalesce(a, b)

        >>> coalesce(1, sql.column('a'))
        Traceback (most recent call last):
            ...
        TypeError: ...
    """
    return sql.functions.coalesce(x, *args)


# lead and lag ---------------------------------------------------------------- 
开发者ID:machow,项目名称:siuba,代码行数:17,代码来源:vector.py

示例13: _lead_sql

# 需要导入模块: from sqlalchemy.sql import elements [as 别名]
# 或者: from sqlalchemy.sql.elements import ClauseElement [as 别名]
def _lead_sql(x, n = 1, default = None) -> ClauseElement:
    """
    Example:
        >>> print(lead(sql.column('a'), 2, 99))
        lead(a, :lead_1, :lead_2) OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
    """
    f = win_cumul("lead")
    return f(x, n, default) 
开发者ID:machow,项目名称:siuba,代码行数:10,代码来源:vector.py

示例14: _n_sql

# 需要导入模块: from sqlalchemy.sql import elements [as 别名]
# 或者: from sqlalchemy.sql.elements import ClauseElement [as 别名]
def _n_sql(x) -> ClauseElement:
    """
    Example:
        >>> print(n(sql.column('a')))
        count(*) OVER ()
    """
    return AggOver(sql.func.count()) 
开发者ID:machow,项目名称:siuba,代码行数:9,代码来源:vector.py

示例15: _n_sql_agg

# 需要导入模块: from sqlalchemy.sql import elements [as 别名]
# 或者: from sqlalchemy.sql.elements import ClauseElement [as 别名]
def _n_sql_agg(x) -> ClauseElement:
    """
    Example:
        >>> from siuba.sql.translate import SqlColumnAgg
        >>> print(n(SqlColumnAgg('x')))
        count(*)
    """

    return sql.func.count() 
开发者ID:machow,项目名称:siuba,代码行数:11,代码来源:vector.py


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