Add item CQL indexes#570
Draft
jakub-id wants to merge 3 commits into
Draft
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds CQL support for querying patron requests by related item attributes (item_id, barcode, call_number) and introduces database indexes intended to keep those queries performant, alongside API documentation and tests.
Changes:
- Added new CQL fields (
item_id,barcode,call_number) implemented viaEXISTSsubqueries against theitemtable. - Added item-table indexes and a migration to apply them.
- Expanded unit/integration tests and updated OpenAPI documentation to reflect the new CQL fields.
Reviewed changes
Copilot reviewed 8 out of 9 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| broker/patron_request/db/prcql.go | Registers new item-related CQL fields using a new EXISTS-based field generator. |
| broker/patron_request/db/field_exists_string.go | Introduces FieldExistsString to generate EXISTS / NOT EXISTS SQL for related-string fields. |
| broker/patron_request/db/prcql_test.go | Adds unit tests validating SQL generation for the new EXISTS field type and item CQL fields. |
| broker/sqlc/pr_schema.sql | Adds item-table indexes to the SQLC schema for parity with migrations. |
| broker/migrations/034_add_item_cql_indexes.up.sql | Adds migration creating item CQL indexes. |
| broker/migrations/034_add_item_cql_indexes.down.sql | Adds migration rollback dropping the new indexes. |
| broker/test/patron_request/db/prrepo_test.go | Extends repository tests to cover filtering patron requests by item fields via CQL. |
| broker/oapi/open-api.yaml | Documents the newly supported CQL fields for /patron_requests. |
| } | ||
|
|
||
| func (f *FieldExistsString) nonEmptyValuePredicate() string { | ||
| return fmt.Sprintf("COALESCE(%s, '') <> ''", f.valueExpression) |
Comment on lines
+44
to
+51
| ON item (barcode, pr_id); | ||
|
|
||
| CREATE INDEX idx_item_item_id_pr_id | ||
| ON item (item_id, pr_id) | ||
| WHERE item_id IS NOT NULL; | ||
|
|
||
| CREATE INDEX idx_item_call_number_pr_id | ||
| ON item (call_number, pr_id) |
Comment on lines
+2
to
+9
| ON item (barcode, pr_id); | ||
|
|
||
| CREATE INDEX idx_item_item_id_pr_id | ||
| ON item (item_id, pr_id) | ||
| WHERE item_id IS NOT NULL; | ||
|
|
||
| CREATE INDEX idx_item_call_number_pr_id | ||
| ON item (call_number, pr_id) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.