Repository: Materials-Consortia/optimade-python-tools
Pull request #2242 (2025-03-08 16:57:19)

Use 1.2 grammar by default and relax rules on nested fields
This PR simply removes the "develop" tag from the v1.2.0 grammar, which should make it the default.

It also allows nested field names to have more flexibility, inspired by e.g., the MP field `_mp_stability.gga_gga+u_r2scan` (#2182). The spec reads that dictionary keys must only be strings, not identifiers, so I have relaxed our previous approach of enforcing an identifier to allow for filtering on such fields. I'll do a bit of testing to make sure that this is still URL-safe, but I think we should be fine.

ml-evs: pre-commit.ci autofix
ml-evs: pre-commit.ci autofix
codecov[bot]: ## [Codecov](https://app.codecov.io/gh/Materials-Consortia/optimade-python-tools/pull/2242?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Materials-Consortia) Report
All modified and coverable lines are covered by tests :white_check_mark:
> Project coverage is 90.60%. Comparing base [(`0be0c7f`)](https://app.codecov.io/gh/Materials-Consortia/optimade-python-tools/commit/0be0c7f0e627652eb6b98ce7cdf83f2f3881843e?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Materials-Consortia) to head [(`4f11c24`)](https://app.codecov.io/gh/Materials-Consortia/optimade-python-tools/commit/4f11c24d3ef56d5019cad31b1040b8b6ca38d899?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Materials-Consortia).

<details><summary>Additional details and impacted files</summary>


```diff
@@           Coverage Diff           @@
##             main    #2242   +/-   ##
=======================================
  Coverage   90.60%   90.60%           
=======================================
  Files          75       75           
  Lines        4929     4929           
=======================================
  Hits         4466     4466           
  Misses        463      463           
```

| [Flag](https://app.codecov.io/gh/Materials-Consortia/optimade-python-tools/pull/2242/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Materials-Consortia) | Coverage Δ | |
|---|---|---|
| [project](https://app.codecov.io/gh/Materials-Consortia/optimade-python-tools/pull/2242/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Materials-Consortia) | `90.60% <ø> (ø)` | |
| [validator](https://app.codecov.io/gh/Materials-Consortia/optimade-python-tools/pull/2242/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Materials-Consortia) | `90.60% <ø> (ø)` | |

Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Materials-Consortia#carryforward-flags-in-the-pull-request-comment) to find out more.

</details>

[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/Materials-Consortia/optimade-python-tools/pull/2242?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Materials-Consortia).   
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Materials-Consortia).

<details><summary>🚀 New features to boost your workflow: </summary>

- ❄ [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
</details>
ml-evs: pre-commit.ci autofix

Patch:
diff --git a/optimade/grammar/v1.2.0.develop.lark b/optimade/grammar/v1.2.0.lark
similarity index 96%
rename from optimade/grammar/v1.2.0.develop.lark
rename to optimade/grammar/v1.2.0.lark
index 12ec22c0..6d803090 100644
--- a/optimade/grammar/v1.2.0.develop.lark
+++ b/optimade/grammar/v1.2.0.lark
@@ -55,7 +55,7 @@ set_zip_op_rhs: property_zip_addon HAS ( value_zip | ONLY value_zip_list | ALL v
 property_zip_addon: ":" property (":" property)*
 
 // Property syntax
-property: IDENTIFIER ( "." IDENTIFIER )*
+property: IDENTIFIER ( "." NESTED_IDENTIFIER )*
 
 // String syntax
 string: ESCAPED_STRING
@@ -95,6 +95,7 @@ ANY:      "ANY"
 OPERATOR: ( "<" ["="] | ">" ["="] | ["!"] "=" )
 
 IDENTIFIER: ( "_" | LCASE_LETTER ) ( "_" | LCASE_LETTER | DIGIT )*
+NESTED_IDENTIFIER: ( "_" | LCASE_LETTER ) ( "_" | "+" | LCASE_LETTER | DIGIT )*
 LCASE_LETTER: "a".."z"
 DIGIT: "0".."9"
 
diff --git a/optimade/server/routers/utils.py b/optimade/server/routers/utils.py
index b2f16186..a6687d5c 100644
--- a/optimade/server/routers/utils.py
+++ b/optimade/server/routers/utils.py
@@ -166,6 +166,10 @@ def get_included_relationships(
             )
 
     endpoint_includes: dict[Any, dict] = defaultdict(dict)
+
+    if not include_param:
+        return []
+
     for doc in results:
         # convert list of references into dict by ID to only included unique IDs
         if doc is None:


Test patch:
diff --git a/optimade/server/data/test_data.jsonl b/optimade/server/data/test_data.jsonl
index 2872b2f2..f1f58619 100644
--- a/optimade/server/data/test_data.jsonl
+++ b/optimade/server/data/test_data.jsonl
@@ -14,7 +14,7 @@
 {"type": "structures", "id": "mpf_3", "attributes": {"immutable_id": "5cfb441f053b174410700d04", "assemblies": null, "chemsys": "Ac-Ag-Pb", "cartesian_site_positions": [[0.6522459815095935, 0.6522459815095935, 0.6522459815095935], [0.6522459815095935, 0.6522459815095935, 0.6522459815095935], [0.6522459815095935, 0.6522459815095935, 0.6522459815095935], [0.6522459815095935, 0.6522459815095935, 0.6522459815095935]], "dimension_types": [1, 1, 1], "nperiodic_dimensions": 3, "elements": ["Ac", "Ag", "Pb"], "elements_ratios": [0.5, 0.25, 0.25], "formula_anonymous": "A2BC", "last_modified": {"$date": "2019-06-08T05:13:37.331Z"}, "lattice_vectors": [[7.698325441636717, 0, 0], [0, 3.9419030762941096, 0], [0, 0, 0.5746646140691603]], "nelements": 3, "nsites": 4, "pretty_formula": "Ac2AgPb", "species": [{"chemical_symbols": ["Ac"], "concentration": [1.0], "name": "Ac1"}, {"chemical_symbols": ["Ac"], "concentration": [1.0], "name": "Ac2"}, {"chemical_symbols": ["Ag"], "concentration": [1.0], "name": "Ag"}, {"chemical_symbols": ["Pb"], "concentration": [1.0], "name": "Pb"}], "species_at_sites": ["Ac1", "Ac2", "Ag", "Pb"], "structure_features": [], "task_id": "mpf_3", "relationships": {"references": {"data": [{"type": "references", "id": "maddox1988"}]}}, "_exmpl_this_provider_field": "test"}}
 {"type": "structures", "id": "mpf_30", "attributes": {"immutable_id": "5cfb441f053b174410700d1f", "assemblies": null, "chemsys": "Ac-O", "cartesian_site_positions": [[0.15817967032742697, 0.15817967032742697, 0.15817967032742697], [0.15817967032742697, 0.15817967032742697, 0.15817967032742697], [0.15817967032742697, 0.15817967032742697, 0.15817967032742697], [0.15817967032742697, 0.15817967032742697, 0.15817967032742697], [0.15817967032742697, 0.15817967032742697, 0.15817967032742697]], "dimension_types": [1, 1, 1], "nperiodic_dimensions": 3, "elements": ["Ac", "O"], "elements_ratios": [0.4, 0.6], "formula_anonymous": "A3B2", "last_modified": {"$date": "2019-06-08T05:13:37.337Z"}, "lattice_vectors": [[5.270508031864836, 0, 0], [0, 7.390955992107494, 0], [0, 0, 3.0995955580253574]], "nelements": 2, "nsites": 5, "pretty_formula": "Ac2O3", "species": [{"chemical_symbols": ["Ac"], "concentration": [1.0], "name": "Ac"}, {"chemical_symbols": ["O"], "concentration": [1.0], "name": "O"}], "species_at_sites": ["Ac", "Ac", "O", "O", "O"], "structure_features": [], "task_id": "mpf_30", "_exmpl_this_provider_field": "test"}}
 {"type": "structures", "id": "mpf_3803", "attributes": {"immutable_id": "5cfb441f053b174410701bdc", "assemblies": null, "chemsys": "Ba-Ce-Fe-H-Na-O-Si-Ti", "cartesian_site_positions": [[0.8417172367979051, 0.8417172367979051, 0.8417172367979051], [0.8417172367979051, 0.8417172367979051, 0.8417172367979051], [0.8417172367979051, 0.8417172367979051, 0.8417172367979051], [0.8417172367979051, 0.8417172367979051, 0.8417172367979051], [0.8417172367979051, 0.8417172367979051, 0.8417172367979051], [0.8417172367979051, 0.8417172367979051, 0.8417172367979051], [0.8417172367979051, 0.8417172367979051, 0.8417172367979051], [0.8417172367979051, 0.8417172367979051, 0.8417172367979051], [0.8417172367979051, 0.8417172367979051, 0.8417172367979051], [0.8417172367979051, 0.8417172367979051, 0.8417172367979051], [0.8417172367979051, 0.8417172367979051, 0.8417172367979051], [0.8417172367979051, 0.8417172367979051, 0.8417172367979051], [0.8417172367979051, 0.8417172367979051, 0.8417172367979051], [0.8417172367979051, 0.8417172367979051, 0.8417172367979051], [0.8417172367979051, 0.8417172367979051, 0.8417172367979051], [0.8417172367979051, 0.8417172367979051, 0.8417172367979051], [0.8417172367979051, 0.8417172367979051, 0.8417172367979051], [0.8417172367979051, 0.8417172367979051, 0.8417172367979051], [0.8417172367979051, 0.8417172367979051, 0.8417172367979051], [0.8417172367979051, 0.8417172367979051, 0.8417172367979051], [0.8417172367979051, 0.8417172367979051, 0.8417172367979051], [0.8417172367979051, 0.8417172367979051, 0.8417172367979051], [0.8417172367979051, 0.8417172367979051, 0.8417172367979051], [0.8417172367979051, 0.8417172367979051, 0.8417172367979051], [0.8417172367979051, 0.8417172367979051, 0.8417172367979051], [0.8417172367979051, 0.8417172367979051, 0.8417172367979051], [0.8417172367979051, 0.8417172367979051, 0.8417172367979051], [0.8417172367979051, 0.8417172367979051, 0.8417172367979051], [0.8417172367979051, 0.8417172367979051, 0.8417172367979051], [0.8417172367979051, 0.8417172367979051, 0.8417172367979051], [0.8417172367979051, 0.8417172367979051, 0.8417172367979051], [0.8417172367979051, 0.8417172367979051, 0.8417172367979051], [0.8417172367979051, 0.8417172367979051, 0.8417172367979051], [0.8417172367979051, 0.8417172367979051, 0.8417172367979051], [0.8417172367979051, 0.8417172367979051, 0.8417172367979051], [0.8417172367979051, 0.8417172367979051, 0.8417172367979051], [0.8417172367979051, 0.8417172367979051, 0.8417172367979051], [0.8417172367979051, 0.8417172367979051, 0.8417172367979051], [0.8417172367979051, 0.8417172367979051, 0.8417172367979051], [0.8417172367979051, 0.8417172367979051, 0.8417172367979051], [0.8417172367979051, 0.8417172367979051, 0.8417172367979051], [0.8417172367979051, 0.8417172367979051, 0.8417172367979051], [0.8417172367979051, 0.8417172367979051, 0.8417172367979051], [0.8417172367979051, 0.8417172367979051, 0.8417172367979051]], "dimension_types": [1, 1, 1], "nperiodic_dimensions": 3, "elements": ["Ba", "Ce", "Fe", "H", "Na", "O", "Si", "Ti"], "elements_ratios": [0.045454545454545456, 0.045454545454545456, 0.022727272727272728, 0.022727272727272728, 0.022727272727272728, 0.6136363636363636, 0.18181818181818182, 0.045454545454545456], "formula_anonymous": "A27B8C2D2E2FGH", "last_modified": {"$date": "2019-06-08T05:13:37.943Z"}, "lattice_vectors": [[3.6001175409341037, 0, 0], [0, 4.438478811675378, 0], [0, 0, 7.718814146224643]], "nelements": 8, "nsites": 44, "pretty_formula": "Ba2Ce2FeHNaO27Si8Ti2", "species": [{"chemical_symbols": ["Ba"], "concentration": [1.0], "name": "Ba"}, {"chemical_symbols": ["Ce"], "concentration": [1.0], "name": "Ce"}, {"chemical_symbols": ["Fe"], "concentration": [1.0], "name": "Fe"}, {"chemical_symbols": ["H"], "concentration": [1.0], "name": "H"}, {"chemical_symbols": ["Na"], "concentration": [1.0], "name": "Na"}, {"chemical_symbols": ["O"], "concentration": [1.0], "name": "O"}, {"chemical_symbols": ["Si"], "concentration": [1.0], "name": "Si"}, {"chemical_symbols": ["Ti"], "concentration": [1.0], "name": "Ti"}], "species_at_sites": ["Ba", "Ba", "Ce", "Ce", "Fe", "H", "Na", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "Si", "Si", "Si", "Si", "Si", "Si", "Si", "Si", "Ti", "Ti"], "structure_features": [], "task_id": "mpf_3803", "_exmpl_this_provider_field": "test"}}
-{"type": "structures", "id": "mpf_3819", "attributes": {"immutable_id": "5cfb441f053b174410701bec", "assemblies": null, "chemsys": "Ba-F-H-Mn-Na-O-Re-Si-Ti", "cartesian_site_positions": [[0.24056412649964642, 0.24056412649964642, 0.24056412649964642], [0.24056412649964642, 0.24056412649964642, 0.24056412649964642], [0.24056412649964642, 0.24056412649964642, 0.24056412649964642], [0.24056412649964642, 0.24056412649964642, 0.24056412649964642], [0.24056412649964642, 0.24056412649964642, 0.24056412649964642], [0.24056412649964642, 0.24056412649964642, 0.24056412649964642], [0.24056412649964642, 0.24056412649964642, 0.24056412649964642], [0.24056412649964642, 0.24056412649964642, 0.24056412649964642], [0.24056412649964642, 0.24056412649964642, 0.24056412649964642], [0.24056412649964642, 0.24056412649964642, 0.24056412649964642], [0.24056412649964642, 0.24056412649964642, 0.24056412649964642], [0.24056412649964642, 0.24056412649964642, 0.24056412649964642], [0.24056412649964642, 0.24056412649964642, 0.24056412649964642], [0.24056412649964642, 0.24056412649964642, 0.24056412649964642], [0.24056412649964642, 0.24056412649964642, 0.24056412649964642], [0.24056412649964642, 0.24056412649964642, 0.24056412649964642], [0.24056412649964642, 0.24056412649964642, 0.24056412649964642], [0.24056412649964642, 0.24056412649964642, 0.24056412649964642], [0.24056412649964642, 0.24056412649964642, 0.24056412649964642], [0.24056412649964642, 0.24056412649964642, 0.24056412649964642], [0.24056412649964642, 0.24056412649964642, 0.24056412649964642], [0.24056412649964642, 0.24056412649964642, 0.24056412649964642], [0.24056412649964642, 0.24056412649964642, 0.24056412649964642], [0.24056412649964642, 0.24056412649964642, 0.24056412649964642], [0.24056412649964642, 0.24056412649964642, 0.24056412649964642], [0.24056412649964642, 0.24056412649964642, 0.24056412649964642], [0.24056412649964642, 0.24056412649964642, 0.24056412649964642], [0.24056412649964642, 0.24056412649964642, 0.24056412649964642], [0.24056412649964642, 0.24056412649964642, 0.24056412649964642], [0.24056412649964642, 0.24056412649964642, 0.24056412649964642], [0.24056412649964642, 0.24056412649964642, 0.24056412649964642], [0.24056412649964642, 0.24056412649964642, 0.24056412649964642], [0.24056412649964642, 0.24056412649964642, 0.24056412649964642], [0.24056412649964642, 0.24056412649964642, 0.24056412649964642], [0.24056412649964642, 0.24056412649964642, 0.24056412649964642], [0.24056412649964642, 0.24056412649964642, 0.24056412649964642], [0.24056412649964642, 0.24056412649964642, 0.24056412649964642], [0.24056412649964642, 0.24056412649964642, 0.24056412649964642], [0.24056412649964642, 0.24056412649964642, 0.24056412649964642], [0.24056412649964642, 0.24056412649964642, 0.24056412649964642], [0.24056412649964642, 0.24056412649964642, 0.24056412649964642], [0.24056412649964642, 0.24056412649964642, 0.24056412649964642], [0.24056412649964642, 0.24056412649964642, 0.24056412649964642], [0.24056412649964642, 0.24056412649964642, 0.24056412649964642]], "dimension_types": [1, 1, 1], "nperiodic_dimensions": 3, "elements": ["Ba", "F", "H", "Mn", "Na", "O", "Re", "Si", "Ti"], "elements_ratios": [0.045454545454545456, 0.022727272727272728, 0.022727272727272728, 0.022727272727272728, 0.022727272727272728, 0.5909090909090909, 0.045454545454545456, 0.18181818181818182, 0.045454545454545456], "formula_anonymous": "A26B8C2D2E2FGHI", "last_modified": {"$date": "2018-06-08T05:13:37.945Z"}, "lattice_vectors": [[0.541264110585089, 0, 0], [0, 0.5211563701526833, 0], [0, 0, 4.063577553377723]], "nelements": 9, "nsites": 44, "pretty_formula": "Ba2FHMnNaO26Re2Si8Ti2", "species": [{"chemical_symbols": ["Ba"], "concentration": [1.0], "name": "Ba"}, {"chemical_symbols": ["F"], "concentration": [1.0], "name": "F"}, {"chemical_symbols": ["H"], "concentration": [1.0], "name": "H"}, {"chemical_symbols": ["Mn"], "concentration": [1.0], "name": "Mn"}, {"chemical_symbols": ["Na"], "concentration": [1.0], "name": "Na"}, {"chemical_symbols": ["O"], "concentration": [1.0], "name": "O"}, {"chemical_symbols": ["Re"], "concentration": [1.0], "name": "Re"}, {"chemical_symbols": ["Si"], "concentration": [1.0], "name": "Si"}, {"chemical_symbols": ["Ti"], "concentration": [1.0], "name": "Ti"}], "species_at_sites": ["Ba", "Ba", "F", "H", "Mn", "Na", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "Re", "Re", "Si", "Si", "Si", "Si", "Si", "Si", "Si", "Si", "Ti", "Ti"], "structure_features": [], "task_id": "mpf_3819", "relationships": {"references": {"data": [{"type": "references", "id": "dummy/2019"}]}}}}
+{"type": "structures", "id": "mpf_3819", "attributes": {"_exmpl_stability": {"gga_gga+u_r2scan": -0.1}, "immutable_id": "5cfb441f053b174410701bec", "assemblies": null, "chemsys": "Ba-F-H-Mn-Na-O-Re-Si-Ti", "cartesian_site_positions": [[0.24056412649964642, 0.24056412649964642, 0.24056412649964642], [0.24056412649964642, 0.24056412649964642, 0.24056412649964642], [0.24056412649964642, 0.24056412649964642, 0.24056412649964642], [0.24056412649964642, 0.24056412649964642, 0.24056412649964642], [0.24056412649964642, 0.24056412649964642, 0.24056412649964642], [0.24056412649964642, 0.24056412649964642, 0.24056412649964642], [0.24056412649964642, 0.24056412649964642, 0.24056412649964642], [0.24056412649964642, 0.24056412649964642, 0.24056412649964642], [0.24056412649964642, 0.24056412649964642, 0.24056412649964642], [0.24056412649964642, 0.24056412649964642, 0.24056412649964642], [0.24056412649964642, 0.24056412649964642, 0.24056412649964642], [0.24056412649964642, 0.24056412649964642, 0.24056412649964642], [0.24056412649964642, 0.24056412649964642, 0.24056412649964642], [0.24056412649964642, 0.24056412649964642, 0.24056412649964642], [0.24056412649964642, 0.24056412649964642, 0.24056412649964642], [0.24056412649964642, 0.24056412649964642, 0.24056412649964642], [0.24056412649964642, 0.24056412649964642, 0.24056412649964642], [0.24056412649964642, 0.24056412649964642, 0.24056412649964642], [0.24056412649964642, 0.24056412649964642, 0.24056412649964642], [0.24056412649964642, 0.24056412649964642, 0.24056412649964642], [0.24056412649964642, 0.24056412649964642, 0.24056412649964642], [0.24056412649964642, 0.24056412649964642, 0.24056412649964642], [0.24056412649964642, 0.24056412649964642, 0.24056412649964642], [0.24056412649964642, 0.24056412649964642, 0.24056412649964642], [0.24056412649964642, 0.24056412649964642, 0.24056412649964642], [0.24056412649964642, 0.24056412649964642, 0.24056412649964642], [0.24056412649964642, 0.24056412649964642, 0.24056412649964642], [0.24056412649964642, 0.24056412649964642, 0.24056412649964642], [0.24056412649964642, 0.24056412649964642, 0.24056412649964642], [0.24056412649964642, 0.24056412649964642, 0.24056412649964642], [0.24056412649964642, 0.24056412649964642, 0.24056412649964642], [0.24056412649964642, 0.24056412649964642, 0.24056412649964642], [0.24056412649964642, 0.24056412649964642, 0.24056412649964642], [0.24056412649964642, 0.24056412649964642, 0.24056412649964642], [0.24056412649964642, 0.24056412649964642, 0.24056412649964642], [0.24056412649964642, 0.24056412649964642, 0.24056412649964642], [0.24056412649964642, 0.24056412649964642, 0.24056412649964642], [0.24056412649964642, 0.24056412649964642, 0.24056412649964642], [0.24056412649964642, 0.24056412649964642, 0.24056412649964642], [0.24056412649964642, 0.24056412649964642, 0.24056412649964642], [0.24056412649964642, 0.24056412649964642, 0.24056412649964642], [0.24056412649964642, 0.24056412649964642, 0.24056412649964642], [0.24056412649964642, 0.24056412649964642, 0.24056412649964642], [0.24056412649964642, 0.24056412649964642, 0.24056412649964642]], "dimension_types": [1, 1, 1], "nperiodic_dimensions": 3, "elements": ["Ba", "F", "H", "Mn", "Na", "O", "Re", "Si", "Ti"], "elements_ratios": [0.045454545454545456, 0.022727272727272728, 0.022727272727272728, 0.022727272727272728, 0.022727272727272728, 0.5909090909090909, 0.045454545454545456, 0.18181818181818182, 0.045454545454545456], "formula_anonymous": "A26B8C2D2E2FGHI", "last_modified": {"$date": "2018-06-08T05:13:37.945Z"}, "lattice_vectors": [[0.541264110585089, 0, 0], [0, 0.5211563701526833, 0], [0, 0, 4.063577553377723]], "nelements": 9, "nsites": 44, "pretty_formula": "Ba2FHMnNaO26Re2Si8Ti2", "species": [{"chemical_symbols": ["Ba"], "concentration": [1.0], "name": "Ba"}, {"chemical_symbols": ["F"], "concentration": [1.0], "name": "F"}, {"chemical_symbols": ["H"], "concentration": [1.0], "name": "H"}, {"chemical_symbols": ["Mn"], "concentration": [1.0], "name": "Mn"}, {"chemical_symbols": ["Na"], "concentration": [1.0], "name": "Na"}, {"chemical_symbols": ["O"], "concentration": [1.0], "name": "O"}, {"chemical_symbols": ["Re"], "concentration": [1.0], "name": "Re"}, {"chemical_symbols": ["Si"], "concentration": [1.0], "name": "Si"}, {"chemical_symbols": ["Ti"], "concentration": [1.0], "name": "Ti"}], "species_at_sites": ["Ba", "Ba", "F", "H", "Mn", "Na", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "Re", "Re", "Si", "Si", "Si", "Si", "Si", "Si", "Si", "Si", "Ti", "Ti"], "structure_features": [], "task_id": "mpf_3819", "relationships": {"references": {"data": [{"type": "references", "id": "dummy/2019"}]}}}}
 {"type": "structures", "id": "mpf_446", "attributes": {"immutable_id": "5cfb441f053b174410700ebf", "assemblies": null, "chemsys": "Ag-Br-Cl-Hg-I-S", "cartesian_site_positions": [[0.7184493830657678, 0.7184493830657678, 0.7184493830657678], [0.7184493830657678, 0.7184493830657678, 0.7184493830657678], [0.7184493830657678, 0.7184493830657678, 0.7184493830657678], [0.7184493830657678, 0.7184493830657678, 0.7184493830657678], [0.7184493830657678, 0.7184493830657678, 0.7184493830657678], [0.7184493830657678, 0.7184493830657678, 0.7184493830657678], [0.7184493830657678, 0.7184493830657678, 0.7184493830657678], [0.7184493830657678, 0.7184493830657678, 0.7184493830657678], [0.7184493830657678, 0.7184493830657678, 0.7184493830657678], [0.7184493830657678, 0.7184493830657678, 0.7184493830657678], [0.7184493830657678, 0.7184493830657678, 0.7184493830657678], [0.7184493830657678, 0.7184493830657678, 0.7184493830657678], [0.7184493830657678, 0.7184493830657678, 0.7184493830657678], [0.7184493830657678, 0.7184493830657678, 0.7184493830657678], [0.7184493830657678, 0.7184493830657678, 0.7184493830657678], [0.7184493830657678, 0.7184493830657678, 0.7184493830657678], [0.7184493830657678, 0.7184493830657678, 0.7184493830657678], [0.7184493830657678, 0.7184493830657678, 0.7184493830657678]], "dimension_types": [1, 1, 1], "nperiodic_dimensions": 3, "elements": ["Ag", "Br", "Cl", "Hg", "I", "S"], "elements_ratios": [0.2222222222222222, 0.05555555555555555, 0.1111111111111111, 0.2777777777777778, 0.05555555555555555, 0.2777777777777778], "formula_anonymous": "A5B5C4D2EF", "last_modified": {"$date": "2019-06-08T05:13:37.412Z"}, "lattice_vectors": [[5.132691156529571, 0, 0], [0, 1.8270015294181907, 0], [0, 0, 4.5549149749018225]], "nelements": 6, "nsites": 18, "pretty_formula": "Ag4BrCl2Hg5IS5", "species": [{"chemical_symbols": ["Ag"], "concentration": [1.0], "name": "Ag"}, {"chemical_symbols": ["Br"], "concentration": [1.0], "name": "Br"}, {"chemical_symbols": ["Cl"], "concentration": [1.0], "name": "Cl"}, {"chemical_symbols": ["Hg"], "concentration": [1.0], "name": "Hg"}, {"chemical_symbols": ["I"], "concentration": [1.0], "name": "I"}, {"chemical_symbols": ["S"], "concentration": [1.0], "name": "S"}], "species_at_sites": ["Ag", "Ag", "Ag", "Ag", "Br", "Cl", "Cl", "Hg", "Hg", "Hg", "Hg", "Hg", "I", "S", "S", "S", "S", "S"], "structure_features": [], "task_id": "mpf_446", "_exmpl_this_provider_field": "test"}}
 {"type": "structures", "id": "mpf_551", "attributes": {"immutable_id": "5cfb441f053b174410700f28", "assemblies": null, "chemsys": "Ag-B-C-Cl-H-N-O-P", "cartesian_site_positions": [[0.449480176317956, 0.449480176317956, 0.449480176317956], [0.449480176317956, 0.449480176317956, 0.449480176317956], [0.449480176317956, 0.449480176317956, 0.449480176317956], [0.449480176317956, 0.449480176317956, 0.449480176317956], [0.449480176317956, 0.449480176317956, 0.449480176317956], [0.449480176317956, 0.449480176317956, 0.449480176317956], [0.449480176317956, 0.449480176317956, 0.449480176317956], [0.449480176317956, 0.449480176317956, 0.449480176317956], [0.449480176317956, 0.449480176317956, 0.449480176317956], [0.449480176317956, 0.449480176317956, 0.449480176317956], [0.449480176317956, 0.449480176317956, 0.449480176317956], [0.449480176317956, 0.449480176317956, 0.449480176317956], [0.449480176317956, 0.449480176317956, 0.449480176317956], [0.449480176317956, 0.449480176317956, 0.449480176317956], [0.449480176317956, 0.449480176317956, 0.449480176317956], [0.449480176317956, 0.449480176317956, 0.449480176317956], [0.449480176317956, 0.449480176317956, 0.449480176317956], [0.449480176317956, 0.449480176317956, 0.449480176317956], [0.449480176317956, 0.449480176317956, 0.449480176317956], [0.449480176317956, 0.449480176317956, 0.449480176317956], [0.449480176317956, 0.449480176317956, 0.449480176317956], [0.449480176317956, 0.449480176317956, 0.449480176317956], [0.449480176317956, 0.449480176317956, 0.449480176317956], [0.449480176317956, 0.449480176317956, 0.449480176317956], [0.449480176317956, 0.449480176317956, 0.449480176317956], [0.449480176317956, 0.449480176317956, 0.449480176317956], [0.449480176317956, 0.449480176317956, 0.449480176317956], [0.449480176317956, 0.449480176317956, 0.449480176317956], [0.449480176317956, 0.449480176317956, 0.449480176317956], [0.449480176317956, 0.449480176317956, 0.449480176317956], [0.449480176317956, 0.449480176317956, 0.449480176317956], [0.449480176317956, 0.449480176317956, 0.449480176317956], [0.449480176317956, 0.449480176317956, 0.449480176317956], [0.449480176317956, 0.449480176317956, 0.449480176317956], [0.449480176317956, 0.449480176317956, 0.449480176317956], [0.449480176317956, 0.449480176317956, 0.449480176317956], [0.449480176317956, 0.449480176317956, 0.449480176317956], [0.449480176317956, 0.449480176317956, 0.449480176317956], [0.449480176317956, 0.449480176317956, 0.449480176317956], [0.449480176317956, 0.449480176317956, 0.449480176317956], [0.449480176317956, 0.449480176317956, 0.449480176317956], [0.449480176317956, 0.449480176317956, 0.449480176317956], [0.449480176317956, 0.449480176317956, 0.449480176317956], [0.449480176317956, 0.449480176317956, 0.449480176317956], [0.449480176317956, 0.449480176317956, 0.449480176317956], [0.449480176317956, 0.449480176317956, 0.449480176317956], [0.449480176317956, 0.449480176317956, 0.449480176317956], [0.449480176317956, 0.449480176317956, 0.449480176317956], [0.449480176317956, 0.449480176317956, 0.449480176317956], [0.449480176317956, 0.449480176317956, 0.449480176317956], [0.449480176317956, 0.449480176317956, 0.449480176317956], [0.449480176317956, 0.449480176317956, 0.449480176317956], [0.449480176317956, 0.449480176317956, 0.449480176317956], [0.449480176317956, 0.449480176317956, 0.449480176317956], [0.449480176317956, 0.449480176317956, 0.449480176317956], [0.449480176317956, 0.449480176317956, 0.449480176317956], [0.449480176317956, 0.449480176317956, 0.449480176317956], [0.449480176317956, 0.449480176317956, 0.449480176317956], [0.449480176317956, 0.449480176317956, 0.449480176317956], [0.449480176317956, 0.449480176317956, 0.449480176317956], [0.449480176317956, 0.449480176317956, 0.449480176317956], [0.449480176317956, 0.449480176317956, 0.449480176317956], [0.449480176317956, 0.449480176317956, 0.449480176317956], [0.449480176317956, 0.449480176317956, 0.449480176317956], [0.449480176317956, 0.449480176317956, 0.449480176317956], [0.449480176317956, 0.449480176317956, 0.449480176317956], [0.449480176317956, 0.449480176317956, 0.449480176317956], [0.449480176317956, 0.449480176317956, 0.449480176317956], [0.449480176317956, 0.449480176317956, 0.449480176317956], [0.449480176317956, 0.449480176317956, 0.449480176317956], [0.449480176317956, 0.449480176317956, 0.449480176317956], [0.449480176317956, 0.449480176317956, 0.449480176317956], [0.449480176317956, 0.449480176317956, 0.449480176317956], [0.449480176317956, 0.449480176317956, 0.449480176317956]], "dimension_types": [1, 1, 1], "nperiodic_dimensions": 3, "elements": ["Ag", "B", "C", "Cl", "H", "N", "O", "P"], "elements_ratios": [0.013513513513513514, 0.13513513513513514, 0.20270270270270271, 0.02702702702702703, 0.5405405405405406, 0.013513513513513514, 0.04054054054054054, 0.02702702702702703], "formula_anonymous": "A40B15C10D3E2F2GH", "last_modified": {"$date": "2019-06-08T05:13:37.434Z"}, "lattice_vectors": [[5.055370731514176, 0, 0], [0, 4.77221883540092, 0], [0, 0, 5.704704278000719]], "nelements": 8, "nsites": 74, "pretty_formula": "AgB10C15Cl2H40NO3P2", "species": [{"chemical_symbols": ["Ag"], "concentration": [1.0], "name": "Ag"}, {"chemical_symbols": ["B"], "concentration": [1.0], "name": "B"}, {"chemical_symbols": ["C"], "concentration": [1.0], "name": "C"}, {"chemical_symbols": ["Cl"], "concentration": [1.0], "name": "Cl"}, {"chemical_symbols": ["H"], "concentration": [1.0], "name": "H"}, {"chemical_symbols": ["N"], "concentration": [1.0], "name": "N"}, {"chemical_symbols": ["O"], "concentration": [1.0], "name": "O"}, {"chemical_symbols": ["P"], "concentration": [1.0], "name": "P"}], "species_at_sites": ["Ag", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "C", "C", "C", "C", "C", "C", "C", "C", "C", "C", "C", "C", "C", "C", "C", "Cl", "Cl", "H", "H", "H", "H", "H", "H", "H", "H", "H", "H", "H", "H", "H", "H", "H", "H", "H", "H", "H", "H", "H", "H", "H", "H", "H", "H", "H", "H", "H", "H", "H", "H", "H", "H", "H", "H", "H", "H", "H", "H", "N", "O", "O", "O", "P", "P"], "structure_features": [], "task_id": "mpf_551", "_exmpl_this_provider_field": "test"}}
 {"type": "structures", "id": "mpf_632", "attributes": {"immutable_id": "5cfb441f053b174410700f79", "assemblies": null, "chemsys": "Ag-C-Cl-H-N-O-S", "cartesian_site_positions": [[0.9116303665281374, 0.9116303665281374, 0.9116303665281374], [0.9116303665281374, 0.9116303665281374, 0.9116303665281374], [0.9116303665281374, 0.9116303665281374, 0.9116303665281374], [0.9116303665281374, 0.9116303665281374, 0.9116303665281374], [0.9116303665281374, 0.9116303665281374, 0.9116303665281374], [0.9116303665281374, 0.9116303665281374, 0.9116303665281374], [0.9116303665281374, 0.9116303665281374, 0.9116303665281374], [0.9116303665281374, 0.9116303665281374, 0.9116303665281374], [0.9116303665281374, 0.9116303665281374, 0.9116303665281374], [0.9116303665281374, 0.9116303665281374, 0.9116303665281374], [0.9116303665281374, 0.9116303665281374, 0.9116303665281374], [0.9116303665281374, 0.9116303665281374, 0.9116303665281374], [0.9116303665281374, 0.9116303665281374, 0.9116303665281374], [0.9116303665281374, 0.9116303665281374, 0.9116303665281374], [0.9116303665281374, 0.9116303665281374, 0.9116303665281374], [0.9116303665281374, 0.9116303665281374, 0.9116303665281374], [0.9116303665281374, 0.9116303665281374, 0.9116303665281374], [0.9116303665281374, 0.9116303665281374, 0.9116303665281374], [0.9116303665281374, 0.9116303665281374, 0.9116303665281374], [0.9116303665281374, 0.9116303665281374, 0.9116303665281374], [0.9116303665281374, 0.9116303665281374, 0.9116303665281374], [0.9116303665281374, 0.9116303665281374, 0.9116303665281374], [0.9116303665281374, 0.9116303665281374, 0.9116303665281374], [0.9116303665281374, 0.9116303665281374, 0.9116303665281374], [0.9116303665281374, 0.9116303665281374, 0.9116303665281374], [0.9116303665281374, 0.9116303665281374, 0.9116303665281374], [0.9116303665281374, 0.9116303665281374, 0.9116303665281374], [0.9116303665281374, 0.9116303665281374, 0.9116303665281374], [0.9116303665281374, 0.9116303665281374, 0.9116303665281374]], "dimension_types": [1, 1, 1], "nperiodic_dimensions": 3, "elements": ["Ag", "C", "Cl", "H", "N", "O", "S"], "elements_ratios": [0.034482758620689655, 0.10344827586206896, 0.034482758620689655, 0.4827586206896552, 0.20689655172413793, 0.034482758620689655, 0.10344827586206896], "formula_anonymous": "A14B6C3D3EFG", "last_modified": {"$date": "2019-06-08T05:13:37.450Z"}, "lattice_vectors": [[4.438269887249414, 0, 0], [0, 0.0037263506973483906, 0], [0, 0, 2.879535498740032]], "nelements": 7, "nsites": 29, "pretty_formula": "AgC3ClH14N6OS3", "species": [{"chemical_symbols": ["Ag"], "concentration": [1.0], "name": "Ag"}, {"chemical_symbols": ["C"], "concentration": [1.0], "name": "C"}, {"chemical_symbols": ["Cl"], "concentration": [1.0], "name": "Cl"}, {"chemical_symbols": ["H"], "concentration": [1.0], "name": "H"}, {"chemical_symbols": ["N"], "concentration": [1.0], "name": "N"}, {"chemical_symbols": ["O"], "concentration": [1.0], "name": "O"}, {"chemical_symbols": ["S"], "concentration": [1.0], "name": "S"}], "species_at_sites": ["Ag", "C", "C", "C", "Cl", "H", "H", "H", "H", "H", "H", "H", "H", "H", "H", "H", "H", "H", "H", "N", "N", "N", "N", "N", "N", "O", "S", "S", "S"], "structure_features": [], "task_id": "mpf_632", "_exmpl_this_provider_field": "test"}}
diff --git a/optimade/server/data/test_structures.json b/optimade/server/data/test_structures.json
index 5a91e3b6..b22e18b7 100644
--- a/optimade/server/data/test_structures.json
+++ b/optimade/server/data/test_structures.json
@@ -3757,6 +3757,7 @@
     ],
     "structure_features": [],
     "task_id": "mpf_3819",
+    "_exmpl_stability": {"gga_gga+u_r2scan": -0.2},
     "relationships": {
       "references": {
         "data": [
diff --git a/tests/filterparser/test_filterparser.py b/tests/filterparser/test_filterparser.py
index 5a01130b..14bca306 100644
--- a/tests/filterparser/test_filterparser.py
+++ b/tests/filterparser/test_filterparser.py
@@ -269,7 +269,7 @@ class TestParserV1_2_0(TestParserV1_0_0):
     """
 
     version = (1, 2, 0)
-    variant = "develop"
+    variant = "default"
 
     def test_boolean_values(self):
         assert isinstance(
@@ -291,3 +291,4 @@ class TestParserV1_2_0(TestParserV1_0_0):
             self.parse("NOT _exmpl_element_counts = TRUE"),
             Tree,
         )
+        assert isinstance(self.parse("_mp_stability.gga_gga+u_r2scan <= 0.0"), Tree)
diff --git a/tests/filtertransformers/test_mongo.py b/tests/filtertransformers/test_mongo.py
index 44f38614..3f3b67c2 100644
--- a/tests/filtertransformers/test_mongo.py
+++ b/tests/filtertransformers/test_mongo.py
@@ -13,7 +13,7 @@ from optimade.warnings import UnknownProviderProperty
 
 
 class TestMongoTransformer:
-    version = (1, 0, 0)
+    version = (1, 2, 0)
     variant = "default"
 
     @pytest.fixture(autouse=True)
@@ -41,6 +41,11 @@ class TestMongoTransformer:
         with pytest.raises(BadRequest):
             self.transform("BadLuck IS KNOWN")  # contains upper-case letters
 
+    def test_awkward_nested_field(self):
+        assert self.transform("_mp_stability.gga_gga+u_r2scan <= 0.0") == {
+            "_mp_stability.gga_gga+u_r2scan": {"$lte": 0.0}
+        }
+
     def test_provider_property_name(self):
         # database-provider-specific prefixes
         assert self.transform("_exmpl_formula_sum = 1") == {
diff --git a/tests/server/routers/test_structures.py b/tests/server/routers/test_structures.py
index a0e089f2..5c107e79 100644
--- a/tests/server/routers/test_structures.py
+++ b/tests/server/routers/test_structures.py
@@ -1,8 +1,11 @@
+import pytest
+
 from optimade.models import (
     ReferenceResource,
     StructureResponseMany,
     StructureResponseOne,
 )
+from optimade.server.config import CONFIG, SupportedBackend
 
 from ..utils import RegularEndpointTests
 
@@ -80,6 +83,19 @@ def test_check_response_single_structure(check_response):
     check_response(request, expected_ids=expected_ids)
 
 
+@pytest.mark.xfail(
+    CONFIG.database_backend == SupportedBackend.ELASTIC,
+    reason="Elasticsearch implementation does not support nested provider fields.",
+)
+def test_awkward_nested_provider_field(check_response):
+    """Tests that structures with a nested provider field that breaks
+    identifier field names can still be filtered on.
+    """
+
+    request = "/structures?filter=_exmpl_stability.gga_gga%2Bu_r2scan < 0"
+    check_response(request, expected_ids=["mpf_3819"])
+
+
 class TestMissingSingleStructureEndpoint(RegularEndpointTests):
     """Tests for /structures/<entry_id> for unknown <entry_id>"""
 
diff --git a/tests/server/test_client.py b/tests/server/test_client.py
index 796cb1a7..69d9b7bb 100644
--- a/tests/server/test_client.py
+++ b/tests/server/test_client.py
@@ -509,7 +509,7 @@ def test_list_properties(
 
     results = cli.list_properties("structures")
     for database in results:
-        assert len(results[database]) == 27, str(results[database])
+        assert len(results[database]) == 28, str(results[database])
 
     results = cli.search_property("structures", "site")
     for database in results:
diff --git a/tests/test_config.json b/tests/test_config.json
index df614295..a1adee5b 100644
--- a/tests/test_config.json
+++ b/tests/test_config.json
@@ -22,7 +22,8 @@
         "structures": [
             "band_gap",
             {"name": "chemsys", "type": "string", "description": "A string representing the chemical system in an ordered fashion"},
-            {"name": "_exmpl_this_provider_field", "type": "string", "description": "A field defined by this provider, added to this config to check whether the server will pass it through without adding two prefixes."}
+            {"name": "_exmpl_this_provider_field", "type": "string", "description": "A field defined by this provider, added to this config to check whether the server will pass it through without adding two prefixes."},
+            {"name": "_exmpl_stability", "type": "dictionary", "description": "A dictionary field with some naughty keys that contain non-URL-safe characters."}
         ]
     },
     "aliases": {