ctrliq / pika

ORM style SQL builder with AIP-160 Support
Apache License 2.0
5 stars 4 forks source link

Add ability for nested field identifiers #11

Open tchinz opened 3 months ago

tchinz commented 3 months ago

Take these as example protobuf types

type AuditEvent struct {
    state         protoimpl.MessageState
    sizeCache     protoimpl.SizeCache
    unknownFields protoimpl.UnknownFields
    ...
    Id             string                 `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
    Actor          *Actor                 `protobuf:"bytes,3,opt,name=actor,proto3" json:"actor,omitempty"`
    ...
}

type Actor struct {
    state         protoimpl.MessageState
    sizeCache     protoimpl.SizeCache
    unknownFields protoimpl.UnknownFields

    Id           string    `protobuf:"bytes,2,opt,name=id,proto3" json:"id,omitempty"`
}

Currently a filter like this:

    ListAuditEventsRequest{
        PageSize: 100,
        Filter:   `actor.id:"` + actorId + `"`,
    })

with pika implementation:

    qs := pika.Q[audit_events](r.pika)
    opts := pika.ProtoReflect(&fbapi.AuditEvent{})

    events, token, err := qs.GetPage(ctx, request, opts)
    if err != nil {
        return nil, err
    }

results in

                Error:          Received unexpected error:
                                applying filter from page token: unexpected identifier id

Note that the actor id is a nested identifier. id is a field on the Actor type

This issue is for adding thee ability for Pika to support AIP160 filtering for nested identifiers like actor.id