Skip to content

fix: apply typeNames SQL filter and scope queryables per profile in multi-profile deployments - #1269

Open
lirantul123 wants to merge 1 commit into
geopython:masterfrom
lirantul123:fix/multiprofile-typename-scoping
Open

lirantul123 wants to merge 1 commit into
geopython:masterfrom
lirantul123:fix/multiprofile-typename-scoping

Conversation

@lirantul123

Copy link
Copy Markdown

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:

  1. repository.query() accepted a typenames argument but never applied it as a SQL filter. A request scoped to one profile returned every row in the table regardless of typename. It now adds a WHERE typename IN (...) clause for non-generic types; csw:Record and csw30:Record still return all rows, leaving single-profile and default behaviour unchanged.
  2. Filter and CQL property names always resolved against queryables['_all'], a flat merge of all loaded profiles in which the last-loaded profile wins. When two profiles define the same property name mapping to different columns, the wrong column was always used. The new _scoped_queryables() method starts from _all (keeping core fields like csw:AnyText) and overlays the queryables specific to the requested typenames on top, so each profile resolves to its own column. Applied to the GET and POST filter/CQL paths in both csw2.py and csw3.py.

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)

  • I'd like to contribute [feature X|bugfix Y|docs|something else] to pycsw. I confirm that my contributions to pycsw will be compatible with the pycsw license guidelines at the time of contribution.
  • I have already previously agreed to the pycsw Contributions and Licensing Guidelines

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
lirantul123 force-pushed the fix/multiprofile-typename-scoping branch from 53da19a to 5323c96 Compare September 23, 2026 14:12
@lirantul123 lirantul123 changed the title fix: honour typeNames and scope queryables for multi-profile tables fix: apply typeNames SQL filter and scope queryables per profile in multi-profile deployments Sep 23, 2026
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.

GetRecords with multiple profiles sharing one table returns wrong rows and resolves wrong columns

1 participant