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

View File

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

View File

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