Fix interpretation of IncludeSubtypes #1018
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix interpretation of IncludeSubtypes in Browse requests.
According to the spec, IncludeSubtypes indicates whether subtypes of the ReferenceType should be included in the browse. If TRUE, then instances of ReferenceType and its subtypes are returned.
The current implementation has a different interpretation: Get instances of ReferenceType and subtypes thereof. If IncludeSubtypes is FALSE, then exclude the type "HasSubtype".
The same applies to RelativePath requests.
Fixes #233.
There may be conflicts with #1017, I can rebase when it got merged.
WARNING: This change has compatibility drawbacks, not sure how to deal with it in all cases.
Old client with new server (or other opcua servers):
If using add_object with type definition (or directly using instantiate), no children will get created because get_children_descriptions(includesubtypes=False) on the ObjectType node which calls get_references(refs=ua.ObjectIds.HierarchicalReferences, includesubtypes=False) won't return anything. This is a breaking change, but also fixes behaviour when used with other opcua servers.
New client with old server:
Some places call get_referenced_nodes(refs=HasSubtype, includesubtypes=True). Includesubtypes could actually be set to False because HasSubtype probably won't get subclassed. It should be harmless to keep it set to True, keeping compatibility with old servers and just wasting some cpu cycles there. However, for code cleanliness I removed the includesubtypes=True parameter from the call. It's still active, as it defaults to True.