MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_use_labels

Method test_use_labels

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

Source from the content-addressed store, hash-verified

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