Skip to content

feat(storage): implement backend sorting with sql injection protection#145

Open
Lutherwaves wants to merge 18 commits intomainfrom
fix/AddSortingSQLAdapter
Open

feat(storage): implement backend sorting with sql injection protection#145
Lutherwaves wants to merge 18 commits intomainfrom
fix/AddSortingSQLAdapter

Conversation

@Lutherwaves
Copy link
Contributor

@Lutherwaves Lutherwaves commented Feb 17, 2026

  • Adds sortDirection support to cursor-paginated queries across SQL, CosmosDB, and DynamoDB adapters
  • Introduces SortingDirection type with Ascending/Descending constants
  • Validates sortKey against a strict column-name whitelist before interpolation into ORDER BY clauses, closing an injection vector where Order() does not escape inputs
  • Surfaces previously silent cursor extraction failures as slog.Warn — pagination that silently breaks now shows up in logs
  • Documents sortKey and SortDirectionKey on the exported StorageAdapter interface following Google's Go style guide

What's NOT in this PR

Replacing params ...map[string]any with typed options is deferred — it's an interface-breaking change across all downstream services, and the migration only pays for itself once a second cross-adapter param is added to the bag.

@Lutherwaves Lutherwaves self-assigned this Feb 17, 2026
@Lutherwaves
Copy link
Contributor Author

@ayashjorden Thanks for the review, available for re-review.

@Lutherwaves Lutherwaves changed the title feat: add sorting to sql adapter feat: add sorting to sql adapter and refactor sort key/direction handling in storage adapter Feb 23, 2026
…interface

Move user-facing documentation (struct field name requirement, sort direction
param) to the exported List and Search interface methods where library consumers
can discover it. Trim unexported executePaginatedQuery docs to maintainer notes.
@Lutherwaves Lutherwaves force-pushed the fix/AddSortingSQLAdapter branch from 331a059 to 4b4931c Compare February 23, 2026 19:31
@Lutherwaves Lutherwaves changed the title feat: add sorting to sql adapter and refactor sort key/direction handling in storage adapter feat(storage): implement backend sorting with sql injection protection Feb 23, 2026
@Lutherwaves
Copy link
Contributor Author

@deanefrati @ayashjorden please take a look when you have time

@Lutherwaves
Copy link
Contributor Author

@ayashjorden @deanefrati ready for rereview

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