MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_naming

Method test_naming

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

Source from the content-addressed store, hash-verified

3626 self.assert_compile(sel3, "(SELECT foo)")
3627
3628 def test_naming(self):
3629 # TODO: the part where we check c.keys() are not "compile" tests, they
3630 # belong probably in test_selectable, or some broken up
3631 # version of that suite
3632
3633 f1 = func.hoho(table1.c.name)
3634 s1 = select(
3635 table1.c.myid,
3636 table1.c.myid.label("foobar"),
3637 f1,
3638 func.lala(table1.c.name).label("gg"),
3639 )
3640
3641 eq_(list(s1.subquery().c.keys()), ["myid", "foobar", "hoho", "gg"])
3642
3643 meta = MetaData()
3644 t1 = Table("mytable", meta, Column("col1", Integer))
3645
3646 exprs = (
3647 table1.c.myid == 12,
3648 func.hoho(table1.c.myid),
3649 cast(table1.c.name, Numeric),
3650 literal("x"),
3651 )
3652 for col, key, expr, lbl in (
3653 (table1.c.name, "name", "mytable.name", None),
3654 (
3655 exprs[0],
3656 "_no_label",
3657 "mytable.myid = :myid_1",
3658 "anon_1",
3659 ),
3660 (exprs[1], "hoho", "hoho(mytable.myid)", "hoho_1"),
3661 (
3662 exprs[2],
3663 "name",
3664 "CAST(mytable.name AS NUMERIC)",
3665 "name", # due to [ticket:4449]
3666 ),
3667 (t1.c.col1, "col1", "mytable.col1", None),
3668 (
3669 column("some wacky thing"),
3670 "some wacky thing",
3671 '"some wacky thing"',
3672 "",
3673 ),
3674 (
3675 exprs[3],
3676 "_no_label",
3677 ":param_1",
3678 "anon_1",
3679 ),
3680 ):
3681 if getattr(col, "table", None) is not None:
3682 t = col.table
3683 else:
3684 t = table1
3685

Callers

nothing calls this directly

Calls 13

selectFunction · 0.90
eq_Function · 0.90
MetaDataClass · 0.90
TableClass · 0.90
ColumnClass · 0.90
castFunction · 0.90
literalFunction · 0.90
columnFunction · 0.90
assert_compileMethod · 0.80
labelMethod · 0.45
keysMethod · 0.45
subqueryMethod · 0.45

Tested by

no test coverage detected