Querying a non-string value

Hi there,

I have a protocol buffer file looking something like this:

message NotificationMessageEntity {
    string notificationId = 1;
    NotificationType type = 2;
    string receiverId = 3;
    string message = 4;
    string generator = 5;
    DeviceType deviceType = 6;
    Data data = 7;
    string read = 8;
    string seen = 9;
    google.protobuf.Timestamp createdTime = 10;
    google.protobuf.Timestamp readTime = 11;
    google.protobuf.Timestamp seenTime = 12;
}

I have omitted imports and other options and messages irrelevant to the problem. The idea is to query the database by seen and read fields.
It works just fine if the fields are defined like here, as type string. If I change the type of the fields to anything but string (I have tried with bool, int32, int64), the query returns an empty list.

I am on a Windows machine, using Java 11, FoundationDB version 2.8.91.0.

Any ideas?

EDIT: This is a snippet of my working Java code for querying the database using String values:

RecordQuery query = RecordQuery.newBuilder()
                    .setRecordType("NotificationMessageEntity")
                    .setFilter(Query.and(Query.field("read").equalsValue("false"), Query.field("seen").equalsValue("false")))
                    .build();

Changing the parameter of the equalsValue(Object comparand) to any other type results in an empty list returned.

Are the boolean and integer values false and 0, respectively?

These are indistinguishable in Protobuf 3 from unset, which means that they by default invoke special null handling behavior.

There is some discussion of this in the docs.

1 Like

Thank you Mike, switching from proto3 to proto2 syntax solved my problem.

Thanks for the tips! I forgot about that proto3 trap, I spent days struggling with that :rofl:

Could it be cool to add a title in the documentation like “Proto3 warning”? Something that can be easily link and easily visible when scrolling the documentation?