Use ‘access’ variable name instead of ‘options’ on parser object

This commit is contained in:
Tobie Morgan Hitchcock 2019-01-09 17:14:13 +00:00
parent 33ba4d5de3
commit 261aff0ee2
23 changed files with 50 additions and 50 deletions

View file

@ -33,17 +33,17 @@ const (
)
// options represents context runtime config.
type options struct {
type access struct {
auth *cnf.Auth
}
func newOptions(c *fibre.Context) *options {
return &options{
func newAccess(c *fibre.Context) *access {
return &access{
auth: c.Get("auth").(*cnf.Auth),
}
}
func (o *options) get(kind int) (kv, ns, db string, err error) {
func (o *access) get(kind int) (kv, ns, db string, err error) {
kv = cnf.Settings.DB.Base
ns = o.auth.Selected.NS
@ -68,7 +68,7 @@ func (o *options) get(kind int) (kv, ns, db string, err error) {
}
func (o *options) ns(ns string) (err error) {
func (o *access) ns(ns string) (err error) {
// Check to see that the current user has
// the necessary authentication privileges
@ -94,7 +94,7 @@ func (o *options) ns(ns string) (err error) {
}
func (o *options) db(db string) (err error) {
func (o *access) db(db string) (err error) {
// Check to see that the current user has
// the necessary authentication privileges

View file

@ -18,7 +18,7 @@ func (p *parser) parseCreateStatement() (stmt *CreateStatement, err error) {
stmt = &CreateStatement{}
if stmt.KV, stmt.NS, stmt.DB, err = p.o.get(AuthNO); err != nil {
if stmt.KV, stmt.NS, stmt.DB, err = p.a.get(AuthNO); err != nil {
return nil, err
}

View file

@ -18,7 +18,7 @@ func (p *parser) parseDefineDatabaseStatement() (stmt *DefineDatabaseStatement,
stmt = &DefineDatabaseStatement{}
if stmt.KV, stmt.NS, stmt.DB, err = p.o.get(AuthNS); err != nil {
if stmt.KV, stmt.NS, stmt.DB, err = p.a.get(AuthNS); err != nil {
return nil, err
}
@ -34,7 +34,7 @@ func (p *parser) parseRemoveDatabaseStatement() (stmt *RemoveDatabaseStatement,
stmt = &RemoveDatabaseStatement{}
if stmt.KV, stmt.NS, stmt.DB, err = p.o.get(AuthNS); err != nil {
if stmt.KV, stmt.NS, stmt.DB, err = p.a.get(AuthNS); err != nil {
return nil, err
}

View file

@ -18,7 +18,7 @@ func (p *parser) parseDeleteStatement() (stmt *DeleteStatement, err error) {
stmt = &DeleteStatement{}
if stmt.KV, stmt.NS, stmt.DB, err = p.o.get(AuthNO); err != nil {
if stmt.KV, stmt.NS, stmt.DB, err = p.a.get(AuthNO); err != nil {
return nil, err
}

View file

@ -18,7 +18,7 @@ func (p *parser) parseDefineEventStatement() (stmt *DefineEventStatement, err er
stmt = &DefineEventStatement{}
if stmt.KV, stmt.NS, stmt.DB, err = p.o.get(AuthDB); err != nil {
if stmt.KV, stmt.NS, stmt.DB, err = p.a.get(AuthDB); err != nil {
return nil, err
}
@ -58,7 +58,7 @@ func (p *parser) parseRemoveEventStatement() (stmt *RemoveEventStatement, err er
stmt = &RemoveEventStatement{}
if stmt.KV, stmt.NS, stmt.DB, err = p.o.get(AuthDB); err != nil {
if stmt.KV, stmt.NS, stmt.DB, err = p.a.get(AuthDB); err != nil {
return nil, err
}

View file

@ -18,7 +18,7 @@ func (p *parser) parseDefineFieldStatement() (stmt *DefineFieldStatement, err er
stmt = &DefineFieldStatement{}
if stmt.KV, stmt.NS, stmt.DB, err = p.o.get(AuthDB); err != nil {
if stmt.KV, stmt.NS, stmt.DB, err = p.a.get(AuthDB); err != nil {
return nil, err
}
@ -81,7 +81,7 @@ func (p *parser) parseRemoveFieldStatement() (stmt *RemoveFieldStatement, err er
stmt = &RemoveFieldStatement{}
if stmt.KV, stmt.NS, stmt.DB, err = p.o.get(AuthDB); err != nil {
if stmt.KV, stmt.NS, stmt.DB, err = p.a.get(AuthDB); err != nil {
return nil, err
}

View file

@ -18,7 +18,7 @@ func (p *parser) parseDefineIndexStatement() (stmt *DefineIndexStatement, err er
stmt = &DefineIndexStatement{}
if stmt.KV, stmt.NS, stmt.DB, err = p.o.get(AuthDB); err != nil {
if stmt.KV, stmt.NS, stmt.DB, err = p.a.get(AuthDB); err != nil {
return nil, err
}
@ -52,7 +52,7 @@ func (p *parser) parseRemoveIndexStatement() (stmt *RemoveIndexStatement, err er
stmt = &RemoveIndexStatement{}
if stmt.KV, stmt.NS, stmt.DB, err = p.o.get(AuthDB); err != nil {
if stmt.KV, stmt.NS, stmt.DB, err = p.a.get(AuthDB); err != nil {
return nil, err
}

View file

@ -27,25 +27,25 @@ func (p *parser) parseInfoStatement() (stmt *InfoStatement, err error) {
}
if is(stmt.Kind, ALL) {
if stmt.KV, stmt.NS, stmt.DB, err = p.o.get(AuthKV); err != nil {
if stmt.KV, stmt.NS, stmt.DB, err = p.a.get(AuthKV); err != nil {
return nil, err
}
}
if is(stmt.Kind, NAMESPACE, NS) {
if stmt.KV, stmt.NS, stmt.DB, err = p.o.get(AuthNS); err != nil {
if stmt.KV, stmt.NS, stmt.DB, err = p.a.get(AuthNS); err != nil {
return nil, err
}
}
if is(stmt.Kind, DATABASE, DB) {
if stmt.KV, stmt.NS, stmt.DB, err = p.o.get(AuthDB); err != nil {
if stmt.KV, stmt.NS, stmt.DB, err = p.a.get(AuthDB); err != nil {
return nil, err
}
}
if is(stmt.Kind, SCOPE) {
if stmt.KV, stmt.NS, stmt.DB, err = p.o.get(AuthDB); err != nil {
if stmt.KV, stmt.NS, stmt.DB, err = p.a.get(AuthDB); err != nil {
return nil, err
}
if stmt.What, err = p.parseIdent(); err != nil {
@ -54,7 +54,7 @@ func (p *parser) parseInfoStatement() (stmt *InfoStatement, err error) {
}
if is(stmt.Kind, TABLE) {
if stmt.KV, stmt.NS, stmt.DB, err = p.o.get(AuthDB); err != nil {
if stmt.KV, stmt.NS, stmt.DB, err = p.a.get(AuthDB); err != nil {
return nil, err
}
if stmt.What, err = p.parseIdent(); err != nil {

View file

@ -18,7 +18,7 @@ func (p *parser) parseInsertStatement() (stmt *InsertStatement, err error) {
stmt = &InsertStatement{}
if stmt.KV, stmt.NS, stmt.DB, err = p.o.get(AuthNO); err != nil {
if stmt.KV, stmt.NS, stmt.DB, err = p.a.get(AuthNO); err != nil {
return nil, err
}

View file

@ -18,7 +18,7 @@ func (p *parser) parseLetStatement() (stmt *LetStatement, err error) {
stmt = &LetStatement{}
if stmt.KV, stmt.NS, stmt.DB, err = p.o.get(AuthNO); err != nil {
if stmt.KV, stmt.NS, stmt.DB, err = p.a.get(AuthNO); err != nil {
return nil, err
}

View file

@ -18,7 +18,7 @@ func (p *parser) parseLiveStatement() (stmt *LiveStatement, err error) {
stmt = &LiveStatement{}
if stmt.KV, stmt.NS, stmt.DB, err = p.o.get(AuthNO); err != nil {
if stmt.KV, stmt.NS, stmt.DB, err = p.a.get(AuthNO); err != nil {
return nil, err
}
@ -62,7 +62,7 @@ func (p *parser) parseKillStatement() (stmt *KillStatement, err error) {
stmt = &KillStatement{}
if stmt.KV, stmt.NS, stmt.DB, err = p.o.get(AuthNO); err != nil {
if stmt.KV, stmt.NS, stmt.DB, err = p.a.get(AuthNO); err != nil {
return nil, err
}

View file

@ -31,13 +31,13 @@ func (p *parser) parseDefineLoginStatement() (stmt *DefineLoginStatement, err er
}
if is(stmt.Kind, NAMESPACE) {
if stmt.KV, stmt.NS, stmt.DB, err = p.o.get(AuthNS); err != nil {
if stmt.KV, stmt.NS, stmt.DB, err = p.a.get(AuthNS); err != nil {
return nil, err
}
}
if is(stmt.Kind, DATABASE) {
if stmt.KV, stmt.NS, stmt.DB, err = p.o.get(AuthDB); err != nil {
if stmt.KV, stmt.NS, stmt.DB, err = p.a.get(AuthDB); err != nil {
return nil, err
}
}
@ -80,13 +80,13 @@ func (p *parser) parseRemoveLoginStatement() (stmt *RemoveLoginStatement, err er
}
if is(stmt.Kind, NAMESPACE) {
if stmt.KV, stmt.NS, stmt.DB, err = p.o.get(AuthNS); err != nil {
if stmt.KV, stmt.NS, stmt.DB, err = p.a.get(AuthNS); err != nil {
return nil, err
}
}
if is(stmt.Kind, DATABASE) {
if stmt.KV, stmt.NS, stmt.DB, err = p.o.get(AuthDB); err != nil {
if stmt.KV, stmt.NS, stmt.DB, err = p.a.get(AuthDB); err != nil {
return nil, err
}
}

View file

@ -18,7 +18,7 @@ func (p *parser) parseDefineNamespaceStatement() (stmt *DefineNamespaceStatement
stmt = &DefineNamespaceStatement{}
if stmt.KV, stmt.NS, stmt.DB, err = p.o.get(AuthKV); err != nil {
if stmt.KV, stmt.NS, stmt.DB, err = p.a.get(AuthKV); err != nil {
return nil, err
}
@ -34,7 +34,7 @@ func (p *parser) parseRemoveNamespaceStatement() (stmt *RemoveNamespaceStatement
stmt = &RemoveNamespaceStatement{}
if stmt.KV, stmt.NS, stmt.DB, err = p.o.get(AuthKV); err != nil {
if stmt.KV, stmt.NS, stmt.DB, err = p.a.get(AuthKV); err != nil {
return nil, err
}

View file

@ -25,7 +25,7 @@ import (
// parser represents a parser.
type parser struct {
s *scanner
o *options
a *access
c *fibre.Context
buf struct {
n int // buffer size
@ -55,7 +55,7 @@ func Parse(c *fibre.Context, i interface{}) (*Query, error) {
// newParser returns a new instance of Parser.
func newParser(c *fibre.Context) *parser {
return &parser{c: c, o: newOptions(c)}
return &parser{c: c, a: newAccess(c)}
}
// parseBytes parses a byte array.

View file

@ -18,7 +18,7 @@ func (p *parser) parseRelateStatement() (stmt *RelateStatement, err error) {
stmt = &RelateStatement{}
if stmt.KV, stmt.NS, stmt.DB, err = p.o.get(AuthNO); err != nil {
if stmt.KV, stmt.NS, stmt.DB, err = p.a.get(AuthNO); err != nil {
return nil, err
}

View file

@ -18,7 +18,7 @@ func (p *parser) parseReturnStatement() (stmt *ReturnStatement, err error) {
stmt = &ReturnStatement{}
if stmt.KV, stmt.NS, stmt.DB, err = p.o.get(AuthNO); err != nil {
if stmt.KV, stmt.NS, stmt.DB, err = p.a.get(AuthNO); err != nil {
return nil, err
}

View file

@ -18,7 +18,7 @@ func (p *parser) parseDefineScopeStatement() (stmt *DefineScopeStatement, err er
stmt = &DefineScopeStatement{}
if stmt.KV, stmt.NS, stmt.DB, err = p.o.get(AuthDB); err != nil {
if stmt.KV, stmt.NS, stmt.DB, err = p.a.get(AuthDB); err != nil {
return nil, err
}
@ -90,7 +90,7 @@ func (p *parser) parseRemoveScopeStatement() (stmt *RemoveScopeStatement, err er
stmt = &RemoveScopeStatement{}
if stmt.KV, stmt.NS, stmt.DB, err = p.o.get(AuthDB); err != nil {
if stmt.KV, stmt.NS, stmt.DB, err = p.a.get(AuthDB); err != nil {
return nil, err
}

View file

@ -18,7 +18,7 @@ func (p *parser) parseSelectStatement() (stmt *SelectStatement, err error) {
stmt = &SelectStatement{}
if stmt.KV, stmt.NS, stmt.DB, err = p.o.get(AuthNO); err != nil {
if stmt.KV, stmt.NS, stmt.DB, err = p.a.get(AuthNO); err != nil {
return nil, err
}

View file

@ -18,7 +18,7 @@ func (p *parser) parseDefineTableStatement() (stmt *DefineTableStatement, err er
stmt = &DefineTableStatement{}
if stmt.KV, stmt.NS, stmt.DB, err = p.o.get(AuthDB); err != nil {
if stmt.KV, stmt.NS, stmt.DB, err = p.a.get(AuthDB); err != nil {
return nil, err
}
@ -109,7 +109,7 @@ func (p *parser) parseRemoveTableStatement() (stmt *RemoveTableStatement, err er
stmt = &RemoveTableStatement{}
if stmt.KV, stmt.NS, stmt.DB, err = p.o.get(AuthDB); err != nil {
if stmt.KV, stmt.NS, stmt.DB, err = p.a.get(AuthDB); err != nil {
return nil, err
}

View file

@ -33,19 +33,19 @@ func (p *parser) parseDefineTokenStatement() (stmt *DefineTokenStatement, err er
}
if is(stmt.Kind, NAMESPACE) {
if stmt.KV, stmt.NS, stmt.DB, err = p.o.get(AuthNS); err != nil {
if stmt.KV, stmt.NS, stmt.DB, err = p.a.get(AuthNS); err != nil {
return nil, err
}
}
if is(stmt.Kind, DATABASE) {
if stmt.KV, stmt.NS, stmt.DB, err = p.o.get(AuthDB); err != nil {
if stmt.KV, stmt.NS, stmt.DB, err = p.a.get(AuthDB); err != nil {
return nil, err
}
}
if is(stmt.Kind, SCOPE) {
if stmt.KV, stmt.NS, stmt.DB, err = p.o.get(AuthDB); err != nil {
if stmt.KV, stmt.NS, stmt.DB, err = p.a.get(AuthDB); err != nil {
return nil, err
}
if stmt.What, err = p.parseIdent(); err != nil {
@ -105,19 +105,19 @@ func (p *parser) parseRemoveTokenStatement() (stmt *RemoveTokenStatement, err er
}
if is(stmt.Kind, NAMESPACE) {
if stmt.KV, stmt.NS, stmt.DB, err = p.o.get(AuthNS); err != nil {
if stmt.KV, stmt.NS, stmt.DB, err = p.a.get(AuthNS); err != nil {
return nil, err
}
}
if is(stmt.Kind, DATABASE) {
if stmt.KV, stmt.NS, stmt.DB, err = p.o.get(AuthDB); err != nil {
if stmt.KV, stmt.NS, stmt.DB, err = p.a.get(AuthDB); err != nil {
return nil, err
}
}
if is(stmt.Kind, SCOPE) {
if stmt.KV, stmt.NS, stmt.DB, err = p.o.get(AuthDB); err != nil {
if stmt.KV, stmt.NS, stmt.DB, err = p.a.get(AuthDB); err != nil {
return nil, err
}
if stmt.What, err = p.parseIdent(); err != nil {

View file

@ -18,7 +18,7 @@ func (p *parser) parseUpdateStatement() (stmt *UpdateStatement, err error) {
stmt = &UpdateStatement{}
if stmt.KV, stmt.NS, stmt.DB, err = p.o.get(AuthNO); err != nil {
if stmt.KV, stmt.NS, stmt.DB, err = p.a.get(AuthNO); err != nil {
return nil, err
}

View file

@ -18,7 +18,7 @@ func (p *parser) parseUpsertStatement() (stmt *UpsertStatement, err error) {
stmt = &UpsertStatement{}
if stmt.KV, stmt.NS, stmt.DB, err = p.o.get(AuthNO); err != nil {
if stmt.KV, stmt.NS, stmt.DB, err = p.a.get(AuthNO); err != nil {
return nil, err
}

View file

@ -43,7 +43,7 @@ func (p *parser) parseUseStatement() (stmt *UseStatement, err error) {
return nil, &ParseError{Expected: []string{"namespace name"}, Found: stmt.NS}
}
if err = p.o.ns(stmt.NS); err != nil {
if err = p.a.ns(stmt.NS); err != nil {
return nil, err
}
@ -60,7 +60,7 @@ func (p *parser) parseUseStatement() (stmt *UseStatement, err error) {
return nil, &ParseError{Expected: []string{"database name"}, Found: stmt.DB}
}
if err = p.o.db(stmt.DB); err != nil {
if err = p.a.db(stmt.DB); err != nil {
return nil, err
}