示例#1
0
/*
Returns all required privileges.
*/
func (this *Update) Privileges() (datastore.Privileges, errors.Error) {
	privs := datastore.NewPrivileges()
	privs[this.keyspace.Namespace()+":"+this.keyspace.Keyspace()] = datastore.PRIV_WRITE

	subprivs, err := subqueryPrivileges(this.Expressions())
	if err != nil {
		return nil, err
	}

	privs.Add(subprivs)
	return privs, nil
}
示例#2
0
文件: base.go 项目: amarantha-k/query
/*
Returns all required privileges.
*/
func subqueryPrivileges(exprs expression.Expressions) (datastore.Privileges, errors.Error) {
	subqueries, err := expression.ListSubqueries(exprs, false)
	if err != nil {
		return nil, errors.NewError(err, "")
	}

	privileges := datastore.NewPrivileges()
	for _, s := range subqueries {
		sub := s.(*Subquery)
		sp, e := sub.Select().Privileges()
		if e != nil {
			return nil, e
		}

		privileges.Add(sp)
	}

	return privileges, nil
}
示例#3
0
/*
Returns all required privileges.
*/
func (this *Subselect) Privileges() (datastore.Privileges, errors.Error) {
	privs := datastore.NewPrivileges()

	if this.from != nil {
		fprivs, err := this.from.Privileges()
		if err != nil {
			return nil, err
		}

		privs.Add(fprivs)
	}

	exprs := make(expression.Expressions, 0, 16)

	if this.let != nil {
		exprs = append(exprs, this.let.Expressions()...)
	}

	if this.where != nil {
		exprs = append(exprs, this.where)
	}

	if this.group != nil {
		exprs = append(exprs, this.group.Expressions()...)
	}

	exprs = append(exprs, this.projection.Expressions()...)

	subprivs, err := subqueryPrivileges(exprs)
	if err != nil {
		return nil, err
	}

	privs.Add(subprivs)
	return privs, nil
}
示例#4
0
文件: from.go 项目: amarantha-k/query
/*
Returns all required privileges.
*/
func (this *KeyspaceTerm) Privileges() (datastore.Privileges, errors.Error) {
	privs := datastore.NewPrivileges()
	privs[this.namespace+":"+this.keyspace] = datastore.PRIV_READ
	return privs, nil
}