Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

bug(arrow-odbc): SQL Server event store index guard never matches

Open Beginner friendly
#816 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
92/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python, sql
Domain
databases

Research direction

Start in sqlspec/adapters/arrow_odbc/events/store.py at the CREATE INDEX regex and inspect the related rendering path. Update the table-name capture so it stops before the column list, then adjust tests/unit/adapters/test_arrow_odbc/test_tsql_stores.py and verify the rendered guard uses OBJECT_ID(N'[dbo]/app_events]').

Written by the indexing model from the issue text.

Description

The SQL Server event queue store in the arrow-odbc adapter wraps CREATE INDEX in an existence check that never matches. The index DDL runs again every time the store's DDL is applied, and fails if the index already exists.

Where

sqlspec/adapters/arrow_odbc/events/store.py: re.search(r"CREATE INDEX\s+(\S+)\s+ON\s+(\S+)", ...)

What happens

For CREATE INDEX idx_app_events_channel_status ON app_events(channel, status, available_at), the second \S+ captures app_events(channel, as the table name. The rendered guard is:

IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'idx_app_events_channel_status'
  AND object_id = OBJECT_ID(N'[dbo].[app_events(channel,]')) BEGIN CREATE INDEX ... END

OBJECT_ID(N'[dbo].[app_events(channel,]') is always NULL, so NOT EXISTS is always true.

Expected

OBJECT_ID(N'[dbo].[app_events]'). Stop the table-name capture at ( or whitespace, for example ON\s+([^\s(]+).

Note

tests/unit/adapters/test_arrow_odbc/test_tsql_stores.py currently asserts the rendered SQL as it is today, including OBJECT_ID(N'[dbo].[app_events(channel,]'). Update that assertion along with the fix.

Dominant language
Python
Stars
102
Forks
9
Avg merge
8h 38m
Merged PRs (30d)
64

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from litestar-org/sqlspec

All issues in litestar-org/sqlspec

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.