Skip to content

Commit

Permalink
Fix panic when not using a pk
Browse files Browse the repository at this point in the history
  • Loading branch information
asdine committed Mar 4, 2020
1 parent ab6a445 commit b4c3131
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 5 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,3 @@ script:
- make
- make gen
- go test -v -mod vendor -race -cover -timeout=2m ./...
- cd engine/badgerengine && go mod vendor && go test -v -mod vendor -race -cover -timeout=2m ./...
2 changes: 0 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@ test:

testrace:
go test -v -race -cover -timeout=2m ./...
cd engine/badgerengine && go test -v -race -cover -timeout=2m ./...
cd cmd/genji && go test -v -race -cover -timeout=2m ./...

bench:
go test -v -run=^\$$ -benchmem -bench=. ./...
cd engine/badgerengine && go test -v -run=^\$$ -benchmem -bench=. ./...
cd cmd/genji && go test -v -run=^\$$ -benchmem -bench=. ./...
5 changes: 3 additions & 2 deletions sql/query/plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func (qo *queryOptimizer) buildQueryPlan() queryPlan {
if len(qo.orderBy) != 0 {
_, ok := qo.indexes[qo.orderBy.Name()]
pk := qo.cfg.GetPrimaryKey()
if ok || pk.Path.String() == qo.orderBy.Name() {
if ok || (pk != nil && pk.Path.String() == qo.orderBy.Name()) {
qp.field = &queryPlanField{
indexedField: qo.orderBy,
isPrimaryKey: pk.Path.String() == qo.orderBy.Name(),
Expand Down Expand Up @@ -184,7 +184,8 @@ func (qo *queryOptimizer) analyseExpr(e Expr) *queryPlanField {
}
}

if qo.cfg.GetPrimaryKey().Path.String() == fs.Name() {
pk := qo.cfg.GetPrimaryKey()
if pk != nil && pk.Path.String() == fs.Name() {
return &queryPlanField{
indexedField: fs,
op: t.Token,
Expand Down

0 comments on commit b4c3131

Please sign in to comment.