Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-125360

QProtobufSerializer does not write default-values of optional fields

    XMLWordPrintable

Details

    • Bug
    • Resolution: Out of scope
    • P2: Important
    • None
    • 6.6.3
    • Protocol Buffers
    • None

    Description

      Given

      message proto_test

      {    optional double value = 1; }

      If we generate the corresponding class using qt_add_protobuf() in our CMAKELists.txt,

      Expected:

      QProtobufSerializer serializer;

      proto_test message;

      message.setValue(0);

      auto bytes = message.serialize(&serializer);

      QCOMPARE(bytes.size(), 9);

      Current behavior:

      QCOMPARE(bytes.size(), 0);

      Thus it is impossible for the receiver of the message to determine whether the field has been set or not. This defeats the whole purpose of having optional fields in the first place!

      (Please note that I am aware that checking for "is set" is not possible with the Qt-generated classes. However, in our case the receiver is using google-generated classes).

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            tatiana.borisova Tatiana Borisova
            mcnepp Gernot Neppert
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes