Skip to content

Add item CQL indexes#570

Draft
jakub-id wants to merge 3 commits into
mainfrom
item-cql-fields
Draft

Add item CQL indexes#570
jakub-id wants to merge 3 commits into
mainfrom
item-cql-fields

Conversation

@jakub-id
Copy link
Copy Markdown
Contributor

@jakub-id jakub-id commented May 4, 2026

No description provided.

Copilot AI review requested due to automatic review settings May 10, 2026 09:40
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 via EXISTS subqueries against the item table.
  • 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 thread broker/sqlc/pr_schema.sql
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants