Skip to content

feat: add SQLite ORM backend via ncruces/go-sqlite3#278

Merged
medcl merged 17 commits into
mainfrom
copilot/add-sqlite3-backend-support
Jun 1, 2026
Merged

feat: add SQLite ORM backend via ncruces/go-sqlite3#278
medcl merged 17 commits into
mainfrom
copilot/add-sqlite3-backend-support

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 18, 2026

BatchMutateAPI was part of the ORM surface but was not covered by interface-level tests. This change adds explicit guards so DeleteByQuery remains part of the contract with the expected signature.

  • Contract coverage

    • add a test asserting ORM continues to embed BatchMutateAPI
    • prevent accidental interface drift when composing the top-level ORM API
  • Batch mutate API coverage

    • add a test asserting BatchMutateAPI exposes DeleteByQuery
    • verify the full method shape:
      • inputs: *Context, *QueryBuilder
      • outputs: *DeleteByQueryResponse, error
  • Why this matters

    • catches silent breaking changes to the batch mutation contract
    • makes the DeleteByQuery API an explicit, enforced part of the public ORM surface
batchMutateType := reflect.TypeOf((*BatchMutateAPI)(nil)).Elem()
method, ok := batchMutateType.MethodByName("DeleteByQuery")

Copilot AI and others added 2 commits April 18, 2026 05:13
Implement a lightweight SQLite-based ORM storage backend as an
alternative to the existing Elasticsearch backend. The new module
follows the same orm.ORM interface pattern and is registered via
orm.Register("sqlite", handler).

Key features:
- JSON document storage with SQLite json_extract for queries
- Full ORM interface: CRUD, Search, SearchV2, DeleteByQuery
- QueryBuilder to SQL WHERE clause translation
- WAL mode for concurrent read performance
- Comprehensive test coverage (17 tests)

Agent-Logs-Url: https://github.com/infinilabs/framework/sessions/c7adba2d-c701-4bd0-9c10-ec59d79b4ae0

Co-authored-by: medcl <64487+medcl@users.noreply.github.com>
- Remove redundant variable assignment in RegisterSchemaWithName
- Fix Search and SearchWithResultItemMapper to return correct total
  count via separate COUNT query instead of counting fetched rows

Agent-Logs-Url: https://github.com/infinilabs/framework/sessions/c7adba2d-c701-4bd0-9c10-ec59d79b4ae0

Co-authored-by: medcl <64487+medcl@users.noreply.github.com>
@medcl medcl changed the title Add SQLite ORM backend via ncruces/go-sqlite3 feat: add SQLite ORM backend via ncruces/go-sqlite3 Apr 18, 2026
This file is in .gitignore and should not be tracked.
It is generated by the build process.

Co-authored-by: medcl <64487+medcl@users.noreply.github.com>
Copilot AI and others added 2 commits April 18, 2026 16:25
…tterns

Add 12 new tests covering the complex nested query patterns used by
the security search operation hook (RegisterSearchOperationHook):
- Must wrapping ShouldQuery with minimum_should_match
- Owner-only queries (no sharing)
- Should with shared resource IDs
- Category filter with owner
- Nested BooleanQuery inside Should (folder access + deny rules)
- Should with MustNot folder deny rules
- Dotted field paths (_system.owner_id, _system.parent_path)
- Filter with MustQuery wrapper
- Full search hook simulation with all patterns combined
- Multiple folder allow/deny paths
- Category children sharing
- Empty ShouldQuery edge case

Agent-Logs-Url: https://github.com/infinilabs/framework/sessions/8d394cd4-0c76-4a0e-9db1-f463b0a2006f

Co-authored-by: medcl <64487+medcl@users.noreply.github.com>
Copilot AI and others added 2 commits April 18, 2026 23:56
…e ORM

Add 7 new integration tests verifying the SQLite backend correctly
handles the patterns used by RegisterDataOperationPreHook for Create,
Update, and Save operations:
- System field round-trip (Create with _system.owner_id, Get, verify)
- Update preserving system fields after deserialization
- Save (upsert) with SystemFieldAccessor interface
- GetOwnerID and Object/SystemFieldAccessor interface after SQLite
  deserialization
- SearchV2 filtering by _system.owner_id via json_extract
- SearchV2 with ShouldQuery combining owner OR shared IDs
- DeleteByQuery filtering by _system.owner_id

Also add missing constants to config/generated.go for build
compatibility.

Agent-Logs-Url: https://github.com/infinilabs/framework/sessions/39670c0d-37f0-4903-969b-1c006bf7cdab

Co-authored-by: medcl <64487+medcl@users.noreply.github.com>
Copilot AI and others added 2 commits April 19, 2026 01:22
Update clauseToSQL to properly read and respect the minimum_should_match
parameter from clause.Parameters:

- When minimum_should_match >= 1: should clauses are required (OR join)
- When only 1 should clause with min_should_match=1: treat as mandatory
  (no unnecessary OR wrapping)
- When minimum_should_match is unset and no must/filter exist: default
  to requiring at least 1 match (Elasticsearch semantics)
- When minimum_should_match is unset with must/filter present: should
  clauses are optional (scoring-only in ES, safely skipped in SQLite)

Add unit tests:
- SingleShouldMinShouldMatch1_IsMandatory
- SingleShouldWithFilterAndMinShouldMatch1
- OptionalShouldWithoutMinShouldMatch

Add integration test:
- SearchV2_SingleShouldOwnerIsMandatory (end-to-end with real SQLite DB)

Agent-Logs-Url: https://github.com/infinilabs/framework/sessions/dc353da8-ad60-4779-86ff-b7a7e5d614d2

Co-authored-by: medcl <64487+medcl@users.noreply.github.com>
This file is gitignored and regenerated at build time by the Makefile.
The LastFrameworkCommitLog and LastFrameworkVendorCommitLog constants
are generated separately into config/generated_framework-info.go.

Agent-Logs-Url: https://github.com/infinilabs/framework/sessions/3922a466-05d7-40bf-8429-fc6e3821230d

Co-authored-by: medcl <64487+medcl@users.noreply.github.com>
@medcl
Copy link
Copy Markdown
Member

medcl commented May 30, 2026

@copilot resolve the merge conflicts in this pull request

…ackend-support

# Conflicts:
#	go.mod
#	go.sum
Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 30, 2026

@copilot resolve the merge conflicts in this pull request

Resolved the merge conflicts in go.mod and go.sum. Kept the tetratelabs/wazero dependency (needed for ncruces/go-sqlite3) and updated tklauser/go-sysconf and tklauser/numcpus to the newer versions from main. Merge commit: 2b4366c7.

Copilot AI changed the title feat: add SQLite ORM backend via ncruces/go-sqlite3 test(sqlite): expand CRUD and nested query coverage May 30, 2026
Copilot finished work on behalf of medcl May 30, 2026 08:38
@medcl medcl marked this pull request as ready for review May 30, 2026 10:24
Copilot AI changed the title test(sqlite): expand CRUD and nested query coverage Add interface coverage for BatchMutateAPI.DeleteByQuery Jun 1, 2026
Copilot finished work on behalf of medcl June 1, 2026 02:25
@medcl medcl changed the title Add interface coverage for BatchMutateAPI.DeleteByQuery feat: add SQLite ORM backend via ncruces/go-sqlite3 Jun 1, 2026
@medcl medcl merged commit 30f3943 into main Jun 1, 2026
3 of 4 checks passed
@medcl medcl deleted the copilot/add-sqlite3-backend-support branch June 1, 2026 10:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants