MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_hints

Method test_hints

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

Source from the content-addressed store, hash-verified

3717 )
3718
3719 def test_hints(self):
3720 s = select(table1.c.myid).with_hint(table1, "test hint %(name)s")
3721
3722 s2 = (
3723 select(table1.c.myid)
3724 .with_hint(table1, "index(%(name)s idx)", "oracle")
3725 .with_hint(table1, "WITH HINT INDEX idx", "mssql")
3726 )
3727
3728 a1 = table1.alias()
3729 s3 = select(a1.c.myid).with_hint(a1, "index(%(name)s hint)")
3730
3731 subs4 = (
3732 select(table1, table2)
3733 .select_from(
3734 table1.join(table2, table1.c.myid == table2.c.otherid)
3735 )
3736 .with_hint(table1, "hint1")
3737 ).subquery()
3738
3739 s4 = (
3740 select(table3)
3741 .select_from(
3742 table3.join(subs4, subs4.c.othername == table3.c.otherstuff)
3743 )
3744 .with_hint(table3, "hint3")
3745 )
3746
3747 t1 = table("QuotedName", column("col1"))
3748 s6 = (
3749 select(t1.c.col1)
3750 .where(t1.c.col1 > 10)
3751 .with_hint(t1, "%(name)s idx1")
3752 )
3753 a2 = t1.alias("SomeName")
3754 s7 = (
3755 select(a2.c.col1)
3756 .where(a2.c.col1 > 10)
3757 .with_hint(a2, "%(name)s idx1")
3758 )
3759
3760 mysql_d, oracle_d, mssql_d = (
3761 mysql.dialect(),
3762 oracle.dialect(),
3763 mssql.dialect(),
3764 )
3765
3766 for stmt, dialect, expected in [
3767 (s, mysql_d, "SELECT mytable.myid FROM mytable test hint mytable"),
3768 (
3769 s,
3770 oracle_d,
3771 "SELECT /*+ test hint mytable */ mytable.myid FROM mytable",
3772 ),
3773 (
3774 s,
3775 mssql_d,
3776 "SELECT mytable.myid FROM mytable test hint mytable",

Callers

nothing calls this directly

Calls 11

selectFunction · 0.90
tableFunction · 0.90
columnFunction · 0.90
assert_compileMethod · 0.80
with_hintMethod · 0.45
aliasMethod · 0.45
subqueryMethod · 0.45
select_fromMethod · 0.45
joinMethod · 0.45
whereMethod · 0.45
dialectMethod · 0.45

Tested by

no test coverage detected