Skip to content

Commit 2373270

Browse files
Fixed bug determining RETURNING binds in a SQL statement when RETURNING
and INTO keywords are not separated by spaces, but are separated by other whitespace characters (#104).
1 parent 5e23347 commit 2373270

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

doc/src/release_notes.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@ For deprecations, see :ref:`Deprecations <deprecations>`.
1010
oracledb 1.2.1 (TBD)
1111
--------------------
1212

13+
Thin Mode Changes
14+
+++++++++++++++++
15+
16+
#) Fixed bug determining RETURNING binds in a SQL statement when RETURNING and
17+
INTO keywords are not separated by spaces, but are separated by other
18+
whitespace characters
19+
(`issue 104 <https://github.com/oracle/python-oracledb/issues/104>`__).
20+
1321
Thick Mode Changes
1422
++++++++++++++++++
1523

src/oracledb/impl/thin/statement.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ BIND_PATTERN = r'(?<!"\:)(?<=\:)\s*("[^\"]*"|[^\W\d_][\w\$#]*|\d+)'
4343
# pattern used for detecting a DML returning clause; bind variables in the
4444
# first group are input variables; bind variables in the second group are
4545
# output only variables
46-
DML_RETURNING_PATTERN = r'(?si)( RETURNING [\s\S]+ INTO )(.*?$)'
46+
DML_RETURNING_PATTERN = r'(?si)(\s+RETURNING\s+[\s\S]+\s+INTO\s+)(.*?$)'
4747

4848
cdef class BindInfo:
4949

tests/test_1600_dml_returning.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -399,9 +399,9 @@ def test_1620_dml_returning_with_index_organized_table(self):
399399
self.cursor.execute("truncate table TestUniversalRowids")
400400
rowid_var = self.cursor.var(oracledb.ROWID)
401401
data = (1, "ABC", datetime.datetime(2017, 4, 11), rowid_var)
402-
self.cursor.execute("""
403-
insert into TestUniversalRowids values (:1, :2, :3)
404-
returning rowid into :4""", data)
402+
sql = "insert into TestUniversalRowids values (:1, :2, :3)\n" + \
403+
"returning rowid into :4"
404+
self.cursor.execute(sql, data)
405405
rowid_value, = rowid_var.getvalue()
406406
self.cursor.execute("""
407407
select * from TestUniversalRowids where rowid = :1""",

0 commit comments

Comments
 (0)