MCPcopy Create free account
hub / github.com/sqlalchemy/sqlalchemy / test_use_labels

Method test_use_labels

test/sql/test_compiler.py:744–775  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

742 )
743
744 def test_use_labels(self):
745 self.assert_compile(
746 select(table1.c.myid == 5).set_label_style(
747 LABEL_STYLE_TABLENAME_PLUS_COL
748 ),
749 "SELECT mytable.myid = :myid_1 AS anon_1 FROM mytable",
750 )
751
752 self.assert_compile(
753 select(func.foo()).set_label_style(LABEL_STYLE_TABLENAME_PLUS_COL),
754 "SELECT foo() AS foo_1",
755 )
756
757 # this is native_boolean=False for default dialect
758 self.assert_compile(
759 select(not_(True)).set_label_style(LABEL_STYLE_TABLENAME_PLUS_COL),
760 "SELECT :param_1 = 0 AS anon_1",
761 )
762
763 self.assert_compile(
764 select(cast("data", Integer)).set_label_style(
765 LABEL_STYLE_TABLENAME_PLUS_COL
766 ),
767 "SELECT CAST(:param_1 AS INTEGER) AS anon_1",
768 )
769
770 self.assert_compile(
771 select(
772 func.sum(func.lala(table1.c.myid).label("foo")).label("bar")
773 ),
774 "SELECT sum(lala(mytable.myid)) AS bar FROM mytable",
775 )
776
777 def test_use_labels_keyed(self):
778 self.assert_compile(

Callers

nothing calls this directly

Calls 8

selectFunction · 0.90
not_Function · 0.90
castFunction · 0.90
assert_compileMethod · 0.80
set_label_styleMethod · 0.45
fooMethod · 0.45
labelMethod · 0.45
sumMethod · 0.45

Tested by

no test coverage detected