Skip to content

Share the mapping core of the ORM storages - #58

Merged
azmeuk merged 1 commit into
mainfrom
mapping-core
Nov 27, 2026
Merged

azmeuk merged 1 commit into
mainfrom
mapping-core

Conversation

@azmeuk

@azmeuk azmeuk commented Nov 27, 2026

Copy link
Copy Markdown
Member

scim2-django and scim2-sqlalchemy store SCIM resources in the records of an ORM, and they shared most of their code by copy. scim2_server.mapping now holds that code, and each backend only gives the primitives of its ORM.

  • A mapping declares each attribute with Attribute, Many, Entry or Link, whose targets the core does not read. The core checks the paths, then the backend resolves the targets into columns and collections, and reports the problems in its own way.
  • A filter becomes a condition through the Predicates protocol, which each backend implements. The SCIM rules stay in the core: ne on a multi-valued attribute, missing values, substrings, strings the policy cannot prepare. The constants of an Entry are compared in Python.
  • The core builds the resources, their version hash and the published schemas, checks the writes, and plans the values to write.
  • A backend subclasses ResourceMapping and implements its hooks. The reference page lists them, with the order of the calls.
  • The API serves these two backends only, and may change in any minor version.
  • A value outside the choices of its field is now refused when the resource comes from the provider, whose model is another class than the one of the mapping. scim2-django 0.2.0 missed it.

The tests run the core on a backend that keeps its records in dicts and builds its conditions as Python predicates. It passes ScimStorageContract with a counter and dates, with a hash and no date, and with an Entry, so its filters and sorts are checked against ScimFilter.match and SearchRequest.sort.

scim2-django and scim2-sqlalchemy have a mapping-core branch that builds on this one. scim2-django only changes some messages of its system checks, and scim2-sqlalchemy gains Entry, optional dates and versions by hash.

@read-the-docs-community

read-the-docs-community Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

scim2_server.mapping is the base of the storages that map SCIM resources
to the records of an ORM: the declaration of a mapping and its checks,
the translation of the filters and of the sorts into the conditions of
the ORM, the reading of the records, and the checks of the writes. A
backend gives the primitives of its ORM through hooks and the Predicates
protocol. scim2-django and scim2-sqlalchemy build on it.

Its API follows the needs of these backends, and may change in any minor
version.
@azmeuk
azmeuk merged commit b081979 into main Nov 27, 2026
10 checks passed
@azmeuk
azmeuk deleted the mapping-core branch November 27, 2026 08:50
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.

1 participant