Skip to content

Commit 7202022

Browse files
authored
Do not add read only attr in templates (#6010)
1 parent 67da0ca commit 7202022

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

backend/infrahub/core/schema/schema_branch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1934,7 +1934,7 @@ def generate_object_template_from_node(
19341934
# Tell if the user explicitely requested this template
19351935
is_autogenerated_subtemplate = node.generate_template is False
19361936
for node_attr in node.attributes:
1937-
if node_attr.unique:
1937+
if node_attr.unique or node_attr.read_only:
19381938
continue
19391939

19401940
attr = AttributeSchema(

backend/tests/unit/core/schema_manager/test_manager_schema.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2910,7 +2910,7 @@ async def test_manage_object_templates(relationship_kind: RelationshipKind):
29102910
test_object_template_thing = schema_branch.get_template(f"Template{TestKind.THING}", duplicate=False)
29112911
assert sorted(
29122912
[a.name for a in test_object_template_thing.attributes if a.name != OBJECT_TEMPLATE_NAME_ATTR]
2913-
) == sorted([a.name for a in THING_WITH_TEMPLATE.attributes if not a.unique])
2913+
) == sorted([a.name for a in THING_WITH_TEMPLATE.attributes if not a.unique and not a.read_only])
29142914
assert sorted(
29152915
[
29162916
r.name

0 commit comments

Comments
 (0)