Fix merging schemas in aos configs

Since all configs are practically required to have schemas today, we are
now getting into situations where we need to merge 2 configs both with
schemas.  Naively merging the schemas together results in all the fields
being duplicated and nothing making sense.

The proper thing to do would be to merge the schemas together while
retaining meaning.  That would let us dynamically add fields and such.
That is hard to do and probably not worth it.  We typically merge new
schemas into old configs, so the easy thing to do is always replace the
existing schema with the new schema.

Through this whole activity, I discovered that if ForceDefaults isn't
set to true, we don't copy over fields with 0 values.  We assume 0 is
the default, even if that is wrong.  This changes the meaning.  Instead,
ignore ForceDefaults when merging.

Change-Id: If83978dd73a542d070eaeb242532e7ee52104999
Signed-off-by: Austin Schuh <austin.schuh@bluerivertech.com>
diff --git a/aos/flatbuffer_merge_test.cc b/aos/flatbuffer_merge_test.cc
index 4162edc..81aa2e1 100644
--- a/aos/flatbuffer_merge_test.cc
+++ b/aos/flatbuffer_merge_test.cc
@@ -258,6 +258,28 @@
     }
 
     {
+      flatbuffers::FlatBufferBuilder aos_flatbuffer_copy_fbb;
+      aos_flatbuffer_copy_fbb.ForceDefaults(false);
+
+      LOG(INFO) << "Copying without defaults " << in1 << " "
+                << absl::BytesToHexString(FromFbb(fb1)) << " at "
+                << reinterpret_cast<const void *>(fb1.span().data()) << " size "
+                << fb1.span().size();
+      aos_flatbuffer_copy_fbb.Finish(CopyFlatBuffer<Configuration>(
+          &fb1.message(), &aos_flatbuffer_copy_fbb));
+
+      const aos::FlatbufferDetachedBuffer<Configuration> fb_copy(
+          aos_flatbuffer_copy_fbb.Release());
+      ASSERT_NE(fb_copy.span().size(), 0u);
+
+      EXPECT_TRUE(fb1.Verify());
+
+      ASSERT_TRUE(fb_copy.Verify()) << in1;
+
+      EXPECT_EQ(in1, FlatbufferToJson(fb_copy));
+    }
+
+    {
       flatbuffers::FlatBufferBuilder aos_flatbuffer_copy_message_ptr_fbb;
       aos_flatbuffer_copy_message_ptr_fbb.ForceDefaults(true);