diff --git a/pkg/common/env.go b/pkg/common/env.go index 649d37f..77d1747 100644 --- a/pkg/common/env.go +++ b/pkg/common/env.go @@ -4,6 +4,7 @@ import "github.com/kelseyhightower/envconfig" type Environment struct { NebulaStmtPrefix string `envconfig:"STMT_PREFIX" ` + NebulaSkipScan bool `envconfig:"SKIP_SCAN" default:"false"` } var nebulaEnv *Environment @@ -27,3 +28,7 @@ func ProcessStmt(stmt string) string { } return stmt } + +func ShouldSkipScan() bool { + return nebulaEnv.NebulaSkipScan +} diff --git a/pkg/common/env_test.go b/pkg/common/env_test.go index 14d9c1f..e4574cf 100644 --- a/pkg/common/env_test.go +++ b/pkg/common/env_test.go @@ -18,3 +18,11 @@ func TestProcessStmt(t *testing.T) { getEnv() assert.Equal(t, "nebula stmt", ProcessStmt("stmt")) } + +func TestSkipScan(t *testing.T) { + getEnv() + assert.False(t, ShouldSkipScan()) + os.Setenv("NEBULA_SKIP_SCAN", "true") + getEnv() + assert.True(t, ShouldSkipScan()) +} diff --git a/pkg/nebulagraph5/client.go b/pkg/nebulagraph5/client.go index edc32a6..64bc941 100644 --- a/pkg/nebulagraph5/client.go +++ b/pkg/nebulagraph5/client.go @@ -354,11 +354,12 @@ func (gc *GraphClient) Execute(stmt string) (common.IGraphResponse, error) { } } } - //TODO could add a flag to just decode the first row - if rows != 0 { - for resp.HasNext() { - if err := resp.Scan(anyValues...); err != nil { - return nil, err + if !common.ShouldSkipScan() { + if rows != 0 { + for resp.HasNext() { + if err := resp.Scan(anyValues...); err != nil { + return nil, err + } } } }