Skip to content

SqliteVec: support per-connection initialization callbacks - #81

Merged
adamsitnik merged 3 commits into
CommunityToolkit:mainfrom
rossdonald:sqlitevec-connection-callback
Nov 3, 2026
Merged

adamsitnik merged 3 commits into
CommunityToolkit:mainfrom
rossdonald:sqlitevec-connection-callback

Conversation

@rossdonald

Copy link
Copy Markdown
Contributor

Add an opt-in connection initialization callback to SqliteVectorStoreOptions and SqliteCollectionOptions. If defined, the connector invokes it right after it opens a connection and loads the vec0 extension allowing per-connection options to be set.

Fixes #73

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The store-level path runs the initializer before loading sqlite-vec, causing ListCollectionNamesAsync to fail with pooling disabled when the initializer calls vec_version().

1 open issue
What changed in this PR

Adds opt-in per-connection initialization to SqliteVec, enabling consumers to configure PRAGMAs and other connection settings as requested in #73.

Changes:

  • Adds initializer callbacks to store and collection options, including propagation to store-created collections.
  • Centralizes connection setup and disposal when initialization fails.
  • Adds callback coverage and bumps the provider version to 1.0.4-preview.
File Description
MEVD/​test/​SqliteVec.ConformanceTests/​SqliteConnectionInitializerTests.cs Tests invocation, propagation, extension ordering, and failure cleanup.
MEVD/​src/​SqliteVec/​SqliteVectorStoreOptions.cs Adds and documents the store-level callback.
MEVD/​src/​SqliteVec/​SqliteVectorStore.cs Propagates callbacks and uses shared connection setup.
MEVD/​src/​SqliteVec/​SqliteVec.csproj Updates the provider package version.
MEVD/​src/​SqliteVec/​SqliteConnectionFactory.cs Centralizes connection opening, initialization, and failure cleanup.
MEVD/​src/​SqliteVec/​SqliteCollectionOptions.cs Adds and documents the collection-level callback.
MEVD/​src/​SqliteVec/​SqliteCollection.cs Routes collection connections through the shared factory.

Review effort: Balanced

Comment thread MEVD/src/SqliteVec/SqliteVectorStore.cs Resolved

@adamsitnik adamsitnik left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rossdonald big thanks for your contribution!

The changes look good, but I think we should rename the callback and make it async, so we don't call sync code from async method. PTAL at my comments.

Similar public API exposed by BCL: https://learn.microsoft.com/en-us/dotnet/api/system.net.http.socketshttphandler.connectcallback?view=net-10.0

@adamsitnik adamsitnik left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall it LGTM, we just need to polish the tests a bit. Thank you for another great contribution @rossdonald !

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Async callbacks without await trigger CS1998 warnings, which are treated as errors and block the conformance test build.

1 open issue
1 resolved since last review

Review effort: Balanced

@adamsitnik adamsitnik left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks a lot @rossdonald !

@adamsitnik
adamsitnik merged commit 0a2537f into CommunityToolkit:main Nov 3, 2026
18 checks passed
@adamsitnik

Copy link
Copy Markdown
Contributor
image
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

4 participants