Skip to content

Commit 66ea717

Browse files
committed
No nest bug fix.
1 parent 26cdde8 commit 66ea717

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

stac_fastapi/core/stac_fastapi/core/models/patch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def validate_model(cls, data: Any):
9999
data["nest"], data["partition"], data["key"] = data["nest"].rpartition(".")
100100

101101
data["es_path"] = to_es(data["path"])
102-
data["es_nest"] = to_es(data["nest"])
102+
data["es_nest"] = f".{to_es(data['nest'])}" if data["nest"] else ""
103103
data["es_key"] = to_es(data["key"])
104104

105105
return data

stac_fastapi/core/stac_fastapi/core/utilities.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -238,16 +238,16 @@ def check_commands(
238238

239239
if path.index or op in ["remove", "replace", "test"] or from_path:
240240
commands.add(
241-
f"if (!ctx._source.{path.es_nest}.containsKey('{path.key}'))"
241+
f"if (!ctx._source{path.es_nest}.containsKey('{path.key}'))"
242242
f"{{Debug.explain('{path.key} does not exist in {path.nest}');}}"
243243
)
244244

245245
if from_path and path.index is not None:
246246
commands.add(
247-
f"if ((ctx._source.{path.es_location} instanceof ArrayList"
248-
f" && ctx._source.{path.es_location}.size() < {path.index})"
249-
f" || (!(ctx._source.{path.es_location} instanceof ArrayList)"
250-
f" && !ctx._source.{path.es_location}.containsKey('{path.index}')))"
247+
f"if ((ctx._source{path.es_location} instanceof ArrayList"
248+
f" && ctx._source{path.es_location}.size() < {path.index})"
249+
f" || (!(ctx._source{path.es_location} instanceof ArrayList)"
250+
f" && !ctx._source{path.es_location}.containsKey('{path.index}')))"
251251
f"{{Debug.explain('{path.path} does not exist');}}"
252252
)
253253

@@ -262,12 +262,12 @@ def remove_commands(commands: ESCommandSet, path: ElasticPath) -> None:
262262
"""
263263
if path.index is not None:
264264
commands.add(
265-
f"def {path.variable_name} = ctx._source.{path.es_location}.remove({path.index});"
265+
f"def {path.variable_name} = ctx._source{path.es_location}.remove({path.index});"
266266
)
267267

268268
else:
269269
commands.add(
270-
f"def {path.variable_name} = ctx._source.{path.es_nest}.remove('{path.key}');"
270+
f"def {path.variable_name} = ctx._source{path.es_nest}.remove('{path.key}');"
271271
)
272272

273273

@@ -298,8 +298,8 @@ def add_commands(
298298

299299
if path.index is not None:
300300
commands.add(
301-
f"if (ctx._source.{path.es_location} instanceof ArrayList)"
302-
f"{{ctx._source.{path.es_location}.{'add' if operation.op in ['add', 'move'] else 'set'}({path.index}, {value})}}"
301+
f"if (ctx._source{path.es_location} instanceof ArrayList)"
302+
f"{{ctx._source{path.es_location}.{'add' if operation.op in ['add', 'move'] else 'set'}({path.index}, {value})}}"
303303
f"else{{ctx._source.{path.es_path} = {value}}}"
304304
)
305305

0 commit comments

Comments
 (0)