Repository navigation
fix: apply typeNames SQL filter and scope queryables per profile in multi-profile deployments - #1269
Open
lirantul123 wants to merge 3 commits into
Open
lirantul123 wants to merge 3 commits into
lirantul123 wants to merge 3 commits into
Conversation
Two bugs made GetRecords unusable when multiple CSW profiles share one repository table (each row tagged by its typename column): - repository.query() accepted a typenames argument but never applied it, so a request scoped to one profile returned every row. It now filters on the typename column for specific, non-generic types; the csw:Record / csw30:Record wildcards still return all rows, leaving default and single-profile behaviour unchanged. - Filter/CQL property names always resolved against queryables['_all'], a flat merge in which the last-loaded profile wins, so profiles sharing a property name mapped to different columns resolved incorrectly. The new _scoped_queryables() overlays the requested typenames' queryables onto _all (returning _all verbatim for no/generic types). Applied to the GET and POST filter/CQL paths of both csw2.py and csw3.py. Adds unit tests for the typename filter, including the wildcard and no-typename cases that must keep returning all rows.
lirantul123
force-pushed
the
fix/multiprofile-typename-scoping
branch
from
September 23, 2026 14:12
53da19a to
5323c96
Compare
- Move scoped_queryables() to Repository, reading directly from context.model per typename to avoid last-wins group name collisions - Normalize string typenames to list at query() entry point, fixing SQLAlchemy crash when POST GetRecords omits typeNames attribute - Change csw2/csw3 POST default from bare string to ['csw:Record'] - Scope sortby resolution through scoped_queryables in GET and POST paths for both CSW 2.0 and 3.0 - Remove duplicate _scoped_queryables from csw2/csw3; all callers now use repository.scoped_queryables()
…ation - test_query_string_typename_no_crash: verifies bare string typenames don't crash SQLAlchemy's IN clause - test_scoped_queryables_*: generic/None/string inputs return _all - test_scoped_queryables_group_collision: two profiles sharing a queryable group name resolve to their own column, not the last-loaded
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.
Two bugs made GetRecords unusable when multiple CSW profiles share one repository table (each row tagged by its typename column):
repository.query() accepted a typenames argument but never applied it, so a request scoped to one profile returned every row. It now filters on the typename column for specific, non-generic types; the csw:Record / csw30:Record wildcards still return all rows, leaving default and single-profile behaviour unchanged.
Filter/CQL property names always resolved against queryables['_all'], a flat merge in which the last-loaded profile wins, so profiles sharing a property name mapped to different columns resolved incorrectly. The new _scoped_queryables() overlays the requested typenames' queryables onto _all (returning _all verbatim for no/generic types). Applied to the GET and POST filter/CQL paths of both csw2.py and csw3.py.
Adds unit tests for the typename filter, including the wildcard and no-typename cases that must keep returning all rows.
Overview
When multiple CSW profiles share one repository table (each row tagged by its typename column), two bugs make GetRecords unusable when scoped to a specific profile typename:
Three unit tests cover the new typename filter: specific typename returns only matching rows, csw:Record wildcard returns all rows, and omitted typenames returns all rows.
Related Issue / Discussion
Fixes #1268
Additional Information
GetRecordById is not addressed here. The CSW 2.0.2 spec includes no typeNames parameter for that operation, so cross-profile record-by-ID resolution is out of scope for this fix.
Contributions and Licensing
(as per https://github.com/geopython/pycsw/blob/master/CONTRIBUTING.rst#contributions-and-licensing)