本文整理汇总了Python中sqlalchemy.func.foo函数的典型用法代码示例。如果您正苦于以下问题:Python foo函数的具体用法?Python foo怎么用?Python foo使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了foo函数的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_union_label
def test_union_label(self):
s1 = select([func.foo("hoho").label("x")])
s2 = select([func.foo("Bar").label("y")])
stmt = union(s1, s2).order_by("x")
self.assert_compile(
stmt,
"SELECT foo(:foo_1) AS x UNION SELECT foo(:foo_2) AS y ORDER BY x",
)
开发者ID:vrajmohan,项目名称:sqlalchemy,代码行数:8,代码来源:test_text.py
示例2: test_function
def test_function(self):
self.assert_compile(func.foo(1, 2), 'foo(:foo_1, :foo_2)')
self.assert_compile(func.current_time(), 'CURRENT_TIME')
self.assert_compile(func.foo(), 'foo()')
m = MetaData()
t = Table(
'sometable', m, Column('col1', Integer), Column('col2', Integer))
self.assert_compile(select([func.max(t.c.col1)]),
'SELECT max(sometable.col1) AS max_1 FROM '
'sometable')
开发者ID:CyberCollins,项目名称:sqlalchemy,代码行数:10,代码来源:test_compiler.py
示例3: test_function
def test_function(self):
self.assert_compile(func.foo(1, 2), "foo(:foo_1, :foo_2)")
self.assert_compile(func.current_time(), "CURRENT_TIME")
self.assert_compile(func.foo(), "foo()")
m = MetaData()
t = Table(
"sometable", m, Column("col1", Integer), Column("col2", Integer)
)
self.assert_compile(
select([func.max(t.c.col1)]),
"SELECT max(sometable.col1) AS max_1 FROM " "sometable",
)
开发者ID:BY-jk,项目名称:sqlalchemy,代码行数:12,代码来源:test_compiler.py
示例4: test_columnadapter_non_anonymized
def test_columnadapter_non_anonymized(self):
"""test issue #3148
Testing the anonymization applied from the ColumnAdapter.columns
collection, typically as used in eager loading.
"""
exprs = [
table1.c.myid,
table1.c.name.label("t1name"),
func.foo("hoho").label("x"),
]
ta = table1.alias()
adapter = sql_util.ColumnAdapter(ta)
s1 = (
select([adapter.columns[expr] for expr in exprs])
.apply_labels()
.order_by("myid", "t1name", "x")
)
# labels are maintained
self.assert_compile(
s1,
"SELECT mytable_1.myid AS mytable_1_myid, "
"mytable_1.name AS t1name, foo(:foo_1) AS x "
"FROM mytable AS mytable_1 ORDER BY mytable_1.myid, t1name, x",
)
开发者ID:vrajmohan,项目名称:sqlalchemy,代码行数:29,代码来源:test_text.py
示例5: test_columnadapter_anonymized
def test_columnadapter_anonymized(self):
"""test issue #3148
Testing the anonymization applied from the ColumnAdapter.columns
collection, typically as used in eager loading.
"""
exprs = [
table1.c.myid,
table1.c.name.label('t1name'),
func.foo("hoho").label('x')]
ta = table1.alias()
adapter = sql_util.ColumnAdapter(ta, anonymize_labels=True)
s1 = select([adapter.columns[expr] for expr in exprs]).\
apply_labels().order_by("myid", "t1name", "x")
def go():
# the labels here are anonymized, so label naming
# can't catch these.
self.assert_compile(
s1,
"SELECT mytable_1.myid AS mytable_1_myid, "
"mytable_1.name AS name_1, foo(:foo_2) AS foo_1 "
"FROM mytable AS mytable_1 ORDER BY mytable_1.myid, t1name, x"
)
assert_warnings(
go,
["Can't resolve label reference 't1name'",
"Can't resolve label reference 'x'"], regex=True)
开发者ID:cpcloud,项目名称:sqlalchemy,代码行数:32,代码来源:test_text.py
示例6: _join_fixture_o2m_to_annotated_func
def _join_fixture_o2m_to_annotated_func(self, **kw):
return relationships.JoinCondition(
self.left,
self.right,
self.left,
self.right,
primaryjoin=self.left.c.id == foreign(func.foo(self.right.c.lid)),
**kw
)
开发者ID:BY-jk,项目名称:sqlalchemy,代码行数:9,代码来源:test_rel_fn.py
示例7: test_order_by_func_label_desc
def test_order_by_func_label_desc(self):
stmt = select([func.foo('bar').label('fb'), table1]).\
order_by(desc('fb'))
self.assert_compile(
stmt,
"SELECT foo(:foo_1) AS fb, mytable.myid, mytable.name, "
"mytable.description FROM mytable ORDER BY fb DESC"
)
开发者ID:cpcloud,项目名称:sqlalchemy,代码行数:9,代码来源:test_text.py
示例8: _join_fixture_o2m_to_oldstyle_func
def _join_fixture_o2m_to_oldstyle_func(self, **kw):
return relationships.JoinCondition(
self.left,
self.right,
self.left,
self.right,
primaryjoin=self.left.c.id == func.foo(self.right.c.lid),
consider_as_foreign_keys=[self.right.c.lid],
**kw
)
开发者ID:BY-jk,项目名称:sqlalchemy,代码行数:10,代码来源:test_rel_fn.py
示例9: test_exec_options
def test_exec_options(self):
f = func.foo()
eq_(f._execution_options, {})
f = f.execution_options(foo="bar")
eq_(f._execution_options, {"foo": "bar"})
s = f.select()
eq_(s._execution_options, {"foo": "bar"})
ret = testing.db.execute(func.now().execution_options(foo="bar"))
eq_(ret.context.execution_options, {"foo": "bar"})
ret.close()
开发者ID:vrajmohan,项目名称:sqlalchemy,代码行数:12,代码来源:test_functions.py
示例10: test_update_to_expression
def test_update_to_expression(self):
"""test update from an expression.
this logic is triggered currently by a left side that doesn't
have a key. The current supported use case is updating the index
of a PostgreSQL ARRAY type.
"""
table1 = self.tables.mytable
expr = func.foo(table1.c.myid)
eq_(expr.key, None)
self.assert_compile(table1.update().values({expr: 'bar'}),
'UPDATE mytable SET foo(myid)=:param_1')
开发者ID:eoghanmurray,项目名称:sqlalchemy,代码行数:13,代码来源:test_update.py
示例11: test_offset_dont_misapply_labelreference
def test_offset_dont_misapply_labelreference(self):
m = MetaData()
t = Table('t', m, Column('x', Integer))
expr1 = func.foo(t.c.x).label('x')
expr2 = func.foo(t.c.x).label('y')
stmt1 = select([expr1]).order_by(expr1.desc()).offset(1)
stmt2 = select([expr2]).order_by(expr2.desc()).offset(1)
self.assert_compile(
stmt1,
"SELECT anon_1.x FROM (SELECT foo(t.x) AS x, "
"ROW_NUMBER() OVER (ORDER BY foo(t.x) DESC) AS mssql_rn FROM t) "
"AS anon_1 WHERE mssql_rn > :param_1"
)
self.assert_compile(
stmt2,
"SELECT anon_1.y FROM (SELECT foo(t.x) AS y, "
"ROW_NUMBER() OVER (ORDER BY foo(t.x) DESC) AS mssql_rn FROM t) "
"AS anon_1 WHERE mssql_rn > :param_1"
)
开发者ID:biroc,项目名称:sqlalchemy,代码行数:24,代码来源:test_compiler.py
示例12: _join_fixture_o2m_composite_selfref_func_remote_side
def _join_fixture_o2m_composite_selfref_func_remote_side(self, **kw):
return relationships.JoinCondition(
self.composite_selfref,
self.composite_selfref,
self.composite_selfref,
self.composite_selfref,
primaryjoin=and_(
self.composite_selfref.c.group_id ==
func.foo(self.composite_selfref.c.group_id),
self.composite_selfref.c.parent_id ==
self.composite_selfref.c.id
),
remote_side=set([self.composite_selfref.c.parent_id]),
**kw
)
开发者ID:CyberCollins,项目名称:sqlalchemy,代码行数:15,代码来源:test_rel_fn.py
示例13: test_inline_defaults
def test_inline_defaults(self):
m = MetaData()
foo = Table("foo", m, Column("id", Integer))
t = Table(
"test",
m,
Column("col1", Integer, default=func.foo(1)),
Column(
"col2",
Integer,
default=select([func.coalesce(func.max(foo.c.id))]),
),
)
self.assert_compile(
t.insert(inline=True, values={}),
"INSERT INTO test (col1, col2) VALUES (foo(:foo_1), "
"(SELECT coalesce(max(foo.id)) AS coalesce_1 FROM "
"foo))",
)
开发者ID:vrajmohan,项目名称:sqlalchemy,代码行数:21,代码来源:test_insert.py
示例14: test_inline_defaults
def test_inline_defaults(self):
m = MetaData()
foo = Table("foo", m, Column("id", Integer))
t = Table(
"test",
m,
Column("col1", Integer, onupdate=func.foo(1)),
Column(
"col2",
Integer,
onupdate=select([func.coalesce(func.max(foo.c.id))]),
),
Column("col3", String(30)),
)
self.assert_compile(
t.update(inline=True, values={"col3": "foo"}),
"UPDATE test SET col1=foo(:foo_1), col2=(SELECT "
"coalesce(max(foo.id)) AS coalesce_1 FROM foo), "
"col3=:col3",
)
开发者ID:BY-jk,项目名称:sqlalchemy,代码行数:22,代码来源:test_update.py
示例15: value
def value(cls):
"This is a class-level docstring"
return func.foo(cls._value) + cls.bar_value
开发者ID:Dorthu,项目名称:sqlalchemy,代码行数:3,代码来源:test_hybrid.py
示例16: test_use_labels
def test_use_labels(self):
self.assert_compile(select([func.foo()], use_labels=True),
"SELECT foo() AS foo_1"
)
开发者ID:cpcloud,项目名称:sqlalchemy,代码行数:4,代码来源:test_functions.py
示例17: value
def value(cls):
return func.foo(cls._value) + cls.bar_value
开发者ID:sleepsonthefloor,项目名称:sqlalchemy,代码行数:2,代码来源:test_hybrid.py
注:本文中的sqlalchemy.func.foo函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论