bolt icon indicating copy to clipboard operation
bolt copied to clipboard

Unexpected behavior mixing path and type definitions

Open 1800joe opened this issue 9 years ago • 2 comments

With the following spec

type User {
  ...
  eventLog: Event[];
}

type Event {
  type: String;
  id: String;
}

path /users/{uid} is User {
  ...
  /eventLog/{eventId} is Event {
    create() { isOwner(uid) }
  }
}

I get an invalid compiled result:

        ...
        "eventLog": {
          "$eventId": {
            ".validate": "newData.hasChildren(['type', 'id'])",
            "type": {
              ".validate": "newData.isString()"
            },
            "id": {
              ".validate": "newData.isString()"
            },
            "$other": {
              ".validate": "false"
            },
            ".write": "data.val() == null && (auth != null && $uid == auth.uid)"
          },
          "$key1": {
            ".validate": "newData.hasChildren(['type', 'id'])",
            "type": {
              ".validate": "newData.isString()"
            },
            "id": {
              ".validate": "newData.isString()"
            },
            "$other": {
              ".validate": "false"
            }
          }
        }...

I may be doing something wrong (please advise if there is a better way), but thought it's worth bringing up anyway because if Firebase throws out the rule the compiler should also complain.

1800joe avatar Feb 11 '16 20:02 1800joe

Yes - see issue #58

mckoss avatar Feb 11 '16 22:02 mckoss

Cool, thanks.

1800joe avatar Feb 12 '16 00:02 1800joe