test the escaping of % characters in the DDL construct.
(self)
| 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 | |
| 869 | class DDLTransactionTest(fixtures.TestBase): |