Skip to content

Commit eddf374

Browse files
Fixed bug determining bind variables when found between two comment blocks
(#105).
1 parent 433391b commit eddf374

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

doc/src/release_notes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ Thin Mode Changes
1717
INTO keywords are not separated by spaces, but are separated by other
1818
whitespace characters
1919
(`issue 104 <https://github.com/oracle/python-oracledb/issues/104>`__).
20+
#) Fixed bug determining bind variables when found between two comment blocks
21+
(`issue 105 <https://github.com/oracle/python-oracledb/issues/105>`__).
2022

2123
Thick Mode Changes
2224
++++++++++++++++++

src/oracledb/impl/thin/statement.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ cdef class Statement:
183183

184184
# Strip single/multiline comments and strings from the sql statement to
185185
# ease searching for bind variables.
186-
sql = re.sub(r"/\*[\S\n ]+\*/", "", sql)
186+
sql = re.sub(r"/\*[\S\n ]+?\*/", "", sql)
187187
sql = re.sub(r"\--.*(\n|$)", "", sql)
188188
sql = re.sub(r"""'[^']*'(?=(?:[^']*[^']*')*[^']*$)*""", "", sql,
189189
flags=re.MULTILINE)

tests/test_4300_cursor_other.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -814,6 +814,17 @@ def test_4363_multiple_parse(self):
814814
self.cursor.parse(sql)
815815
self.cursor.execute(sql, ("Updated value", data[0]))
816816

817+
def test_4364_binds_between_comment_blocks(self):
818+
"4364 - test bindnames() for bind variables between comment blocks"
819+
self.cursor.prepare("""
820+
select
821+
/* comment 1 */
822+
:a,
823+
/* comment 2 */
824+
:b
825+
/* comment 3 */
826+
from dual""")
827+
self.assertEqual(self.cursor.bindnames(), ["A", "B"])
817828

818829
if __name__ == "__main__":
819830
test_env.run_test_cases()

0 commit comments

Comments
 (0)