File tree Expand file tree Collapse file tree 1 file changed +4
-17
lines changed
Expand file tree Collapse file tree 1 file changed +4
-17
lines changed Original file line number Diff line number Diff line change 88)
99from sqlalchemy_declarative_extensions .alembic .view import UpdateViewOp
1010from sqlalchemy_declarative_extensions .dialects import postgresql
11+ from sqlalchemy_declarative_extensions .dialects .postgresql import View
1112from sqlalchemy_declarative_extensions .sqlalchemy import declarative_base
1213from sqlalchemy_declarative_extensions .view .compare import compare_views
1314
@@ -47,20 +48,6 @@ def test_escape_bindparam_postgres(pg):
4748
4849 # Make sure that bindparams escaping doesn't create unnecessary escapes
4950 # for the literal casts that appear after view definition round-tripping
50- pg .execute (text ("CREATE VIEW simple_select AS SELECT 'a' as col1" ))
51-
52- @view (Base )
53- class SimpleSelect :
54- __tablename__ = "simple_select"
55- __view__ = r"SELECT 'b' as col1"
56-
57- ops = compare_views (pg .connection (), Base .metadata .info ["views" ])
58- assert len (ops ) == 1
59-
60- create_op = ops [0 ]
61- assert isinstance (create_op , UpdateViewOp )
62-
63- update_statements = "\n " .join (create_op .to_sql (postgresql ))
64-
65- assert "::" in update_statements , "Literals in the view definition are expected to get explicit type casts"
66- assert "\\ :\\ :" not in update_statements , "Bind parameters escaping should leave type casts unescaped"
51+ rendered = View ("simple_select" , "SELECT 'a' as col1" ).render_definition (pg .connection ())
52+ assert "::" in rendered , "Literals in the view definition are expected to get explicit type casts"
53+ assert "\\ :\\ :" not in rendered , "Bind parameters escaping should leave type casts unescaped"
You can’t perform that action at this time.
0 commit comments