From 6075e4d1d7eb9904b5502182ad0a91a851fea0b0 Mon Sep 17 00:00:00 2001 From: Tobie Morgan Hitchcock Date: Tue, 18 Oct 2016 13:48:07 +0100 Subject: [PATCH] Ensure NS KV is added when defining --- db/define.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/db/define.go b/db/define.go index 8bb74eac..197fa59a 100644 --- a/db/define.go +++ b/db/define.go @@ -37,6 +37,12 @@ func executeDefineTableStatement(txn kvs.TX, ast *sql.DefineTableStatement) (out for _, TB := range ast.What { + // Set the namespace definition + nkey := &keys.NS{KV: ast.KV, NS: ast.NS} + if err := txn.Put(nkey.Encode(), nil); err != nil { + return nil, err + } + // Set the database definition dkey := &keys.DB{KV: ast.KV, NS: ast.NS, DB: ast.DB} if err := txn.Put(dkey.Encode(), nil); err != nil { @@ -76,6 +82,12 @@ func executeDefineRulesStatement(txn kvs.TX, ast *sql.DefineRulesStatement) (out for _, RU := range ast.When { + // Set the namespace definition + nkey := &keys.NS{KV: ast.KV, NS: ast.NS} + if err := txn.Put(nkey.Encode(), nil); err != nil { + return nil, err + } + // Set the database definition dkey := &keys.DB{KV: ast.KV, NS: ast.NS, DB: ast.DB} if err := txn.Put(dkey.Encode(), nil); err != nil { @@ -121,6 +133,12 @@ func executeDefineFieldStatement(txn kvs.TX, ast *sql.DefineFieldStatement) (out for _, TB := range ast.What { + // Set the namespace definition + nkey := &keys.NS{KV: ast.KV, NS: ast.NS} + if err := txn.Put(nkey.Encode(), nil); err != nil { + return nil, err + } + // Set the database definition dkey := &keys.DB{KV: ast.KV, NS: ast.NS, DB: ast.DB} if err := txn.Put(dkey.Encode(), nil); err != nil { @@ -164,6 +182,12 @@ func executeDefineIndexStatement(txn kvs.TX, ast *sql.DefineIndexStatement) (out for _, TB := range ast.What { + // Set the namespace definition + nkey := &keys.NS{KV: ast.KV, NS: ast.NS} + if err := txn.Put(nkey.Encode(), nil); err != nil { + return nil, err + } + // Set the database definition dkey := &keys.DB{KV: ast.KV, NS: ast.NS, DB: ast.DB} if err := txn.Put(dkey.Encode(), nil); err != nil {