Skip to content

fix: avoid duplicating trailing semicolons in executemany - #2854

Open
BlocksecPHD wants to merge 1 commit into
snowflakedb:mainfrom
BlocksecPHD:fix/executemany-trailing-semicolon-2853
Open

fix: avoid duplicating trailing semicolons in executemany#2854
BlocksecPHD wants to merge 1 commit into
snowflakedb:mainfrom
BlocksecPHD:fix/executemany-trailing-semicolon-2853

Conversation

@BlocksecPHD

Copy link
Copy Markdown

Fixes #2853

Pre-review checklist

  • I am adding a new automated test(s) to verify correctness of my new code
  • I am adding new logging messages
  • I am adding a new telemetry message
  • I am modifying authorization mechanisms
  • I am adding new credentials
  • I am modifying OCSP code
  • I am adding a new dependency

Summary

This fixes the executemany(..., num_statements=...) semicolon handling in both sync and async cursors.

The current code uses re.search(";/s*$", command), which never matches trailing whitespace after a semicolon because /s is treated literally instead of as \\s. As a result, commands that already end with ; can still receive an extra ; during multi-statement concatenation.

This change replaces that check with not command.endswith(";"). executemany already normalizes the command with command.strip(" \\t\\n\\r") before this branch, so endswith(";") correctly handles the intended trailing-whitespace cases without regex.

Tests

  • python3 -m pytest test/unit/test_cursor.py test/unit/aio/test_cursor_async_unit.py -k trailing_semicolon -q

@BlocksecPHD
BlocksecPHD requested a review from a team as a code owner April 15, 2026 00:39
@github-actions

Copy link
Copy Markdown


Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.


I have read the CLA Document and I hereby sign the CLA


Funan Zhou seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

@sfc-gh-turbaszek sfc-gh-turbaszek added the cla check pending The contributor needs to sign Snowflake CLA label May 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla check pending The contributor needs to sign Snowflake CLA

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SNOW-3379021: Mistaken regex in cursor.py

2 participants