fix: duplicate fragment crash issue

This commit is contained in:
Vikram Rangnekar 2020-06-07 17:03:09 -04:00
parent 7169dd65f5
commit 6716b97a39
2 changed files with 7 additions and 34 deletions

View File

@ -330,8 +330,6 @@ func (p *Parser) parseFields(fields []Field) ([]Field, error) {
return nil, fmt.Errorf("unexpected token: %s", p.peekNext())
}
// fm := make(map[uint64]struct{})
for {
if p.peek(itemEOF) {
p.ignore()
@ -384,23 +382,10 @@ func (p *Parser) parseFields(fields []Field) ([]Field, error) {
n := int32(len(fields))
fields = append(fields, fr.Fields...)
for i := int(n); i < len(fields); i++ {
f := &fields[i]
f.ID = int32(i)
// var name string
// if f.Alias != "" {
// name = f.Alias
// } else {
// name = f.Name
// }
// if _, ok := fm[name]; ok {
// continue
// } else {
// fm[name] = struct{}{}
// }
for i := 0; i < len(fr.Fields); i++ {
k := (n + int32(i))
f := &fields[k]
f.ID = int32(k)
// If this is the top-level point the parent to the parent of the
// previous field.
@ -415,6 +400,9 @@ func (p *Parser) parseFields(fields []Field) ([]Field, error) {
f.ParentID += n
}
f.Children = make([]int32, len(f.Children))
copy(f.Children, fr.Fields[i].Children)
// Update all the children which is needed.
for j := range f.Children {
f.Children[j] += n
@ -433,20 +421,6 @@ func (p *Parser) parseFields(fields []Field) ([]Field, error) {
return nil, err
}
// var name string
// if f.Alias != "" {
// name = f.Alias
// } else {
// name = f.Name
// }
// if _, ok := fm[name]; ok {
// continue
// } else {
// fm[name] = struct{}{}
// }
if st.Len() == 0 {
f.ParentID = -1
} else {

View File

@ -450,7 +450,6 @@ func (com *Compiler) compileQuery(qc *QCode, op *Operation, role string) error {
}
col := Column{Name: f.Name, FieldName: fname}
s.Cols = append(s.Cols, col)
}