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

Method test_hints

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

Source from the content-addressed store, hash-verified

3512 )
3513
3514 def test_hints(self):
3515 s = select(table1.c.myid).with_hint(table1, "test hint %(name)s")
3516
3517 s2 = (
3518 select(table1.c.myid)
3519 .with_hint(table1, "index(%(name)s idx)", "oracle")
3520 .with_hint(table1, "WITH HINT INDEX idx", "mssql")
3521 )
3522
3523 a1 = table1.alias()
3524 s3 = select(a1.c.myid).with_hint(a1, "index(%(name)s hint)")
3525
3526 subs4 = (
3527 select(table1, table2)
3528 .select_from(
3529 table1.join(table2, table1.c.myid == table2.c.otherid)
3530 )
3531 .with_hint(table1, "hint1")
3532 ).subquery()
3533
3534 s4 = (
3535 select(table3)
3536 .select_from(
3537 table3.join(subs4, subs4.c.othername == table3.c.otherstuff)
3538 )
3539 .with_hint(table3, "hint3")
3540 )
3541
3542 t1 = table("QuotedName", column("col1"))
3543 s6 = (
3544 select(t1.c.col1)
3545 .where(t1.c.col1 > 10)
3546 .with_hint(t1, "%(name)s idx1")
3547 )
3548 a2 = t1.alias("SomeName")
3549 s7 = (
3550 select(a2.c.col1)
3551 .where(a2.c.col1 > 10)
3552 .with_hint(a2, "%(name)s idx1")
3553 )
3554
3555 mysql_d, oracle_d, mssql_d = (
3556 mysql.dialect(),
3557 oracle.dialect(),
3558 mssql.dialect(),
3559 )
3560
3561 for stmt, dialect, expected in [
3562 (s, mysql_d, "SELECT mytable.myid FROM mytable test hint mytable"),
3563 (
3564 s,
3565 oracle_d,
3566 "SELECT /*+ test hint mytable */ mytable.myid FROM mytable",
3567 ),
3568 (
3569 s,
3570 mssql_d,
3571 "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