MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_warn_dml

Method test_warn_dml

test/sql/test_from_linter.py:525–554  ·  view source on GitHub ↗
(self, dml, twotable, error)

Source from the content-addressed store, hash-verified

523 (False, False), (True, False), (True, True), argnames="twotable,error"
524 )
525 def test_warn_dml(self, dml, twotable, error):
526 a, b = self.tables("table_a", "table_b")
527
528 if dml.update:
529 stmt = update(a).values(col_a=5)
530 elif dml.delete:
531 stmt = delete(a)
532 else:
533 dml.fail()
534
535 stmt = stmt.where(a.c.col_a == 1)
536 if twotable:
537 stmt = stmt.where(b.c.col_b == 1)
538
539 if not error:
540 stmt = stmt.where(b.c.col_b == a.c.col_a)
541
542 stmt_type = "UPDATE" if dml.update else "DELETE"
543
544 with self.bind.connect() as conn:
545 if error:
546 with expect_warnings(
547 rf"{stmt_type} statement has a cartesian product between "
548 rf'FROM element\(s\) "table_[ab]" and FROM '
549 rf'element "table_[ab]"'
550 ):
551 with self.bind.connect() as conn:
552 conn.execute(stmt)
553 else:
554 conn.execute(stmt)
555
556 def test_no_linting(self, metadata, connection):
557 eng = engines.testing_engine(

Callers

nothing calls this directly

Calls 8

updateFunction · 0.90
deleteFunction · 0.90
expect_warningsFunction · 0.90
valuesMethod · 0.45
failMethod · 0.45
whereMethod · 0.45
connectMethod · 0.45
executeMethod · 0.45

Tested by

no test coverage detected