Fixed bug in identifying bind variables in SQL statements containing

multiple line comments with multiple asterisks before the closing slash.
This commit is contained in:
Anthony Tuininga 2023-11-21 16:42:20 -07:00
parent 5250faee6f
commit ddfa64e3fe
3 changed files with 12 additions and 1 deletions

View File

@ -19,6 +19,8 @@ Thin Mode Changes
lists in full connect descriptors.
#) Fixed bug in handling database response in certain unusual circumstances.
#) Fixed bug in handling exceptions raised during connection establishment.
#) Fixed bug in identifying bind variables in SQL statements containing
multiple line comments with multiple asterisks before the closing slash.
Thick Mode Changes
++++++++++++++++++

View File

@ -131,7 +131,7 @@ cdef class Parser:
if ch != '*':
break
in_comment = True
elif not exiting_comment and ch == '*':
elif ch == '*':
exiting_comment = True
elif exiting_comment:
if ch == '/':

View File

@ -180,6 +180,15 @@ class TestCase(test_env.BaseTestCase):
)
self.assertEqual(self.cursor.bindnames(), ["BV1", "BV2", "BV3", "BV4"])
def test_5213_multiple_line_comment_multiple_asterisks(self):
"5213 - multiple line comment with multiple asterisks"
self.cursor.prepare(
"/****--select * from :a where :a = 1\n"
"select * from table_names where :a = 1****/\n"
"select :table_name, :value from dual"
)
self.assertEqual(self.cursor.bindnames(), ["TABLE_NAME", "VALUE"])
if __name__ == "__main__":
test_env.run_test_cases()