From 6882f5fa64a36b43d5a541a58382738204bc7ec3 Mon Sep 17 00:00:00 2001 From: Ashley Sommer Date: Tue, 27 Aug 2024 13:00:45 +1000 Subject: [PATCH] In .patch serializer, default to "add" operation if no operation or no target is given on the commandline. (#2898) --- rdflib/plugins/serializers/patch.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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)