Fix to ensure cursor fields can be defined in the query

This commit is contained in:
Vikram Rangnekar 2020-03-16 01:40:47 -04:00
parent 81338b6123
commit a172193955
3 changed files with 20 additions and 6 deletions

View File

@ -3,6 +3,7 @@ package psql
import ( import (
"errors" "errors"
"fmt"
"io" "io"
"strings" "strings"
@ -35,8 +36,6 @@ func (c *compilerContext) renderBaseColumns(
c.renderComma(i) c.renderComma(i)
realColsRendered = append(realColsRendered, n) realColsRendered = append(realColsRendered, n)
colWithTable(c.w, ti.Name, cn) colWithTable(c.w, ti.Name, cn)
i++
continue
} else { } else {
switch { switch {
@ -44,27 +43,31 @@ func (c *compilerContext) renderBaseColumns(
if err := c.renderColumnSearchRank(sel, ti, col, i); err != nil { if err := c.renderColumnSearchRank(sel, ti, col, i); err != nil {
return nil, false, err return nil, false, err
} }
i++
case isSearch && strings.HasPrefix(cn, "search_headline_"): case isSearch && strings.HasPrefix(cn, "search_headline_"):
if err := c.renderColumnSearchHeadline(sel, ti, col, i); err != nil { if err := c.renderColumnSearchHeadline(sel, ti, col, i); err != nil {
return nil, false, err return nil, false, err
} }
i++
case cn == "__typename": case cn == "__typename":
if err := c.renderColumnTypename(sel, ti, col, i); err != nil { if err := c.renderColumnTypename(sel, ti, col, i); err != nil {
return nil, false, err return nil, false, err
} }
i++
case strings.HasSuffix(cn, "_cursor"):
continue
default: default:
if err := c.renderColumnFunction(sel, ti, col, i); err != nil { if err := c.renderColumnFunction(sel, ti, col, i); err != nil {
return nil, false, err return nil, false, err
} }
fmt.Println(">>>> isAgg", cn, sel.Name)
isAgg = true isAgg = true
}
}
i++ i++
}
}
} }
if isCursorPaged { if isCursorPaged {

View File

@ -516,6 +516,10 @@ func (c *compilerContext) renderColumns(sel *qcode.Select, ti *DBTableInfo, skip
cn = col.Name[n:] cn = col.Name[n:]
} else { } else {
cn = col.Name cn = col.Name
if strings.HasSuffix(cn, "_cursor") {
continue
}
} }
if len(sel.Allowed) != 0 { if len(sel.Allowed) != 0 {

View File

@ -339,6 +339,13 @@ func (p *Parser) parseFields(fields []Field) ([]Field, error) {
if p.peek(itemObjOpen) { if p.peek(itemObjOpen) {
p.ignore() p.ignore()
st.Push(f.ID) st.Push(f.ID)
} else if p.peek(itemObjClose) {
if st.Len() == 0 {
break
} else {
continue
}
} }
} }