Skip to content

Commit 23af6a7

Browse files
Fixed bug when using a "select * from table" query and columns are added
to the table (#125).
1 parent 7076712 commit 23af6a7

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

doc/src/release_notes.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ Thin Mode Changes
2020
(`issue 119 <https://github.com/oracle/python-oracledb/issues/119>`__).
2121
#) Fixed bug when getting a record type based on a table (%ROWTYPE)
2222
(`issue 123 <https://github.com/oracle/python-oracledb/issues/123>`__).
23+
#) Fixed bug when using a `select * from table` query and columns are added to
24+
the table
25+
(`issue 125 <https://github.com/oracle/python-oracledb/issues/125>`__).
2326

2427
Thick Mode Changes
2528
++++++++++++++++++

src/oracledb/impl/thin/messages.pyx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -716,7 +716,8 @@ cdef class MessageWithData(Message):
716716
conn = self.cursor.connection
717717
for i in range(cursor_impl._num_columns):
718718
fetch_info = self._process_column_info(buf, cursor_impl)
719-
if prev_fetch_var_impls is not None:
719+
if prev_fetch_var_impls is not None \
720+
and i < len(prev_fetch_var_impls):
720721
self._adjust_fetch_info(prev_fetch_var_impls[i], fetch_info)
721722
cursor_impl._create_fetch_var(conn, self.cursor, type_handler, i,
722723
fetch_info)

tests/test_4300_cursor_other.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#------------------------------------------------------------------------------
2-
# Copyright (c) 2020, 2022, Oracle and/or its affiliates.
2+
# Copyright (c) 2020, 2023, Oracle and/or its affiliates.
33
#
44
# This software is dual-licensed to you under the Universal Permissive License
55
# (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License
@@ -826,5 +826,24 @@ def test_4364_binds_between_comment_blocks(self):
826826
from dual""")
827827
self.assertEqual(self.cursor.bindnames(), ["A", "B"])
828828

829+
def test_4365_add_column_to_cached_query(self):
830+
"4365 - test addition of column to cached query"
831+
table_name = "test_4365"
832+
try:
833+
self.cursor.execute(f"drop table {table_name}")
834+
except:
835+
pass
836+
data = ('val 1', 'val 2')
837+
self.cursor.execute(f"create table {table_name} (col1 varchar2(10))")
838+
self.cursor.execute(f"insert into {table_name} values (:1)", [data[0]])
839+
self.connection.commit()
840+
self.cursor.execute(f"select * from {table_name}")
841+
self.assertEqual(self.cursor.fetchall(), [(data[0],)])
842+
self.cursor.execute(f"alter table {table_name} add col2 varchar2(10)")
843+
self.cursor.execute(f"update {table_name} set col2 = :1", [data[1]])
844+
self.connection.commit()
845+
self.cursor.execute(f"select * from {table_name}")
846+
self.assertEqual(self.cursor.fetchall(), [data])
847+
829848
if __name__ == "__main__":
830849
test_env.run_test_cases()

0 commit comments

Comments
 (0)