Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions core/wren/src/wren/connector/redshift.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ def query(self, sql: str, limit: int | None = None) -> pa.Table:
f"SELECT * FROM ({_strip_trailing_semicolon(sql)}) "
f"AS _q LIMIT {int(limit)}"
)
else:
# Unlimited path also rejects trailing ``;`` for single statements
# depending on driver/session settings — strip for consistency.
sql = _strip_trailing_semicolon(sql)
with closing(self.connection.cursor()) as cursor:
cursor.execute(sql)
cols = [desc[0] for desc in cursor.description]
Expand Down
8 changes: 8 additions & 0 deletions core/wren/tests/unit/test_redshift_semicolon.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,11 @@ def test_helper_preserves_semicolon_inside_string_literal() -> None:

def test_helper_no_trailing_semicolon_unchanged() -> None:
assert _strip_trailing_semicolon("SELECT 1") == "SELECT 1"


def test_query_without_limit_strips_trailing_semicolon() -> None:
connector, cursor = _make_mock_connector()
connector.query("SELECT 1;")
(sent,), _ = cursor.execute.call_args
assert sent == "SELECT 1"
assert not sent.endswith(";")
Loading