Check permissions on the initial document when deleting

When deleting a document, we need to check the visibility permissions using the initial document, as the current document will now have been emptied. As a result, no delete notifications were being delivered to LIVE queries.
This commit is contained in:
Tobie Morgan Hitchcock 2018-04-15 01:53:36 +01:00
parent 55ece805e4
commit 6fe4db6a58

View file

@ -87,7 +87,16 @@ func (d *document) grant(ctx context.Context, met method) (ok bool, err error) {
// a scoped request, return an error.
if p, ok := tb.Perms.(*sql.PermExpression); ok {
val, err = d.i.e.fetch(ctx, p.Select, d.current)
switch met {
case _SELECT:
val, err = d.i.e.fetch(ctx, p.Select, d.current)
case _CREATE:
val, err = d.i.e.fetch(ctx, p.Select, d.current)
case _UPDATE:
val, err = d.i.e.fetch(ctx, p.Select, d.current)
case _DELETE:
val, err = d.i.e.fetch(ctx, p.Select, d.initial)
}
}
// If the permissions expressions