Skip to content

Commit c1d82f2

Browse files
committed
fix filtering
1 parent cbcd156 commit c1d82f2

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

pharus/component_interface.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -353,10 +353,25 @@ def presets_route(self):
353353

354354
# Helper function to filter out fields not in the insert,
355355
# as well as apply the fields_map
356-
def filterPreset(preset: dict):
357-
return {
358-
(self.input_lookup[k] if k in self.input_lookup else k): v
356+
def filter_preset(preset: dict):
357+
# Any key that follows the schema.table.attribute format,
358+
# and its schema.table is not in the forms is filtered out.
359+
360+
preset_with_tables_filtered = {
361+
k: v
359362
for k, v in preset.items()
363+
if (
364+
len(k.split(".")) == 1
365+
or ".".join(k.split(".")[0:2]) in self.component_config["tables"]
366+
)
367+
}
368+
return {
369+
(
370+
self.input_lookup[k.split(".").pop()]
371+
if k.split(".").pop() in self.input_lookup
372+
else k.split(".").pop()
373+
): v
374+
for k, v in preset_with_tables_filtered.items()
360375
}
361376

362377
if "presets" not in self.component_config:
@@ -367,7 +382,7 @@ def filterPreset(preset: dict):
367382
)
368383

369384
filtered_preset_dictionary = {
370-
k: filterPreset(v) for k, v in self.presets_dict.items()
385+
k: filter_preset(v) for k, v in self.presets_dict.items()
371386
}
372387

373388
return (

0 commit comments

Comments
 (0)