diff --git a/rdflib/plugins/serializers/patch.py b/rdflib/plugins/serializers/patch.py index f548cbe3d..3a5d37215 100644 --- a/rdflib/plugins/serializers/patch.py +++ b/rdflib/plugins/serializers/patch.py @@ -81,7 +81,10 @@ def write_triples(contexts, op_code, use_passed_contexts=False): if operation: assert operation in add_remove_methods, f"Invalid operation: {operation}" - + elif not target: + # No operation specified and no target specified + # Fall back to default operation of "add" to prevent a no-op + operation = "add" write_header() if operation: operation_code = add_remove_methods.get(operation)