summaryrefslogtreecommitdiff
path: root/test/sql
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2020-05-20 13:41:44 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2020-05-21 14:16:03 -0400
commit4550983e0ce2f35b3585e53894c941c23693e71d (patch)
tree3928e6e333c2b9bb6e23a4de079565a387d309ae /test/sql
parent3d55263c92ee29a0257d823124c353a35246cf31 (diff)
downloadsqlalchemy-4550983e0ce2f35b3585e53894c941c23693e71d.tar.gz
Performance fixes for new result set
A few small mistakes led to huge callcounts. Additionally, the warn-on-get behavior which is attempting to warn for deprecated access in SQLAlchemy 2.0 is very expensive; it's not clear if its feasible to have this warning or to somehow alter how it works. Fixes: #5340 Change-Id: I73bdd2d7b6f1b25cc0222accabd585cf761a5af4
Diffstat (limited to 'test/sql')
-rw-r--r--test/sql/test_deprecations.py28
-rw-r--r--test/sql/test_resultset.py12
2 files changed, 22 insertions, 18 deletions
diff --git a/test/sql/test_deprecations.py b/test/sql/test_deprecations.py
index 17f9e1579..578743750 100644
--- a/test/sql/test_deprecations.py
+++ b/test/sql/test_deprecations.py
@@ -1119,20 +1119,20 @@ class CursorResultTest(fixtures.TablesTest):
def test_column_accessor_textual_select(self, connection):
users = self.tables.users
- # this will create column() objects inside
- # the select(), these need to match on name anyway
- r = connection.execute(
- select([column("user_id"), column("user_name")])
- .select_from(table("users"))
- .where(text("user_id=2"))
- ).first()
-
with testing.expect_deprecated(
"Retreiving row values using Column objects "
"with only matching names",
"Using non-integer/slice indices on Row is "
"deprecated and will be removed in version 2.0",
):
+ # this will create column() objects inside
+ # the select(), these need to match on name anyway
+ r = connection.execute(
+ select([column("user_id"), column("user_name")])
+ .select_from(table("users"))
+ .where(text("user_id=2"))
+ ).first()
+
eq_(r[users.c.user_id], 2)
r._keymap.pop(users.c.user_id) # reset lookup
@@ -1151,16 +1151,16 @@ class CursorResultTest(fixtures.TablesTest):
def test_column_accessor_basic_text(self, connection):
users = self.tables.users
- r = connection.execute(
- text("select * from users where user_id=2")
- ).first()
-
with testing.expect_deprecated(
"Using non-integer/slice indices on Row is deprecated "
"and will be removed in version 2.0",
"Retreiving row values using Column objects "
"with only matching names",
):
+ r = connection.execute(
+ text("select * from users where user_id=2")
+ ).first()
+
eq_(r[users.c.user_id], 2)
r._keymap.pop(users.c.user_id)
@@ -1344,24 +1344,24 @@ class CursorResultTest(fixtures.TablesTest):
def test_row_getitem_string(self, connection):
col = literal_column("1").label("foo")
- row = connection.execute(select([col])).first()
with testing.expect_deprecated(
"Using non-integer/slice indices on Row is deprecated "
"and will be removed in version 2.0;"
):
+ row = connection.execute(select([col])).first()
eq_(row["foo"], 1)
eq_(row._mapping["foo"], 1)
def test_row_getitem_column(self, connection):
col = literal_column("1").label("foo")
- row = connection.execute(select([col])).first()
with testing.expect_deprecated(
"Using non-integer/slice indices on Row is deprecated "
"and will be removed in version 2.0;"
):
+ row = connection.execute(select([col])).first()
eq_(row[col], 1)
eq_(row._mapping[col], 1)
diff --git a/test/sql/test_resultset.py b/test/sql/test_resultset.py
index a0c456056..6c83697dc 100644
--- a/test/sql/test_resultset.py
+++ b/test/sql/test_resultset.py
@@ -1246,6 +1246,7 @@ class CursorResultTest(fixtures.TablesTest):
object(),
[None],
{"key": (0, None, "key"), 0: (0, None, "key")},
+ Row._default_key_style,
MyList(["value"]),
)
eq_(list(proxy), ["value"])
@@ -1296,7 +1297,11 @@ class CursorResultTest(fixtures.TablesTest):
def test_row_is_sequence(self):
row = Row(
- object(), [None], {"key": (None, 0), 0: (None, 0)}, ["value"]
+ object(),
+ [None],
+ {"key": (None, 0), 0: (None, 0)},
+ Row._default_key_style,
+ ["value"],
)
is_true(isinstance(row, collections_abc.Sequence))
@@ -1306,6 +1311,7 @@ class CursorResultTest(fixtures.TablesTest):
object(),
[None, None, None],
{"key": (None, 0), 0: (None, 0)},
+ Row._default_key_style,
(1, "value", "foo"),
)
eq_(hash(row), hash((1, "value", "foo")))
@@ -2100,12 +2106,10 @@ class AlternateCursorResultTest(fixtures.TablesTest):
def get_result_cursor_strategy(self, result):
return cls.create(result)
- def get_result_proxy(self):
- raise NotImplementedError()
-
self.patcher = patch.object(
self.engine.dialect, "execution_ctx_cls", ExcCtx
)
+
with self.patcher:
yield