summaryrefslogtreecommitdiff
path: root/test/sql/test_text.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2020-09-05 19:45:04 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2020-09-06 09:55:27 -0400
commitb0e9083eb2a786670a1a129d7968d768d1c4ab42 (patch)
treee13e21eb1743258c8a376ab8c816f998bab0abb8 /test/sql/test_text.py
parentfc612d17145453ad95e5f9ba6a40ba70d2f507c3 (diff)
downloadsqlalchemy-b0e9083eb2a786670a1a129d7968d768d1c4ab42.tar.gz
Don't rely on string col name in adapt_to_context
fixed an issue where even though the method claims to be matching up columns positionally, it was failing on that by looking in "keymap" based on string name. Adds a new member to the _keymap recs MD_RESULT_MAP_INDEX so that we can efficiently link from the generated keymap back to the compiled._result_columns structure without any ambiguity. Fixes: #5559 Change-Id: Ie2fa9165c16625ef860ffac1190e00575e96761f
Diffstat (limited to 'test/sql/test_text.py')
-rw-r--r--test/sql/test_text.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/test/sql/test_text.py b/test/sql/test_text.py
index 1a7ee6f34..9d5ab65ed 100644
--- a/test/sql/test_text.py
+++ b/test/sql/test_text.py
@@ -435,6 +435,8 @@ class AsFromTest(fixtures.TestBase, AssertsCompiledSQL):
column("id", Integer), column("name")
)
+ col_pos = {col.name: idx for idx, col in enumerate(t.selected_columns)}
+
compiled = t.compile()
eq_(
compiled._create_result_map(),
@@ -443,11 +445,13 @@ class AsFromTest(fixtures.TestBase, AssertsCompiledSQL):
"id",
(t.selected_columns.id, "id", "id", "id"),
t.selected_columns.id.type,
+ col_pos["id"],
),
"name": (
"name",
(t.selected_columns.name, "name", "name", "name"),
t.selected_columns.name.type,
+ col_pos["name"],
),
},
)
@@ -455,6 +459,8 @@ class AsFromTest(fixtures.TestBase, AssertsCompiledSQL):
def test_basic_toplevel_resultmap(self):
t = text("select id, name from user").columns(id=Integer, name=String)
+ col_pos = {col.name: idx for idx, col in enumerate(t.selected_columns)}
+
compiled = t.compile()
eq_(
compiled._create_result_map(),
@@ -463,11 +469,13 @@ class AsFromTest(fixtures.TestBase, AssertsCompiledSQL):
"id",
(t.selected_columns.id, "id", "id", "id"),
t.selected_columns.id.type,
+ col_pos["id"],
),
"name": (
"name",
(t.selected_columns.name, "name", "name", "name"),
t.selected_columns.name.type,
+ col_pos["name"],
),
},
)
@@ -490,6 +498,7 @@ class AsFromTest(fixtures.TestBase, AssertsCompiledSQL):
"myid",
(table1.c.myid, "myid", "myid", "mytable_myid"),
table1.c.myid.type,
+ 0,
)
},
)