Skip to content

Commit

Permalink
feat: allow quoting object keys in OPL
Browse files Browse the repository at this point in the history
  • Loading branch information
zepatrik committed Nov 16, 2022
1 parent 640abc1 commit 081d834
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions internal/schema/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ func (p *parser) parseRelated() {
switch item := p.next(); item.Typ {
case itemBraceRight:
return
case itemIdentifier:
case itemIdentifier, itemStringLiteral:
relation := item.Val
var types []ast.RelationType
p.match(":")
Expand All @@ -216,7 +216,7 @@ func (p *parser) parseRelated() {
Types: types,
})
default:
p.addFatal(item, "expected identifier or '}', got %q", item.Val)
p.addFatal(item, "expected identifier or '}', got %s %q", item.Typ.String(), item.Val)
return
}
}
Expand Down Expand Up @@ -258,7 +258,7 @@ func (p *parser) parsePermits() {
case itemBraceRight:
return

case itemIdentifier:
case itemIdentifier, itemStringLiteral:
permission := item.Val
p.match(
":", "(", "ctx", optional(":", "Context"), ")",
Expand All @@ -276,7 +276,7 @@ func (p *parser) parsePermits() {
})

default:
p.addFatal(item, "expected identifier or '}', got %q", item.Val)
p.addFatal(item, "expected identifier or '}', got %s %q", item.Typ.String(), item.Val)
return
}
}
Expand Down
4 changes: 2 additions & 2 deletions internal/schema/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ var parserTestCases = []struct {
related: {
parents: (File | Folder)[]
viewers: (User | SubjectSet<Group, "members">)[]
owners: (User | SubjectSet<Group, "members">)[]
"owners": (User | SubjectSet<Group, "members">)[]
siblings: File[]
}
Expand All @@ -107,7 +107,7 @@ var parserTestCases = []struct {
this.related.viewers.includes(ctx.subject) ) ||
this.related.owners.includes(ctx.subject),
edit: (ctx: Context) => this.related.owners.includes(ctx.subject),
'edit': (ctx: Context) => this.related.owners.includes(ctx.subject),
not: (ctx: Context) => !this.related.owners.includes(ctx.subject),
Expand Down

0 comments on commit 081d834

Please sign in to comment.