summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/testing
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2022-12-02 17:00:10 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2022-12-02 18:31:36 -0500
commit96db7cdd53ee9004be66545989b4ac5632bb7ccf (patch)
tree92f3947dd30a15d2dcb3931da7606ab7a08806a7 /lib/sqlalchemy/testing
parent7a5a4c14545f4d86d9fb49a2ef50c74119e919d3 (diff)
downloadsqlalchemy-96db7cdd53ee9004be66545989b4ac5632bb7ccf.tar.gz
add spaces, leading underscore to oracle checks
Expand the test suite from #8708 which unfortunately did not exercise the bound parameter codepaths completely. Continued fixes for Oracle fix :ticket:`8708` released in 1.4.43 where bound parameter names that start with underscores, which are disallowed by Oracle, were still not being properly escaped in all circumstances. Fixes: #8708 Change-Id: Ic389c09bd7c53b773e5de35f1a18ef20769b92a7
Diffstat (limited to 'lib/sqlalchemy/testing')
-rw-r--r--lib/sqlalchemy/testing/suite/test_dialect.py66
1 files changed, 63 insertions, 3 deletions
diff --git a/lib/sqlalchemy/testing/suite/test_dialect.py b/lib/sqlalchemy/testing/suite/test_dialect.py
index 01cec1fb0..945edef85 100644
--- a/lib/sqlalchemy/testing/suite/test_dialect.py
+++ b/lib/sqlalchemy/testing/suite/test_dialect.py
@@ -370,7 +370,7 @@ class FutureWeCanSetDefaultSchemaWEventsTest(
class DifficultParametersTest(fixtures.TestBase):
__backend__ = True
- @testing.combinations(
+ tough_parameters = testing.combinations(
("boring",),
("per cent",),
("per % cent",),
@@ -381,14 +381,26 @@ class DifficultParametersTest(fixtures.TestBase):
("_starts_with_underscore",),
("dot.s",),
("more :: %colons%",),
+ ("_name",),
+ ("___name",),
+ ("[BracketsAndCase]",),
+ ("42numbers",),
+ ("percent%signs",),
+ ("has spaces",),
("/slashes/",),
("more/slashes",),
("q?marks",),
("1param",),
("1col:on",),
- argnames="name",
+ argnames="paramname",
)
- def test_round_trip(self, name, connection, metadata):
+
+ @tough_parameters
+ def test_round_trip_same_named_column(
+ self, paramname, connection, metadata
+ ):
+ name = paramname
+
t = Table(
"t",
metadata,
@@ -422,6 +434,54 @@ class DifficultParametersTest(fixtures.TestBase):
row = connection.execute(stmt).first()
+ @testing.fixture
+ def multirow_fixture(self, metadata, connection):
+ mytable = Table(
+ "mytable",
+ metadata,
+ Column("myid", Integer),
+ Column("name", String(50)),
+ Column("desc", String(50)),
+ )
+
+ mytable.create(connection)
+
+ connection.execute(
+ mytable.insert(),
+ [
+ {"myid": 1, "name": "a", "desc": "a_desc"},
+ {"myid": 2, "name": "b", "desc": "b_desc"},
+ {"myid": 3, "name": "c", "desc": "c_desc"},
+ {"myid": 4, "name": "d", "desc": "d_desc"},
+ ],
+ )
+ yield mytable
+
+ @tough_parameters
+ def test_standalone_bindparam_escape(
+ self, paramname, connection, multirow_fixture
+ ):
+ tbl1 = multirow_fixture
+ stmt = select(tbl1.c.myid).where(
+ tbl1.c.name == bindparam(paramname, value="x")
+ )
+ res = connection.scalar(stmt, {paramname: "c"})
+ eq_(res, 3)
+
+ @tough_parameters
+ def test_standalone_bindparam_escape_expanding(
+ self, paramname, connection, multirow_fixture
+ ):
+ tbl1 = multirow_fixture
+ stmt = (
+ select(tbl1.c.myid)
+ .where(tbl1.c.name.in_(bindparam(paramname, value=["a", "b"])))
+ .order_by(tbl1.c.myid)
+ )
+
+ res = connection.scalars(stmt, {paramname: ["d", "a"]}).all()
+ eq_(res, [1, 4])
+
class ReturningGuardsTest(fixtures.TablesTest):
"""test that the various 'returning' flags are set appropriately"""