Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optional fields not supported #244

Open
pontaoski opened this issue Sep 20, 2021 · 6 comments
Open

Optional fields not supported #244

pontaoski opened this issue Sep 20, 2021 · 6 comments
Assignees
Labels
bug Something isn't working

Comments

@pontaoski
Copy link

Optional fields aren't supported, resulting in this error when you try to use a file with optional fields:

ERROR: profile/v1/stream.proto: is a proto3 file that contains optional fields, but code generator protoc-gen-qtprotobuf hasn't been updated to support optional fields in proto3. Please ask the owner of this code generator to support proto3 optional.--qtprotobuf_out: 
@pontaoski pontaoski added the bug Something isn't working label Sep 20, 2021
@Eijebong
Copy link

Eijebong commented Feb 5, 2022

Just ran into this, any progress?

@semlanik
Copy link
Owner

semlanik commented Feb 5, 2022

Sorry, all activities are temporary frozen, because of the migration to Qt6. I will try to cover this ASAP. :(

@glaubnichtalles
Copy link

Hello,

have also encountered the problem described here and would like to add the following information. From version 3.12 and up to version 3.15 protoc still needs the addition of --experimental_allow_proto3_optional, which is unfortunately not supported with Qt6 using qt_add_protobuf.

Unable to execute /usr/bin/protoc:(1) xxx.proto: This file contains proto3 optional fields, but --experimental_allow_proto3_optional was not set.

A workaround here is to edit the file lib/cmake/Qt6ProtobufTools/Qt6ProtobufToolsMacros.cmake

    string(JOIN "\\$<SEMICOLON>" protoc_arguments
        "--plugin=protoc-gen-${generator}=${generator_file}"
        "--${generator}_out=${tmp_output_directory}"
        "--${generator}_opt=${generation_options_string}"
        "${proto_files_string}"
        "${proto_includes_string}"
        "--experimental_allow_proto3_optional"
    )

Following this, one comes very close to the problem described here, since the error message that now arises is identical.

Unable to execute /usr/bin/protoc:(1) xxx.proto: is a proto3 file that contains optional fields, but code generator protoc-gen-qtprotobufgen hasn't been updated to support optional fields in proto3. Please ask the owner of this code generator to support proto3 optional.

More information about supporting optional can be found in the protobuf repository and I would start by implementing the method uint64_t GetSupportedFeatures() const override in generatorbase.h

King regards

@semlanik
Copy link
Owner

semlanik commented Jun 6, 2023

Hi, @glaubnichtalles the 'optional' fields support is planned for Qt6: QTBUG-103978

Unfortunately I don't plan any backporting from Qt6 to this repo because of complexity.

@arietto
Copy link

arietto commented Jul 11, 2023

Hi, I can't open https://bugreports.qt.io/browse/QTBUG-103978 even after login. The problem does exist in Qt 6.5.1 and Qt 6.6.0 (beta).

@glaubnichtalles
Copy link

Hi, thanks for the development regarding "Optional fields" support. My latest tests with Qt 6.6.0 beta 3 show that there are problems with the use of reserved c++ keywords. It would be great if for example the following entries could be added to the tests for the proto files:

optional bool private = 13; optional bool public = 42;

Kind reagrds

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants