Log sql queries centrally, not separately
This commit is contained in:
parent
98f103cbaf
commit
73c56e4df5
11 changed files with 6 additions and 130 deletions
|
@ -16,7 +16,6 @@ package db
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/abcum/surreal/log"
|
|
||||||
"github.com/abcum/surreal/sql"
|
"github.com/abcum/surreal/sql"
|
||||||
"github.com/abcum/surreal/util/item"
|
"github.com/abcum/surreal/util/item"
|
||||||
"github.com/abcum/surreal/util/keys"
|
"github.com/abcum/surreal/util/keys"
|
||||||
|
@ -25,11 +24,6 @@ import (
|
||||||
|
|
||||||
func (e *executor) executeCreateStatement(ast *sql.CreateStatement) (out []interface{}, err error) {
|
func (e *executor) executeCreateStatement(ast *sql.CreateStatement) (out []interface{}, err error) {
|
||||||
|
|
||||||
log.WithPrefix("sql").WithFields(map[string]interface{}{
|
|
||||||
"ns": ast.NS,
|
|
||||||
"db": ast.DB,
|
|
||||||
}).Debugln(ast)
|
|
||||||
|
|
||||||
for k, w := range ast.What {
|
for k, w := range ast.What {
|
||||||
if what, ok := w.(*sql.Param); ok {
|
if what, ok := w.(*sql.Param); ok {
|
||||||
ast.What[k] = e.ctx.Get(what.ID).Data()
|
ast.What[k] = e.ctx.Get(what.ID).Data()
|
||||||
|
|
6
db/db.go
6
db/db.go
|
@ -310,6 +310,12 @@ func (e *executor) execute(quit <-chan bool, send chan<- *Response) {
|
||||||
err, now = nil, time.Now()
|
err, now = nil, time.Now()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// When in debugging mode, log every sql
|
||||||
|
// query, along with the query execution
|
||||||
|
// speed, so we can analyse slow queries.
|
||||||
|
|
||||||
|
log.WithPrefix("sql").Debugln(stm)
|
||||||
|
|
||||||
// Check to see if the current statement is
|
// Check to see if the current statement is
|
||||||
// a TRANSACTION statement, and if it is
|
// a TRANSACTION statement, and if it is
|
||||||
// then deal with it and move on to the next.
|
// then deal with it and move on to the next.
|
||||||
|
|
41
db/define.go
41
db/define.go
|
@ -15,7 +15,6 @@
|
||||||
package db
|
package db
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/abcum/surreal/log"
|
|
||||||
"github.com/abcum/surreal/sql"
|
"github.com/abcum/surreal/sql"
|
||||||
"github.com/abcum/surreal/util/item"
|
"github.com/abcum/surreal/util/item"
|
||||||
"github.com/abcum/surreal/util/keys"
|
"github.com/abcum/surreal/util/keys"
|
||||||
|
@ -24,11 +23,6 @@ import (
|
||||||
|
|
||||||
func (e *executor) executeDefineNamespaceStatement(ast *sql.DefineNamespaceStatement) (out []interface{}, err error) {
|
func (e *executor) executeDefineNamespaceStatement(ast *sql.DefineNamespaceStatement) (out []interface{}, err error) {
|
||||||
|
|
||||||
log.WithPrefix("sql").WithFields(map[string]interface{}{
|
|
||||||
"ns": ast.NS,
|
|
||||||
"db": ast.DB,
|
|
||||||
}).Debugln(ast)
|
|
||||||
|
|
||||||
// Set the namespace
|
// Set the namespace
|
||||||
nkey := &keys.NS{KV: ast.KV, NS: ast.Name}
|
nkey := &keys.NS{KV: ast.KV, NS: ast.Name}
|
||||||
_, err = e.txn.Put(0, nkey.Encode(), ast.Encode())
|
_, err = e.txn.Put(0, nkey.Encode(), ast.Encode())
|
||||||
|
@ -39,11 +33,6 @@ func (e *executor) executeDefineNamespaceStatement(ast *sql.DefineNamespaceState
|
||||||
|
|
||||||
func (e *executor) executeDefineDatabaseStatement(ast *sql.DefineDatabaseStatement) (out []interface{}, err error) {
|
func (e *executor) executeDefineDatabaseStatement(ast *sql.DefineDatabaseStatement) (out []interface{}, err error) {
|
||||||
|
|
||||||
log.WithPrefix("sql").WithFields(map[string]interface{}{
|
|
||||||
"ns": ast.NS,
|
|
||||||
"db": ast.DB,
|
|
||||||
}).Debugln(ast)
|
|
||||||
|
|
||||||
// Set the namespace
|
// Set the namespace
|
||||||
nkey := &keys.NS{KV: ast.KV, NS: ast.NS}
|
nkey := &keys.NS{KV: ast.KV, NS: ast.NS}
|
||||||
nval := &sql.DefineNamespaceStatement{Name: ast.NS}
|
nval := &sql.DefineNamespaceStatement{Name: ast.NS}
|
||||||
|
@ -59,11 +48,6 @@ func (e *executor) executeDefineDatabaseStatement(ast *sql.DefineDatabaseStateme
|
||||||
|
|
||||||
func (e *executor) executeDefineLoginStatement(ast *sql.DefineLoginStatement) (out []interface{}, err error) {
|
func (e *executor) executeDefineLoginStatement(ast *sql.DefineLoginStatement) (out []interface{}, err error) {
|
||||||
|
|
||||||
log.WithPrefix("sql").WithFields(map[string]interface{}{
|
|
||||||
"ns": ast.NS,
|
|
||||||
"db": ast.DB,
|
|
||||||
}).Debugln(ast)
|
|
||||||
|
|
||||||
if ast.Kind == sql.NAMESPACE {
|
if ast.Kind == sql.NAMESPACE {
|
||||||
|
|
||||||
// Set the namespace
|
// Set the namespace
|
||||||
|
@ -101,11 +85,6 @@ func (e *executor) executeDefineLoginStatement(ast *sql.DefineLoginStatement) (o
|
||||||
|
|
||||||
func (e *executor) executeDefineTokenStatement(ast *sql.DefineTokenStatement) (out []interface{}, err error) {
|
func (e *executor) executeDefineTokenStatement(ast *sql.DefineTokenStatement) (out []interface{}, err error) {
|
||||||
|
|
||||||
log.WithPrefix("sql").WithFields(map[string]interface{}{
|
|
||||||
"ns": ast.NS,
|
|
||||||
"db": ast.DB,
|
|
||||||
}).Debugln(ast)
|
|
||||||
|
|
||||||
if ast.Kind == sql.NAMESPACE {
|
if ast.Kind == sql.NAMESPACE {
|
||||||
|
|
||||||
// Set the namespace
|
// Set the namespace
|
||||||
|
@ -143,11 +122,6 @@ func (e *executor) executeDefineTokenStatement(ast *sql.DefineTokenStatement) (o
|
||||||
|
|
||||||
func (e *executor) executeDefineScopeStatement(ast *sql.DefineScopeStatement) (out []interface{}, err error) {
|
func (e *executor) executeDefineScopeStatement(ast *sql.DefineScopeStatement) (out []interface{}, err error) {
|
||||||
|
|
||||||
log.WithPrefix("sql").WithFields(map[string]interface{}{
|
|
||||||
"ns": ast.NS,
|
|
||||||
"db": ast.DB,
|
|
||||||
}).Debugln(ast)
|
|
||||||
|
|
||||||
// Set the namespace
|
// Set the namespace
|
||||||
nkey := &keys.NS{KV: ast.KV, NS: ast.NS}
|
nkey := &keys.NS{KV: ast.KV, NS: ast.NS}
|
||||||
nval := &sql.DefineNamespaceStatement{Name: ast.NS}
|
nval := &sql.DefineNamespaceStatement{Name: ast.NS}
|
||||||
|
@ -168,11 +142,6 @@ func (e *executor) executeDefineScopeStatement(ast *sql.DefineScopeStatement) (o
|
||||||
|
|
||||||
func (e *executor) executeDefineTableStatement(ast *sql.DefineTableStatement) (out []interface{}, err error) {
|
func (e *executor) executeDefineTableStatement(ast *sql.DefineTableStatement) (out []interface{}, err error) {
|
||||||
|
|
||||||
log.WithPrefix("sql").WithFields(map[string]interface{}{
|
|
||||||
"ns": ast.NS,
|
|
||||||
"db": ast.DB,
|
|
||||||
}).Debugln(ast)
|
|
||||||
|
|
||||||
// Set the namespace
|
// Set the namespace
|
||||||
nkey := &keys.NS{KV: ast.KV, NS: ast.NS}
|
nkey := &keys.NS{KV: ast.KV, NS: ast.NS}
|
||||||
nval := &sql.DefineNamespaceStatement{Name: ast.NS}
|
nval := &sql.DefineNamespaceStatement{Name: ast.NS}
|
||||||
|
@ -199,11 +168,6 @@ func (e *executor) executeDefineTableStatement(ast *sql.DefineTableStatement) (o
|
||||||
|
|
||||||
func (e *executor) executeDefineFieldStatement(ast *sql.DefineFieldStatement) (out []interface{}, err error) {
|
func (e *executor) executeDefineFieldStatement(ast *sql.DefineFieldStatement) (out []interface{}, err error) {
|
||||||
|
|
||||||
log.WithPrefix("sql").WithFields(map[string]interface{}{
|
|
||||||
"ns": ast.NS,
|
|
||||||
"db": ast.DB,
|
|
||||||
}).Debugln(ast)
|
|
||||||
|
|
||||||
// Set the namespace
|
// Set the namespace
|
||||||
nkey := &keys.NS{KV: ast.KV, NS: ast.NS}
|
nkey := &keys.NS{KV: ast.KV, NS: ast.NS}
|
||||||
nval := &sql.DefineNamespaceStatement{Name: ast.NS}
|
nval := &sql.DefineNamespaceStatement{Name: ast.NS}
|
||||||
|
@ -235,11 +199,6 @@ func (e *executor) executeDefineFieldStatement(ast *sql.DefineFieldStatement) (o
|
||||||
|
|
||||||
func (e *executor) executeDefineIndexStatement(ast *sql.DefineIndexStatement) (out []interface{}, err error) {
|
func (e *executor) executeDefineIndexStatement(ast *sql.DefineIndexStatement) (out []interface{}, err error) {
|
||||||
|
|
||||||
log.WithPrefix("sql").WithFields(map[string]interface{}{
|
|
||||||
"ns": ast.NS,
|
|
||||||
"db": ast.DB,
|
|
||||||
}).Debugln(ast)
|
|
||||||
|
|
||||||
// Set the namespace
|
// Set the namespace
|
||||||
nkey := &keys.NS{KV: ast.KV, NS: ast.NS}
|
nkey := &keys.NS{KV: ast.KV, NS: ast.NS}
|
||||||
nval := &sql.DefineNamespaceStatement{Name: ast.NS}
|
nval := &sql.DefineNamespaceStatement{Name: ast.NS}
|
||||||
|
|
|
@ -16,7 +16,6 @@ package db
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/abcum/surreal/log"
|
|
||||||
"github.com/abcum/surreal/sql"
|
"github.com/abcum/surreal/sql"
|
||||||
"github.com/abcum/surreal/util/item"
|
"github.com/abcum/surreal/util/item"
|
||||||
"github.com/abcum/surreal/util/keys"
|
"github.com/abcum/surreal/util/keys"
|
||||||
|
@ -24,11 +23,6 @@ import (
|
||||||
|
|
||||||
func (e *executor) executeDeleteStatement(ast *sql.DeleteStatement) (out []interface{}, err error) {
|
func (e *executor) executeDeleteStatement(ast *sql.DeleteStatement) (out []interface{}, err error) {
|
||||||
|
|
||||||
log.WithPrefix("sql").WithFields(map[string]interface{}{
|
|
||||||
"ns": ast.NS,
|
|
||||||
"db": ast.DB,
|
|
||||||
}).Debugln(ast)
|
|
||||||
|
|
||||||
for k, w := range ast.What {
|
for k, w := range ast.What {
|
||||||
if what, ok := w.(*sql.Param); ok {
|
if what, ok := w.(*sql.Param); ok {
|
||||||
ast.What[k] = e.ctx.Get(what.ID).Data()
|
ast.What[k] = e.ctx.Get(what.ID).Data()
|
||||||
|
|
|
@ -15,18 +15,12 @@
|
||||||
package db
|
package db
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/abcum/surreal/log"
|
|
||||||
"github.com/abcum/surreal/sql"
|
"github.com/abcum/surreal/sql"
|
||||||
"github.com/abcum/surreal/util/data"
|
"github.com/abcum/surreal/util/data"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (e *executor) executeInfoStatement(ast *sql.InfoStatement) (out []interface{}, err error) {
|
func (e *executor) executeInfoStatement(ast *sql.InfoStatement) (out []interface{}, err error) {
|
||||||
|
|
||||||
log.WithPrefix("sql").WithFields(map[string]interface{}{
|
|
||||||
"ns": ast.NS,
|
|
||||||
"db": ast.DB,
|
|
||||||
}).Debugln(ast)
|
|
||||||
|
|
||||||
switch ast.Kind {
|
switch ast.Kind {
|
||||||
case sql.NAMESPACE:
|
case sql.NAMESPACE:
|
||||||
return e.executeInfoNSStatement(ast)
|
return e.executeInfoNSStatement(ast)
|
||||||
|
|
|
@ -15,17 +15,11 @@
|
||||||
package db
|
package db
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/abcum/surreal/log"
|
|
||||||
"github.com/abcum/surreal/sql"
|
"github.com/abcum/surreal/sql"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (e *executor) executeLetStatement(ast *sql.LetStatement) (out []interface{}, err error) {
|
func (e *executor) executeLetStatement(ast *sql.LetStatement) (out []interface{}, err error) {
|
||||||
|
|
||||||
log.WithPrefix("sql").WithFields(map[string]interface{}{
|
|
||||||
"ns": ast.NS,
|
|
||||||
"db": ast.DB,
|
|
||||||
}).Debugln(ast)
|
|
||||||
|
|
||||||
switch what := ast.What.(type) {
|
switch what := ast.What.(type) {
|
||||||
default:
|
default:
|
||||||
e.Set(ast.Name, what)
|
e.Set(ast.Name, what)
|
||||||
|
|
|
@ -15,17 +15,11 @@
|
||||||
package db
|
package db
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/abcum/surreal/log"
|
|
||||||
"github.com/abcum/surreal/sql"
|
"github.com/abcum/surreal/sql"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (e *executor) executeRelateStatement(ast *sql.RelateStatement) (out []interface{}, err error) {
|
func (e *executor) executeRelateStatement(ast *sql.RelateStatement) (out []interface{}, err error) {
|
||||||
|
|
||||||
log.WithPrefix("sql").WithFields(map[string]interface{}{
|
|
||||||
"ns": ast.NS,
|
|
||||||
"db": ast.DB,
|
|
||||||
}).Debugln(ast)
|
|
||||||
|
|
||||||
return nil, nil
|
return nil, nil
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
41
db/remove.go
41
db/remove.go
|
@ -15,18 +15,12 @@
|
||||||
package db
|
package db
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/abcum/surreal/log"
|
|
||||||
"github.com/abcum/surreal/sql"
|
"github.com/abcum/surreal/sql"
|
||||||
"github.com/abcum/surreal/util/keys"
|
"github.com/abcum/surreal/util/keys"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (e *executor) executeRemoveNamespaceStatement(ast *sql.RemoveNamespaceStatement) (out []interface{}, err error) {
|
func (e *executor) executeRemoveNamespaceStatement(ast *sql.RemoveNamespaceStatement) (out []interface{}, err error) {
|
||||||
|
|
||||||
log.WithPrefix("sql").WithFields(map[string]interface{}{
|
|
||||||
"ns": ast.NS,
|
|
||||||
"db": ast.DB,
|
|
||||||
}).Debugln(ast)
|
|
||||||
|
|
||||||
// Remove the namespace
|
// Remove the namespace
|
||||||
nkey := &keys.NS{KV: ast.KV, NS: ast.Name}
|
nkey := &keys.NS{KV: ast.KV, NS: ast.Name}
|
||||||
_, err = e.txn.DelP(0, nkey.Encode(), 0)
|
_, err = e.txn.DelP(0, nkey.Encode(), 0)
|
||||||
|
@ -37,11 +31,6 @@ func (e *executor) executeRemoveNamespaceStatement(ast *sql.RemoveNamespaceState
|
||||||
|
|
||||||
func (e *executor) executeRemoveDatabaseStatement(ast *sql.RemoveDatabaseStatement) (out []interface{}, err error) {
|
func (e *executor) executeRemoveDatabaseStatement(ast *sql.RemoveDatabaseStatement) (out []interface{}, err error) {
|
||||||
|
|
||||||
log.WithPrefix("sql").WithFields(map[string]interface{}{
|
|
||||||
"ns": ast.NS,
|
|
||||||
"db": ast.DB,
|
|
||||||
}).Debugln(ast)
|
|
||||||
|
|
||||||
// Remove the database
|
// Remove the database
|
||||||
dkey := &keys.DB{KV: ast.KV, NS: ast.NS, DB: ast.Name}
|
dkey := &keys.DB{KV: ast.KV, NS: ast.NS, DB: ast.Name}
|
||||||
_, err = e.txn.DelP(0, dkey.Encode(), 0)
|
_, err = e.txn.DelP(0, dkey.Encode(), 0)
|
||||||
|
@ -52,11 +41,6 @@ func (e *executor) executeRemoveDatabaseStatement(ast *sql.RemoveDatabaseStateme
|
||||||
|
|
||||||
func (e *executor) executeRemoveLoginStatement(ast *sql.RemoveLoginStatement) (out []interface{}, err error) {
|
func (e *executor) executeRemoveLoginStatement(ast *sql.RemoveLoginStatement) (out []interface{}, err error) {
|
||||||
|
|
||||||
log.WithPrefix("sql").WithFields(map[string]interface{}{
|
|
||||||
"ns": ast.NS,
|
|
||||||
"db": ast.DB,
|
|
||||||
}).Debugln(ast)
|
|
||||||
|
|
||||||
if ast.Kind == sql.NAMESPACE {
|
if ast.Kind == sql.NAMESPACE {
|
||||||
|
|
||||||
// Remove the login
|
// Remove the login
|
||||||
|
@ -79,11 +63,6 @@ func (e *executor) executeRemoveLoginStatement(ast *sql.RemoveLoginStatement) (o
|
||||||
|
|
||||||
func (e *executor) executeRemoveTokenStatement(ast *sql.RemoveTokenStatement) (out []interface{}, err error) {
|
func (e *executor) executeRemoveTokenStatement(ast *sql.RemoveTokenStatement) (out []interface{}, err error) {
|
||||||
|
|
||||||
log.WithPrefix("sql").WithFields(map[string]interface{}{
|
|
||||||
"ns": ast.NS,
|
|
||||||
"db": ast.DB,
|
|
||||||
}).Debugln(ast)
|
|
||||||
|
|
||||||
if ast.Kind == sql.NAMESPACE {
|
if ast.Kind == sql.NAMESPACE {
|
||||||
|
|
||||||
// Remove the token
|
// Remove the token
|
||||||
|
@ -106,11 +85,6 @@ func (e *executor) executeRemoveTokenStatement(ast *sql.RemoveTokenStatement) (o
|
||||||
|
|
||||||
func (e *executor) executeRemoveScopeStatement(ast *sql.RemoveScopeStatement) (out []interface{}, err error) {
|
func (e *executor) executeRemoveScopeStatement(ast *sql.RemoveScopeStatement) (out []interface{}, err error) {
|
||||||
|
|
||||||
log.WithPrefix("sql").WithFields(map[string]interface{}{
|
|
||||||
"ns": ast.NS,
|
|
||||||
"db": ast.DB,
|
|
||||||
}).Debugln(ast)
|
|
||||||
|
|
||||||
// Remove the scope
|
// Remove the scope
|
||||||
skey := &keys.SC{KV: ast.KV, NS: ast.NS, DB: ast.DB, SC: ast.Name}
|
skey := &keys.SC{KV: ast.KV, NS: ast.NS, DB: ast.DB, SC: ast.Name}
|
||||||
_, err = e.txn.DelP(0, skey.Encode(), 0)
|
_, err = e.txn.DelP(0, skey.Encode(), 0)
|
||||||
|
@ -121,11 +95,6 @@ func (e *executor) executeRemoveScopeStatement(ast *sql.RemoveScopeStatement) (o
|
||||||
|
|
||||||
func (e *executor) executeRemoveTableStatement(ast *sql.RemoveTableStatement) (out []interface{}, err error) {
|
func (e *executor) executeRemoveTableStatement(ast *sql.RemoveTableStatement) (out []interface{}, err error) {
|
||||||
|
|
||||||
log.WithPrefix("sql").WithFields(map[string]interface{}{
|
|
||||||
"ns": ast.NS,
|
|
||||||
"db": ast.DB,
|
|
||||||
}).Debugln(ast)
|
|
||||||
|
|
||||||
for _, TB := range ast.What {
|
for _, TB := range ast.What {
|
||||||
|
|
||||||
// Remove the table
|
// Remove the table
|
||||||
|
@ -140,11 +109,6 @@ func (e *executor) executeRemoveTableStatement(ast *sql.RemoveTableStatement) (o
|
||||||
|
|
||||||
func (e *executor) executeRemoveFieldStatement(ast *sql.RemoveFieldStatement) (out []interface{}, err error) {
|
func (e *executor) executeRemoveFieldStatement(ast *sql.RemoveFieldStatement) (out []interface{}, err error) {
|
||||||
|
|
||||||
log.WithPrefix("sql").WithFields(map[string]interface{}{
|
|
||||||
"ns": ast.NS,
|
|
||||||
"db": ast.DB,
|
|
||||||
}).Debugln(ast)
|
|
||||||
|
|
||||||
for _, TB := range ast.What {
|
for _, TB := range ast.What {
|
||||||
|
|
||||||
// Remove the field
|
// Remove the field
|
||||||
|
@ -159,11 +123,6 @@ func (e *executor) executeRemoveFieldStatement(ast *sql.RemoveFieldStatement) (o
|
||||||
|
|
||||||
func (e *executor) executeRemoveIndexStatement(ast *sql.RemoveIndexStatement) (out []interface{}, err error) {
|
func (e *executor) executeRemoveIndexStatement(ast *sql.RemoveIndexStatement) (out []interface{}, err error) {
|
||||||
|
|
||||||
log.WithPrefix("sql").WithFields(map[string]interface{}{
|
|
||||||
"ns": ast.NS,
|
|
||||||
"db": ast.DB,
|
|
||||||
}).Debugln(ast)
|
|
||||||
|
|
||||||
for _, TB := range ast.What {
|
for _, TB := range ast.What {
|
||||||
|
|
||||||
// Remove the index
|
// Remove the index
|
||||||
|
|
|
@ -15,17 +15,11 @@
|
||||||
package db
|
package db
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/abcum/surreal/log"
|
|
||||||
"github.com/abcum/surreal/sql"
|
"github.com/abcum/surreal/sql"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (e *executor) executeReturnStatement(ast *sql.ReturnStatement) (out []interface{}, err error) {
|
func (e *executor) executeReturnStatement(ast *sql.ReturnStatement) (out []interface{}, err error) {
|
||||||
|
|
||||||
log.WithPrefix("sql").WithFields(map[string]interface{}{
|
|
||||||
"ns": ast.NS,
|
|
||||||
"db": ast.DB,
|
|
||||||
}).Debugln(ast)
|
|
||||||
|
|
||||||
switch what := ast.What.(type) {
|
switch what := ast.What.(type) {
|
||||||
default:
|
default:
|
||||||
out = append(out, what)
|
out = append(out, what)
|
||||||
|
|
|
@ -15,7 +15,6 @@
|
||||||
package db
|
package db
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/abcum/surreal/log"
|
|
||||||
"github.com/abcum/surreal/sql"
|
"github.com/abcum/surreal/sql"
|
||||||
"github.com/abcum/surreal/util/item"
|
"github.com/abcum/surreal/util/item"
|
||||||
"github.com/abcum/surreal/util/keys"
|
"github.com/abcum/surreal/util/keys"
|
||||||
|
@ -23,11 +22,6 @@ import (
|
||||||
|
|
||||||
func (e *executor) executeSelectStatement(ast *sql.SelectStatement) (out []interface{}, err error) {
|
func (e *executor) executeSelectStatement(ast *sql.SelectStatement) (out []interface{}, err error) {
|
||||||
|
|
||||||
log.WithPrefix("sql").WithFields(map[string]interface{}{
|
|
||||||
"ns": ast.NS,
|
|
||||||
"db": ast.DB,
|
|
||||||
}).Debugln(ast)
|
|
||||||
|
|
||||||
for k, w := range ast.What {
|
for k, w := range ast.What {
|
||||||
if what, ok := w.(*sql.Param); ok {
|
if what, ok := w.(*sql.Param); ok {
|
||||||
ast.What[k] = e.ctx.Get(what.ID).Data()
|
ast.What[k] = e.ctx.Get(what.ID).Data()
|
||||||
|
|
|
@ -16,7 +16,6 @@ package db
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/abcum/surreal/log"
|
|
||||||
"github.com/abcum/surreal/sql"
|
"github.com/abcum/surreal/sql"
|
||||||
"github.com/abcum/surreal/util/item"
|
"github.com/abcum/surreal/util/item"
|
||||||
"github.com/abcum/surreal/util/keys"
|
"github.com/abcum/surreal/util/keys"
|
||||||
|
@ -24,11 +23,6 @@ import (
|
||||||
|
|
||||||
func (e *executor) executeUpdateStatement(ast *sql.UpdateStatement) (out []interface{}, err error) {
|
func (e *executor) executeUpdateStatement(ast *sql.UpdateStatement) (out []interface{}, err error) {
|
||||||
|
|
||||||
log.WithPrefix("sql").WithFields(map[string]interface{}{
|
|
||||||
"ns": ast.NS,
|
|
||||||
"db": ast.DB,
|
|
||||||
}).Debugln(ast)
|
|
||||||
|
|
||||||
for k, w := range ast.What {
|
for k, w := range ast.What {
|
||||||
if what, ok := w.(*sql.Param); ok {
|
if what, ok := w.(*sql.Param); ok {
|
||||||
ast.What[k] = e.ctx.Get(what.ID).Data()
|
ast.What[k] = e.ctx.Get(what.ID).Data()
|
||||||
|
|
Loading…
Reference in a new issue