Skip to content

Commit e1b206f

Browse files
Fixed bug determining RETURNING binds in a SQL statement when RETURNING
and INTO keywords are not separated by whitespace, but are separated by parentheses.
1 parent ce6373b commit e1b206f

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

doc/src/release_notes.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ Thin Mode Changes
4646
potentially exceed the 32767 byte limit but the actual value bound does not
4747
(`issue 146 <https://github.com/oracle/python-oracledb/issues/146>`__).
4848
#) Fixed bug connecting to an IPv6 address with IAM tokens.
49+
#) Fixed bug determining RETURNING binds in a SQL statement when RETURNING and
50+
INTO keywords are not separated by whitespace, but are separated by
51+
parentheses.
4952
#) Internal implementation changes:
5053

5154
- Added internal support for prefetching the LOB size and chunk size,

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)([)\s]RETURNING\s+[\s\S]+\s+INTO\s+)(.*?$)'
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: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,5 +424,14 @@ def test_1621_plsql_returning_rowids_with_index_organized_table(self):
424424
row, = self.cursor.fetchall()
425425
self.assertEqual(data[:3], row)
426426

427+
def test_1622_parse_returning_clause_without_spaces(self):
428+
"1622 - parse DML returning with no spaces"
429+
self.cursor.execute("truncate table TestTempTable")
430+
sql = 'insert into TestTempTable (IntCol) values (:in_val)' + \
431+
'returning(IntCol)into :out_val'
432+
out_val = self.cursor.var(int, arraysize=5)
433+
self.cursor.execute(sql, in_val=25, out_val=out_val)
434+
self.assertEqual(out_val.getvalue(), [25])
435+
427436
if __name__ == "__main__":
428437
test_env.run_test_cases()

0 commit comments

Comments
 (0)