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

Method test_platform_escape

test/engine/test_ddlevents.py:834–860  ·  view source on GitHub ↗

test the escaping of % characters in the DDL construct.

(self)

Source from the content-addressed store, hash-verified

832 eq_(list(r), [(1,)])
833
834 def test_platform_escape(self):
835 """test the escaping of % characters in the DDL construct."""
836
837 default_from = testing.db.dialect.statement_compiler(
838 testing.db.dialect, None
839 ).default_from()
840
841 # We're abusing the DDL()
842 # construct here by pushing a SELECT through it
843 # so that we can verify the round trip.
844 # the DDL() will trigger autocommit, which prohibits
845 # some DBAPIs from returning results (pyodbc), so we
846 # run in an explicit transaction.
847 with testing.db.begin() as conn:
848 eq_(
849 conn.execute(
850 text("select 'foo%something'" + default_from)
851 ).scalar(),
852 "foo%something",
853 )
854
855 eq_(
856 conn.execute(
857 DDL("select 'foo%%something'" + default_from)
858 ).scalar(),
859 "foo%something",
860 )
861
862
863class DDLTransactionTest(fixtures.TestBase):

Callers

nothing calls this directly

Calls 7

eq_Function · 0.90
textFunction · 0.90
DDLClass · 0.85
default_fromMethod · 0.45
beginMethod · 0.45
scalarMethod · 0.45
executeMethod · 0.45

Tested by

no test coverage detected