MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_platform_escape

Method test_platform_escape

test/engine/test_ddlevents.py:840–866  ·  view source on GitHub ↗

test the escaping of % characters in the DDL construct.

(self)

Source from the content-addressed store, hash-verified

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