Skip to content

schema using 'patternProperties' with square bracket character classes gets interpreted as array access#8522

Closed
KampfCaspar wants to merge 2 commits into
pubkey:masterfrom
KampfCaspar:patternProperties
Closed

schema using 'patternProperties' with square bracket character classes gets interpreted as array access#8522
KampfCaspar wants to merge 2 commits into
pubkey:masterfrom
KampfCaspar:patternProperties

Conversation

@KampfCaspar
Copy link
Copy Markdown

This PR contains:

BUG TEST CASE

Describe the problem

I want to include objects as fields in an RxJsonSchema. If I specify that deep objects properties by patternProperties I want
to use character classes in the regex. rxdb seems to interpret the square brackets (originating from the regex character classes) as indicating array indizes and bails out.

Describe solution

Regexs in patternProperties should NOT be interpreted as array indizes - at least not directly. If such indizes serve a purpose, only interpret square brackets that are not part of the regex as such (e.g. escaped by backslash for a 'literal' square bracket).

@KampfCaspar
Copy link
Copy Markdown
Author

It seems the issue resides in plugins/dev-mode/check-schema, while patternProperties seem to be excluded in validateFieldsDeep (line 78), it is not handled in checkSchema (line 501).

The block seems to check for an older configuration variant with 'index: true' on individual fields. I don't know if that ever worked for patternProperties - the 'flattened' object path and regex syntax just don't mix.

I therefore suggest excluding patternProperties from this old-config check.

Copilot AI added a commit that referenced this pull request May 26, 2026
pubkey added a commit that referenced this pull request May 26, 2026
…#8522) (#8577)

Agent-Logs-Url: https://github.com/pubkey/rxdb/sessions/832b1569-3c4f-442b-b40a-dcd34bbca5ed

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: pubkey <8926560+pubkey@users.noreply.github.com>
@pubkey
Copy link
Copy Markdown
Owner

pubkey commented May 26, 2026

Fixed at #8577

@pubkey pubkey closed this May 26, 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.

2 participants