If a table's schema allows no columns to be set when inserting,
python-ovs should handle that case.

Signed-off-by: Terry Wilson <[email protected]>
---
 python/ovs/db/idl.py | 2 +-
 tests/ovsdb-idl.at   | 9 +++++++++
 tests/test-ovsdb.c   | 2 ++
 tests/test-ovsdb.py  | 2 ++
 4 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/python/ovs/db/idl.py b/python/ovs/db/idl.py
index c8cc54346..abb82154b 100644
--- a/python/ovs/db/idl.py
+++ b/python/ovs/db/idl.py
@@ -1856,7 +1856,7 @@ class Transaction(object):
                 else:
                     # Let ovsdb-server decide whether to really delete it.
                     pass
-            elif row._changes:
+            else:
                 op = {"table": row._table.name}
                 if row._data is None:
                     op["op"] = "insert"
diff --git a/tests/ovsdb-idl.at b/tests/ovsdb-idl.at
index f9f79f194..5244358e3 100644
--- a/tests/ovsdb-idl.at
+++ b/tests/ovsdb-idl.at
@@ -494,6 +494,15 @@ OVSDB_CHECK_IDL([simple idl, writing via IDL with unicode],
 003: done
 ]])
 
+OVSDB_CHECK_IDL([simple idl, inserting without modifying a column, 
insert_no_columns_changed],
+  [],
+  [['insert_no_columns_changed']],
+  [[000: empty
+001: commit, status=success
+002: table simple: i=0 r=0 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] 
uuid=<1>
+003: done
+]])
+
 m4_define([OVSDB_CHECK_IDL_PY_WITH_EXPOUT],
   [AT_SETUP([ovsdb-idl - $1 - Python3])
    AT_KEYWORDS([ovsdb server idl positive Python $5])
diff --git a/tests/test-ovsdb.c b/tests/test-ovsdb.c
index eb5688e46..e88912693 100644
--- a/tests/test-ovsdb.c
+++ b/tests/test-ovsdb.c
@@ -2503,6 +2503,8 @@ idl_set(struct ovsdb_idl *idl, char *commands, int step)
 
             s = idltest_simple_insert(txn);
             idltest_simple_set_i(s, atoi(arg1));
+        } else if (!strcmp(name, "insert_no_columns_changed")) {
+            idltest_simple_insert(txn);
         } else if (!strcmp(name, "insert_uuid")) {
             struct idltest_simple *s;
 
diff --git a/tests/test-ovsdb.py b/tests/test-ovsdb.py
index 57fc1d449..ed47e2447 100644
--- a/tests/test-ovsdb.py
+++ b/tests/test-ovsdb.py
@@ -508,6 +508,8 @@ def idl_set(idl, commands, step):
 
             s = txn.insert(idl.tables["simple"])
             s.i = int(args[0])
+        elif name == "insert_no_columns_changed":
+            txn.insert(idl.tables["simple"])
         elif name == "insert_uuid":
             if len(args) != 2:
                 sys.stderr.write('"set" command requires 2 argument\n')
-- 
2.47.1

_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to